}
}
+static gchar*
+atom_get_title (FeedParser* fparser)
+{
+ if (!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);
+}
+
static void
atom_preparse_entry (FeedParser* fparser)
{
}
else if (!xmlStrcmp (node->name, BAD_CAST "title"))
{
- content = feed_get_element_string (fparser);
+ content = atom_get_title (fparser);
katze_item_set_name (fparser->item, content);
}
else if (!xmlStrcmp (node->name, BAD_CAST "summary"))
}
else if (!xmlStrcmp (node->name, BAD_CAST "title"))
{
- content = feed_get_element_string (fparser);
+ content = atom_get_title (fparser);
katze_item_set_name (fparser->item, content);
}
else if (!xmlStrcmp (node->name, BAD_CAST "subtitle"))
g_assert (KATZE_IS_ITEM (item));
title = katze_item_get_name (item);
- if (!title)
+ if (!title || !*title || g_str_equal (title, " "))
title = katze_item_get_text (item);
- if (!title)
+ if (!title || !*title || g_str_equal (title, " "))
title = katze_item_get_uri (item);
g_object_set (renderer, "text", title, NULL);
text = g_strdup (katze_item_get_text (KATZE_ITEM (item)));
else
{
+ KatzeItem* parent;
+ const gchar* puri;
+
+ parent = katze_item_get_parent (item);
+ g_assert (KATZE_IS_ARRAY (parent));
date = katze_item_get_added (item);
+ puri = katze_item_get_uri (parent);
if (date)
{
time_t date_t;
const struct tm* tm;
static gchar date_format[512];
- const gchar* puri;
- KatzeItem* parent;
gchar* last_updated;
date_t = (time_t)date;
tm = localtime (&date_t);
/* Some gcc versions complain about "%c" for no reason */
strftime (date_format, sizeof (date_format), "%c", tm);
- parent = katze_item_get_parent (item);
- g_assert (KATZE_IS_ARRAY (parent));
- puri = katze_item_get_uri (parent);
/* i18n: The local date a feed was last updated */
last_updated = g_strdup_printf (C_("Feed", "Last updated: %s."),
date_format);
puri, last_updated);
g_free (last_updated);
}
+ else
+ {
+ text = g_strdup_printf (
+ "<html><head><title>feed</title></head>"
+ "<body><h3>%s</h3></body></html>", puri);
+ }
}
webkit_web_view_load_html_string (
WEBKIT_WEB_VIEW (panel->webview), text ? text : "", uri);
else
{
text = katze_item_get_text (item);
- if (text)
- {
- webkit_web_view_load_html_string (
- WEBKIT_WEB_VIEW (panel->webview), text, uri);
- }
+ webkit_web_view_load_html_string (
+ WEBKIT_WEB_VIEW (panel->webview), text ? text : "", uri);
}
g_object_unref (item);
}
return g_strdup (" ");
}
- return (gchar* )xmlNodeListGetString (fparser->doc, node->children, 1);
+ return (gchar*)xmlNodeListGetString (fparser->doc, node->children, 1);
+}
+
+void
+handle_markup_chars (void* user_data,
+ const xmlChar* ch,
+ int len)
+{
+ gchar** markup;
+ gchar* temp;
+
+ markup = (gchar**)user_data;
+ temp = g_strndup ((gchar*)ch, len);
+ *markup = (*markup) ? g_strconcat (*markup, temp, NULL) : g_strdup (temp);
+ g_free (temp);
+}
+
+gchar*
+feed_get_element_markup (FeedParser* fparser)
+{
+ gchar* markup;
+ const xmlChar* stag;
+
+ markup = feed_get_element_string (fparser);
+ if ((stag = xmlStrchr (BAD_CAST markup, '<')) && xmlStrchr (stag, '>'))
+ {
+ gchar* text = NULL;
+ htmlSAXHandlerPtr psax;
+
+ psax = g_new0 (htmlSAXHandler, 1);
+ psax->characters = handle_markup_chars;
+ htmlSAXParseDoc (BAD_CAST markup, NULL, psax, &text);
+ g_free (psax);
+ g_free (markup);
+ return text;
+ }
+ return markup;
}
gint64
#include <libsoup/soup.h>
#include <libxml/parser.h>
+#include <libxml/HTMLparser.h>
G_BEGIN_DECLS
#define feed_parser_set_error(fparser, err, msg) \
*(fparser)->error = g_error_new ( \
FEED_PARSE_ERROR, (err), (msg))
+
gchar*
feed_get_element_string (FeedParser* fparser);
+gchar*
+feed_get_element_markup (FeedParser* fparser);
+
gint64
feed_get_element_date (FeedParser* fparser);
}
else if (!xmlStrcmp (node->name, BAD_CAST "title"))
{
- content = feed_get_element_string (fparser);
+ content = feed_get_element_markup (fparser);
katze_item_set_name (fparser->item, content);
}
else if (!xmlStrcmp (node->name, BAD_CAST "description"))
if (!xmlStrcmp (node->name, BAD_CAST "title"))
{
- content = feed_get_element_string (fparser);
+ content = feed_get_element_markup (fparser);
katze_item_set_name (fparser->item, content);
}
else if (!xmlStrcmp (node->name, BAD_CAST "description"))