Added feed aggregation module.
Improved the CMS Block system to support condition.
This commit is contained in:
42
modules/feed_aggregator/feed_aggregation.e
Normal file
42
modules/feed_aggregator/feed_aggregation.e
Normal file
@@ -0,0 +1,42 @@
|
||||
note
|
||||
description: "Feed aggregation parameters."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
FEED_AGGREGATION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_name: READABLE_STRING_GENERAL)
|
||||
do
|
||||
create name.make_from_string_general (a_name)
|
||||
create {ARRAYED_LIST [READABLE_STRING_8]} locations.make (0)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: IMMUTABLE_STRING_32
|
||||
-- Associated name.
|
||||
|
||||
description: detachable IMMUTABLE_STRING_32
|
||||
-- Optional description.
|
||||
|
||||
locations: LIST [READABLE_STRING_8]
|
||||
-- List of feed location aggregated into current.
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_description (a_desc: detachable READABLE_STRING_GENERAL)
|
||||
do
|
||||
if a_desc = Void then
|
||||
description := Void
|
||||
else
|
||||
create description.make_from_string_general (a_desc)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
17
modules/feed_aggregator/feed_aggregator-safe.ecf
Normal file
17
modules/feed_aggregator/feed_aggregator-safe.ecf
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="feed_aggregator" uuid="6A78AB37-9B07-4C42-9E24-0CA7D3C61E12" library_target="feed_aggregator">
|
||||
<target name="feed_aggregator">
|
||||
<root all_classes="true"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension-safe.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<library name="cms" location="..\..\cms-safe.ecf"/>
|
||||
<library name="cms_model" location="..\..\library\model\cms_model-safe.ecf" readonly="false"/>
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
|
||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
|
||||
<library name="wsf_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html-safe.ecf" readonly="false"/>
|
||||
<cluster name="src" location="." recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
39
modules/feed_aggregator/feed_aggregator_api.e
Normal file
39
modules/feed_aggregator/feed_aggregator_api.e
Normal file
@@ -0,0 +1,39 @@
|
||||
note
|
||||
description: "API for Feed aggregator module."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
FEED_AGGREGATOR_API
|
||||
|
||||
inherit
|
||||
CMS_MODULE_API
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Access
|
||||
|
||||
aggregations: HASH_TABLE [FEED_AGGREGATION, STRING]
|
||||
-- List of feed aggregations.
|
||||
local
|
||||
agg: FEED_AGGREGATION
|
||||
do
|
||||
create Result.make (2)
|
||||
create agg.make ("Blog from Bertrand Meyer")
|
||||
agg.locations.force ("https://bertrandmeyer.com/category/computer-science/feed/")
|
||||
Result.force (agg, "bertrandmeyer")
|
||||
|
||||
create agg.make ("Eiffel Room")
|
||||
agg.locations.force ("https://room.eiffel.com/recent_changes/feed")
|
||||
Result.force (agg, "eiffelroom")
|
||||
end
|
||||
|
||||
aggregation (a_name: READABLE_STRING_GENERAL): detachable FEED_AGGREGATION
|
||||
do
|
||||
if attached a_name.is_valid_as_string_8 then
|
||||
Result := aggregations.item (a_name.as_string_8)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
146
modules/feed_aggregator/feed_aggregator_module.e
Normal file
146
modules/feed_aggregator/feed_aggregator_module.e
Normal file
@@ -0,0 +1,146 @@
|
||||
note
|
||||
description: "CMS module bringing support for feed aggregation."
|
||||
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||
revision: "$Revision: 96616 $"
|
||||
|
||||
class
|
||||
FEED_AGGREGATOR_MODULE
|
||||
|
||||
inherit
|
||||
CMS_MODULE
|
||||
rename
|
||||
module_api as feed_aggregator_api
|
||||
redefine
|
||||
initialize,
|
||||
register_hooks,
|
||||
permissions,
|
||||
feed_aggregator_api
|
||||
end
|
||||
|
||||
CMS_HOOK_BLOCK
|
||||
|
||||
CMS_HOOK_RESPONSE_ALTER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Create Current module, disabled by default.
|
||||
do
|
||||
version := "1.0"
|
||||
description := "Feed aggregation"
|
||||
package := "feed"
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: STRING = "feed_aggregator"
|
||||
|
||||
permissions: LIST [READABLE_STRING_8]
|
||||
-- List of permission ids, used by this module, and declared.
|
||||
do
|
||||
Result := Precursor
|
||||
Result.force ("manage feed aggregator")
|
||||
end
|
||||
|
||||
feature {CMS_API} -- Module Initialization
|
||||
|
||||
initialize (api: CMS_API)
|
||||
-- <Precursor>
|
||||
do
|
||||
Precursor (api)
|
||||
create feed_aggregator_api.make (api)
|
||||
end
|
||||
|
||||
feature {CMS_API} -- Access: API
|
||||
|
||||
feed_aggregator_api: detachable FEED_AGGREGATOR_API
|
||||
-- Eventual module api.
|
||||
|
||||
feature -- Access: router
|
||||
|
||||
setup_router (a_router: WSF_ROUTER; a_api: CMS_API)
|
||||
-- <Precursor>
|
||||
do
|
||||
-- a_router.handle ("/admin/feed_aggregator/", create {WSF_URI_AGENT_HANDLER}.make (agent handle_feed_aggregator_admin (a_api, ?, ?)), a_router.methods_head_get_post)
|
||||
end
|
||||
|
||||
feature -- Hooks configuration
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
-- Module hooks configuration.
|
||||
do
|
||||
a_response.hooks.subscribe_to_block_hook (Current)
|
||||
a_response.hooks.subscribe_to_response_alter_hook (Current)
|
||||
end
|
||||
|
||||
feature -- Hook
|
||||
|
||||
block_list: ITERABLE [like {CMS_BLOCK}.name]
|
||||
-- List of block names, managed by current object.
|
||||
local
|
||||
res: ARRAYED_LIST [like {CMS_BLOCK}.name]
|
||||
do
|
||||
create res.make (5)
|
||||
if attached feed_aggregator_api as l_feed_api then
|
||||
across
|
||||
l_feed_api.aggregations as ic
|
||||
loop
|
||||
res.force ("feed__" + ic.key)
|
||||
end
|
||||
end
|
||||
Result := res
|
||||
end
|
||||
|
||||
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'.
|
||||
local
|
||||
i: INTEGER
|
||||
s: READABLE_STRING_8
|
||||
b: CMS_CONTENT_BLOCK
|
||||
l_content: STRING
|
||||
pref: STRING
|
||||
do
|
||||
if attached feed_aggregator_api as l_feed_api then
|
||||
pref := "feed__"
|
||||
if a_block_id.starts_with (pref) then
|
||||
s := a_block_id.substring (pref.count + 1, a_block_id.count)
|
||||
else
|
||||
s := a_block_id
|
||||
end
|
||||
if attached l_feed_api.aggregation (s) as l_agg then
|
||||
create l_content.make_empty
|
||||
if attached l_agg.description as l_desc then
|
||||
l_content.append_string_general (l_desc)
|
||||
l_content.append_character ('%N')
|
||||
l_content.append_character ('%N')
|
||||
end
|
||||
across
|
||||
l_agg.locations as ic
|
||||
loop
|
||||
l_content.append ("%T-" + ic.item)
|
||||
l_content.append_character ('%N')
|
||||
end
|
||||
create b.make (a_block_id, l_agg.name, l_content, Void)
|
||||
a_response.add_block (b, Void)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Hook
|
||||
|
||||
response_alter (a_response: CMS_RESPONSE)
|
||||
do
|
||||
-- a_response.add_additional_head_line ("[
|
||||
-- <style>
|
||||
-- table.recent-changes th { padding: 3px; }
|
||||
-- table.recent-changes td { padding: 3px; border: dotted 1px #ddd; }
|
||||
-- table.recent-changes td.date { padding-left: 15px; }
|
||||
-- table.recent-changes td.title { font-weight: bold; }
|
||||
-- </style>
|
||||
-- ]", True)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user