Skip to content

Commit 34f0aa5

Browse files
committed
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.
1 parent 78ef7af commit 34f0aa5

File tree

9 files changed

+337
-110
lines changed

9 files changed

+337
-110
lines changed

modules/auth/cms_authentication_module.e

Lines changed: 61 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -362,79 +362,78 @@ feature -- Handler
362362
l_captcha_passed: BOOLEAN
363363
l_email: READABLE_STRING_8
364364
do
365-
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
366-
if r.has_permission ("account register") then
367-
if req.is_post_request_method then
368-
if
369-
attached {WSF_STRING} req.form_parameter ("name") as l_name and then
370-
attached {WSF_STRING} req.form_parameter ("password") as l_password and then
371-
attached {WSF_STRING} req.form_parameter ("email") as p_email and then
372-
attached {WSF_STRING} req.form_parameter ("personal_information") as l_personal_information
373-
then
374-
if p_email.value.is_valid_as_string_8 then
375-
l_email := p_email.value.to_string_8
376-
l_user_api := api.user_api
377-
if attached l_user_api.user_by_name (l_name.value) or else attached l_user_api.temp_user_by_name (l_name.value) then
378-
-- Username already exist.
379-
r.set_value ("User name already exists!", "error_name")
380-
l_exist := True
381-
end
382-
if attached l_user_api.user_by_email (l_email) or else attached l_user_api.temp_user_by_email (l_email) then
383-
-- Email already exists.
384-
r.set_value ("An account is already associated with that email address!", "error_email")
385-
l_exist := True
386-
end
387-
if attached recaptcha_secret_key (api) as l_recaptcha_key then
388-
if attached {WSF_STRING} req.form_parameter ("g-recaptcha-response") as l_recaptcha_response and then is_captcha_verified (l_recaptcha_key, l_recaptcha_response.url_encoded_value) then
389-
l_captcha_passed := True
390-
else
391-
--| Bad or missing captcha
392-
l_captcha_passed := False
393-
end
394-
else
395-
--| reCaptcha is not setup, so no verification
365+
if
366+
api.has_permission ("account register") and then
367+
req.is_post_request_method
368+
then
369+
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
370+
if
371+
attached {WSF_STRING} req.form_parameter ("name") as l_name and then
372+
attached {WSF_STRING} req.form_parameter ("password") as l_password and then
373+
attached {WSF_STRING} req.form_parameter ("email") as p_email and then
374+
attached {WSF_STRING} req.form_parameter ("personal_information") as l_personal_information
375+
then
376+
if p_email.value.is_valid_as_string_8 then
377+
l_email := p_email.value.to_string_8
378+
l_user_api := api.user_api
379+
if attached l_user_api.user_by_name (l_name.value) or else attached l_user_api.temp_user_by_name (l_name.value) then
380+
-- Username already exist.
381+
r.set_value ("User name already exists!", "error_name")
382+
l_exist := True
383+
end
384+
if attached l_user_api.user_by_email (l_email) or else attached l_user_api.temp_user_by_email (l_email) then
385+
-- Email already exists.
386+
r.set_value ("An account is already associated with that email address!", "error_email")
387+
l_exist := True
388+
end
389+
if attached recaptcha_secret_key (api) as l_recaptcha_key then
390+
if attached {WSF_STRING} req.form_parameter ("g-recaptcha-response") as l_recaptcha_response and then is_captcha_verified (l_recaptcha_key, l_recaptcha_response.url_encoded_value) then
396391
l_captcha_passed := True
397-
end
398-
if not l_exist then
399-
-- New temp user
400-
create u.make (l_name.value)
401-
u.set_email (l_email)
402-
u.set_password (l_password.value)
403-
u.set_personal_information (l_personal_information.value)
404-
l_user_api.new_temp_user (u)
405-
406-
-- Create activation token
407-
l_token := new_token
408-
l_user_api.new_activation (l_token, u.id)
409-
l_url_activate := req.absolute_script_url ("/account/activate/" + l_token)
410-
l_url_reject := req.absolute_script_url ("/account/reject/" + l_token)
411-
412-
-- Send Email to webmaster
413-
create es.make (create {CMS_AUTHENTICATION_EMAIL_SERVICE_PARAMETERS}.make (api))
414-
write_debug_log (generator + ".handle register: send_register_email")
415-
es.send_account_evaluation (u, l_personal_information.value, l_url_activate, l_url_reject, req.absolute_script_url (""))
416-
417-
-- Send Email to user
418-
create es.make (create {CMS_AUTHENTICATION_EMAIL_SERVICE_PARAMETERS}.make (api))
419-
write_debug_log (generator + ".handle register: send_contact_email")
420-
es.send_contact_email (l_email, u, req.absolute_script_url (""))
421392
else
422-
r.set_value (l_name.value, "name")
423-
r.set_value (l_email, "email")
424-
r.set_value (l_personal_information.value, "personal_information")
425-
r.set_status_code ({HTTP_CONSTANTS}.bad_request)
393+
--| Bad or missing captcha
394+
l_captcha_passed := False
426395
end
396+
else
397+
--| reCaptcha is not setup, so no verification
398+
l_captcha_passed := True
399+
end
400+
if not l_exist then
401+
-- New temp user
402+
create u.make (l_name.value)
403+
u.set_email (l_email)
404+
u.set_password (l_password.value)
405+
u.set_personal_information (l_personal_information.value)
406+
l_user_api.new_temp_user (u)
407+
-- Create activation token
408+
l_token := new_token
409+
l_user_api.new_activation (l_token, u.id)
410+
l_url_activate := req.absolute_script_url ("/account/activate/" + l_token)
411+
l_url_reject := req.absolute_script_url ("/account/reject/" + l_token)
412+
-- Send Email to webmaster
413+
create es.make (create {CMS_AUTHENTICATION_EMAIL_SERVICE_PARAMETERS}.make (api))
414+
write_debug_log (generator + ".handle register: send_register_email")
415+
es.send_account_evaluation (u, l_personal_information.value, l_url_activate, l_url_reject, req.absolute_script_url (""))
416+
417+
-- Send Email to user
418+
create es.make (create {CMS_AUTHENTICATION_EMAIL_SERVICE_PARAMETERS}.make (api))
419+
write_debug_log (generator + ".handle register: send_contact_email")
420+
es.send_contact_email (l_email, u, req.absolute_script_url (""))
427421
else
428422
r.set_value (l_name.value, "name")
429-
r.set_value (p_email.value, "email")
423+
r.set_value (l_email, "email")
430424
r.set_value (l_personal_information.value, "personal_information")
431425
r.set_status_code ({HTTP_CONSTANTS}.bad_request)
432426
end
433427
else
434-
api.response_api.send_bad_request ("There were issue with your application, invalid or missing values.", req, res)
428+
r.set_value (l_name.value, "name")
429+
r.set_value (p_email.value, "email")
430+
r.set_value (l_personal_information.value, "personal_information")
431+
r.set_status_code ({HTTP_CONSTANTS}.bad_request)
435432
end
433+
r.execute
434+
else
435+
api.response_api.send_bad_request ("There were issue with your application, invalid or missing values.", req, res)
436436
end
437-
r.execute
438437
else
439438
api.response_api.send_permissions_access_denied ("You can also contact the webmaster to ask for an account.", Void, req, res)
440439
end

modules/feed_aggregator/feed_aggregation.e

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ feature -- Access
5252
feature -- Status report
5353

5454
has_category_filter: BOOLEAN
55-
-- Is there any category filtering?
55+
-- Is there any global category filtering?
5656
-- i.e via `included_categories'
5757
do
5858
Result := attached included_categories as cats and then not cats.is_empty
5959
end
6060

6161
has_category_filter_for_location (a_location: READABLE_STRING_GENERAL): BOOLEAN
62-
-- Is there any category filtering for `a_location'?
62+
-- Is there any specific category filtering for `a_location'?
6363
do
6464
Result := attached included_categories_per_feed as cats_per_location and then
6565
attached cats_per_location.item (a_location) as cats and then
@@ -118,7 +118,7 @@ feature -- Element change
118118
end
119119
end
120120

121-
include_category_per_feed (a_cat: READABLE_STRING_GENERAL; a_feed_location: READABLE_STRING_8)
121+
include_category_per_feed (a_cat: READABLE_STRING_GENERAL; a_feed_location: READABLE_STRING_GENERAL)
122122
local
123123
tb: like included_categories_per_feed
124124
lst: like included_categories
@@ -163,20 +163,22 @@ feature -- Status report
163163

164164
is_included_for_location (e: FEED_ITEM; a_location: READABLE_STRING_GENERAL): BOOLEAN
165165
-- Is `e' included in feed related to `a_location'?
166-
-- note that if `e' has no category, it is included by default,
167-
-- even if `included_categories_per_feed' is defined for `a_location'.
166+
-- notes:
167+
-- - it also check for `included_categories' condition.
168+
-- - if `e' has no category, it is included by default,
169+
-- even if `included_categories_per_feed' is defined for `a_location'.
168170
do
169-
Result := True
170-
if attached e.categories as e_cats then
171+
Result := is_included (e)
172+
if Result and attached e.categories as e_cats then
171173
if
172174
attached included_categories_per_feed as tb and then
173175
attached tb.item (a_location) as lst
174176
then
175177
Result := across lst as ic some
176-
across e_cats as e_ic some
177-
e_ic.item.same_string (ic.item)
178+
across e_cats as e_ic some
179+
e_ic.item.same_string (ic.item)
180+
end
178181
end
179-
end
180182
end
181183
end
182184
end

modules/feed_aggregator/feed_aggregator_api.e

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ feature -- Access
3535
l_feed_id: READABLE_STRING_32
3636
l_title: detachable READABLE_STRING_GENERAL
3737
l_locations: detachable STRING_TABLE [READABLE_STRING_8]
38+
loc_name: READABLE_STRING_GENERAL
39+
loc: READABLE_STRING_8
3840
l_table: like internal_aggregations
3941
do
4042
l_table := internal_aggregations
@@ -102,6 +104,19 @@ feature -- Access
102104
agg.include_category (cats_ic.item)
103105
end
104106
end
107+
across
108+
l_locations as locs_ic
109+
loop
110+
loc_name := locs_ic.key
111+
loc := locs_ic.item
112+
if attached cfg.text_list_item ({STRING_32} "feeds." + l_feed_id + {STRING_32} ".categories." + loc_name.as_string_32) as l_loc_cats then
113+
across
114+
l_loc_cats as cats_ic
115+
loop
116+
agg.include_category_per_feed (cats_ic.item, loc)
117+
end
118+
end
119+
end
105120
end
106121
end
107122
end
@@ -138,11 +153,42 @@ feature -- Operation
138153

139154
aggregation_feed (agg: FEED_AGGREGATION): detachable FEED
140155
-- Feed from aggregation `agg'.
156+
local
157+
loc: READABLE_STRING_8
158+
lst: LIST [FEED_ITEM]
141159
do
142160
across
143161
agg.locations as ic
144162
loop
145-
if attached feed (ic.item) as f then
163+
loc := ic.item
164+
if attached feed (loc) as f then
165+
lst := f.items
166+
if agg.has_category_filter_for_location (loc) then
167+
-- Note: it also check the global filter.
168+
from
169+
lst.start
170+
until
171+
lst.after
172+
loop
173+
if agg.is_included_for_location (lst.item, loc) then
174+
lst.forth
175+
else
176+
lst.remove
177+
end
178+
end
179+
elseif agg.has_category_filter then
180+
from
181+
lst.start
182+
until
183+
lst.after
184+
loop
185+
if agg.is_included (lst.item) then
186+
lst.forth
187+
else
188+
lst.remove
189+
end
190+
end
191+
end
146192
if Result /= Void then
147193
if f /= Void then
148194
Result := Result + f
@@ -152,6 +198,9 @@ feature -- Operation
152198
end
153199
end
154200
end
201+
if Result /= Void then
202+
Result.set_date (create {DATE_TIME}.make_now_utc)
203+
end
155204
end
156205

157206
new_http_client_session (a_url: READABLE_STRING_8): HTTP_CLIENT_SESSION

0 commit comments

Comments
 (0)