1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-01 03:36:26 -04:00

Add basic support for RSS parsing for application/rss+xml content types

This means the RSS source will be highlighted, but by default the HTML
renderer will be used for the default rendering.
This commit is contained in:
Jonas Fonseca 2005-12-20 03:08:13 +01:00 committed by Jonas Fonseca
parent 5777941d06
commit 56d634b946
10 changed files with 92 additions and 3 deletions

View File

@ -811,6 +811,7 @@ render_dom_document(struct cache_entry *cached, struct document *document,
struct dom_renderer renderer;
struct conv_table *convert_table;
struct sgml_parser *parser;
enum sgml_document_type doctype;
assert(document->options.plain);
@ -824,7 +825,13 @@ render_dom_document(struct cache_entry *cached, struct document *document,
document->bgcolor = document->options.default_bg;
parser = init_sgml_parser(SGML_PARSER_STREAM, SGML_DOCTYPE_HTML,
if (cached->content_type
&& !strlcasecmp("application/rss+xml", 19, cached->content_type, -1))
doctype = SGML_DOCTYPE_RSS;
else
doctype = SGML_DOCTYPE_HTML;
parser = init_sgml_parser(SGML_PARSER_STREAM, doctype,
&renderer, cached->uri,
dom_source_renderer_push_callbacks,
dom_source_renderer_pop_callbacks);

View File

@ -19,6 +19,7 @@
#include "document/html/renderer.h"
#include "document/plain/renderer.h"
#include "document/renderer.h"
#include "document/rss/renderer.h"
#include "document/view.h"
#include "ecmascript/ecmascript.h"
#include "encoding/encoding.h"
@ -241,7 +242,8 @@ render_encoded_document(struct cache_entry *cached, struct document *document)
if (document->options.plain) {
#ifdef CONFIG_DOM
if (cached->content_type
&& !strlcasecmp("text/html", 9, cached->content_type, -1))
&& (!strlcasecmp("text/html", 9, cached->content_type, -1)
|| !strlcasecmp("application/rss+xml", 19, cached->content_type, -1)))
render_dom_document(cached, document, &buffer);
else
#endif

View File

@ -1,7 +1,7 @@
top_builddir=../../..
include $(top_builddir)/Makefile.config
SUBDIRS = html
SUBDIRS = html rss
OBJS = sgml.o parser.o scanner.o
include $(top_srcdir)/Makefile.lib

View File

@ -0,0 +1,3 @@
/* RSS attributes */
RSS_(ATTRIBUTE, ISPERMALINK, 0),

View File

@ -0,0 +1,10 @@
/* RSS elements */
RSS_(ELEMENT, CHANNEL, 0),
RSS_(ELEMENT, ITEM, 0),
RSS_(ELEMENT, TITLE, 0),
RSS_(ELEMENT, AUTHOR, 0),
RSS_(ELEMENT, PUBDATE, 0),
RSS_(ELEMENT, GUID, 0),
RSS_(ELEMENT, LINK, 0),
RSS_(ELEMENT, DESCRIPTION, 0),

View File

@ -0,0 +1,35 @@
/* SGML node handling */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "elinks.h"
#include "document/sgml/rss/rss.h"
#include "document/sgml/sgml.h"
#define RSS_(node, name, id) SGML_NODE_INFO(RSS, node, name, id)
static struct sgml_node_info rss_attributes[RSS_ATTRIBUTES] = {
SGML_NODE_HEAD(RSS, ATTRIBUTE),
#include "document/sgml/rss/attribute.inc"
};
static struct sgml_node_info rss_elements[RSS_ELEMENTS] = {
SGML_NODE_HEAD(RSS, ELEMENT),
#include "document/sgml/rss/element.inc"
};
struct sgml_info sgml_rss_info = {
SGML_DOCTYPE_RSS,
rss_attributes,
rss_elements,
};

View File

@ -0,0 +1,28 @@
#ifndef EL__DOCUMENT_SGML_RSS_RSS_H
#define EL__DOCUMENT_SGML_RSS_RSS_H
#include "document/sgml/sgml.h"
extern struct sgml_info sgml_rss_info;
#define RSS_(node, name, flags) SGML_NODE_INFO_TYPE(RSS, node, name)
enum rss_element_type {
RSS_ELEMENT_UNKNOWN,
#include "document/sgml/rss/element.inc"
RSS_ELEMENTS,
};
enum rss_attribute_type {
RSS_ATTRIBUTE_UNKNOWN,
#include "document/sgml/rss/attribute.inc"
RSS_ATTRIBUTES,
};
#undef RSS_
#endif

View File

@ -17,6 +17,7 @@
/* Backend includes: */
#include "document/sgml/html/html.h"
#include "document/sgml/rss/rss.h"
int
@ -30,6 +31,7 @@ sgml_info_strcmp(const void *key_, const void *node_)
struct sgml_info *sgml_info[SGML_DOCTYPES] = {
&sgml_html_info,
&sgml_rss_info,
};
struct sgml_info *

View File

@ -77,6 +77,7 @@ get_sgml_node_info(struct sgml_node_info list[], struct dom_node *node)
enum sgml_document_type {
SGML_DOCTYPE_HTML,
SGML_DOCTYPE_RSS,
SGML_DOCTYPES,
};

View File

@ -1146,6 +1146,7 @@ struct {
} static known_types[] = {
{ "text/html", 0 },
{ "application/xhtml+xml", 0 }, /* RFC 3236 */
{ "application/rss+xml", 0 },
{ "text/plain", 1 },
{ NULL, 1 },
};