[Xfce4-commits] <midori:master> Take text from each feed element for tree and web view

Christian Dywan noreply at xfce.org
Sat Mar 27 14:24:01 CET 2010


Updating branch refs/heads/master
         to 9607f2107eac71155a032f92a65a9797eb6e4b58 (commit)
       from fdf075513caa9647c4f8dcba28a01382a38d138f (commit)

commit 9607f2107eac71155a032f92a65a9797eb6e4b58
Author: Dale Whittaker <dayul at users.sf.net>
Date:   Fri Mar 26 21:06:44 2010 +0100

    Take text from each feed element for tree and web view

 extensions/feed-panel/feed-atom.c  |   40 +++++------------------------------
 extensions/feed-panel/feed-parse.c |   21 +++++++++---------
 extensions/feed-panel/feed-rss.c   |   10 ++++----
 3 files changed, 21 insertions(+), 50 deletions(-)

diff --git a/extensions/feed-panel/feed-atom.c b/extensions/feed-panel/feed-atom.c
index 3b0a33e..0cf14c3 100644
--- a/extensions/feed-panel/feed-atom.c
+++ b/extensions/feed-panel/feed-atom.c
@@ -1,5 +1,5 @@
 /*
- Copyright (C) 2009 Dale Whittaker <dayul at users.sf.net>
+ Copyright (C) 2009-2010 Dale Whittaker <dayul at users.sf.net>
 
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
@@ -130,34 +130,6 @@ atom_get_link (KatzeItem* item,
     xmlFree (newtype);
 }
 
-static gchar*
-atom_get_title (FeedParser* fparser)
-{
-    const gchar* name;
-
-    if (!(name = katze_item_get_name (fparser->item)))
-    {
-        gchar* type;
-
-        type = (gchar*)xmlGetProp (fparser->node, BAD_CAST "type");
-        if (type)
-        {
-            gchar* content = NULL;
-
-            if (g_str_equal (type, "html") ||
-                g_str_equal (type, "xhtml"))
-                content = feed_get_element_markup (fparser);
-
-            xmlFree (type);
-
-            if (content)
-                return content;
-        }
-        return feed_get_element_string (fparser);
-    }
-    return g_strdup (name);
-}
-
 static void
 atom_preparse_entry (FeedParser* fparser)
 {
@@ -181,12 +153,12 @@ atom_parse_entry (FeedParser* fparser)
     }
     else if (!xmlStrcmp (node->name, BAD_CAST "title"))
     {
-        content = atom_get_title (fparser);
+        content = feed_get_element_string (fparser);
         katze_item_set_name (fparser->item, content);
     }
     else if (!xmlStrcmp (node->name, BAD_CAST "summary"))
     {
-        content = feed_get_element_string (fparser);
+        content = feed_get_element_markup (fparser);
         katze_item_set_text (fparser->item, content);
     }
     else if (!xmlStrcmp (node->name, BAD_CAST "updated"))
@@ -209,7 +181,7 @@ atom_parse_entry (FeedParser* fparser)
         /* Only retrieve content if there is no summary */
         if (!katze_item_get_text (fparser->item))
         {
-            content = feed_get_element_string (fparser);
+            content = feed_get_element_markup (fparser);
             katze_item_set_text (fparser->item, content);
         }
     }
@@ -269,12 +241,12 @@ atom_parse_feed (FeedParser* fparser)
     }
     else if (!xmlStrcmp (node->name, BAD_CAST "title"))
     {
-        content = atom_get_title (fparser);
+        content = feed_get_element_string (fparser);
         katze_item_set_name (fparser->item, content);
     }
     else if (!xmlStrcmp (node->name, BAD_CAST "subtitle"))
     {
-        content = feed_get_element_string (fparser);
+        content = feed_get_element_markup (fparser);
         katze_item_set_text (fparser->item, content);
     }
     else if (!xmlStrcmp (node->name, BAD_CAST "updated"))
diff --git a/extensions/feed-panel/feed-parse.c b/extensions/feed-panel/feed-parse.c
index 5a9e8e3..1f7c41b 100644
--- a/extensions/feed-panel/feed-parse.c
+++ b/extensions/feed-panel/feed-parse.c
@@ -13,12 +13,19 @@
 #include <time.h>
 
 gchar*
-feed_get_element_string (FeedParser* fparser)
+feed_get_element_markup (FeedParser* fparser)
 {
     xmlNodePtr node;
 
     node = fparser->node;
 
+    if (node->children &&
+        !xmlIsBlankNode (node->children) &&
+        node->children->type == XML_ELEMENT_NODE)
+    {
+        return ((gchar*) xmlNodeGetContent (node->children));
+    }
+
     if (!node->children ||
         xmlIsBlankNode (node->children) ||
         (node->children->type != XML_TEXT_NODE &&
@@ -71,19 +78,11 @@ feed_remove_markup (gchar* markup)
 }
 
 gchar*
-feed_get_element_markup (FeedParser* fparser)
+feed_get_element_string (FeedParser* fparser)
 {
     gchar* markup;
-    xmlNodePtr node = fparser->node;
-
-    if (node->children &&
-        !xmlIsBlankNode (node->children) &&
-        node->children->type == XML_ELEMENT_NODE)
-    {
-        return (gchar*) xmlNodeGetContent (node->children);
-    }
 
-    markup = feed_get_element_string (fparser);
+    markup = feed_get_element_markup (fparser);
     return feed_remove_markup (markup);
 }
 
diff --git a/extensions/feed-panel/feed-rss.c b/extensions/feed-panel/feed-rss.c
index e802263..8351fd5 100644
--- a/extensions/feed-panel/feed-rss.c
+++ b/extensions/feed-panel/feed-rss.c
@@ -1,5 +1,5 @@
 /*
- Copyright (C) 2009 Dale Whittaker <dayul at users.sf.net>
+ Copyright (C) 2009-2010 Dale Whittaker <dayul at users.sf.net>
 
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
@@ -107,12 +107,12 @@ rss_parse_item (FeedParser* fparser)
     }
     else if (!xmlStrcmp (node->name, BAD_CAST "title"))
     {
-        content = feed_get_element_markup (fparser);
+        content = feed_get_element_string (fparser);
         katze_item_set_name (fparser->item, content);
     }
     else if (!xmlStrcmp (node->name, BAD_CAST "description"))
     {
-        content = feed_get_element_string (fparser);
+        content = feed_get_element_markup (fparser);
         katze_item_set_text (fparser->item, content);
     }
     else if (!xmlStrcmp (node->name, BAD_CAST "pubDate"))
@@ -184,12 +184,12 @@ rss_parse_channel (FeedParser* fparser)
 
     if (!xmlStrcmp (node->name, BAD_CAST "title"))
     {
-        content = feed_get_element_markup (fparser);
+        content = feed_get_element_string (fparser);
         katze_item_set_name (fparser->item, content);
     }
     else if (!xmlStrcmp (node->name, BAD_CAST "description"))
     {
-        content = feed_get_element_string (fparser);
+        content = feed_get_element_markup (fparser);
         katze_item_set_text (fparser->item, content);
     }
     else if (!xmlStrcmp (node->name, BAD_CAST "lastBuildDate"))



More information about the Xfce4-commits mailing list