Moved all location related queries into CMS_API, instead of CMS_SETUP.

Note that CMS_SETUP provides locations set by default or from configuration file.
Now theme related resources can be found under site/modules/$mod_name/... or site/themes/$theme/modules/...
  so only theme related resources can be overriden for now.
This commit is contained in:
2015-06-24 17:15:05 +02:00
parent fa5efede2c
commit 2886c90782
14 changed files with 231 additions and 225 deletions

View File

@@ -1,83 +1,83 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="demo" uuid="3643E657-BCBE-46AA-931B-71EAEA877A18" library_target="demo"> <system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="demo" uuid="3643E657-BCBE-46AA-931B-71EAEA877A18" library_target="demo">
<description>Example/demo for Eiffel ROC CMS library</description> <description>Example/demo for Eiffel ROC CMS library</description>
<target name="common" abstract="true"> <target name="common" abstract="true">
<file_rule> <file_rule>
<exclude>/EIFGENs$</exclude> <exclude>/EIFGENs$</exclude>
<exclude>/CVS$</exclude> <exclude>/CVS$</exclude>
<exclude>/.svn$</exclude> <exclude>/.svn$</exclude>
</file_rule> </file_rule>
<option debug="true" warning="true" full_class_checking="false" is_attached_by_default="true" void_safety="all" syntax="transitional"> <option debug="true" warning="true" full_class_checking="false" is_attached_by_default="true" void_safety="all" syntax="transitional">
<debug name="dbglog" enabled="true"/> <debug name="dbglog" enabled="true"/>
</option> </option>
<setting name="concurrency" value="thread"/> <setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> <library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="cms" location="..\..\cms-safe.ecf" readonly="false"/> <library name="cms" location="..\..\cms-safe.ecf" readonly="false"/>
<library name="cms_app_env" location="..\..\library\app_env\app_env-safe.ecf" readonly="false"/> <library name="cms_app_env" location="..\..\library\app_env\app_env-safe.ecf" readonly="false"/>
<library name="cms_basic_auth_module" location="..\..\modules\basic_auth\basic_auth-safe.ecf" readonly="false"/> <library name="cms_auth_module" location="..\..\modules\auth\auth-safe.ecf" readonly="false"/>
<library name="cms_blog_module" location="modules\blog\cms_blog_module-safe.ecf" readonly="false"/> <library name="cms_basic_auth_module" location="..\..\modules\basic_auth\basic_auth-safe.ecf" readonly="false"/>
<library name="cms_demo_module" location="modules\demo\cms_demo_module-safe.ecf" readonly="false"/> <library name="cms_blog_module" location="modules\blog\cms_blog_module-safe.ecf" readonly="false"/>
<library name="cms_model" location="..\..\library\model\cms_model-safe.ecf" readonly="false"/> <library name="cms_demo_module" location="modules\demo\cms_demo_module-safe.ecf" readonly="false"/>
<library name="cms_auth_module" location="..\..\modules\auth\auth-safe.ecf" readonly="false"/> <library name="cms_model" location="..\..\library\model\cms_model-safe.ecf" readonly="false"/>
<library name="cms_node_module" location="..\..\modules\node\node-safe.ecf" readonly="false"/> <library name="cms_node_module" location="..\..\modules\node\node-safe.ecf" readonly="false"/>
<!-- <!--
<library name="persistence_store_mysql" location="..\..\library\persistence\store_mysql\store_mysql-safe.ecf" readonly="false"/> <library name="persistence_store_mysql" location="..\..\library\persistence\store_mysql\store_mysql-safe.ecf" readonly="false"/>
--> -->
<library name="persistence_store_odbc" location="..\..\library\persistence\store_odbc\store_odbc-safe.ecf" readonly="false"/> <library name="persistence_store_odbc" location="..\..\library\persistence\store_odbc\store_odbc-safe.ecf" readonly="false"/>
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/> <library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/> <library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
</target> </target>
<target name="demo_any" extends="common"> <target name="demo_any" extends="common">
<root class="EWF_ROC_SERVER" feature="make_and_launch"/> <root class="EWF_ROC_SERVER" feature="make_and_launch"/>
<setting name="concurrency" value="thread"/> <setting name="concurrency" value="thread"/>
<library name="cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\cgi-safe.ecf"/> <library name="cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\cgi-safe.ecf"/>
<library name="libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\libfcgi-safe.ecf"/> <library name="libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\libfcgi-safe.ecf"/>
<library name="nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\nino-safe.ecf"/> <library name="nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\nino-safe.ecf"/>
<library name="standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\standalone-safe.ecf"/> <library name="standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\standalone-safe.ecf"/>
<cluster name="launcher" location=".\launcher\any\" recursive="true"/> <cluster name="launcher" location=".\launcher\any\" recursive="true"/>
<cluster name="src" location=".\src\" recursive="true"/> <cluster name="src" location=".\src\" recursive="true"/>
</target> </target>
<target name="demo_standalone" extends="common"> <target name="demo_standalone" extends="common">
<root class="EWF_ROC_SERVER" feature="make_and_launch"/> <root class="EWF_ROC_SERVER" feature="make_and_launch"/>
<option debug="true"> <option debug="true">
<debug name="dbglog" enabled="true"/> <debug name="dbglog" enabled="true"/>
</option> </option>
<variable name="httpd_ssl_disabled" value="true"/><!-- for now ... due to issue with libcurl+eiffelnet ssl --> <setting name="concurrency" value="thread"/>
<setting name="concurrency" value="thread"/> <variable name="httpd_ssl_disabled" value="true"/>
<library name="default_standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\standalone-safe.ecf"/> <library name="default_standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\standalone-safe.ecf"/>
<cluster name="launcher" location=".\launcher\default\" recursive="true"/> <cluster name="launcher" location=".\launcher\default\" recursive="true"/>
<cluster name="src" location=".\src\" recursive="true"/> <cluster name="src" location=".\src\" recursive="true"/>
</target> </target>
<target name="demo_standalone_none" extends="demo_standalone"> <target name="demo_standalone_none" extends="demo_standalone">
<setting name="concurrency" value="none"/> <setting name="concurrency" value="none"/>
</target> </target>
<target name="demo_standalone_mt" extends="demo_standalone"> <target name="demo_standalone_mt" extends="demo_standalone">
<setting name="concurrency" value="thread"/> <setting name="concurrency" value="thread"/>
</target> </target>
<target name="demo_standalone_scoop" extends="demo_standalone"> <target name="demo_standalone_scoop" extends="demo_standalone">
<setting name="concurrency" value="scoop"/> <setting name="concurrency" value="scoop"/>
</target> </target>
<target name="demo_nino" extends="common"> <target name="demo_nino" extends="common">
<root class="EWF_ROC_SERVER" feature="make_and_launch"/> <root class="EWF_ROC_SERVER" feature="make_and_launch"/>
<setting name="concurrency" value="none"/> <setting name="concurrency" value="none"/>
<library name="default_nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\nino-safe.ecf"/> <library name="default_nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\nino-safe.ecf"/>
<cluster name="launcher" location=".\launcher\default\" recursive="true"/> <cluster name="launcher" location=".\launcher\default\" recursive="true"/>
<cluster name="src" location=".\src\" recursive="true"/> <cluster name="src" location=".\src\" recursive="true"/>
</target> </target>
<target name="demo_cgi" extends="common"> <target name="demo_cgi" extends="common">
<root class="EWF_ROC_SERVER" feature="make_and_launch"/> <root class="EWF_ROC_SERVER" feature="make_and_launch"/>
<setting name="concurrency" value="none"/> <setting name="concurrency" value="none"/>
<library name="default_cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\cgi-safe.ecf"/> <library name="default_cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\cgi-safe.ecf"/>
<cluster name="launcher" location=".\launcher\default\" recursive="true"/> <cluster name="launcher" location=".\launcher\default\" recursive="true"/>
<cluster name="src" location=".\src\" recursive="true"/> <cluster name="src" location=".\src\" recursive="true"/>
</target> </target>
<target name="demo_libfcgi" extends="common"> <target name="demo_libfcgi" extends="common">
<root class="EWF_ROC_SERVER" feature="make_and_launch"/> <root class="EWF_ROC_SERVER" feature="make_and_launch"/>
<setting name="concurrency" value="none"/> <setting name="concurrency" value="none"/>
<library name="default_libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\libfcgi-safe.ecf"/> <library name="default_libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\libfcgi-safe.ecf"/>
<cluster name="launcher" location=".\launcher\default\" recursive="true"/> <cluster name="launcher" location=".\launcher\default\" recursive="true"/>
<cluster name="src" location=".\src\" recursive="true"/> <cluster name="src" location=".\src\" recursive="true"/>
</target> </target>
<target name="demo" extends="demo_standalone"> <target name="demo" extends="demo_standalone">
</target> </target>
</system> </system>

View File

@@ -117,18 +117,18 @@ feature -- Access: router
-- Let the class BLOG_HANDLER handle the requests on "/blogs" -- Let the class BLOG_HANDLER handle the requests on "/blogs"
create l_uri_mapping.make_trailing_slash_ignored ("/blogs", l_blog_handler) create l_uri_mapping.make_trailing_slash_ignored ("/blogs", l_blog_handler)
a_router.map_with_request_methods (l_uri_mapping, a_router.methods_get) a_router.map (l_uri_mapping, a_router.methods_get)
-- We can add a page number after /blogs/ to get older posts -- We can add a page number after /blogs/ to get older posts
a_router.handle_with_request_methods ("/blogs/page/{page}", l_blog_handler, a_router.methods_get) a_router.handle ("/blogs/page/{page}", l_blog_handler, a_router.methods_get)
-- If a user id is given route with blog user handler -- If a user id is given route with blog user handler
--| FIXME: maybe /user/{user}/blogs/ would be better. --| FIXME: maybe /user/{user}/blogs/ would be better.
a_router.handle_with_request_methods ("/blogs/user/{user}", l_blog_user_handler, a_router.methods_get) a_router.handle ("/blogs/user/{user}", l_blog_user_handler, a_router.methods_get)
-- If a user id is given we also want to allow different pages -- If a user id is given we also want to allow different pages
--| FIXME: what about /user/{user}/blogs/?page={page} ? --| FIXME: what about /user/{user}/blogs/?page={page} ?
a_router.handle_with_request_methods ("/blogs/user/{user}/page/{page}", l_blog_user_handler, a_router.methods_get) a_router.handle ("/blogs/user/{user}/page/{page}", l_blog_user_handler, a_router.methods_get)
end end

View File

@@ -86,8 +86,6 @@ feature -- Query
-- User id from path /blogs/{user}. -- User id from path /blogs/{user}.
-- Unsigned integer since negative ids are not allowed. -- Unsigned integer since negative ids are not allowed.
-- If no valid id can be read it returns -1 -- If no valid id can be read it returns -1
local
s: STRING
do do
Result := -1 Result := -1
if attached {WSF_STRING} req.path_parameter ("user") as l_user_id then if attached {WSF_STRING} req.path_parameter ("user") as l_user_id then

View File

@@ -83,8 +83,8 @@ feature -- Access: router
setup_router (a_router: WSF_ROUTER; a_api: CMS_API) setup_router (a_router: WSF_ROUTER; a_api: CMS_API)
-- <Precursor> -- <Precursor>
do do
map_uri_template_agent (a_router, "/demo/", agent handle_demo (?,?,a_api)) map_uri_template_agent (a_router, "/demo/", agent handle_demo (?,?,a_api), Void)
map_uri_template_agent (a_router, "/demo/{id}", agent handle_demo_entry (?,?,a_api)) map_uri_template_agent (a_router, "/demo/{id}", agent handle_demo_entry (?,?,a_api), Void)
end end
feature -- Hooks feature -- Hooks
@@ -144,42 +144,24 @@ feature -- Handler
feature -- Mapping helper: uri template feature -- Mapping helper: uri template
map_uri_template (a_router: WSF_ROUTER; a_tpl: STRING; h: WSF_URI_TEMPLATE_HANDLER) map_uri_template (a_router: WSF_ROUTER; a_tpl: READABLE_STRING_8; h: WSF_URI_TEMPLATE_HANDLER; rqst_methods: detachable WSF_REQUEST_METHODS)
-- Map `h' as handler for `a_tpl'
require
a_tpl_attached: a_tpl /= Void
h_attached: h /= Void
do
map_uri_template_with_request_methods (a_router, a_tpl, h, Void)
end
map_uri_template_with_request_methods (a_router: WSF_ROUTER; a_tpl: READABLE_STRING_8; h: WSF_URI_TEMPLATE_HANDLER; rqst_methods: detachable WSF_REQUEST_METHODS)
-- Map `h' as handler for `a_tpl' for request methods `rqst_methods'. -- Map `h' as handler for `a_tpl' for request methods `rqst_methods'.
require require
a_tpl_attached: a_tpl /= Void a_tpl_attached: a_tpl /= Void
h_attached: h /= Void h_attached: h /= Void
do do
a_router.map_with_request_methods (create {WSF_URI_TEMPLATE_MAPPING}.make (a_tpl, h), rqst_methods) a_router.map (create {WSF_URI_TEMPLATE_MAPPING}.make (a_tpl, h), rqst_methods)
end end
feature -- Mapping helper: uri template agent feature -- Mapping helper: uri template agent
map_uri_template_agent (a_router: WSF_ROUTER; a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]) map_uri_template_agent (a_router: WSF_ROUTER; a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS)
-- Map `proc' as handler for `a_tpl'
require
a_tpl_attached: a_tpl /= Void
proc_attached: proc /= Void
do
map_uri_template_agent_with_request_methods (a_router, a_tpl, proc, Void)
end
map_uri_template_agent_with_request_methods (a_router: WSF_ROUTER; a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS)
-- Map `proc' as handler for `a_tpl' for request methods `rqst_methods'. -- Map `proc' as handler for `a_tpl' for request methods `rqst_methods'.
require require
a_tpl_attached: a_tpl /= Void a_tpl_attached: a_tpl /= Void
proc_attached: proc /= Void proc_attached: proc /= Void
do do
map_uri_template_with_request_methods (a_router, a_tpl, create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (proc), rqst_methods) map_uri_template (a_router, a_tpl, create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (proc), rqst_methods)
end end
end end

View File

@@ -1,6 +1,7 @@
[layout] [layout]
root-dir=site/www root-dir=site/www
themes-dir=site/themes #themes-dir=site/themes
#modules-dir=site/modules
[site] [site]
name=Eiffel CMS name=Eiffel CMS

View File

@@ -31,7 +31,7 @@ feature {NONE} -- Initialization
admin_email := l_site_name + " <" + admin_email +">" admin_email := l_site_name + " <" + admin_email +">"
end end
if attached {CONFIG_READER} a_cms_api.module_configuration ("login", Void) as cfg then if attached {CONFIG_READER} a_cms_api.module_configuration_by_name ("login", Void) as cfg then
if attached cfg.text_item ("smtp") as l_smtp then if attached cfg.text_item ("smtp") as l_smtp then
-- Overwrite global smtp setting if any. -- Overwrite global smtp setting if any.
smtp_server := utf.utf_32_string_to_utf_8_string_8 (l_smtp) smtp_server := utf.utf_32_string_to_utf_8_string_8 (l_smtp)

View File

@@ -529,7 +529,8 @@ feature {NONE} -- Helpers
do do
create p.make_from_string ("templates") create p.make_from_string ("templates")
p := p.extended ("block_").appended (a_block_id).appended_with_extension ("tpl") p := p.extended ("block_").appended (a_block_id).appended_with_extension ("tpl")
p := a_response.module_resource_path (Current, p)
p := a_response.api.module_theme_resource_location (Current, p)
if p /= Void then if p /= Void then
if attached p.entry as e then if attached p.entry as e then
create Result.make (a_block_id, Void, p.parent, e) create Result.make (a_block_id, Void, p.parent, e)

View File

@@ -149,26 +149,26 @@ feature -- Access: router
-- TODO: for now, focused only on web interface, add REST api later. [2015-April-29] -- TODO: for now, focused only on web interface, add REST api later. [2015-April-29]
create l_node_handler.make (a_api, a_node_api) create l_node_handler.make (a_api, a_node_api)
create l_uri_mapping.make_trailing_slash_ignored ("/node", l_node_handler) create l_uri_mapping.make_trailing_slash_ignored ("/node", l_node_handler)
a_router.map_with_request_methods (l_uri_mapping, a_router.methods_get_post) a_router.map (l_uri_mapping, a_router.methods_get_post)
a_router.handle_with_request_methods ("/node/add/{type}", l_node_handler, a_router.methods_get_post) a_router.handle ("/node/add/{type}", l_node_handler, a_router.methods_get_post)
a_router.handle_with_request_methods ("/node/{id}/edit", l_node_handler, a_router.methods_get_post) a_router.handle ("/node/{id}/edit", l_node_handler, a_router.methods_get_post)
a_router.handle_with_request_methods ("/node/{id}/delete", l_node_handler, a_router.methods_get_post) a_router.handle ("/node/{id}/delete", l_node_handler, a_router.methods_get_post)
a_router.handle_with_request_methods ("/node/{id}/trash", l_node_handler, a_router.methods_get_post) a_router.handle ("/node/{id}/trash", l_node_handler, a_router.methods_get_post)
a_router.handle_with_request_methods ("/node/{id}", l_node_handler, a_router.methods_get) a_router.handle ("/node/{id}", l_node_handler, a_router.methods_get)
-- For now: no REST API handling... a_router.methods_get_put_delete + a_router.methods_get_post) -- For now: no REST API handling... a_router.methods_get_put_delete + a_router.methods_get_post)
-- Nodes -- Nodes
create l_nodes_handler.make (a_api, a_node_api) create l_nodes_handler.make (a_api, a_node_api)
create l_uri_mapping.make_trailing_slash_ignored ("/nodes", l_nodes_handler) create l_uri_mapping.make_trailing_slash_ignored ("/nodes", l_nodes_handler)
a_router.map_with_request_methods (l_uri_mapping, a_router.methods_get) a_router.map (l_uri_mapping, a_router.methods_get)
--Trash --Trash
create l_trash_handler.make (a_api, a_node_api) create l_trash_handler.make (a_api, a_node_api)
create l_uri_mapping.make_trailing_slash_ignored ("/trash", l_trash_handler) create l_uri_mapping.make_trailing_slash_ignored ("/trash", l_trash_handler)
a_router.map_with_request_methods (l_uri_mapping, a_router.methods_get) a_router.map (l_uri_mapping, a_router.methods_get)
end end

View File

@@ -61,11 +61,18 @@ feature {NONE} -- Initialization
-- Can be also used to precise the "From:" value for email. -- Can be also used to precise the "From:" value for email.
site_email := text_item_or_default ("site.email", "webmaster") site_email := text_item_or_default ("site.email", "webmaster")
-- Location for theme folders. -- Location for modules folders.
if attached text_item ("modules-dir") as s then
create modules_location.make_from_string (s)
else
modules_location := environment.modules_path
end
-- Location for themes folders.
if attached text_item ("themes-dir") as s then if attached text_item ("themes-dir") as s then
create themes_location.make_from_string (s) create themes_location.make_from_string (s)
else else
themes_location := environment.www_path.extended ("themes") themes_location := environment.themes_path
end end
-- Selected theme's name -- Selected theme's name
@@ -76,7 +83,6 @@ feature {NONE} -- Initialization
end end
compute_theme_location compute_theme_location
compute_theme_assets_location
end end
initialize_storages initialize_storages
@@ -163,15 +169,4 @@ feature -- Theme: Compute location
theme_location := themes_location.extended (theme_name) theme_location := themes_location.extended (theme_name)
end end
compute_theme_assets_location
-- assets (js, css, images, etc)
-- Not used at the moment.
do
debug ("refactor_fixme")
fixme ("Check if we really need it")
end
-- Check how to get this path from the CMS_THEME information.
theme_assets_location := theme_location.extended ("assets")
end
end end

View File

@@ -23,15 +23,35 @@ create
feature -- Access feature -- Access
theme_path: PATH site_path: PATH
-- Directory containing the site.
--| For now, an alias for `path'.
do
Result := path
end
modules_path: PATH
-- Directory for templates (HTML, etc). -- Directory for templates (HTML, etc).
local local
p: detachable PATH p: detachable PATH
do do
p := internal_theme_path p := internal_modules_path
if p = Void then if p = Void then
p := www_path.extended ("theme") p := site_path.extended ("modules")
internal_theme_path := p internal_modules_path := p
end
Result := p
end
themes_path: PATH
-- Directory for cms themes.
local
p: detachable PATH
do
p := internal_themes_path
if p = Void then
p := site_path.extended ("themes")
internal_themes_path := p
end end
Result := p Result := p
end end
@@ -58,7 +78,9 @@ feature -- Access
feature {NONE} -- Implementation feature {NONE} -- Implementation
internal_theme_path: detachable like theme_path internal_modules_path: detachable like modules_path
internal_themes_path: detachable like themes_path
internal_cms_config_ini_path: detachable like cms_config_ini_path internal_cms_config_ini_path: detachable like cms_config_ini_path

View File

@@ -90,7 +90,10 @@ feature -- Query
deferred deferred
end end
feature -- Access: Theme feature -- Access: Theme
modules_location: PATH
-- Path to modules.
themes_location: PATH themes_location: PATH
-- Path to themes. -- Path to themes.
@@ -98,9 +101,6 @@ feature -- Access: Theme
theme_location: PATH theme_location: PATH
-- Path to a active theme. -- Path to a active theme.
theme_assets_location: PATH
-- Path to a active theme assets folder.
theme_information_location: PATH theme_information_location: PATH
-- Active theme informations. -- Active theme informations.
do do

View File

@@ -152,11 +152,8 @@ feature -- Query: module
-- Enabled module typed `a_type', if any. -- Enabled module typed `a_type', if any.
--| usage: if attached module ({FOO_MODULE}) as mod then ... --| usage: if attached module ({FOO_MODULE}) as mod then ...
local local
-- t: STRING_8
l_type: TYPE [detachable CMS_MODULE] l_type: TYPE [detachable CMS_MODULE]
do do
-- t := type_name_without_annotation (a_type)
across across
setup.modules as ic setup.modules as ic
until until
@@ -173,8 +170,6 @@ feature -- Query: module
attached a_type.attempt (Result) and then attached l_type.generating_type.attempt (a_type) attached a_type.attempt (Result) and then attached l_type.generating_type.attempt (a_type)
then then
-- Found -- Found
-- elseif t.same_string (type_name_without_annotation (l_type)) then
-- -- Found
else else
Result := Void Result := Void
end end
@@ -322,55 +317,41 @@ feature {NONE}-- Implemenation
internal_user_api: detachable like user_api internal_user_api: detachable like user_api
-- Cached value for `user_api'. -- Cached value for `user_api'.
type_name_without_annotation (a_type: TYPE [detachable ANY]): STRING feature -- Environment/ theme
-- Type name for `a_type, without any annotation.
-- Used by `module' to search by type. theme_location: PATH
local -- Active theme location.
i,j,n: INTEGER
c: CHARACTER
do do
create Result.make_from_string (a_type.name) Result := setup.theme_location
from
i := 1
n := Result.count
until
i > n
loop
c := Result[i]
if c = '!' or c = '?' then
Result.remove (i)
n := n - 1
elseif c.is_lower then
j := Result.index_of (' ', i + 1)
if j > 0 then
Result.remove_substring (i, j)
n := n - (j - i)
end
else
i := i + 1
end
end
if Result.starts_with ("!") or Result.starts_with ("?") then
Result.remove_head (1)
elseif Result.starts_with ("detachable ") then
Result.remove_head (11)
end
end end
feature -- Environment theme_assets_location: PATH
-- assets (js, css, images, etc).
do
debug ("refactor_fixme")
fixme ("Check if we really need it")
end
-- Check how to get this path from the CMS_THEME information.
Result := theme_location.extended ("assets")
end
module_configuration (a_module_name: READABLE_STRING_GENERAL; a_name: detachable READABLE_STRING_GENERAL): detachable CONFIG_READER feature -- Environment/ module
module_configuration_by_name (a_module_name: READABLE_STRING_GENERAL; a_name: detachable READABLE_STRING_GENERAL): detachable CONFIG_READER
-- Configuration reader for `a_module', and if `a_name' is set, using name `a_name'. -- Configuration reader for `a_module', and if `a_name' is set, using name `a_name'.
local local
p, l_path: PATH p, l_path: detachable PATH
l_name: READABLE_STRING_GENERAL
ut: FILE_UTILITIES ut: FILE_UTILITIES
do do
p := setup.environment.config_path.extended ("modules").extended (a_module_name)
if a_name = Void then if a_name = Void then
p := p.extended (a_module_name) l_name := a_module_name
else else
p := p.extended (a_name) l_name := a_name
end end
p := module_location_by_name (a_module_name).extended ("config").extended (l_name)
l_path := p.appended_with_extension ("json") l_path := p.appended_with_extension ("json")
if ut.file_path_exists (l_path) then if ut.file_path_exists (l_path) then
create {JSON_CONFIG} Result.make_from_file (l_path) create {JSON_CONFIG} Result.make_from_file (l_path)
@@ -382,13 +363,72 @@ feature -- Environment
end end
if Result = Void and a_name /= Void then if Result = Void and a_name /= Void then
-- Use sub config from default? -- Use sub config from default?
if attached {CONFIG_READER} module_configuration (a_module_name, Void) as cfg then if attached {CONFIG_READER} module_configuration_by_name (a_module_name, Void) as cfg then
Result := cfg.sub_config (a_name) Result := cfg.sub_config (a_name)
else else
-- Maybe try to use the global cms.ini ? -- Maybe try to use the global cms.ini ?
end end
end end
end end
modules_location: PATH
-- Directory containing cms modules.
do
Result := setup.modules_location
end
module_location (a_module: CMS_MODULE): PATH
-- Location associated with `a_module'.
do
Result := module_location_by_name (a_module.name)
end
module_location_by_name (a_module_name: READABLE_STRING_GENERAL): PATH
-- Location associated with `a_module_name'.
do
Result := modules_location.extended (a_module_name)
end
module_resource_location (a_module: CMS_MODULE; a_resource: PATH): PATH
-- Location of resource `a_resource' for `a_module'.
do
--| site/modules/$modname/$a_name.json
Result := module_location (a_module).extended_path (a_resource)
end
feature -- Environment/ modules and theme
module_theme_resource_location (a_module: CMS_MODULE; a_resource: PATH): detachable PATH
-- Theme resource location of `a_resource' for module `a_module', if exists.
-- By default, located under the module location folder, but could be overriden
-- from files located under modules subfolder of active `theme_location'.
--| First search in themes/$theme/modules/$a_module.name/$a_resource,
--| and if not found then search in
--| modules/$a_module_name/$a_resource.
local
ut: FILE_UTILITIES
do
-- Check first in selected theme folder.
Result := module_theme_location (a_module).extended_path (a_resource)
if not ut.file_path_exists (Result) then
-- And if not found, look into site/modules/$a_module.name/.... folders.
Result := module_resource_location (a_module, a_resource)
if not ut.file_path_exists (Result) then
Result := Void
end
end
end
module_theme_location (a_module: CMS_MODULE): PATH
-- Location for overriden files associated with `a_module_name'.
do
Result := theme_location.extended ("modules").extended (a_module.name)
end
module_configuration (a_module: CMS_MODULE; a_name: detachable READABLE_STRING_GENERAL): detachable CONFIG_READER
do
Result := module_configuration_by_name (a_module.name, a_name)
end
end end

View File

@@ -156,7 +156,7 @@ feature -- Settings: router
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 (setup.theme_assets_location) create fhdl.make_hidden_with_path (api.theme_assets_location)
fhdl.disable_index fhdl.disable_index
fhdl.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
@@ -253,7 +253,7 @@ feature -- Execution
r: NOT_FOUND_ERROR_CMS_RESPONSE r: NOT_FOUND_ERROR_CMS_RESPONSE
f: WSF_FILE_RESPONSE f: WSF_FILE_RESPONSE
do do
p := api.setup.theme_assets_location.extended ("favicon.ico") p := api.theme_assets_location.extended ("favicon.ico")
if ut.file_path_exists (p) then if ut.file_path_exists (p) then
create f.make_with_path (p) create f.make_with_path (p)
res.send (f) res.send (f)

View File

@@ -152,39 +152,6 @@ feature -- API
Result := api.formats Result := api.formats
end end
feature -- Module
module_resource_path (a_module: CMS_MODULE; a_resource: PATH): detachable PATH
-- Resource path of `a_resource' for module `a_module', if resource exists.
local
rp: PATH
ut: FILE_UTILITIES
do
-- Check first in selected theme folder.
rp := module_assets_theme_location (a_module)
Result := rp.extended_path (a_resource)
if not ut.file_path_exists (Result) then
-- And if not found, look into site/modules/$a_module.name/.... folders.
rp := module_assets_location (a_module)
Result := rp.extended_path (a_resource)
if not ut.file_path_exists (Result) then
Result := Void
end
end
end
module_assets_location (a_module: CMS_MODULE): PATH
-- Location for the assets associated with `a_module'.
do
Result := setup.environment.path.extended ("modules").extended (a_module.name)
end
module_assets_theme_location (a_module: CMS_MODULE): PATH
-- Location for the assets associated with `a_module'.
do
Result := setup.theme_location.extended ("modules").extended (a_module.name)
end
feature -- URL utilities feature -- URL utilities
is_front: BOOLEAN is_front: BOOLEAN