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

@@ -36,7 +36,7 @@ feature {NONE} -- Initialization
site_url := l_url
-- Site name
site_name := text_item_or_default ("site.name", "Another Eiffel ROC Website")
site_name := text_item_or_default ("site.name", "Your ROC CMS")
-- Website email used to send email.
-- used as real "From:" email.
@@ -77,6 +77,13 @@ feature {NONE} -- Initialization
temp_location := site_location.extended ("temp")
end
-- Location for cache folder
if attached text_item ("cache-dir") as l_cache_dir then
create cache_location.make_from_string (l_cache_dir)
else
cache_location := temp_location.extended ("cache")
end
-- Location for modules folders.
if attached text_item ("modules-dir") as l_modules_dir then
create modules_location.make_from_string (l_modules_dir)
@@ -92,13 +99,23 @@ feature {NONE} -- Initialization
end
-- Selected theme's name
theme_name := text_item_or_default ("theme", "default")
site_theme_name := text_item_or_default ("theme", "default")
set_theme (site_theme_name)
debug ("refactor_fixme")
fixme ("Review export clause for configuration and environment")
-- Administration
l_url := string_8_item ("administration.base_path")
if l_url /= Void and then not l_url.is_empty then
if l_url [l_url.count] = '/' then
l_url := l_url.substring (1, l_url.count - 1)
end
if l_url [1] /= '/' then
l_url := "/" + l_url
end
create administration_base_path.make_from_string (l_url)
else
create administration_base_path.make_from_string (default_administration_base_path)
end
theme_location := themes_location.extended (theme_name)
administration_theme_name := text_item_or_default ("administration.theme", theme_name) -- TODO: Default to builtin theme?
end
feature -- Access
@@ -296,11 +313,37 @@ feature -- Access: Site
-- Optional path defining the front page.
-- By default "" or "/".
administration_base_path: IMMUTABLE_STRING_8
-- Administration base url, default=`default_administration_base_path`.
feature {NONE} -- Constants
default_administration_base_path: STRING = "/admin"
feature -- Settings
is_debug: BOOLEAN
-- Is debug mode enabled?
set_administration_mode
-- Switch to administration mode.
--| - Change theme
--| - ..
do
if is_theme_valid (administration_theme_name) then
set_theme (administration_theme_name)
else
-- Keep previous theme!
end
end
set_theme (a_name: READABLE_STRING_GENERAL)
-- Set theme to `a_name`.
do
theme_name := a_name.as_string_32
theme_location := themes_location.extended (theme_name)
end
feature -- Query
text_item (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
@@ -343,7 +386,7 @@ feature -- Query
end
end
feature -- Access: Theme
feature -- Access: directory
site_location: PATH
-- Path to CMS site root dir.
@@ -353,7 +396,10 @@ feature -- Access: Theme
-- (Mainly for uploaded file).
files_location: PATH
-- Path to public "files" dir.
-- Path to public "files" dir.
cache_location: PATH
-- Path to internal cache dir.
modules_location: PATH
-- Path to modules.
@@ -361,9 +407,19 @@ feature -- Access: Theme
themes_location: PATH
-- Path to themes.
feature -- Access: theme
theme_location: PATH
-- Path to a active theme.
is_theme_valid (a_theme_name: READABLE_STRING_GENERAL): BOOLEAN
-- Does `a_theme_name` exists?
local
fu: FILE_UTILITIES
do
Result := fu.directory_path_exists (themes_location.extended (a_theme_name))
end
theme_information_location: PATH
-- Active theme informations.
do
@@ -373,6 +429,14 @@ feature -- Access: Theme
theme_name: READABLE_STRING_32
-- theme name.
site_theme_name: READABLE_STRING_32
-- Site theme name.
administration_theme_name: READABLE_STRING_32
-- Administration theme name.
-- Default: same as site theme.
-- TODO: change to builtin "admin" theme?
feature -- Access
mailer: NOTIFICATION_MAILER