Improved theming for admin vs site.
- Added $theme_path, $base_path - Added CMS_RESPONSE.module_resource_url (...) instead of using hardcoded "/module/" + name + ... - Use base_path rather than base_url (note ROC CMS is not yet working with EWF standalone "base" url option)
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
.messaging-box fieldset {
|
.messaging-box fieldset {
|
||||||
resize: both;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
.messaging-box {
|
.messaging-box {
|
||||||
fieldset {
|
fieldset {
|
||||||
resize: both;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<!-- EWF CMS -->
|
<!-- EWF CMS -->
|
||||||
<link rel="stylesheet" href="{$site_url/}theme/css/style.css">
|
<link rel="stylesheet" href="{$theme_path/}css/style.css">
|
||||||
|
|
||||||
<!-- jQuery dep -->
|
<!-- jQuery dep -->
|
||||||
<script src="{$site_url/}theme/js/jquery-1.10.2.min.js"></script>
|
<script src="{$theme_path/}js/jquery-1.10.2.min.js"></script>
|
||||||
<script src="{$site_url/}theme/js/popup_search.js"></script>
|
<script src="{$theme_path/}js/popup_search.js"></script>
|
||||||
|
|
||||||
{if isset="$head"}{$head/}{/if}
|
{if isset="$head"}{$head/}{/if}
|
||||||
{if isset="$styles"}{$styles/}{/if}
|
{if isset="$styles"}{$styles/}{/if}
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ feature -- Hooks
|
|||||||
response_alter (a_response: CMS_RESPONSE)
|
response_alter (a_response: CMS_RESPONSE)
|
||||||
-- <Precursor>
|
-- <Precursor>
|
||||||
do
|
do
|
||||||
a_response.add_style (a_response.url ("/module/" + name + "/files/css/admin.css", Void), Void)
|
a_response.add_style (a_response.module_resource_url (Current, "/files/css/admin.css", Void), Void)
|
||||||
end
|
end
|
||||||
|
|
||||||
menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
|
menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
|
||||||
|
|||||||
@@ -1157,7 +1157,7 @@ feature -- Response Alter
|
|||||||
response_alter (a_response: CMS_RESPONSE)
|
response_alter (a_response: CMS_RESPONSE)
|
||||||
do
|
do
|
||||||
a_response.add_javascript_url ("https://www.google.com/recaptcha/api.js")
|
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)
|
a_response.add_style (a_response.module_resource_url (Current, "/files/css/auth.css", Void), Void)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {NONE} -- Implementation
|
feature {NONE} -- Implementation
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ feature -- Hooks
|
|||||||
|
|
||||||
response_alter (a_response: CMS_RESPONSE)
|
response_alter (a_response: CMS_RESPONSE)
|
||||||
do
|
do
|
||||||
a_response.add_style (a_response.url ("/module/" + name + "/files/css/blog.css", Void), Void)
|
a_response.add_style (a_response.module_resource_url (Current, "/files/css/blog.css", Void), Void)
|
||||||
end
|
end
|
||||||
|
|
||||||
menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
|
menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ feature -- Hooks
|
|||||||
|
|
||||||
response_alter (a_response: CMS_RESPONSE)
|
response_alter (a_response: CMS_RESPONSE)
|
||||||
do
|
do
|
||||||
a_response.add_style (a_response.url ("/module/" + name + "/files/css/comments.css", Void), Void)
|
a_response.add_style (a_response.module_resource_url (Current, "/files/css/comments.css", Void), Void)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ feature -- Hooks
|
|||||||
l_tpl_block.set_value (l_recaptcha_site_key, "recaptcha_site_key")
|
l_tpl_block.set_value (l_recaptcha_site_key, "recaptcha_site_key")
|
||||||
end
|
end
|
||||||
a_response.add_block (l_tpl_block, "content")
|
a_response.add_block (l_tpl_block, "content")
|
||||||
a_response.add_style (a_response.url ("/module/" + name + "/files/css/contact.css", Void), Void)
|
a_response.add_style (a_response.module_resource_url (Current, "/files/css/contact.css", Void), Void)
|
||||||
else
|
else
|
||||||
debug ("cms")
|
debug ("cms")
|
||||||
a_response.add_warning_message ("Error with block [" + a_block_id + "]")
|
a_response.add_warning_message ("Error with block [" + a_block_id + "]")
|
||||||
@@ -200,7 +200,7 @@ feature -- Hooks
|
|||||||
local
|
local
|
||||||
f: CMS_FORM
|
f: CMS_FORM
|
||||||
do
|
do
|
||||||
a_response.add_style (a_response.url ("/module/" + name + "/files/css/contact.css", Void), Void)
|
a_response.add_style (a_response.module_resource_url (Current, "/files/css/contact.css", Void), Void)
|
||||||
if attached smarty_template_block (Current, "contact", api) as l_tpl_block then
|
if attached smarty_template_block (Current, "contact", api) as l_tpl_block then
|
||||||
if attached recaptcha_site_key (api) as l_recaptcha_site_key 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")
|
l_tpl_block.set_value (l_recaptcha_site_key, "recaptcha_site_key")
|
||||||
@@ -281,7 +281,7 @@ feature -- Hooks
|
|||||||
do
|
do
|
||||||
write_information_log (generator + ".handle_post_contact")
|
write_information_log (generator + ".handle_post_contact")
|
||||||
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
|
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
|
||||||
r.add_style (r.url ("/module/" + name + "/files/css/contact.css", Void), Void)
|
r.add_style (r.module_resource_url (Current, "/files/css/contact.css", Void), Void)
|
||||||
r.values.force (False, "has_error")
|
r.values.force (False, "has_error")
|
||||||
|
|
||||||
create vars.make_caseless (5)
|
create vars.make_caseless (5)
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ feature -- Hook
|
|||||||
|
|
||||||
response_alter (a_response: CMS_RESPONSE)
|
response_alter (a_response: CMS_RESPONSE)
|
||||||
do
|
do
|
||||||
a_response.add_style (a_response.url ("/module/" + name + "/files/css/feed_aggregator.css", Void), Void)
|
a_response.add_style (a_response.module_resource_url (Current, "/files/css/feed_aggregator.css", Void), Void)
|
||||||
end
|
end
|
||||||
|
|
||||||
menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
|
menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ feature -- Handler
|
|||||||
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
|
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
|
||||||
|
|
||||||
-- add style
|
-- add style
|
||||||
r.add_style (r.url ("/module/" + name + "/files/css/files.css", Void), Void)
|
r.add_style (r.module_resource_url (Current, "/files/css/files.css", Void), Void)
|
||||||
|
|
||||||
create body.make_empty
|
create body.make_empty
|
||||||
|
|
||||||
@@ -245,7 +245,7 @@ feature -- Handler
|
|||||||
body.append ("<h1> Upload files </h1>%N")
|
body.append ("<h1> Upload files </h1>%N")
|
||||||
|
|
||||||
-- set style
|
-- set style
|
||||||
r.add_style (r.url ("/module/" + name + "/files/css/files.css", Void), Void)
|
r.add_style (r.module_resource_url (Current, "/files/css/files.css", Void), Void)
|
||||||
|
|
||||||
if api.has_permission (upload_files_permission) then
|
if api.has_permission (upload_files_permission) then
|
||||||
body.append ("<p>Please choose file(s) to upload.</p>")
|
body.append ("<p>Please choose file(s) to upload.</p>")
|
||||||
@@ -269,8 +269,8 @@ feature -- Handler
|
|||||||
body.append ("<a href=%""+ r.url (uploads_location, Void) +"?basic_upload=no%">Use advanced file uploading.</a>%N")
|
body.append ("<a href=%""+ r.url (uploads_location, Void) +"?basic_upload=no%">Use advanced file uploading.</a>%N")
|
||||||
else
|
else
|
||||||
-- add JS for dropzone
|
-- add JS for dropzone
|
||||||
r.add_javascript_url (r.url ("/module/" + name + "/files/js/dropzone.js", Void))
|
r.add_javascript_url (r.module_resource_url (Current, "/files/js/dropzone.js", Void))
|
||||||
r.add_style (r.url ("/module/" + name + "/files/js/dropzone.css", Void), Void)
|
r.add_style (r.module_resource_url (Current, "/files/js/dropzone.css", Void), Void)
|
||||||
|
|
||||||
-- create form to choose files and upload them
|
-- create form to choose files and upload them
|
||||||
body.append ("<form action=%"" + r.url (uploads_location, Void) + "%" class=%"dropzone%">")
|
body.append ("<form action=%"" + r.url (uploads_location, Void) + "%" class=%"dropzone%">")
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ feature -- Hooks
|
|||||||
local
|
local
|
||||||
f: CMS_FORM
|
f: CMS_FORM
|
||||||
do
|
do
|
||||||
a_response.add_style (a_response.url ("/module/" + name + "/files/css/messaging.css", Void), Void)
|
a_response.add_style (a_response.module_resource_url (Current, "/files/css/messaging.css", Void), Void)
|
||||||
-- TODO: use template to overwrite/customize
|
-- TODO: use template to overwrite/customize
|
||||||
-- if attached smarty_template_block (Current, "messaging", api) as l_tpl_block then
|
-- if attached smarty_template_block (Current, "messaging", api) as l_tpl_block then
|
||||||
-- across
|
-- across
|
||||||
@@ -249,7 +249,7 @@ $(document).ready(function() {
|
|||||||
do
|
do
|
||||||
if api.has_permission ("message any user") then
|
if api.has_permission ("message any user") then
|
||||||
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
|
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
|
||||||
r.add_style (r.url ("/module/" + name + "/files/css/messaging.css", Void), Void)
|
r.add_style (r.module_resource_url (Current, "/files/css/messaging.css", Void), Void)
|
||||||
|
|
||||||
create s.make_empty
|
create s.make_empty
|
||||||
|
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ feature -- Hooks
|
|||||||
response_alter (a_response: CMS_RESPONSE)
|
response_alter (a_response: CMS_RESPONSE)
|
||||||
-- <Precursor>
|
-- <Precursor>
|
||||||
do
|
do
|
||||||
a_response.add_style (a_response.url ("/module/" + name + "/files/css/node.css", Void), Void)
|
a_response.add_style (a_response.module_resource_url (Current, "/files/css/node.css", Void), Void)
|
||||||
end
|
end
|
||||||
|
|
||||||
block_list: ITERABLE [like {CMS_BLOCK}.name]
|
block_list: ITERABLE [like {CMS_BLOCK}.name]
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ feature -- Hooks
|
|||||||
|
|
||||||
response_alter (a_response: CMS_RESPONSE)
|
response_alter (a_response: CMS_RESPONSE)
|
||||||
do
|
do
|
||||||
a_response.add_style (a_response.url ("/module/" + name + "/files/css/taxonomy.css", Void), Void)
|
a_response.add_style (a_response.module_resource_url (Current, "/files/css/taxonomy.css", Void), Void)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ feature -- Hooks
|
|||||||
|
|
||||||
response_alter (a_response: CMS_RESPONSE)
|
response_alter (a_response: CMS_RESPONSE)
|
||||||
do
|
do
|
||||||
a_response.add_style (a_response.url ("/module/" + name + "/files/css/wikitext.css", Void), Void)
|
a_response.add_style (a_response.module_resource_url (Current, "/files/css/wikitext.css", Void), Void)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ feature {NONE} -- Initialization
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Selected theme's name
|
-- Selected theme's name
|
||||||
site_theme_name := text_item_or_default ("theme", "default")
|
site_theme_name := text_item_or_default ("site.theme", "default")
|
||||||
set_theme (site_theme_name)
|
set_theme (site_theme_name)
|
||||||
|
|
||||||
-- Administration
|
-- Administration
|
||||||
@@ -325,6 +325,18 @@ feature -- Settings
|
|||||||
is_debug: BOOLEAN
|
is_debug: BOOLEAN
|
||||||
-- Is debug mode enabled?
|
-- Is debug mode enabled?
|
||||||
|
|
||||||
|
set_site_mode
|
||||||
|
-- Switch to site mode.
|
||||||
|
--| - Change theme
|
||||||
|
--| - ..
|
||||||
|
do
|
||||||
|
if is_theme_valid (site_theme_name) then
|
||||||
|
set_theme (site_theme_name)
|
||||||
|
else
|
||||||
|
-- Keep previous theme!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
set_administration_mode
|
set_administration_mode
|
||||||
-- Switch to administration mode.
|
-- Switch to administration mode.
|
||||||
--| - Change theme
|
--| - Change theme
|
||||||
@@ -341,7 +353,7 @@ feature -- Settings
|
|||||||
-- Set theme to `a_name`.
|
-- Set theme to `a_name`.
|
||||||
do
|
do
|
||||||
theme_name := a_name.as_string_32
|
theme_name := a_name.as_string_32
|
||||||
theme_location := themes_location.extended (theme_name)
|
theme_location := theme_location_for (theme_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Query
|
feature -- Query
|
||||||
@@ -417,7 +429,7 @@ feature -- Access: theme
|
|||||||
local
|
local
|
||||||
fu: FILE_UTILITIES
|
fu: FILE_UTILITIES
|
||||||
do
|
do
|
||||||
Result := fu.directory_path_exists (themes_location.extended (a_theme_name))
|
Result := fu.directory_path_exists (theme_location_for (a_theme_name))
|
||||||
end
|
end
|
||||||
|
|
||||||
theme_information_location: PATH
|
theme_information_location: PATH
|
||||||
@@ -437,6 +449,12 @@ feature -- Access: theme
|
|||||||
-- Default: same as site theme.
|
-- Default: same as site theme.
|
||||||
-- TODO: change to builtin "admin" theme?
|
-- TODO: change to builtin "admin" theme?
|
||||||
|
|
||||||
|
theme_location_for (a_theme_name: READABLE_STRING_GENERAL): PATH
|
||||||
|
-- Theme directory location for theme `a_theme_name`.
|
||||||
|
do
|
||||||
|
Result := themes_location.extended (a_theme_name)
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
mailer: NOTIFICATION_MAILER
|
mailer: NOTIFICATION_MAILER
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ feature {NONE} -- Initialize
|
|||||||
initialize_site_url
|
initialize_site_url
|
||||||
-- Initialize site and base url.
|
-- Initialize site and base url.
|
||||||
local
|
local
|
||||||
|
l_base_url: detachable READABLE_STRING_8
|
||||||
l_url: detachable STRING_8
|
l_url: detachable STRING_8
|
||||||
i,j: INTEGER
|
i,j: INTEGER
|
||||||
do
|
do
|
||||||
@@ -134,12 +135,23 @@ feature {NONE} -- Initialize
|
|||||||
if i > 0 then
|
if i > 0 then
|
||||||
j := l_url.index_of ('/', i + 3)
|
j := l_url.index_of ('/', i + 3)
|
||||||
if j > 0 then
|
if j > 0 then
|
||||||
base_url := l_url.substring (j, l_url.count)
|
l_base_url := l_url.substring (j, l_url.count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if l_base_url /= Void then
|
||||||
|
base_url := l_base_url
|
||||||
|
if l_base_url.ends_with_general ("/") then
|
||||||
|
create base_path.make_from_string (l_base_url)
|
||||||
|
else
|
||||||
|
create base_path.make_from_string (l_base_url + "/")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
create base_path.make_from_string ("/")
|
||||||
|
end
|
||||||
ensure
|
ensure
|
||||||
site_url_set: site_url /= Void
|
site_url_set: site_url /= Void
|
||||||
site_url_ends_with_slash: site_url.ends_with_general ("/")
|
site_url_ends_with_slash: site_url.ends_with_general ("/")
|
||||||
|
base_path_set: base_path /= Void and then base_path.ends_with_general ("/")
|
||||||
end
|
end
|
||||||
|
|
||||||
initialize_content_types
|
initialize_content_types
|
||||||
@@ -380,6 +392,9 @@ feature -- Access: url
|
|||||||
--| Usually it is Void, but it could be
|
--| Usually it is Void, but it could be
|
||||||
--| /project/demo/
|
--| /project/demo/
|
||||||
|
|
||||||
|
base_path: IMMUTABLE_STRING_8
|
||||||
|
-- Base path, default to "/"
|
||||||
|
|
||||||
site_url: IMMUTABLE_STRING_8
|
site_url: IMMUTABLE_STRING_8
|
||||||
-- Site url
|
-- Site url
|
||||||
|
|
||||||
@@ -493,11 +508,21 @@ feature -- Helpers: html links
|
|||||||
|
|
||||||
feature -- Settings
|
feature -- Settings
|
||||||
|
|
||||||
|
switch_to_site_mode
|
||||||
|
do
|
||||||
|
if is_administration_mode then
|
||||||
|
setup.set_site_mode
|
||||||
|
is_administration_mode := False
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
switch_to_administration_mode
|
switch_to_administration_mode
|
||||||
do
|
do
|
||||||
|
if not is_administration_mode then
|
||||||
setup.set_administration_mode
|
setup.set_administration_mode
|
||||||
is_administration_mode := True
|
is_administration_mode := True
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
is_administration_mode: BOOLEAN
|
is_administration_mode: BOOLEAN
|
||||||
-- Is administration mode?
|
-- Is administration mode?
|
||||||
@@ -1101,6 +1126,14 @@ feature -- Environment/ theme
|
|||||||
Result := setup.files_location
|
Result := setup.files_location
|
||||||
end
|
end
|
||||||
|
|
||||||
|
files_path: STRING_8
|
||||||
|
do
|
||||||
|
create Result.make_from_string (base_path)
|
||||||
|
Result.append ("files/")
|
||||||
|
ensure
|
||||||
|
ends_with_slash: Result.ends_with ("/")
|
||||||
|
end
|
||||||
|
|
||||||
cache_location: PATH
|
cache_location: PATH
|
||||||
-- CMS internal cache location.
|
-- CMS internal cache location.
|
||||||
do
|
do
|
||||||
@@ -1118,16 +1151,44 @@ feature -- Environment/ theme
|
|||||||
Result := setup.theme_name
|
Result := setup.theme_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
theme_path: STRING_8
|
||||||
|
-- URL path to the theme.
|
||||||
|
do
|
||||||
|
Result := theme_path_for (theme_name)
|
||||||
|
ensure
|
||||||
|
ends_with_slash: Result.ends_with ("/")
|
||||||
|
end
|
||||||
|
|
||||||
theme_assets_location: PATH
|
theme_assets_location: PATH
|
||||||
-- assets (js, css, images, etc).
|
-- assets (js, css, images, etc).
|
||||||
do
|
do
|
||||||
debug ("refactor_fixme")
|
|
||||||
fixme ("Check if we really need it")
|
|
||||||
end
|
|
||||||
-- Check how to get this path from the CMS_THEME information.
|
-- Check how to get this path from the CMS_THEME information.
|
||||||
Result := theme_location.extended ("assets")
|
Result := theme_location.extended ("assets")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Theming path helpers
|
||||||
|
|
||||||
|
theme_location_for (a_theme_name: READABLE_STRING_GENERAL): PATH
|
||||||
|
do
|
||||||
|
Result := setup.theme_location_for (a_theme_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
theme_path_for (a_theme_name: READABLE_STRING_GENERAL): STRING_8
|
||||||
|
-- URL path to the theme `a_theme_name`.
|
||||||
|
do
|
||||||
|
create Result.make_from_string (base_path)
|
||||||
|
Result.append ("theme/")
|
||||||
|
Result.append (url_encoded (a_theme_name))
|
||||||
|
Result.append_character ('/')
|
||||||
|
ensure
|
||||||
|
ends_with_slash: Result.ends_with ("/")
|
||||||
|
end
|
||||||
|
|
||||||
|
theme_assets_location_for (a_theme_name: READABLE_STRING_GENERAL): PATH
|
||||||
|
do
|
||||||
|
Result := theme_location_for (a_theme_name).extended ("assets")
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Environment/ module
|
feature -- Environment/ module
|
||||||
|
|
||||||
module_configuration (a_module: CMS_MODULE; a_name: detachable READABLE_STRING_GENERAL): detachable CONFIG_READER
|
module_configuration (a_module: CMS_MODULE; a_name: detachable READABLE_STRING_GENERAL): detachable CONFIG_READER
|
||||||
|
|||||||
@@ -195,16 +195,17 @@ feature -- Settings: router
|
|||||||
configure_api_file_handler (a_router: WSF_ROUTER)
|
configure_api_file_handler (a_router: WSF_ROUTER)
|
||||||
local
|
local
|
||||||
fhdl: WSF_FILE_SYSTEM_HANDLER
|
fhdl: WSF_FILE_SYSTEM_HANDLER
|
||||||
|
themehdl: CMS_THEME_FILE_SYSTEM_HANDLER
|
||||||
do
|
do
|
||||||
api.logger.put_information (generator + ".configure_api_file_handler", Void)
|
api.logger.put_information (generator + ".configure_api_file_handler", Void)
|
||||||
|
|
||||||
create fhdl.make_hidden_with_path (api.theme_assets_location)
|
create themehdl.make (api)
|
||||||
fhdl.disable_index
|
themehdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
|
||||||
fhdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
|
|
||||||
do
|
do
|
||||||
execute_default (ia_req, ia_res)
|
execute_default (ia_req, ia_res)
|
||||||
end)
|
end)
|
||||||
a_router.handle ("/theme/", fhdl, router.methods_GET)
|
-- See CMS_API.api.theme_path_for (...) for the hardcoded "/theme/" path.
|
||||||
|
a_router.handle ("/theme/{theme_id}{/vars}", themehdl, router.methods_GET)
|
||||||
|
|
||||||
-- "/files/.."
|
-- "/files/.."
|
||||||
create fhdl.make_hidden_with_path (api.files_location)
|
create fhdl.make_hidden_with_path (api.files_location)
|
||||||
@@ -213,7 +214,7 @@ feature -- Settings: router
|
|||||||
do
|
do
|
||||||
execute_default (ia_req, ia_res)
|
execute_default (ia_req, ia_res)
|
||||||
end)
|
end)
|
||||||
a_router.handle ("/files/", fhdl, router.methods_GET)
|
a_router.handle (api.files_path, fhdl, router.methods_GET)
|
||||||
|
|
||||||
-- files folder from specific module.
|
-- files folder from specific module.
|
||||||
a_router.handle ("/module/{modname}/files{/vars}", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_module_files), a_router.methods_get)
|
a_router.handle ("/module/{modname}/files{/vars}", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_module_files), a_router.methods_get)
|
||||||
@@ -244,6 +245,7 @@ feature -- Request execution
|
|||||||
initialize_site_execution
|
initialize_site_execution
|
||||||
-- Initialize for site execution.
|
-- Initialize for site execution.
|
||||||
do
|
do
|
||||||
|
api.switch_to_site_mode
|
||||||
api.initialize_execution
|
api.initialize_execution
|
||||||
setup_router
|
setup_router
|
||||||
end
|
end
|
||||||
|
|||||||
59
src/service/handler/cms_theme_file_system_handler.e
Normal file
59
src/service/handler/cms_theme_file_system_handler.e
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {CMS_THEME_FILE_SYSTEM_HANDLER}."
|
||||||
|
author: ""
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
CMS_THEME_FILE_SYSTEM_HANDLER
|
||||||
|
|
||||||
|
inherit
|
||||||
|
WSF_URI_TEMPLATE_HANDLER
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature -- Initialization
|
||||||
|
|
||||||
|
make (a_cms_api: CMS_API)
|
||||||
|
do
|
||||||
|
api := a_cms_api
|
||||||
|
end
|
||||||
|
|
||||||
|
api: CMS_API
|
||||||
|
|
||||||
|
feature -- Execution
|
||||||
|
|
||||||
|
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
|
-- Execute `req' responding in `res'.
|
||||||
|
local
|
||||||
|
fhdl: WSF_FILE_SYSTEM_HANDLER
|
||||||
|
not_found: NOT_FOUND_ERROR_CMS_RESPONSE
|
||||||
|
do
|
||||||
|
if attached {WSF_STRING} req.path_parameter ("theme_id") as l_theme_id then
|
||||||
|
create fhdl.make_hidden_with_path (api.theme_assets_location_for (l_theme_id.value))
|
||||||
|
fhdl.disable_index
|
||||||
|
fhdl.set_not_found_handler (not_found_handler)
|
||||||
|
fhdl.execute_starts_with (api.theme_path_for (l_theme_id.value), req, res)
|
||||||
|
-- a_router.handle (api.theme_path, fhdl, router.methods_GET)
|
||||||
|
elseif attached not_found_handler as h then
|
||||||
|
h.call (req.percent_encoded_path_info, req, res)
|
||||||
|
else
|
||||||
|
create not_found.make (req, res, api)
|
||||||
|
not_found.execute
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Not found handling
|
||||||
|
|
||||||
|
not_found_handler: detachable PROCEDURE [READABLE_STRING_8, WSF_REQUEST, WSF_RESPONSE]
|
||||||
|
|
||||||
|
set_not_found_handler (h: like not_found_handler)
|
||||||
|
do
|
||||||
|
not_found_handler := h
|
||||||
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||||
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
|
end
|
||||||
@@ -25,7 +25,10 @@ feature {NONE} -- Initialization
|
|||||||
create header.make
|
create header.make
|
||||||
create values.make (3)
|
create values.make (3)
|
||||||
site_url := a_api.site_url
|
site_url := a_api.site_url
|
||||||
base_url := a_api.base_url
|
if attached a_api.base_url as l_base_url then
|
||||||
|
base_url := l_base_url
|
||||||
|
end
|
||||||
|
base_path := a_api.base_path
|
||||||
initialize
|
initialize
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -124,8 +127,8 @@ feature -- URL utilities
|
|||||||
if attached setup.front_page_path as l_front_page_path then
|
if attached setup.front_page_path as l_front_page_path then
|
||||||
Result := l_front_page_path.same_string (l_path_info)
|
Result := l_front_page_path.same_string (l_path_info)
|
||||||
else
|
else
|
||||||
if attached base_url as l_base_url then
|
if base_path.same_string (l_path_info) then
|
||||||
Result := l_path_info.same_string (l_base_url)
|
Result := True
|
||||||
else
|
else
|
||||||
Result := l_path_info.is_empty or else l_path_info.same_string ("/")
|
Result := l_path_info.is_empty or else l_path_info.same_string ("/")
|
||||||
end
|
end
|
||||||
@@ -134,12 +137,18 @@ feature -- URL utilities
|
|||||||
|
|
||||||
site_url: IMMUTABLE_STRING_8
|
site_url: IMMUTABLE_STRING_8
|
||||||
-- Absolute site url.
|
-- Absolute site url.
|
||||||
|
-- Always ends with '/'
|
||||||
|
|
||||||
base_url: detachable IMMUTABLE_STRING_8
|
base_url: detachable IMMUTABLE_STRING_8
|
||||||
-- Base url if any.
|
-- Base url if any.
|
||||||
--| Usually it is Void, but it could be
|
--| Usually it is Void, but it could be
|
||||||
--| /project/demo/
|
--| /project/demo/
|
||||||
|
|
||||||
|
base_path: IMMUTABLE_STRING_8
|
||||||
|
-- Base path, default to "/".
|
||||||
|
-- Always ends with '/'
|
||||||
|
-- Could be /project/demo/
|
||||||
|
|
||||||
feature -- Access: CMS
|
feature -- Access: CMS
|
||||||
|
|
||||||
site_name: STRING_32
|
site_name: STRING_32
|
||||||
@@ -1242,6 +1251,7 @@ feature -- Generation
|
|||||||
|
|
||||||
-- Variables
|
-- Variables
|
||||||
page.register_variable (absolute_url ("", Void), "site_url")
|
page.register_variable (absolute_url ("", Void), "site_url")
|
||||||
|
page.register_variable (base_path, "base_path")
|
||||||
page.register_variable (absolute_url ("", Void), "host") -- Same as `site_url'.
|
page.register_variable (absolute_url ("", Void), "host") -- Same as `site_url'.
|
||||||
page.register_variable (request.is_https, "is_https")
|
page.register_variable (request.is_https, "is_https")
|
||||||
if attached title as l_title then
|
if attached title as l_title then
|
||||||
@@ -1253,6 +1263,8 @@ feature -- Generation
|
|||||||
page.set_is_https (request.is_https)
|
page.set_is_https (request.is_https)
|
||||||
|
|
||||||
-- Variables/Misc
|
-- Variables/Misc
|
||||||
|
page.register_variable (is_administration_mode, "is_administration_mode")
|
||||||
|
page.register_variable (api.theme_path, "theme_path")
|
||||||
|
|
||||||
-- FIXME: logo .. could be a settings of theme, managed by admin front-end/database.
|
-- FIXME: logo .. could be a settings of theme, managed by admin front-end/database.
|
||||||
-- if attached logo_location as l_logo then
|
-- if attached logo_location as l_logo then
|
||||||
@@ -1398,6 +1410,14 @@ feature -- Helpers: URLs
|
|||||||
Result := api.location_url (a_location, opts)
|
Result := api.location_url (a_location, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module_resource_url (a_module: CMS_MODULE; a_path: READABLE_STRING_8; opts: detachable CMS_API_OPTIONS): STRING_8
|
||||||
|
-- Url for resource `a_path` associated with module `a_module`.
|
||||||
|
require
|
||||||
|
a_valid_valid: a_path.is_empty or else a_path.starts_with ("/")
|
||||||
|
do
|
||||||
|
Result := url ("/module/" + a_module.name + a_path, opts)
|
||||||
|
end
|
||||||
|
|
||||||
user_url (u: CMS_USER): like url
|
user_url (u: CMS_USER): like url
|
||||||
require
|
require
|
||||||
u_with_id: u.has_id
|
u_with_id: u.has_id
|
||||||
|
|||||||
Reference in New Issue
Block a user