Updated a few comments.
Renamed generator to follow *_FEED_GENERATOR naming. Renamed feed entry as feed item. Made FEED conforms to ITERABLE [FEED_ITEM] for convenience.
This commit is contained in:
@@ -4,7 +4,7 @@ note
|
|||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
|
|
||||||
class
|
class
|
||||||
ATOM_GENERATOR
|
ATOM_FEED_GENERATOR
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
FEED_VISITOR
|
FEED_VISITOR
|
||||||
@@ -44,7 +44,7 @@ feature -- Visitor
|
|||||||
append_content_tag_to ("updated", Void, date_to_string (dt), buffer)
|
append_content_tag_to ("updated", Void, date_to_string (dt), buffer)
|
||||||
end
|
end
|
||||||
across
|
across
|
||||||
a_feed.entries as ic
|
a_feed.items as ic
|
||||||
loop
|
loop
|
||||||
ic.item.accept (Current)
|
ic.item.accept (Current)
|
||||||
end
|
end
|
||||||
@@ -53,7 +53,7 @@ feature -- Visitor
|
|||||||
buffer.append ("</feed>")
|
buffer.append ("</feed>")
|
||||||
end
|
end
|
||||||
|
|
||||||
visit_entry (a_entry: FEED_ENTRY)
|
visit_item (a_entry: FEED_ITEM)
|
||||||
do
|
do
|
||||||
buffer.append (indentation)
|
buffer.append (indentation)
|
||||||
buffer.append ("<entry>%N")
|
buffer.append ("<entry>%N")
|
||||||
@@ -36,7 +36,7 @@ feature -- Access
|
|||||||
local
|
local
|
||||||
l_title: READABLE_STRING_32
|
l_title: READABLE_STRING_32
|
||||||
x_entry, x_link: detachable XML_ELEMENT
|
x_entry, x_link: detachable XML_ELEMENT
|
||||||
e: FEED_ENTRY
|
e: FEED_ITEM
|
||||||
l_author: FEED_AUTHOR
|
l_author: FEED_AUTHOR
|
||||||
lnk: FEED_LINK
|
lnk: FEED_LINK
|
||||||
s: STRING_32
|
s: STRING_32
|
||||||
@@ -92,7 +92,7 @@ feature -- Access
|
|||||||
e.set_author (l_author)
|
e.set_author (l_author)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Result.add_entry (e)
|
Result.add_item (e)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
note
|
note
|
||||||
description: "Collection of default feed parsers."
|
description: "[
|
||||||
|
Collection of default feed parsers provided by the current library.
|
||||||
|
A new parser can be easily added via `parsers.extend (...)'.
|
||||||
|
]"
|
||||||
date: "$Date$"
|
date: "$Date$"
|
||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
|
|
||||||
@@ -32,7 +35,8 @@ feature -- Access
|
|||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
feed_from_string (a_atom_content: READABLE_STRING_8): detachable FEED
|
feed_from_string (a_content: READABLE_STRING_8): detachable FEED
|
||||||
|
-- Feed object from `a_content' string, if a parser is able to parse.it.
|
||||||
local
|
local
|
||||||
p: XML_STANDARD_PARSER
|
p: XML_STANDARD_PARSER
|
||||||
cb_tree: XML_CALLBACKS_FILTER_DOCUMENT
|
cb_tree: XML_CALLBACKS_FILTER_DOCUMENT
|
||||||
@@ -41,7 +45,7 @@ feature -- Access
|
|||||||
create p.make
|
create p.make
|
||||||
create cb_tree.make_null
|
create cb_tree.make_null
|
||||||
p.set_callbacks (cb_tree)
|
p.set_callbacks (cb_tree)
|
||||||
p.parse_from_string_8 (a_atom_content)
|
p.parse_from_string_8 (a_content)
|
||||||
if p.is_correct then
|
if p.is_correct then
|
||||||
xdoc := cb_tree.document
|
xdoc := cb_tree.document
|
||||||
Result := feed (xdoc)
|
Result := feed (xdoc)
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ class
|
|||||||
inherit
|
inherit
|
||||||
FEED_HELPERS
|
FEED_HELPERS
|
||||||
|
|
||||||
|
ITERABLE [FEED_ITEM]
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
|
|
||||||
@@ -17,7 +19,7 @@ feature {NONE} -- Initialization
|
|||||||
make (a_title: READABLE_STRING_GENERAL)
|
make (a_title: READABLE_STRING_GENERAL)
|
||||||
do
|
do
|
||||||
create title.make_from_string_general (a_title)
|
create title.make_from_string_general (a_title)
|
||||||
create entries.make (1)
|
create items.make (1)
|
||||||
create links.make (1)
|
create links.make (1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -42,9 +44,17 @@ feature -- Access
|
|||||||
links: STRING_TABLE [FEED_LINK]
|
links: STRING_TABLE [FEED_LINK]
|
||||||
-- Url indexed by relation
|
-- Url indexed by relation
|
||||||
|
|
||||||
entries: ARRAYED_LIST [FEED_ENTRY]
|
items: ARRAYED_LIST [FEED_ITEM]
|
||||||
-- List of feed items.
|
-- List of feed items.
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
new_cursor: ITERATION_CURSOR [FEED_ITEM]
|
||||||
|
-- <Precursor>
|
||||||
|
do
|
||||||
|
Result := items.new_cursor
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Element change
|
feature -- Element change
|
||||||
|
|
||||||
set_description (a_description: detachable READABLE_STRING_GENERAL; a_description_content_type: like description_content_type)
|
set_description (a_description: detachable READABLE_STRING_GENERAL; a_description_content_type: like description_content_type)
|
||||||
@@ -69,6 +79,7 @@ feature -- Element change
|
|||||||
end
|
end
|
||||||
|
|
||||||
set_updated_date_with_text (a_date_text: detachable READABLE_STRING_32)
|
set_updated_date_with_text (a_date_text: detachable READABLE_STRING_32)
|
||||||
|
-- Set `date' from date string representation `a_date_text'.
|
||||||
do
|
do
|
||||||
if a_date_text = Void then
|
if a_date_text = Void then
|
||||||
date := Void
|
date := Void
|
||||||
@@ -77,9 +88,10 @@ feature -- Element change
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
add_entry (e: FEED_ENTRY)
|
add_item (a_item: FEED_ITEM)
|
||||||
|
-- Add item `a_item' to feed `items'.
|
||||||
do
|
do
|
||||||
entries.force (e)
|
items.force (a_item)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Visitor
|
feature -- Visitor
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
note
|
note
|
||||||
description: "Object representing author of Feed or feed entry."
|
description: "[
|
||||||
|
Author of feed or feed entry.
|
||||||
|
- name and email information.
|
||||||
|
]"
|
||||||
date: "$Date$"
|
date: "$Date$"
|
||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
note
|
note
|
||||||
description: "Item of feed."
|
description: "[
|
||||||
|
A feed contains a list of items.
|
||||||
|
This FEED_ITEM interface provides
|
||||||
|
- title, description, content, id, date, ...
|
||||||
|
- could be compared with other item to sort by date+title.
|
||||||
|
]"
|
||||||
date: "$Date$"
|
date: "$Date$"
|
||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
|
|
||||||
class
|
class
|
||||||
FEED_ENTRY
|
FEED_ITEM
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
FEED_HELPERS
|
FEED_HELPERS
|
||||||
@@ -41,6 +46,7 @@ feature -- Access
|
|||||||
-- By default, this should be text/html.
|
-- By default, this should be text/html.
|
||||||
|
|
||||||
content_type_or_default (dft: READABLE_STRING_8): READABLE_STRING_8
|
content_type_or_default (dft: READABLE_STRING_8): READABLE_STRING_8
|
||||||
|
-- Associated content type, and if none, return given value `dft'.
|
||||||
do
|
do
|
||||||
if attached content_type as l_type then
|
if attached content_type as l_type then
|
||||||
Result := l_type
|
Result := l_type
|
||||||
@@ -166,7 +172,7 @@ feature -- Visitor
|
|||||||
|
|
||||||
accept (vis: FEED_VISITOR)
|
accept (vis: FEED_VISITOR)
|
||||||
do
|
do
|
||||||
vis.visit_entry (Current)
|
vis.visit_item (Current)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -4,7 +4,7 @@ note
|
|||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
|
|
||||||
class
|
class
|
||||||
RSS_2_GENERATOR
|
RSS_2_FEED_GENERATOR
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
FEED_VISITOR
|
FEED_VISITOR
|
||||||
@@ -43,7 +43,7 @@ feature -- Visitor
|
|||||||
append_content_tag_to ("lastBuildDate", Void, date_to_string (dt), buffer)
|
append_content_tag_to ("lastBuildDate", Void, date_to_string (dt), buffer)
|
||||||
end
|
end
|
||||||
across
|
across
|
||||||
a_feed.entries as ic
|
a_feed.items as ic
|
||||||
loop
|
loop
|
||||||
ic.item.accept (Current)
|
ic.item.accept (Current)
|
||||||
end
|
end
|
||||||
@@ -55,33 +55,33 @@ feature -- Visitor
|
|||||||
]")
|
]")
|
||||||
end
|
end
|
||||||
|
|
||||||
visit_entry (a_entry: FEED_ENTRY)
|
visit_item (a_item: FEED_ITEM)
|
||||||
do
|
do
|
||||||
buffer.append (indentation)
|
buffer.append (indentation)
|
||||||
buffer.append ("<item>%N")
|
buffer.append ("<item>%N")
|
||||||
indent
|
indent
|
||||||
append_content_tag_to ("title", Void, a_entry.title, buffer)
|
append_content_tag_to ("title", Void, a_item.title, buffer)
|
||||||
if attached a_entry.date as dt then
|
if attached a_item.date as dt then
|
||||||
append_content_tag_to ("pubDate", Void, date_to_string (dt), buffer)
|
append_content_tag_to ("pubDate", Void, date_to_string (dt), buffer)
|
||||||
end
|
end
|
||||||
across
|
across
|
||||||
a_entry.links as tb
|
a_item.links as tb
|
||||||
loop
|
loop
|
||||||
tb.item.accept (Current)
|
tb.item.accept (Current)
|
||||||
end
|
end
|
||||||
if attached a_entry.author as u then
|
if attached a_item.author as u then
|
||||||
u.accept (Current)
|
u.accept (Current)
|
||||||
end
|
end
|
||||||
if attached a_entry.categories as cats then
|
if attached a_item.categories as cats then
|
||||||
across
|
across
|
||||||
cats as ic
|
cats as ic
|
||||||
loop
|
loop
|
||||||
append_content_tag_to ("category", Void, ic.item, buffer)
|
append_content_tag_to ("category", Void, ic.item, buffer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
append_content_tag_to ("guid", Void, a_entry.id, buffer)
|
append_content_tag_to ("guid", Void, a_item.id, buffer)
|
||||||
append_content_tag_to ("description", Void, a_entry.description, buffer)
|
append_content_tag_to ("description", Void, a_item.description, buffer)
|
||||||
append_cdata_content_tag_to ("content:encoded", Void, a_entry.content, buffer)
|
append_cdata_content_tag_to ("content:encoded", Void, a_item.content, buffer)
|
||||||
|
|
||||||
exdent
|
exdent
|
||||||
buffer.append (indentation)
|
buffer.append (indentation)
|
||||||
@@ -40,7 +40,7 @@ feature -- Access
|
|||||||
local
|
local
|
||||||
lnk: FEED_LINK
|
lnk: FEED_LINK
|
||||||
x_item, x_content, x_author: detachable XML_ELEMENT
|
x_item, x_content, x_author: detachable XML_ELEMENT
|
||||||
e: FEED_ENTRY
|
e: FEED_ITEM
|
||||||
l_author: FEED_AUTHOR
|
l_author: FEED_AUTHOR
|
||||||
do
|
do
|
||||||
if attached xdoc.element_by_name ("rss") as x_rss then
|
if attached xdoc.element_by_name ("rss") as x_rss then
|
||||||
@@ -112,7 +112,7 @@ feature -- Access
|
|||||||
else
|
else
|
||||||
e.set_content (xml_element_code (x_content), Void)
|
e.set_content (xml_element_code (x_content), Void)
|
||||||
end
|
end
|
||||||
Result.add_entry (e)
|
Result.add_item (e)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
note
|
note
|
||||||
description: "Convert a FEED to STRING_32 representation. Mostly for debug output."
|
description: "[
|
||||||
|
Convert a FEED to STRING_32 representation.
|
||||||
|
Mostly for debug output!
|
||||||
|
]"
|
||||||
date: "$Date$"
|
date: "$Date$"
|
||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
|
|
||||||
class
|
class
|
||||||
FEED_TO_STRING_32_VISITOR
|
FEED_TO_STRING_32_DEBUG_VISITOR
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
FEED_VISITOR
|
FEED_VISITOR
|
||||||
@@ -55,7 +58,7 @@ feature -- Visitor
|
|||||||
append_new_line
|
append_new_line
|
||||||
|
|
||||||
across
|
across
|
||||||
a_feed.entries as ic
|
a_feed.items as ic
|
||||||
loop
|
loop
|
||||||
exdent
|
exdent
|
||||||
append_text (create {STRING_32}.make_filled ('-', 40))
|
append_text (create {STRING_32}.make_filled ('-', 40))
|
||||||
@@ -66,7 +69,7 @@ feature -- Visitor
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
visit_entry (a_entry: FEED_ENTRY)
|
visit_item (a_entry: FEED_ITEM)
|
||||||
do
|
do
|
||||||
if attached a_entry.id as l_id then
|
if attached a_entry.id as l_id then
|
||||||
append_text ("#")
|
append_text ("#")
|
||||||
@@ -16,7 +16,7 @@ feature -- Visit
|
|||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
visit_entry (a_entry: FEED_ENTRY)
|
visit_item (a_item: FEED_ITEM)
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ feature -- Initialization
|
|||||||
test_feed (t: READABLE_STRING_8)
|
test_feed (t: READABLE_STRING_8)
|
||||||
local
|
local
|
||||||
feed_parser: FEED_DEFAULT_PARSERS
|
feed_parser: FEED_DEFAULT_PARSERS
|
||||||
vis: FEED_TO_STRING_32_VISITOR
|
vis: FEED_TO_STRING_32_DEBUG_VISITOR
|
||||||
gen: RSS_2_GENERATOR
|
gen: RSS_2_FEED_GENERATOR
|
||||||
atom_gen: ATOM_GENERATOR
|
atom_gen: ATOM_FEED_GENERATOR
|
||||||
s: STRING_32
|
s: STRING_32
|
||||||
s8: STRING_8
|
s8: STRING_8
|
||||||
pp: XML_PRETTY_PRINT_FILTER
|
pp: XML_PRETTY_PRINT_FILTER
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ feature -- Test routines
|
|||||||
-- New test routine
|
-- New test routine
|
||||||
local
|
local
|
||||||
feed_parser: FEED_DEFAULT_PARSERS
|
feed_parser: FEED_DEFAULT_PARSERS
|
||||||
vis: FEED_TO_STRING_32_VISITOR
|
vis: FEED_TO_STRING_32_DEBUG_VISITOR
|
||||||
s: STRING_32
|
s: STRING_32
|
||||||
do
|
do
|
||||||
create feed_parser
|
create feed_parser
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ feature -- Test routines
|
|||||||
-- New test routine
|
-- New test routine
|
||||||
local
|
local
|
||||||
feed_parser: FEED_DEFAULT_PARSERS
|
feed_parser: FEED_DEFAULT_PARSERS
|
||||||
vis: FEED_TO_STRING_32_VISITOR
|
vis: FEED_TO_STRING_32_DEBUG_VISITOR
|
||||||
s: STRING_32
|
s: STRING_32
|
||||||
do
|
do
|
||||||
create feed_parser
|
create feed_parser
|
||||||
|
|||||||
Reference in New Issue
Block a user