From 9607f2107eac71155a032f92a65a9797eb6e4b58 Mon Sep 17 00:00:00 2001 From: Dale Whittaker Date: Fri, 26 Mar 2010 21:06:44 +0100 Subject: [PATCH] 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 3b0a33e5..0cf14c30 100644 --- a/extensions/feed-panel/feed-atom.c +++ b/extensions/feed-panel/feed-atom.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2009 Dale Whittaker + Copyright (C) 2009-2010 Dale Whittaker 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 5a9e8e3f..1f7c41b0 100644 --- a/extensions/feed-panel/feed-parse.c +++ b/extensions/feed-panel/feed-parse.c @@ -13,12 +13,19 @@ #include 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 e8022634..8351fd53 100644 --- a/extensions/feed-panel/feed-rss.c +++ b/extensions/feed-panel/feed-rss.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2009 Dale Whittaker + Copyright (C) 2009-2010 Dale Whittaker 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")) -- 2.39.5