Splitted administration and normal web site interfaces.

This optimises a bit the routing map, and make cleaner separation.
Make the base url for admin pages customizable via `administration.base_path` variable in cms.ini
   note: could be /admin, /roc-admin, or ..
It is possible to have a specific theme for administration via the variable "administration.admin"
This commit is contained in:
2017-03-24 18:38:58 +01:00
parent 13cbb7d987
commit 21e75a6492
40 changed files with 1172 additions and 512 deletions

View File

@@ -21,7 +21,7 @@ inherit
permissions
end
CMS_HOOK_MENU_SYSTEM_ALTER
CMS_ADMINISTRABLE
CMS_HOOK_RESPONSE_ALTER
@@ -46,12 +46,18 @@ feature -- Access
-- List of permission ids, used by this module, and declared.
do
Result := Precursor
Result.force ("admin taxonomy")
Result.force ("update any taxonomy")
Result.force ("update page taxonomy") -- related to node module
Result.force ("update blog taxonomy") -- related to blog module
end
feature {CMS_EXECUTION} -- Administration
administration: CMS_TAXONOMY_MODULE_ADMINISTRATION
do
create Result.make (Current)
end
feature {CMS_API} -- Module Initialization
initialize (api: CMS_API)
@@ -99,7 +105,7 @@ feature {CMS_API} -- Module management
Precursor (api)
end
feature {CMS_API} -- Access: API
feature {CMS_API, CMS_MODULE_ADMINISTRATION} -- Access: API
taxonomy_api: detachable CMS_TAXONOMY_API
-- <Precursor>
@@ -111,7 +117,6 @@ feature -- Access: router
do
if attached taxonomy_api as l_taxonomy_api then
configure_web (a_api, l_taxonomy_api, a_router)
configure_web_amin (a_api, l_taxonomy_api, a_router)
else
-- Issue with api/dependencies,
-- thus Current module should not be used!
@@ -133,45 +138,10 @@ feature -- Access: router
a_router.handle ("/taxonomy/vocabulary/{vocid}", l_voc_handler, a_router.methods_get)
end
configure_web_amin (a_api: CMS_API; a_taxonomy_api: CMS_TAXONOMY_API; a_router: WSF_ROUTER)
-- Configure router mapping for web interface.
local
l_taxonomy_handler: TAXONOMY_TERM_ADMIN_HANDLER
l_voc_handler: TAXONOMY_VOCABULARY_ADMIN_HANDLER
do
a_router.handle ("/admin/taxonomy/", create {WSF_URI_AGENT_HANDLER}.make (agent handle_admin_taxonomy (?, ?, a_api)), a_router.methods_get)
create l_taxonomy_handler.make (a_api, a_taxonomy_api)
a_router.handle ("/admin/taxonomy/term/", l_taxonomy_handler, a_router.methods_get_post)
a_router.handle ("/admin/taxonomy/term/{termid}", l_taxonomy_handler, a_router.methods_get_post)
create l_voc_handler.make (a_api, a_taxonomy_api)
a_router.handle ("/admin/taxonomy/vocabulary/", l_voc_handler, a_router.methods_get_post)
a_router.handle ("/admin/taxonomy/vocabulary/{vocid}", l_voc_handler, a_router.methods_get_post)
end
feature -- Handler
handle_admin_taxonomy (req: WSF_REQUEST; res: WSF_RESPONSE; api: CMS_API)
local
l_page: CMS_RESPONSE
lnk: CMS_LOCAL_LINK
do
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
create lnk.make ("Admin Vocabularies", "admin/taxonomy/vocabulary/")
l_page.add_to_primary_tabs (lnk)
create lnk.make ("Create terms", "admin/taxonomy/term/")
l_page.add_to_primary_tabs (lnk)
l_page.execute
end
feature -- Hooks
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
do
a_hooks.subscribe_to_menu_system_alter_hook (Current)
a_hooks.subscribe_to_response_alter_hook (Current)
end
@@ -180,15 +150,4 @@ feature -- Hooks
a_response.add_style (a_response.url ("/module/" + name + "/files/css/taxonomy.css", Void), Void)
end
menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
local
lnk: CMS_LOCAL_LINK
do
-- 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_into (lnk, "Admin", "admin")
end
end
end

View File

@@ -0,0 +1,100 @@
note
description: "Summary description for {CMS_TAXONOMY_MODULE_ADMINISTRATION}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
CMS_TAXONOMY_MODULE_ADMINISTRATION
inherit
CMS_MODULE_ADMINISTRATION [CMS_TAXONOMY_MODULE]
redefine
setup_hooks,
permissions
end
CMS_HOOK_MENU_SYSTEM_ALTER
CMS_HOOK_RESPONSE_ALTER
create
make
feature -- Security
permissions: LIST [READABLE_STRING_8]
-- List of permission ids, used by this module, and declared.
do
Result := Precursor
Result.force ("admin taxonomy")
end
feature {NONE} -- Router/administration
setup_administration_router (a_router: WSF_ROUTER; a_api: CMS_API)
do
if attached module.taxonomy_api as l_taxonomy_api then
configure_web_admin (a_api, l_taxonomy_api, a_router)
end
end
configure_web_admin (a_api: CMS_API; a_taxonomy_api: CMS_TAXONOMY_API; a_router: WSF_ROUTER)
-- Configure router mapping for web interface.
local
l_taxonomy_handler: TAXONOMY_TERM_ADMIN_HANDLER
l_voc_handler: TAXONOMY_VOCABULARY_ADMIN_HANDLER
do
a_router.handle ("/taxonomy/", create {WSF_URI_AGENT_HANDLER}.make (agent handle_admin_taxonomy (?, ?, a_api)), a_router.methods_get)
create l_taxonomy_handler.make (a_api, a_taxonomy_api)
a_router.handle ("/taxonomy/term/", l_taxonomy_handler, a_router.methods_get_post)
a_router.handle ("/taxonomy/term/{termid}", l_taxonomy_handler, a_router.methods_get_post)
create l_voc_handler.make (a_api, a_taxonomy_api)
a_router.handle ("/taxonomy/vocabulary/", l_voc_handler, a_router.methods_get_post)
a_router.handle ("/taxonomy/vocabulary/{vocid}", l_voc_handler, a_router.methods_get_post)
end
feature -- Handler
handle_admin_taxonomy (req: WSF_REQUEST; res: WSF_RESPONSE; api: CMS_API)
local
l_page: CMS_RESPONSE
lnk: CMS_LOCAL_LINK
do
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
create lnk.make ("Admin Vocabularies", api.administration_path_location ("taxonomy/vocabulary/"))
l_page.add_to_primary_tabs (lnk)
create lnk.make ("Create terms", api.administration_path_location ("taxonomy/term/"))
l_page.add_to_primary_tabs (lnk)
l_page.execute
end
feature -- Hooks
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
do
a_hooks.subscribe_to_menu_system_alter_hook (Current)
a_hooks.subscribe_to_response_alter_hook (Current)
end
response_alter (a_response: CMS_RESPONSE)
do
module.response_alter (a_response)
end
menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
local
lnk: CMS_LOCAL_LINK
do
-- Add the link to the taxonomy to the main menu
if a_response.has_permission ("admin taxonomy") then
create lnk.make ("Taxonomy", a_response.api.administration_path_location ("taxonomy/"))
a_menu_system.management_menu.extend_into (lnk, "Admin", "admin")
end
end
end

View File

@@ -118,7 +118,7 @@ feature -- HTTP Methods
else
l_page.add_success_message ("Term creation succeed.")
s.append ("<div>View term: ")
s.append (l_page.link (t.text, "admin/taxonomy/term/" + t.id.out, Void))
s.append (l_page.link (t.text, api.administration_path_location ("taxonomy/term/" + t.id.out), Void))
s.append ("</div>")
if

View File

@@ -88,7 +88,7 @@ feature -- HTTP Methods
l_page.add_error_message ("Vocabulary creation failed!")
else
l_page.add_success_message ("Vocabulary creation succeed!")
l_page.set_redirection ("admin/taxonomy/vocabulary/" + voc.id.out)
l_page.set_redirection (api.administration_path_location ("taxonomy/vocabulary/" + voc.id.out))
end
else
create {BAD_REQUEST_ERROR_CMS_RESPONSE} l_page.make (req, res, api)
@@ -143,7 +143,7 @@ feature -- HTTP Methods
end
end
if not taxonomy_api.has_error then
l_page.add_notice_message (l_page.link ({STRING_32} "Back to vocabulary %"" + l_vocabulary.name + "%"", "admin/taxonomy/vocabulary/" + l_vocabulary.id.out, Void))
l_page.add_notice_message (l_page.link ({STRING_32} "Back to vocabulary %"" + l_vocabulary.name + "%"", api.administration_path_location ("taxonomy/vocabulary/" + l_vocabulary.id.out), Void))
end
l_page.set_main_content (s)
else
@@ -239,7 +239,7 @@ feature -- HTTP Methods
create wtb_row.make (3)
wtb.add_row (wtb_row)
create wtb_item.make_with_text (l_page.link (ic.item.text, "admin/taxonomy/term/" + l_term.id.out, Void))
create wtb_item.make_with_text (l_page.link (ic.item.text, api.administration_path_location ("taxonomy/term/" + l_term.id.out), Void))
wtb_row.set_item (wtb_item, 1)
if attached ic.item.description as l_desc then
create wtb_item.make_with_text (api.html_encoded (l_desc))
@@ -362,7 +362,7 @@ feature -- HTTP Methods
create wtb_row.make (3)
wtb.add_row (wtb_row)
create wtb_item.make_with_text (l_page.link (ic.item.name, "admin/taxonomy/vocabulary/" + ic.item.id.out, Void))
create wtb_item.make_with_text (l_page.link (ic.item.name, api.administration_path_location ("taxonomy/vocabulary/" + ic.item.id.out), Void))
-- if attached ic.item.description as l_desc then
-- s.append (" : <em>")
-- s.append (api.html_encoded (l_desc))
@@ -385,7 +385,7 @@ feature -- HTTP Methods
wtb_row.set_item (wtb_item, 2)
end
s := l_page.link ("edit", "admin/taxonomy/vocabulary/" + voc.id.out, Void)
s := l_page.link ("edit", api.administration_path_location ("taxonomy/vocabulary/" + voc.id.out), Void)
create wtb_item.make_with_text (s)
wtb_row.set_item (wtb_item, 3)
end