From a5e150d1c021018c579989f041a795a9a9d17724 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 8 Sep 2015 21:45:27 +0200 Subject: [PATCH] Improved feed library with comments, bug fixes and code factorization. --- .../parser/feed/src/atom/atom_feed_parser.e | 2 +- .../parser/feed/src/atom/atom_generator.e | 13 +++-------- library/text/parser/feed/src/kernel/feed.e | 14 +++++++----- .../text/parser/feed/src/kernel/feed_author.e | 3 +-- .../text/parser/feed/src/kernel/feed_entry.e | 5 +---- .../text/parser/feed/src/kernel/feed_link.e | 6 +++-- .../parser/feed/src/rss/rss_2_feed_parser.e | 2 +- .../parser/feed/src/rss/rss_2_generator.e | 13 +++-------- .../parser/feed/src/support/feed_generator.e | 22 +++++++++++++++---- .../parser/feed/src/support/feed_visitor.e | 3 +-- tools/install_ewf.bat | 2 ++ tools/uninstall_ewf.bat | 2 ++ 12 files changed, 46 insertions(+), 41 deletions(-) diff --git a/library/text/parser/feed/src/atom/atom_feed_parser.e b/library/text/parser/feed/src/atom/atom_feed_parser.e index 75c89691..b8c538c1 100644 --- a/library/text/parser/feed/src/atom/atom_feed_parser.e +++ b/library/text/parser/feed/src/atom/atom_feed_parser.e @@ -48,7 +48,7 @@ feature -- Access then l_title := t create Result.make (l_title) - Result.set_description (xml_element_text (x_feed, "subtitle")) + Result.set_description (xml_element_text (x_feed, "subtitle"), "plain") Result.set_id (xml_element_text (x_feed, "id")) Result.set_updated_date_with_text (xml_element_text (x_feed, "updated")) if attached links_from_xml (x_feed, "link") as l_links then diff --git a/library/text/parser/feed/src/atom/atom_generator.e b/library/text/parser/feed/src/atom/atom_generator.e index c5d3aa01..00f1a8d3 100644 --- a/library/text/parser/feed/src/atom/atom_generator.e +++ b/library/text/parser/feed/src/atom/atom_generator.e @@ -10,20 +10,13 @@ inherit FEED_VISITOR FEED_GENERATOR + rename + process_feed as visit_feed + end create make -feature {NONE} -- Initialization - - make (a_buffer: STRING_8) - do - buffer := a_buffer - create indentation.make_empty - end - - buffer: STRING_8 - feature -- Visitor visit_feed (a_feed: FEED) diff --git a/library/text/parser/feed/src/kernel/feed.e b/library/text/parser/feed/src/kernel/feed.e index fdb47957..8a951519 100644 --- a/library/text/parser/feed/src/kernel/feed.e +++ b/library/text/parser/feed/src/kernel/feed.e @@ -1,6 +1,5 @@ note - description: "Summary description for {FEED}." - author: "" + description: "FEED interface, could be RSS, ATOM, ..." date: "$Date$" revision: "$Revision$" @@ -30,6 +29,10 @@ feature -- Access description: detachable IMMUTABLE_STRING_32 -- Associated description/subtitle. + description_content_type: detachable READABLE_STRING_8 + -- Optional content type for `description'. + -- By default, this should be text/plain. + id: detachable IMMUTABLE_STRING_32 -- Id associated with Current feed if any. @@ -44,12 +47,15 @@ feature -- Access feature -- Element change - set_description (a_description: detachable READABLE_STRING_GENERAL) + set_description (a_description: detachable READABLE_STRING_GENERAL; a_description_content_type: like description_content_type) + -- Set `description' with `a_description' and optional content type `text:$a_description_content_type'. do if a_description = Void then description := Void + description_content_type := Void else create description.make_from_string_general (a_description) + description_content_type := a_description_content_type end end @@ -83,6 +89,4 @@ feature -- Visitor vis.visit_feed (Current) end -invariant - end diff --git a/library/text/parser/feed/src/kernel/feed_author.e b/library/text/parser/feed/src/kernel/feed_author.e index 45ae8c49..7d841d2b 100644 --- a/library/text/parser/feed/src/kernel/feed_author.e +++ b/library/text/parser/feed/src/kernel/feed_author.e @@ -1,6 +1,5 @@ note - description: "Summary description for {FEED_AUTHOR}." - author: "" + description: "Object representing author of Feed or feed entry." date: "$Date$" revision: "$Revision$" diff --git a/library/text/parser/feed/src/kernel/feed_entry.e b/library/text/parser/feed/src/kernel/feed_entry.e index 31b7efdc..097acf89 100644 --- a/library/text/parser/feed/src/kernel/feed_entry.e +++ b/library/text/parser/feed/src/kernel/feed_entry.e @@ -1,6 +1,5 @@ note - description: "Summary description for {FEED_ENTRY}." - author: "" + description: "Item of feed." date: "$Date$" revision: "$Revision$" @@ -170,6 +169,4 @@ feature -- Visitor vis.visit_entry (Current) end -invariant - end diff --git a/library/text/parser/feed/src/kernel/feed_link.e b/library/text/parser/feed/src/kernel/feed_link.e index afe81df1..8c72682d 100644 --- a/library/text/parser/feed/src/kernel/feed_link.e +++ b/library/text/parser/feed/src/kernel/feed_link.e @@ -1,6 +1,5 @@ note - description: "Summary description for {FEED_LINK}." - author: "" + description: "Link mentioned in feed and feed entry." date: "$Date$" revision: "$Revision$" @@ -21,10 +20,13 @@ feature {NONE} -- Initialization feature -- Access href: READABLE_STRING_8 + -- Location of Current link. relation: READABLE_STRING_32 + -- Relation associated with Current link. type: detachable READABLE_STRING_8 + -- Optional type of link. feature -- Element change diff --git a/library/text/parser/feed/src/rss/rss_2_feed_parser.e b/library/text/parser/feed/src/rss/rss_2_feed_parser.e index 162ffb14..e9e860ca 100644 --- a/library/text/parser/feed/src/rss/rss_2_feed_parser.e +++ b/library/text/parser/feed/src/rss/rss_2_feed_parser.e @@ -51,7 +51,7 @@ feature -- Access if attached x_rss.element_by_name ("channel") as x_channel then if attached xml_element_text (x_channel, "title") as x_title then create Result.make (x_title) - Result.set_description (xml_element_text (x_channel, "description")) + Result.set_description (xml_element_text (x_channel, "description"), "xhtml") Result.set_updated_date_with_text (xml_element_text (x_channel, "lastBuildDate")) if attached links_from_xml (x_channel, "link") as l_links then across diff --git a/library/text/parser/feed/src/rss/rss_2_generator.e b/library/text/parser/feed/src/rss/rss_2_generator.e index dd506794..640693ae 100644 --- a/library/text/parser/feed/src/rss/rss_2_generator.e +++ b/library/text/parser/feed/src/rss/rss_2_generator.e @@ -10,20 +10,13 @@ inherit FEED_VISITOR FEED_GENERATOR + rename + process_feed as visit_feed + end create make -feature {NONE} -- Initialization - - make (a_buffer: STRING_8) - do - buffer := a_buffer - initialize - end - - buffer: STRING_8 - feature -- Visitor visit_feed (a_feed: FEED) diff --git a/library/text/parser/feed/src/support/feed_generator.e b/library/text/parser/feed/src/support/feed_generator.e index 3396c135..efbb8b8e 100644 --- a/library/text/parser/feed/src/support/feed_generator.e +++ b/library/text/parser/feed/src/support/feed_generator.e @@ -1,6 +1,5 @@ note - description: "Summary description for {FEED_GENERATOR}." - author: "" + description: "Common ancestor for feed generator." date: "$Date$" revision: "$Revision$" @@ -10,13 +9,28 @@ deferred class inherit XML_UTILITIES -feature {NONE} -- Helpers +feature {NONE} -- Initialization - initialize + make (a_buffer: STRING_8) do + buffer := a_buffer create indentation.make_empty end +feature -- Access + + buffer: STRING_8 + -- Output of feed conversion. + +feature -- Conversion + + process_feed (a_feed: FEED) + -- Convert `a_feed' into string representation in `buffer'. + deferred + end + +feature {NONE} -- Helpers + indent do indentation.append ("%T") diff --git a/library/text/parser/feed/src/support/feed_visitor.e b/library/text/parser/feed/src/support/feed_visitor.e index a0f22d97..05a8cba2 100644 --- a/library/text/parser/feed/src/support/feed_visitor.e +++ b/library/text/parser/feed/src/support/feed_visitor.e @@ -1,6 +1,5 @@ note - description: "Summary description for {FEED_VISITOR}." - author: "" + description: "Interface to visit Feed objects." date: "$Date$" revision: "$Revision$" diff --git a/tools/install_ewf.bat b/tools/install_ewf.bat index 8e26ee65..59816bcf 100644 --- a/tools/install_ewf.bat +++ b/tools/install_ewf.bat @@ -98,6 +98,8 @@ echo Install library: openid echo Install library: uri_template %COPYCMD% %TMP_DIR%\library\text\parser\uri_template %TMP_CONTRIB_DIR%\library\text\parser\uri_template +echo Install library: feed +%COPYCMD% %TMP_DIR%\library\text\parser\feed %TMP_CONTRIB_DIR%\library\text\parser\feed echo Install library: notification_email %SAFE_MD% %TMP_CONTRIB_DIR%\library\runtime diff --git a/tools/uninstall_ewf.bat b/tools/uninstall_ewf.bat index 39232ac2..f1cef7c3 100644 --- a/tools/uninstall_ewf.bat +++ b/tools/uninstall_ewf.bat @@ -65,6 +65,8 @@ echo Uninstall library: security\openid %RDCMD% %TMP_CONTRIB_DIR%\library\web\authentication\openid echo Uninstall library: uri_template %RDCMD% %TMP_CONTRIB_DIR%\library\text\parser\uri_template +echo Uninstall library: feed +%RDCMD% %TMP_CONTRIB_DIR%\library\text\parser\feed echo Uninstall library: runtime\process\notification_email %RDCMD% %TMP_CONTRIB_DIR%\library\runtime\process\notification_email