Compare commits

...

6 Commits

Author SHA1 Message Date
a7f1f14b8a Added missing change to installed file for demo example. 2016-02-18 16:14:58 +01:00
fbda2c9eb2 Reuse improved CMS_HOOK_BLOCK_HELPER to help creation of block templates.
Fixed typo in basic auth login form.
2016-02-18 16:13:58 +01:00
ff58593bff Added functions to get link from menu or link composite.
Improved management menu, but using sub menu.
2016-02-18 12:47:21 +01:00
c65f5765d6 Removed unwanted auth.json file (wrong directory). 2016-02-17 16:11:50 +01:00
19565b9c98 Updated registration form. 2016-02-17 16:07:20 +01:00
6716cb5575 Protected cache, export and feeds menu link. 2016-02-17 15:20:38 +01:00
26 changed files with 339 additions and 250 deletions

View File

@@ -2,8 +2,8 @@
#navigation.region=sidebar_first
#navigation.condition=is_front
management.conditions[]=path:admin*
management.conditions[]=is_front
#management.conditions[]=path:admin*
#management.conditions[]=is_front
#Feeds
feed.news.weight=3

View File

@@ -1,5 +1,10 @@
{
"subject": "Thank you for contacting us",
"forms": {
"registration": {
"application_description": "Present yourself in a few lines, otherwise your application is likely to be rejected."
}
},
"recaptcha": {
"site_key":"6Lex9RMTAAAAAKleC4x6TaRlFcpLbEWgH_U7MSiD",
"secret_key":"6Lex9RMTAAAAAAkBczvX5DUiyg_xoM_EthVVgRRx"

View File

@@ -1,39 +1,38 @@
<div>
<form action="{$site_url/}account/roc-register" method="post">
<fieldset>
<legend>Registration</legend>
<div>
<input type="text" id="name" name="name" value="{$name/}" required autofocus />
<label for="name">Name</label>
{if isset="$error_name"}
<span><i>{$error_name/}</i></span> <br>
{/if}
</div>
<div>
<input type="password" id="password" name="password" value="" required/>
<label for="password">Password</label>
</div>
<div>
<input type="email" id="email" name="email" value="{$email/}" required/>
<label for="email">Email</label>
{if isset="$error_email"}
<span><i>{$error_email/}</i></span> <br>
{/if}
</div>
<div>
<textarea rows="4" cols="50" name="personal_information" id="personal_information" required>
{$personal_information/}
</textarea>
<label for="personal_information">Tell us why you want to register an account</label>
{if isset="$error_application"}
<span><i>{$error_application/}</i></span> <br>
{/if}
</div>
{unless isempty="$recaptcha_site_key"}
<div class="g-recaptcha" data-sitekey="{$recaptcha_site_key/}"></div>
<br/>
{/unless}
<button type="submit">Register</button>
</fieldset>
</form>
<div>
<form action="{$site_url/}account/roc-register" method="post">
<fieldset>
<legend>Registration</legend>
<div>
<input type="text" id="name" name="name" value="{$name/}" required autofocus />
<label for="name">Name</label>
{if isset="$error_name"}
<span><i>{$error_name/}</i></span> <br>
{/if}
</div>
<div>
<input type="password" id="password" name="password" value="" required/>
<label for="password">Password</label>
</div>
<div>
<input type="email" id="email" name="email" value="{$email/}" required/>
<label for="email">Email</label>
{if isset="$error_email"}
<span><i>{$error_email/}</i></span> <br/>
{/if}
</div>
<div>
<textarea rows="4" cols="50" name="personal_information" id="personal_information" required>{$personal_information/}</textarea>
<label for="personal_information">Tell us why you want to register an account</label>
{if isset="$error_application"}
<span><i>{$error_application/}</i></span><br/>
{/if}
{if isset="$application_description"}
<br/>
<p class="description">{$application_description/}</p>
{/if}
</div>
{unless isempty="$recaptcha_site_key"}<div class="g-recaptcha" data-sitekey="{$recaptcha_site_key/}"></div><br/>{/unless}
<button type="submit">Register</button>
</fieldset>
</form>
</div>

View File

@@ -1,6 +1,6 @@
{unless isset="$user"}
<div class="login-box">
<div class="description">The "Basic Auth" relies on the HTTP basic acces authentication.<br/>(see also: <a href="https://en.wikipedia.org/wiki/Basic_access_authentication">https://en.wikipedia.org/wiki/Basic_access_authentication</a> )</div>
<div class="description">The "Basic Auth" relies on the HTTP basic access authentication.<br/>(see also: <a href="https://en.wikipedia.org/wiki/Basic_access_authentication">https://en.wikipedia.org/wiki/Basic_access_authentication</a> )</div>
<h3>Login or <a href="{$site_url/}account/roc-register">Register</a></h3>
<div>
<form name="cms_basic_auth" action="{$site_url/}roc-basic-login" method="POST">

View File

@@ -163,6 +163,22 @@ feature -- Security
feature -- Element change
set_title (a_title: detachable READABLE_STRING_GENERAL)
-- Set `title' to `a_title' or `location'.
do
if a_title /= Void then
title := a_title.as_string_32
else
title := location.as_string_32
end
end
set_location (a_loc: READABLE_STRING_8)
-- Set `location' to `a_loc'.
do
location := a_loc
end
set_weight (a_weight: INTEGER)
-- Set `weight' to `a_weight'.
do

View File

@@ -18,6 +18,65 @@ feature -- Access
deferred
end
item_by_title (a_title: READABLE_STRING_GENERAL): detachable CMS_LINK
-- First link with title `a_title' if any.
do
if attached items as l_items then
across
l_items as ic
until
Result /= Void
loop
Result := ic.item
if not a_title.is_case_insensitive_equal (Result.title) then
Result := Void
end
end
end
ensure
coherent_result: Result /= Void implies Result.title.is_case_insensitive_equal_general (a_title)
end
item_by_location (a_loc: READABLE_STRING_8): detachable CMS_LINK
-- First link with location `a_loc' if any.
do
if attached items as l_items then
across
l_items as ic
until
Result /= Void
loop
Result := ic.item
if not a_loc.same_string (Result.location) then
Result := Void
end
end
end
ensure
coherent_result: Result /= Void implies Result.location.same_string (a_loc)
end
new_composite_item (a_title: detachable READABLE_STRING_GENERAL; a_location: READABLE_STRING_8): CMS_LINK_COMPOSITE
-- If exists, item with location `a_location' or title `a_title',
-- otherwise create new local link and extend to Current.
local
lnk: CMS_LOCAL_LINK
do
if attached {CMS_LINK_COMPOSITE} item_by_location (a_location) as l_parent then
Result := l_parent
elseif a_title /= Void and then attached {CMS_LINK_COMPOSITE} item_by_title (a_title) as l_parent then
Result := l_parent
else
create lnk.make (a_title, a_location)
extend (lnk)
Result := lnk
end
if attached {CMS_LOCAL_LINK} Result as l_local_lnk and then not l_local_lnk.is_expanded then
l_local_lnk.set_expandable (True)
l_local_lnk.set_collapsed (True)
end
end
feature -- Element change
extend (lnk: CMS_LINK)
@@ -25,6 +84,16 @@ feature -- Element change
deferred
end
extend_into (lnk: CMS_LINK; a_parent_title: detachable READABLE_STRING_GENERAL; a_parent_location: READABLE_STRING_8)
-- Extend `lnk' into local link with location `a_parent_location'.
-- If the parent is not found, create it with title `a_parent_title'.
local
l_parent: CMS_LINK_COMPOSITE
do
l_parent := new_composite_item (a_parent_title, a_parent_location)
l_parent.extend (lnk)
end
remove (lnk: CMS_LINK)
-- Remove link `lnk' from Current container.
deferred
@@ -68,6 +137,6 @@ feature -- status report
end
note
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
copyright: "2011-2016, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -79,16 +79,6 @@ feature -- Security
feature -- Element change
set_title (a_title: detachable READABLE_STRING_GENERAL)
-- Set `title' to `a_title' or `location'.
do
if a_title /= Void then
title := a_title.as_string_32
else
title := location.as_string_32
end
end
add_link (lnk: CMS_LINK)
-- <Precursor>
local
@@ -194,6 +184,6 @@ feature {NONE} -- Implementation
invariant
note
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
copyright: "2011-2016, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -104,6 +104,6 @@ feature -- Access
invariant
note
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
copyright: "2011-2016, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -103,7 +103,7 @@ feature -- Security
-- List of permission ids, used by this module, and declared.
do
Result := Precursor
Result.force ("manage admin")
Result.force ("access admin")
Result.force ("admin users")
Result.force ("admin roles")
Result.force ("admin modules")
@@ -132,28 +132,35 @@ feature -- Hooks
menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
local
lnk: CMS_LOCAL_LINK
admin_lnk: CMS_LINK_COMPOSITE
do
if
a_response.has_permission ("manage " + {CMS_ADMIN_MODULE}.name) -- Note: admin user has all permissions enabled by default.
then
-- TODO: we should probably use more side menu and less primary_menu.
create lnk.make ("Admin", "admin")
lnk.set_permission_arguments (<<"manage " + {CMS_ADMIN_MODULE}.name>>)
a_menu_system.management_menu.extend (lnk)
if a_response.api.user_is_authenticated then
admin_lnk := a_menu_system.management_menu.new_composite_item ("Admin", "admin")
create lnk.make ("Module", "admin/modules")
lnk.set_permission_arguments (<<"manage module">>)
admin_lnk.extend (lnk)
-- Per module cache permission!
create lnk.make ("Cache", "admin/cache")
admin_lnk.extend (lnk)
-- Per module export permission!
create lnk.make ("Export", "admin/export")
admin_lnk.extend (lnk)
-- if
-- a_response.has_permission ("access " + {CMS_ADMIN_MODULE}.name) -- Note: admin user has all permissions enabled by default.
-- then
-- lnk := admin_lnk
-- lnk.set_title ("Admin")
-- a_menu_system.management_menu.extend (lnk)
-- elseif admin_lnk.has_children then
-- a_menu_system.management_menu.extend (admin_lnk)
-- end
-- admin_lnk.set_permission_arguments (<<"access " + {CMS_ADMIN_MODULE}.name>>)
end
create lnk.make ("Module", "admin/modules")
lnk.set_permission_arguments (<<"manage module">>)
a_menu_system.management_menu.extend (lnk)
-- Per module cache permission!
create lnk.make ("Cache", "admin/cache")
a_menu_system.management_menu.extend (lnk)
-- Per module export permission!
create lnk.make ("Export", "admin/export")
a_menu_system.management_menu.extend (lnk)
end
note

View File

@@ -17,22 +17,58 @@ feature -- Process
process
local
b: STRING
l_admin_links: ARRAYED_LIST [TUPLE [package: READABLE_STRING_8; permissions: ARRAY [READABLE_STRING_GENERAL]; link: CMS_LINK; help: READABLE_STRING_GENERAL]]
lst: detachable ARRAYED_LIST [TUPLE [permissions: ARRAY [READABLE_STRING_GENERAL]; link: CMS_LINK; help: READABLE_STRING_GENERAL]]
categories: STRING_TABLE [ARRAYED_LIST [TUPLE [permissions: ARRAY [READABLE_STRING_GENERAL]; link: CMS_LINK; help: READABLE_STRING_GENERAL]]]
l_package: READABLE_STRING_8
do
create l_admin_links.make (5)
l_admin_links.force (["core", <<"admin users">>, local_link ("Users", "admin/users"), "View/Edit/Add Users"])
l_admin_links.force (["core", <<"admin roles">>, local_link ("Roles", "admin/roles"), "View/Edit/Add Roles"])
l_admin_links.force (["core", <<"admin modules">>, local_link ("Modules", "admin/modules"), "(un)Install modules"])
l_admin_links.force (["support", <<"admin cache">>, local_link ("Cache", "admin/cache"), "Clear caches"])
l_admin_links.force (["support", <<"admin export">>, local_link ("Export", "admin/export"), "Export CMS contents, and modules contents."])
create categories.make_caseless (3)
across
l_admin_links as ic
loop
l_package := ic.item.package
lst := categories.item (l_package)
if lst = Void then
create lst.make (1)
categories.force (lst, l_package)
end
lst.force ([ic.item.permissions, ic.item.link, ic.item.help])
end
create b.make_empty
set_title (translation ("Admin Page", Void))
b.append ("<ul id=%"content-types%">")
fixme ("Check how to make it configurable")
if has_permissions (<< "admin users">>) then
b.append ("<li>" + link ("Users", "admin/users", Void))
b.append ("<div class=%"description%">View/Edit/Add Users</div>")
b.append ("</li>")
across
categories as cats_ic
loop
lst := cats_ic.item
b.append ("<h3>")
b.append (html_encoded (cats_ic.key))
b.append ("</h3>")
b.append ("<ul>")
across
lst as ic
loop
if has_permissions (ic.item.permissions) then
b.append ("<li>")
if attached ic.item.link as lnk then
b.append (link (lnk.title, lnk.location, Void))
end
b.append ("<div class=%"description%">")
b.append (html_encoded (ic.item.help))
b.append ("</div>")
b.append ("</li>")
end
end
b.append ("</ul>")
end
if has_permissions (<< "admin roles">>) then
b.append ("<li>" + link ("Roles", "admin/roles", Void))
b.append ("<div class=%"description%">View/Edit/Add Roles</div>")
b.append ("</li>")
end
b.append ("</ul>")
set_main_content (b)
end

View File

@@ -16,6 +16,8 @@ inherit
CMS_HOOK_MENU_SYSTEM_ALTER
CMS_HOOK_BLOCK_HELPER
SHARED_LOGGER
feature {NONE} -- Initialization
@@ -86,23 +88,4 @@ feature -- Hooks
end
end
feature {NONE} -- Helpers
template_block (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE): detachable CMS_SMARTY_TEMPLATE_BLOCK
-- Smarty content block for `a_block_id'
local
p: detachable PATH
do
create p.make_from_string ("templates")
p := p.extended ("block_").appended (a_block_id).appended_with_extension ("tpl")
p := a_response.api.module_theme_resource_location (Current, p)
if p /= Void then
if attached p.entry as e then
create Result.make (a_block_id, Void, p.parent, e)
else
create Result.make (a_block_id, Void, p.parent, p)
end
end
end
end

View File

@@ -21,6 +21,8 @@ inherit
CMS_HOOK_BLOCK
CMS_HOOK_BLOCK_HELPER
CMS_HOOK_MENU_SYSTEM_ALTER
SHARED_EXECUTION_ENVIRONMENT
@@ -192,7 +194,7 @@ feature -- Hooks configuration
-- Add the link to the taxonomy to the main menu
if a_response.has_permission ("admin registration") then
create lnk.make ("Registration", "admin/pending-registrations/")
a_menu_system.management_menu.extend (lnk)
a_menu_system.management_menu.extend_into (lnk, "Admin", "admin")
end
end
@@ -208,7 +210,7 @@ feature -- Handler
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
create b.make_empty
l_user := r.user
if attached template_block ("account_info", r) as l_tpl_block then
if attached template_block (Current, "account_info", api) as l_tpl_block then
l_tpl_block.set_weight (-10)
r.add_block (l_tpl_block, "content")
else
@@ -246,7 +248,7 @@ feature -- Handler
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
create b.make_empty
l_user := r.user
if attached template_block ("account_edit", r) as l_tpl_block then
if attached template_block (Current, "account_edit", api) as l_tpl_block then
l_tpl_block.set_weight (-10)
r.add_block (l_tpl_block, "content")
else
@@ -831,7 +833,7 @@ feature -- Handler
block_list: ITERABLE [like {CMS_BLOCK}.name]
do
Result := <<"register", "reactivate", "new_password", "reset_password", "registration">>
Result := <<"register", "reactivate", "new_password", "reset_password">>
end
get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
@@ -847,8 +849,6 @@ feature -- Handler
get_block_view_new_password (a_block_id, a_response)
elseif a_block_id.is_case_insensitive_equal_general ("reset_password") and then loc.starts_with ("account/reset-password") then
get_block_view_reset_password (a_block_id, a_response)
elseif a_block_id.is_case_insensitive_equal_general ("registration") and then loc.starts_with ("admin/pending-registrations") then
get_block_view_registration (a_block_id, a_response)
end
end
@@ -923,32 +923,24 @@ feature {NONE} -- Token Generation
Result := l_token
end
feature {NONE} -- Helpers
template_block (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE): detachable CMS_SMARTY_TEMPLATE_BLOCK
-- Smarty content block for `a_block_id'
local
p: detachable PATH
do
create p.make_from_string ("templates")
p := p.extended ("block_").appended (a_block_id).appended_with_extension ("tpl")
p := a_response.api.module_theme_resource_location (Current, p)
if p /= Void then
if attached p.entry as e then
create Result.make (a_block_id, Void, p.parent, e)
else
create Result.make (a_block_id, Void, p.parent, p)
end
end
end
feature {NONE} -- Block views
get_block_view_register (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
do
if a_response.has_permission ("account register") then
if a_response.request.is_get_request_method then
if attached template_block (a_block_id, a_response) as l_tpl_block then
if
a_response.request.is_get_request_method
or else (
a_response.values.has ("error_name")
or else a_response.values.has ("error_email")
)
then
if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then
-- l_tpl_block.set_value (a_response.values.item ("error_name"), "error_name")
-- l_tpl_block.set_value (a_response.values.item ("error_email"), "error_email")
-- l_tpl_block.set_value (a_response.values.item ("email"), "email")
-- l_tpl_block.set_value (a_response.values.item ("name"), "name")
l_tpl_block.set_value (form_registration_application_description (a_response.api), "application_description")
if attached recaptcha_site_key (a_response.api) as l_recaptcha_site_key then
l_tpl_block.set_value (l_recaptcha_site_key, "recaptcha_site_key")
end
@@ -959,28 +951,11 @@ feature {NONE} -- Block views
end
end
elseif a_response.request.is_post_request_method then
if a_response.values.has ("error_name") or else a_response.values.has ("error_email") then
if attached template_block (a_block_id, a_response) as l_tpl_block then
-- l_tpl_block.set_value (a_response.values.item ("error_name"), "error_name")
-- l_tpl_block.set_value (a_response.values.item ("error_email"), "error_email")
-- l_tpl_block.set_value (a_response.values.item ("email"), "email")
-- l_tpl_block.set_value (a_response.values.item ("name"), "name")
if attached recaptcha_site_key (a_response.api) as l_recaptcha_site_key then
l_tpl_block.set_value (l_recaptcha_site_key, "recaptcha_site_key")
end
a_response.add_block (l_tpl_block, "content")
else
debug ("cms")
a_response.add_warning_message ("Error with block [" + a_block_id + "]")
end
end
if attached template_block (Current, "post_register", a_response.api) as l_tpl_block then
a_response.add_block (l_tpl_block, "content")
else
if attached template_block ("post_register", a_response) as l_tpl_block then
a_response.add_block (l_tpl_block, "content")
else
debug ("cms")
a_response.add_warning_message ("Error with block [" + a_block_id + "]")
end
debug ("cms")
a_response.add_warning_message ("Error with block [" + a_block_id + "]")
end
end
end
@@ -990,7 +965,7 @@ feature {NONE} -- Block views
get_block_view_reactivate (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
do
if a_response.request.is_get_request_method then
if attached template_block (a_block_id, a_response) as l_tpl_block then
if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then
a_response.add_block (l_tpl_block, "content")
else
debug ("cms")
@@ -999,7 +974,7 @@ feature {NONE} -- Block views
end
elseif a_response.request.is_post_request_method then
if a_response.values.has ("error_email") or else a_response.values.has ("is_active") then
if attached template_block (a_block_id, a_response) as l_tpl_block then
if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then
-- l_tpl_block.set_value (a_response.values.item ("error_email"), "error_email")
-- l_tpl_block.set_value (a_response.values.item ("email"), "email")
-- l_tpl_block.set_value (a_response.values.item ("is_active"), "is_active")
@@ -1010,7 +985,7 @@ feature {NONE} -- Block views
end
end
else
if attached template_block ("post_reactivate", a_response) as l_tpl_block then
if attached template_block (Current, "post_reactivate", a_response.api) as l_tpl_block then
a_response.add_block (l_tpl_block, "content")
else
debug ("cms")
@@ -1024,7 +999,7 @@ feature {NONE} -- Block views
get_block_view_new_password (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
do
if a_response.request.is_get_request_method then
if attached template_block (a_block_id, a_response) as l_tpl_block then
if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then
a_response.add_block (l_tpl_block, "content")
else
debug ("cms")
@@ -1033,7 +1008,7 @@ feature {NONE} -- Block views
end
elseif a_response.request.is_post_request_method then
if a_response.values.has ("error_email") or else a_response.values.has ("error_username") then
if attached template_block (a_block_id, a_response) as l_tpl_block then
if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then
-- l_tpl_block.set_value (a_response.values.item ("error_email"), "error_email")
-- l_tpl_block.set_value (a_response.values.item ("email"), "email")
-- l_tpl_block.set_value (a_response.values.item ("error_username"), "error_username")
@@ -1045,7 +1020,7 @@ feature {NONE} -- Block views
end
end
else
if attached template_block ("post_password", a_response) as l_tpl_block then
if attached template_block (Current, "post_password", a_response.api) as l_tpl_block then
a_response.add_block (l_tpl_block, "content")
else
debug ("cms")
@@ -1059,7 +1034,7 @@ feature {NONE} -- Block views
get_block_view_reset_password (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
do
if a_response.request.is_get_request_method then
if attached template_block (a_block_id, a_response) as l_tpl_block then
if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then
-- l_tpl_block.set_value (a_response.values.item ("token"), "token")
-- l_tpl_block.set_value (a_response.values.item ("error_token"), "error_token")
a_response.add_block (l_tpl_block, "content")
@@ -1070,7 +1045,7 @@ feature {NONE} -- Block views
end
elseif a_response.request.is_post_request_method then
if a_response.values.has ("error_token") or else a_response.values.has ("error_password") then
if attached template_block (a_block_id, a_response) as l_tpl_block then
if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then
-- l_tpl_block.set_value (a_response.values.item ("error_token"), "error_token")
-- l_tpl_block.set_value (a_response.values.item ("error_password"), "error_password")
-- l_tpl_block.set_value (a_response.values.item ("token"), "token")
@@ -1081,7 +1056,7 @@ feature {NONE} -- Block views
end
end
else
if attached template_block ("post_reset", a_response) as l_tpl_block then
if attached template_block (Current, "post_reset", a_response.api) as l_tpl_block then
a_response.add_block (l_tpl_block, "content")
else
debug ("cms")
@@ -1092,11 +1067,19 @@ feature {NONE} -- Block views
end
end
get_block_view_registration (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
do
end
feature -- Access: configuration
feature -- Recaptcha
form_registration_application_description (api: CMS_API): detachable READABLE_STRING_8
-- Get recaptcha security key.
local
utf: UTF_CONVERTER
do
if attached api.module_configuration (Current, Void) as cfg then
if attached cfg.text_item ("forms.registration.application_description") as l_desc and then not l_desc.is_whitespace then
Result := utf.utf_32_string_to_utf_8_string_8 (l_desc)
end
end
end
recaptcha_secret_key (api: CMS_API): detachable READABLE_STRING_8
-- Get recaptcha security key.
@@ -1129,6 +1112,7 @@ feature -- Response Alter
a_response.add_javascript_url ("https://www.google.com/recaptcha/api.js")
a_response.add_style (a_response.url ("/module/" + name + "/files/css/auth.css", Void), Void)
end
feature {NONE} -- Implementation
is_captcha_verified (a_secret, a_response: READABLE_STRING_8): BOOLEAN

View File

@@ -1,8 +0,0 @@
{
"email": "webmaster@example.com",
"subjet_register": "Thank you for regitering with us, activate account",
"subjet_activate": "New account ativation token",
"subjet_password": "Password Recovery!!!",
"subjet_oauth": "Welcome",
"smtp": "127.0.0.1"
}

View File

@@ -1,5 +1,10 @@
{
"subject": "Thank you for contacting us",
"forms": {
"registration": {
"application_description": "Present yourself in a few lines, otherwise your application is likely to be rejected."
}
},
"recaptcha": {
"site_key":"6Lex9RMTAAAAAKleC4x6TaRlFcpLbEWgH_U7MSiD",
"secret_key":"6Lex9RMTAAAAAAkBczvX5DUiyg_xoM_EthVVgRRx"

View File

@@ -1,39 +1,38 @@
<div>
<form action="{$site_url/}account/roc-register" method="post">
<fieldset>
<legend>Registration</legend>
<div>
<input type="text" id="name" name="name" value="{$name/}" required autofocus />
<label for="name">Name</label>
{if isset="$error_name"}
<span><i>{$error_name/}</i></span> <br>
{/if}
</div>
<div>
<input type="password" id="password" name="password" value="" required/>
<label for="password">Password</label>
</div>
<div>
<input type="email" id="email" name="email" value="{$email/}" required/>
<label for="email">Email</label>
{if isset="$error_email"}
<span><i>{$error_email/}</i></span> <br>
{/if}
</div>
<div>
<textarea rows="4" cols="50" name="personal_information" id="personal_information" required>
{$personal_information/}
</textarea>
<label for="personal_information">Tell us why you want to register an account</label>
{if isset="$error_application"}
<span><i>{$error_application/}</i></span> <br>
{/if}
</div>
{unless isempty="$recaptcha_site_key"}
<div class="g-recaptcha" data-sitekey="{$recaptcha_site_key/}"></div>
<br/>
{/unless}
<button type="submit">Register</button>
</fieldset>
</form>
<div>
<form action="{$site_url/}account/roc-register" method="post">
<fieldset>
<legend>Registration</legend>
<div>
<input type="text" id="name" name="name" value="{$name/}" required autofocus />
<label for="name">Name</label>
{if isset="$error_name"}
<span><i>{$error_name/}</i></span> <br>
{/if}
</div>
<div>
<input type="password" id="password" name="password" value="" required/>
<label for="password">Password</label>
</div>
<div>
<input type="email" id="email" name="email" value="{$email/}" required/>
<label for="email">Email</label>
{if isset="$error_email"}
<span><i>{$error_email/}</i></span> <br/>
{/if}
</div>
<div>
<textarea rows="4" cols="50" name="personal_information" id="personal_information" required>{$personal_information/}</textarea>
<label for="personal_information">Tell us why you want to register an account</label>
{if isset="$error_application"}
<span><i>{$error_application/}</i></span><br/>
{/if}
{if isset="$application_description"}
<br/>
<p class="description">{$application_description/}</p>
{/if}
</div>
{unless isempty="$recaptcha_site_key"}<div class="g-recaptcha" data-sitekey="{$recaptcha_site_key/}"></div><br/>{/unless}
<button type="submit">Register</button>
</fieldset>
</form>
</div>

View File

@@ -118,7 +118,7 @@ feature {NONE} -- Implementation: routes
r.add_error_message ("You are already signed in!")
r.set_main_content (r.link ("Logout", "account/roc-logout", Void))
else
if attached template_block ("login", r) as l_tpl_block then
if attached template_block (Current, "login", api) as l_tpl_block then
r.add_javascript_url (r.url ("module/" + name + "/files/js/roc_basic_auth.js", Void))
create vals.make (1)
@@ -170,7 +170,7 @@ feature {NONE} -- Block views
local
vals: CMS_VALUE_TABLE
do
if attached template_block (a_block_id, a_response) as l_tpl_block then
if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then
create vals.make (1)
-- add the variable to the block
a_response.api.hooks.invoke_value_table_alter (vals, a_response)

View File

@@ -1,6 +1,6 @@
{unless isset="$user"}
<div class="login-box">
<div class="description">The "Basic Auth" relies on the HTTP basic acces authentication.<br/>(see also: <a href="https://en.wikipedia.org/wiki/Basic_access_authentication">https://en.wikipedia.org/wiki/Basic_access_authentication</a> )</div>
<div class="description">The "Basic Auth" relies on the HTTP basic access authentication.<br/>(see also: <a href="https://en.wikipedia.org/wiki/Basic_access_authentication">https://en.wikipedia.org/wiki/Basic_access_authentication</a> )</div>
<h3>Login or <a href="{$site_url/}account/roc-register">Register</a></h3>
<div>
<form name="cms_basic_auth" action="{$site_url/}roc-basic-login" method="POST">

View File

@@ -181,7 +181,7 @@ feature -- Hooks
if a_block_id.is_case_insensitive_equal_general ("contact") then
-- "contact", "post_contact"
if a_response.request.is_get_request_method then
if attached template_block (Current, a_block_id, a_response) as l_tpl_block then
if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then
if attached recaptcha_site_key (a_response.api) as l_recaptcha_site_key then
l_tpl_block.set_value (l_recaptcha_site_key, "recaptcha_site_key")
end
@@ -201,7 +201,7 @@ feature -- Hooks
f: CMS_FORM
do
a_response.add_style (a_response.url ("/module/" + name + "/files/css/contact.css", Void), Void)
if attached template_block (Current, "contact", a_response) as l_tpl_block then
if attached template_block (Current, "contact", api) as l_tpl_block then
if attached recaptcha_site_key (api) as l_recaptcha_site_key then
l_tpl_block.set_value (l_recaptcha_site_key, "recaptcha_site_key")
end
@@ -339,7 +339,7 @@ feature -- Hooks
r.values.force (True, "has_error")
vars.put ("True", "has_error")
end
if attached template_block_with_values (Current, "post_contact", r, vars) as l_tpl_block then
if attached template_block_with_values (Current, "post_contact", api, vars) as l_tpl_block then
across
r.values as tb
loop
@@ -354,7 +354,7 @@ feature -- Hooks
-- send a bad request status code and redisplay the form with the previous data loaded.
r.set_value (False, "error")
r.set_status_code ({HTTP_STATUS_CODE}.bad_request)
if attached template_block_with_values (Current, "contact", r, vars) as l_tpl_block then
if attached template_block_with_values (Current, "contact", api, vars) as l_tpl_block then
across
r.values as tb
loop
@@ -377,7 +377,7 @@ feature -- Hooks
write_error_log (generator + ".handle_post_contact: Internal Server error")
r.values.force (True, "has_error")
r.set_status_code ({HTTP_CONSTANTS}.internal_server_error)
if attached template_block_with_values (Current, "post_contact", r, vars) as l_tpl_block then
if attached template_block_with_values (Current, "post_contact", api, vars) as l_tpl_block then
across
r.values as tb
loop
@@ -422,18 +422,6 @@ feature {NONE} -- Helpers
feature {NONE} -- Contact Message
template_block_with_values (a_module: CMS_MODULE; a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE; a_values: STRING_TABLE [ANY]): like template_block
do
Result := template_block (a_module, a_block_id, a_response)
if Result /= Void then
across
a_values as ic
loop
Result.set_value (ic.item, ic.key)
end
end
end
email_html_message (a_message_id: READABLE_STRING_8; a_response: CMS_RESPONSE; a_html_encoded_values: STRING_TABLE [READABLE_STRING_8]): STRING
-- html message related to `a_message_id'.
local

View File

@@ -346,9 +346,11 @@ feature -- Hook
-- Hook execution on collection of menu contained by `a_menu_system'
-- for related response `a_response'.
do
a_menu_system.navigation_menu.extend (create {CMS_LOCAL_LINK}.make ("Feeds", "feed_aggregation/"))
if a_response.has_permission (permission__manage_feed_aggregator) then
a_menu_system.management_menu.extend (create {CMS_LOCAL_LINK}.make ("Feeds (admin)", "admin/feed_aggregator/"))
if a_response.is_authenticated then
a_menu_system.navigation_menu.extend (create {CMS_LOCAL_LINK}.make ("Feeds", "feed_aggregation/"))
if a_response.has_permission (permission__manage_feed_aggregator) then
a_menu_system.management_menu.extend_into (create {CMS_LOCAL_LINK}.make ("Feeds (admin)", "admin/feed_aggregator/"), "Admin", "admin")
end
end
end

View File

@@ -114,7 +114,7 @@ feature -- Handler
attached l_search.last_result as l_result and then
l_result.status = 200
then
if attached template_block (Current, "search", r) as l_tpl_block then
if attached template_block (Current, "search", api) as l_tpl_block then
l_tpl_block.set_value (l_result, "result")
r.add_block (l_tpl_block, "content")
end

View File

@@ -243,7 +243,7 @@ feature -- Hooks
a_response.location.same_string ("account")
then
if
attached template_block ("account_info", a_response) as l_tpl_block and then
attached template_block (Current, "account_info", a_response.api) as l_tpl_block and then
attached a_response.user as l_user
then
associate_account (l_user, a_response.values)
@@ -323,7 +323,7 @@ feature {NONE} -- Block views
local
vals: CMS_VALUE_TABLE
do
if attached template_block (a_block_id, a_response) as l_tpl_block then
if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then
create vals.make (1)
-- add the variable to the block
a_response.api.hooks.invoke_value_table_alter (vals, a_response)

View File

@@ -270,7 +270,7 @@ feature {NONE} -- Block views
local
vals: CMS_VALUE_TABLE
do
if attached template_block (a_block_id, a_response) as l_tpl_block then
if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then
create vals.make (1)
-- add the variable to the block
a_response.api.hooks.invoke_value_table_alter (vals, a_response)

View File

@@ -141,7 +141,7 @@ feature {NONE} -- Implementation: routes
if api.user_is_authenticated then
r.add_error_message ("You are already signed in!")
else
if attached template_block ("login", r) as l_tpl_block then
if attached template_block (Current, "login", api) as l_tpl_block then
create vals.make (1)
-- add the variable to the block
l_tpl_block.set_value (api.user, "user")
@@ -223,7 +223,7 @@ feature {NONE} -- Implementation: routes
end
else
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
if attached template_block ("login", r) as l_tpl_block then
if attached template_block (Current, "login", api) as l_tpl_block then
l_tpl_block.set_value (l_username.value, "username")
l_tpl_block.set_value ("Wrong: Username or password ", "error")
r.add_block (l_tpl_block, "content")
@@ -232,7 +232,7 @@ feature {NONE} -- Implementation: routes
r.execute
else
create {BAD_REQUEST_ERROR_CMS_RESPONSE} r.make (req, res, api)
if attached template_block ("login", r) as l_tpl_block then
if attached template_block (Current, "login", api) as l_tpl_block then
if attached {WSF_STRING} req.form_parameter ("username") as l_username then
l_tpl_block.set_value (l_username.value, "username")
end
@@ -272,7 +272,7 @@ feature {NONE} -- Block views
local
vals: CMS_VALUE_TABLE
do
if attached template_block (a_block_id, a_response) as l_tpl_block then
if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then
create vals.make (1)
-- add the variable to the block
a_response.api.hooks.invoke_value_table_alter (vals, a_response)

View File

@@ -187,7 +187,7 @@ feature -- Hooks
-- Add the link to the taxonomy to the main menu
if a_response.has_permission ("admin taxonomy") then
create lnk.make ("Taxonomy", "admin/taxonomy/")
a_menu_system.management_menu.extend (lnk)
a_menu_system.management_menu.extend_into (lnk, "Admin", "admin")
end
end

View File

@@ -26,6 +26,6 @@ feature -- Hook
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -6,17 +6,17 @@ note
deferred class
CMS_HOOK_BLOCK_HELPER
feature -- Factory
feature {NONE} -- Factory
template_block (a_module: CMS_MODULE; a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE): detachable CMS_SMARTY_TEMPLATE_BLOCK
-- Smarty content block for `a_block_id' in the context of `a_module' and `a_response'.
template_block (a_module: CMS_MODULE; a_block_id: READABLE_STRING_8; a_cms_api: CMS_API): detachable CMS_SMARTY_TEMPLATE_BLOCK
-- Smarty content block for `a_block_id' in the context of `a_module' and `a_cms_api'.
local
res: PATH
p: detachable PATH
do
create res.make_from_string ("templates")
res := res.extended ("block_").appended (a_block_id).appended_with_extension ("tpl")
p := a_response.api.module_theme_resource_location (a_module, res)
p := a_cms_api.module_theme_resource_location (a_module, res)
if p /= Void then
if attached p.entry as e then
create Result.make (a_block_id, Void, p.parent, e)
@@ -26,6 +26,20 @@ feature -- Factory
end
end
template_block_with_values (a_module: CMS_MODULE; a_block_id: READABLE_STRING_8; a_cms_api: CMS_API; a_values: STRING_TABLE [ANY]): like template_block
-- Smarty content block for `a_block_id' in the context of `a_module' and `a_cms_api',
-- With additional `a_values'.
do
Result := template_block (a_module, a_block_id, a_cms_api)
if Result /= Void then
across
a_values as ic
loop
Result.set_value (ic.item, ic.key)
end
end
end
note
copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"