Added the possibility to have feed aggregation as embedded view using "?view=embedded".

Convenient to include the feed aggregation in a page with for instance jquery load(..) function.
This commit is contained in:
2017-01-02 18:10:40 +01:00
parent 219969cae4
commit 3bcfb0a44a
@@ -1,7 +1,7 @@
note note
description: "CMS module bringing support for feed aggregation." description: "CMS module bringing support for feed aggregation."
date: "$Date$" date: "$Date: 2016-12-21 15:17:16 +0100 (mer., 21 déc. 2016) $"
revision: "$Revision$" revision: "$Revision: 99686 $"
class class
FEED_AGGREGATOR_MODULE FEED_AGGREGATOR_MODULE
@@ -92,7 +92,8 @@ feature -- Handle
handle_feed_aggregation (a_api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE) handle_feed_aggregation (a_api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE)
local local
r: CMS_RESPONSE m: WSF_PAGE_RESPONSE
r: detachable CMS_RESPONSE
s: STRING s: STRING
nb: INTEGER nb: INTEGER
do do
@@ -101,49 +102,66 @@ feature -- Handle
else else
nb := -1 nb := -1
end end
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, a_api)
if attached {WSF_STRING} req.path_parameter ("feed_id") as p_feed_id then 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 feed_aggregation (p_feed_id.value) as l_agg then
create s.make_empty if attached {WSF_STRING} req.query_parameter ("view") as p_view and then p_view.same_string ("embedded") then
s.append ("<h1>") create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, a_api)
s.append (r.html_encoded (l_agg.name)) if attached feed_to_html (p_feed_id.value, nb, True, r) as l_html then
s.append ("</h1>") r := Void
if attached l_agg.included_categories as l_categories then create m.make_with_body (l_html)
s.append ("<span class=%"category%">") m.header.put_content_type_text_html
across res.send (m)
l_categories as cats_ic else
loop create {NOT_FOUND_ERROR_CMS_RESPONSE} r.make (req, res, a_api)
s.append (" [") r.execute
s.append (r.html_encoded (cats_ic.item))
s.append ("]")
end end
s.append ("</span>") else
end create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, a_api)
if attached l_agg.description as l_desc and then l_desc.is_valid_as_string_8 then create s.make_empty
s.append ("<div class=%"description%">") s.append ("<h1>")
s.append (l_desc.as_string_8) s.append (r.html_encoded (l_agg.name))
s.append ("</div>") s.append ("</h1>")
end if attached l_agg.included_categories as l_categories then
s.append ("<ul>") s.append ("<span class=%"category%">")
across across
l_agg.locations as ic l_categories as cats_ic
loop loop
s.append ("<li><a href=%"") s.append (" [")
s.append (ic.item) s.append (r.html_encoded (cats_ic.item))
s.append ("%">") s.append ("]")
s.append (ic.item) end
s.append ("</a></li>") s.append ("</span>")
end end
s.append ("</ul>") if attached l_agg.description as l_desc and then l_desc.is_valid_as_string_8 then
s.append ("<div class=%"description%">")
s.append (l_desc.as_string_8)
s.append ("</div>")
end
s.append ("<ul>")
across
l_agg.locations as ic
loop
s.append ("<li><a href=%"")
s.append (ic.item)
s.append ("%">")
s.append (ic.item)
s.append ("</a></li>")
end
s.append ("</ul>")
if attached feed_to_html (p_feed_id.value, nb, True, r) as l_html then if attached feed_to_html (p_feed_id.value, nb, True, r) as l_html then
s.append (l_html) s.append (l_html)
end
r.set_main_content (s)
r.execute
end end
r.set_main_content (s)
else else
create {NOT_FOUND_ERROR_CMS_RESPONSE} r.make (req, res, a_api) create {NOT_FOUND_ERROR_CMS_RESPONSE} r.make (req, res, a_api)
r.execute
end end
else else
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, a_api)
if attached feed_aggregator_api as l_feed_agg_api then if attached feed_aggregator_api as l_feed_agg_api then
create s.make_empty create s.make_empty
across across
@@ -175,8 +193,8 @@ feature -- Handle
else else
create {BAD_REQUEST_ERROR_CMS_RESPONSE} r.make (req, res, a_api) create {BAD_REQUEST_ERROR_CMS_RESPONSE} r.make (req, res, a_api)
end end
r.execute
end end
r.execute
end end
feature -- Hooks configuration feature -- Hooks configuration
@@ -231,7 +249,7 @@ feature -- Hook
end end
Result := res Result := res
end end
get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE) get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
-- Get block object identified by `a_block_id' and associate with `a_response'. -- Get block object identified by `a_block_id' and associate with `a_response'.
local local