Improved feed aggregation module.
Added support to choose either atom or rss for the "/feed" format. Added support for feed format view to feed aggregation. Use proper content type for RSS and ATOM response. For feed aggregation use `?view=feed` or `?view=feed.atom` or `?view=feed.rss` Improved sized feed view. Use site name for recent changes feed title. Better name for node feeds (include the site name). Use current date when a feed aggregation is converted to a new feed, to set the last build date. Fixed category filter per feed location for the feed aggregation module. Fixed authentication module, where a potential case (but not probable) had no response content. Cosmetic and minor changes on messaging module.
This commit is contained in:
@@ -90,16 +90,33 @@ feature -- Handle
|
||||
end
|
||||
if attached {WSF_STRING} req.path_parameter ("feed_id") as p_feed_id then
|
||||
if attached feed_aggregation (p_feed_id.value) as l_agg then
|
||||
if attached {WSF_STRING} req.query_parameter ("view") as p_view and then p_view.same_string ("embedded") then
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, a_api)
|
||||
if attached feed_to_html (p_feed_id.value, nb, True, r) as l_html then
|
||||
r := Void
|
||||
if
|
||||
attached {WSF_STRING} req.query_parameter ("view") as p_view and then
|
||||
p_view.same_string ("embedded")
|
||||
then
|
||||
if attached feed_to_html (p_feed_id.value, nb, True, create {GENERIC_VIEW_CMS_RESPONSE}.make (req, res, a_api)) as l_html then
|
||||
create m.make_with_body (l_html)
|
||||
m.header.put_content_type_text_html
|
||||
res.send (m)
|
||||
else
|
||||
a_api.response_api.send_not_found (Void, req, res)
|
||||
end
|
||||
elseif
|
||||
attached {WSF_STRING} req.query_parameter ("view") as p_view and then
|
||||
(p_view.same_string ("feed") or p_view.same_string ("feed.atom")) and then
|
||||
attached feed_to_atom (p_feed_id.value, nb) as l_feed_content
|
||||
then
|
||||
create m.make_with_body (l_feed_content)
|
||||
m.header.put_content_type ("application/atom+xml")
|
||||
res.send (m)
|
||||
elseif
|
||||
attached {WSF_STRING} req.query_parameter ("view") as p_view and then
|
||||
(p_view.same_string ("feed.rss")) and then
|
||||
attached feed_to_rss (p_feed_id.value, nb) as l_feed_content
|
||||
then
|
||||
create m.make_with_body (l_feed_content)
|
||||
m.header.put_content_type ("application/rss+xml")
|
||||
res.send (m)
|
||||
else
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, a_api)
|
||||
create s.make_empty
|
||||
@@ -130,13 +147,29 @@ feature -- Handle
|
||||
s.append (ic.item)
|
||||
s.append ("%">")
|
||||
s.append (ic.item)
|
||||
s.append ("</a></li>")
|
||||
s.append ("</a>")
|
||||
if
|
||||
attached l_agg.included_categories_per_feed as tb and then
|
||||
attached tb.item (ic.item) as l_cats
|
||||
then
|
||||
s.append ("<span class=%"category%">")
|
||||
across
|
||||
l_cats as cats_ic
|
||||
loop
|
||||
s.append (" [")
|
||||
s.append (r.html_encoded (cats_ic.item))
|
||||
s.append ("]")
|
||||
end
|
||||
s.append ("</span>")
|
||||
end
|
||||
s.append ("</li>")
|
||||
end
|
||||
s.append ("</ul>")
|
||||
|
||||
if attached feed_to_html (p_feed_id.value, nb, True, r) as l_html then
|
||||
s.append (l_html)
|
||||
end
|
||||
append_bottom_feed_links_to (s, p_feed_id.value, r)
|
||||
|
||||
r.set_main_content (s)
|
||||
r.execute
|
||||
@@ -252,6 +285,70 @@ feature -- Hook
|
||||
end
|
||||
end
|
||||
|
||||
to_adapted_feed (a_feed_api: FEED_AGGREGATOR_API; a_feed_agg: FEED_AGGREGATION; a_count: INTEGER): detachable FEED
|
||||
-- Feed aggregation `a_feed_agg` adapted according to filter and `a_count`.
|
||||
local
|
||||
nb: INTEGER
|
||||
do
|
||||
if a_count = 0 then
|
||||
nb := a_feed_agg.size
|
||||
else
|
||||
nb := a_count
|
||||
end
|
||||
if attached a_feed_api.aggregation_feed (a_feed_agg) as l_feed then
|
||||
if attached l_feed.items as lst then
|
||||
if a_feed_agg.has_category_filter then
|
||||
from
|
||||
lst.start
|
||||
until
|
||||
lst.after
|
||||
loop
|
||||
if nb = 0 then
|
||||
lst.remove
|
||||
elseif a_feed_agg.is_included (lst.item_for_iteration) then
|
||||
nb := nb - 1
|
||||
lst.forth
|
||||
elseif a_feed_agg.is_included_for_location (lst.item_For_iteration, "") then
|
||||
|
||||
else
|
||||
lst.remove
|
||||
end
|
||||
end
|
||||
elseif nb > 0 then
|
||||
from
|
||||
lst.start
|
||||
until
|
||||
lst.after
|
||||
loop
|
||||
if nb = 0 then
|
||||
lst.remove
|
||||
else
|
||||
nb := nb - 1
|
||||
lst.forth
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Result := l_feed
|
||||
end
|
||||
end
|
||||
|
||||
append_bottom_feed_links_to (s: STRING; a_feed_id: READABLE_STRING_GENERAL; a_response: CMS_RESPONSE)
|
||||
do
|
||||
s.append_string ("<ul class=%"nav%">")
|
||||
s.append_string ("<li>")
|
||||
s.append_string (a_response.link ("Embedded", "feed_aggregation/" + a_response.url_encoded (a_feed_id) + "?view=embedded", Void))
|
||||
s.append_string ("</li>")
|
||||
s.append_string ("<li>")
|
||||
s.append_string (a_response.link ("ATOM", "feed_aggregation/" + a_response.url_encoded (a_feed_id) + "?view=feed.atom", Void))
|
||||
s.append_string ("</li>")
|
||||
s.append_string ("<li>")
|
||||
s.append_string (a_response.link ("RSS", "feed_aggregation/" + a_response.url_encoded (a_feed_id) + "?view=feed.rss", Void))
|
||||
s.append_string ("</li>")
|
||||
s.append_string ("</ul>")
|
||||
end
|
||||
|
||||
feed_to_html (a_feed_id: READABLE_STRING_GENERAL; a_count: INTEGER; with_feed_info: BOOLEAN; a_response: CMS_RESPONSE): detachable STRING
|
||||
local
|
||||
nb: INTEGER
|
||||
@@ -262,18 +359,21 @@ feature -- Hook
|
||||
vis: FEED_TO_XHTML_VISITOR
|
||||
s: STRING
|
||||
do
|
||||
if attached feed_aggregator_api as l_feed_api then
|
||||
if attached l_feed_api.aggregation (a_feed_id) as l_agg then
|
||||
create l_cache.make (l_feed_api.cms_api.cache_location.extended (name).extended ("feed__" + a_feed_id + "__" + a_count.out + "_" + with_feed_info.out))
|
||||
Result := l_cache.item
|
||||
if Result = Void or l_cache.expired (Void, l_agg.expiration) then
|
||||
|
||||
if
|
||||
attached feed_aggregator_api as l_feed_api and then
|
||||
attached l_feed_api.aggregation (a_feed_id) as l_agg
|
||||
then
|
||||
create l_cache.make (l_feed_api.cms_api.cache_location.extended (name).extended ("feed__" + a_feed_id + "__" + a_count.out + "_" + with_feed_info.out))
|
||||
Result := l_cache.item
|
||||
if Result = Void or l_cache.expired (Void, l_agg.expiration) then
|
||||
if attached to_adapted_feed (l_feed_api, l_agg, a_count) as l_feed then
|
||||
create Result.make (1024)
|
||||
Result.append ("<!-- ")
|
||||
Result.append ("Updated: " + l_cache.cache_date_time.out)
|
||||
Result.append (" -->")
|
||||
|
||||
create vis.make (Result)
|
||||
|
||||
if a_count = 0 then
|
||||
nb := l_agg.size
|
||||
else
|
||||
@@ -292,29 +392,72 @@ feature -- Hook
|
||||
vis.set_header (s)
|
||||
end
|
||||
create s.make_empty
|
||||
s.append_string ("<liv class=%"nav%">")
|
||||
s.append ("<li>")
|
||||
s.append_string (a_response.link ("See more ...", "feed_aggregation/" + a_response.url_encoded (a_feed_id), Void))
|
||||
s.append_string ("</li>")
|
||||
s.append ("</li>")
|
||||
vis.set_footer (s)
|
||||
|
||||
if attached l_feed_api.aggregation_feed (l_agg) as l_feed then
|
||||
if l_agg.has_category_filter and attached l_feed.items as lst then
|
||||
from
|
||||
lst.start
|
||||
until
|
||||
lst.after
|
||||
loop
|
||||
if not l_agg.is_included (lst.item_for_iteration) then
|
||||
lst.remove
|
||||
else
|
||||
lst.forth
|
||||
end
|
||||
end
|
||||
end
|
||||
l_feed.accept (vis)
|
||||
end
|
||||
l_feed.accept (vis)
|
||||
l_cache.put (Result)
|
||||
elseif l_cache /= Void then
|
||||
l_cache.delete
|
||||
end
|
||||
elseif l_cache /= Void then
|
||||
l_cache.delete
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feed_to_atom (a_feed_id: READABLE_STRING_GENERAL; a_count: INTEGER): detachable STRING
|
||||
local
|
||||
nb: INTEGER
|
||||
i: INTEGER
|
||||
e: FEED_ITEM
|
||||
vis: ATOM_FEED_GENERATOR
|
||||
s: STRING
|
||||
l_cache: CMS_FILE_STRING_8_CACHE
|
||||
do
|
||||
if
|
||||
attached feed_aggregator_api as l_feed_api and then
|
||||
attached l_feed_api.aggregation (a_feed_id) as l_agg
|
||||
then
|
||||
create l_cache.make (l_feed_api.cms_api.cache_location.extended (name).extended ("feed__" + a_feed_id + "__" + a_count.out + ".atom"))
|
||||
Result := l_cache.item
|
||||
if Result = Void or l_cache.expired (Void, l_agg.expiration) then
|
||||
if attached to_adapted_feed (l_feed_api, l_agg, a_count) as l_feed then
|
||||
create Result.make (1024)
|
||||
create vis.make (Result)
|
||||
l_feed.accept (vis)
|
||||
elseif l_cache /= Void then
|
||||
l_cache.delete
|
||||
end
|
||||
elseif l_cache /= Void then
|
||||
l_cache.delete
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feed_to_rss (a_feed_id: READABLE_STRING_GENERAL; a_count: INTEGER): detachable STRING
|
||||
local
|
||||
vis: RSS_2_FEED_GENERATOR
|
||||
l_cache: CMS_FILE_STRING_8_CACHE
|
||||
do
|
||||
if
|
||||
attached feed_aggregator_api as l_feed_api and then
|
||||
attached l_feed_api.aggregation (a_feed_id) as l_agg
|
||||
then
|
||||
create l_cache.make (l_feed_api.cms_api.cache_location.extended (name).extended ("feed__" + a_feed_id + "__" + a_count.out + ".rss"))
|
||||
Result := l_cache.item
|
||||
if Result = Void or l_cache.expired (Void, l_agg.expiration) then
|
||||
if attached to_adapted_feed (l_feed_api, l_agg, a_count) as l_feed then
|
||||
create Result.make (1024)
|
||||
create vis.make (Result)
|
||||
l_feed.accept (vis)
|
||||
elseif l_cache /= Void then
|
||||
l_cache.delete
|
||||
end
|
||||
elseif l_cache /= Void then
|
||||
l_cache.delete
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user