From 307a87eaf4bb2adea9861791cbef52a937418856 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Fri, 24 Mar 2017 21:56:48 +0100 Subject: [PATCH 1/4] Better handling of path or location for administration links. --- library/model/src/link/cms_local_link.e | 14 +++++++++- src/service/cms_api.e | 26 ++++++++++++++----- src/service/cms_execution.e | 4 +-- .../handler/cms_admin_install_handler.e | 2 +- src/service/response/cms_response.e | 6 +++-- 5 files changed, 39 insertions(+), 13 deletions(-) diff --git a/library/model/src/link/cms_local_link.e b/library/model/src/link/cms_local_link.e index 227a09c..82a393e 100644 --- a/library/model/src/link/cms_local_link.e +++ b/library/model/src/link/cms_local_link.e @@ -90,6 +90,10 @@ feature -- Element change children := lst end lst.force (lnk) + if not is_expanded then + set_expandable (True) + set_collapsed (True) + end end remove_link (lnk: CMS_LINK) @@ -102,6 +106,8 @@ feature -- Element change lst.prune_all (lnk) if lst.is_empty then children := Void + set_collapsed (False) + set_expandable (False) end end end @@ -110,6 +116,12 @@ feature -- Element change -- Set `children' to `lst'. do children := lst + if lst /= Void and then not lst.is_empty then + if not is_expanded then + set_expandable (True) + set_collapsed (True) + end + end ensure children_set: children = lst end @@ -184,6 +196,6 @@ feature {NONE} -- Implementation invariant note - copyright: "2011-2016, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + copyright: "2011-2017, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/src/service/cms_api.e b/src/service/cms_api.e index 4c7ab49..262e02e 100644 --- a/src/service/cms_api.e +++ b/src/service/cms_api.e @@ -256,11 +256,15 @@ feature -- Access: url administration_path (a_relative_path: detachable READABLE_STRING_8): STRING_8 do create Result.make_from_string (setup.administration_base_path) - if a_relative_path /= Void and then not a_relative_path.is_empty then - if a_relative_path[1] /= '/' then + if a_relative_path /= Void then + if a_relative_path.is_empty then Result.append_character ('/') + else + if a_relative_path[1] /= '/' then + Result.append_character ('/') + end + Result.append (a_relative_path) end - Result.append (a_relative_path) end end @@ -270,8 +274,14 @@ feature -- Access: url do create Result.make_from_string (administration_base_path_location) if a_relative_location /= Void then - Result.append_character ('/') - Result.append (a_relative_location) + if a_relative_location.is_empty then + Result.append_character ('/') + else + if a_relative_location[1] /= '/' then + Result.append_character ('/') + end + Result.append (a_relative_location) + end end end @@ -282,9 +292,11 @@ feature {NONE} -- Url implementation. feature -- CMS links - administration_link (a_title: READABLE_STRING_GENERAL; a_location: READABLE_STRING_8): CMS_LOCAL_LINK + administration_link (a_title: READABLE_STRING_GENERAL; a_relative_location: detachable READABLE_STRING_8): CMS_LOCAL_LINK + require + no_first_slash: a_relative_location = Void or else not a_relative_location.starts_with_general ("/") do - Result := local_link (a_title, administration_path_location (a_location)) + Result := local_link (a_title, administration_path_location (a_relative_location)) end local_link (a_title: READABLE_STRING_GENERAL; a_location: READABLE_STRING_8): CMS_LOCAL_LINK diff --git a/src/service/cms_execution.e b/src/service/cms_execution.e index 0054e0b..bccb96c 100644 --- a/src/service/cms_execution.e +++ b/src/service/cms_execution.e @@ -160,8 +160,8 @@ feature -- Settings: router l_api.logger.put_debug (generator + ".setup_router_for_administration", Void) -- Configure root of api handler. - l_router.set_base_url (l_api.administration_path ("")) - + l_router.set_base_url (l_api.administration_path (Void)) + -- Include routes from modules. across modules as ic diff --git a/src/service/handler/cms_admin_install_handler.e b/src/service/handler/cms_admin_install_handler.e index c696ef0..0eaf680 100644 --- a/src/service/handler/cms_admin_install_handler.e +++ b/src/service/handler/cms_admin_install_handler.e @@ -105,7 +105,7 @@ feature -- HTTP Methods s.append ("%N") end s.append ("") - s.append ("
Back to the " + r.link ("Administration", api.administration_path (""), Void) + " ...
") + s.append ("
Back to the " + r.link ("Administration", api.administration_path (Void), Void) + " ...
") r.set_main_content (s) end r.set_title (r.translation ("CMS Installation ...", Void)) diff --git a/src/service/response/cms_response.e b/src/service/response/cms_response.e index 4c212a7..0d1ffca 100644 --- a/src/service/response/cms_response.e +++ b/src/service/response/cms_response.e @@ -1333,9 +1333,11 @@ feature -- Generation feature -- Helpers: cms link - administration_link (a_title: READABLE_STRING_GENERAL; a_location: READABLE_STRING_8): CMS_LOCAL_LINK + administration_link (a_title: READABLE_STRING_GENERAL; a_relative_location: detachable READABLE_STRING_8): CMS_LOCAL_LINK + require + no_first_slash: a_relative_location = Void or else not a_relative_location.starts_with_general ("/") do - Result := api.administration_link (a_title, a_location) + Result := api.administration_link (a_title, a_relative_location) end local_link (a_title: READABLE_STRING_GENERAL; a_location: READABLE_STRING_8): CMS_LOCAL_LINK From 134f876e622af32e3d2fcc85c306fa07bd92f644 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 28 Mar 2017 22:26:21 +0200 Subject: [PATCH 2/4] Display the full url for uploaded files via the CMS_FILES_MODULE. Keep db/mails in checkout. --- examples/demo/site/db/mails/README.md | 1 + modules/files/cms_files_module.e | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 examples/demo/site/db/mails/README.md diff --git a/examples/demo/site/db/mails/README.md b/examples/demo/site/db/mails/README.md new file mode 100644 index 0000000..4be5133 --- /dev/null +++ b/examples/demo/site/db/mails/README.md @@ -0,0 +1 @@ +This directory can be used to keep emails sent by the CMS. diff --git a/modules/files/cms_files_module.e b/modules/files/cms_files_module.e index 8f64d5d..b48c3a5 100644 --- a/modules/files/cms_files_module.e +++ b/modules/files/cms_files_module.e @@ -97,7 +97,7 @@ feature -- Access: router do map_uri_template_agent (a_router, "/" + uploads_location, agent execute_upload (?, ?, a_api), Void) -- Accepts any method GET, HEAD, POST, PUT, DELETE, ... map_uri_template_agent (a_router, "/" + uploads_location + "{filename}", agent display_uploaded_file_info (?, ?, a_api), a_router.methods_get) - map_uri_template_agent (a_router, "/" + uploads_location + "remove/{filename}", agent remove_file (?, ?, a_api), a_router.methods_get) + map_uri_template_agent (a_router, "/" + uploads_location + "{filename}/remove", agent remove_file (?, ?, a_api), a_router.methods_get) end uploads_location: STRING = "upload/" @@ -133,6 +133,7 @@ feature -- Handler local body: STRING_8 r: CMS_RESPONSE + l_file_url: STRING_8 f: CMS_FILE md: detachable CMS_FILE_METADATA fn: READABLE_STRING_32 @@ -193,12 +194,18 @@ feature -- Handler else body.append ("NA") end + body.append ("
%N") + + --| File Url + l_file_url := req.script_url ("/" + l_files_api.file_link (f).location) + body.append ("File URL: ") + body.append (l_file_url) body.append ("

%N") - body.append ("Download%N") - body.append ("Remove%N") + body.append ("Download%N") + body.append ("Remove%N") body.append ("%N") -- metadata - + body.append ("
%N") body.append ("
") if attached f.relative_path.extension as ext and then @@ -425,7 +432,7 @@ feature -- Handler -- add remove button a_output.append ("") - a_output.append ("Remove%N") + a_output.append ("Remove%N") a_output.append ("%N") a_output.append ("%N") From 0ce7d11e525448798d3d790aacc66b148aa3f790 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Thu, 30 Mar 2017 11:58:44 +0200 Subject: [PATCH 3/4] Implemented custom cms format, and associated administration pages. Applied to existing filter and format. Added embedded_video filter (initially contribute by Javier Velilla). --- examples/demo/demo.ecf | 1 + examples/demo/roc.cfg | 1 + examples/demo/src/demo_cms_execution.e | 1 + modules/admin/admin-safe.ecf | 1 + .../admin/cms_admin_module_administration.e | 15 ++ modules/blog/cms_blog_module.e | 6 - .../embedded_video/embedded_video-safe.ecf | 14 ++ .../src/embedded_video_module.e | 61 ++++++ .../embedded_video/src/video_content_filter.e | 182 +++++++++++++++++ .../src/video_html_content_format.e | 34 ++++ .../test/test_content_filter_set.e | 183 +++++++++++++++++ modules/embedded_video/test/testing-safe.ecf | 3 + modules/embedded_video/test/testing.ecf | 21 ++ modules/node/submodules/page/cms_page_api.e | 6 - modules/wikitext/wikitext_module.e | 12 +- src/kernel/content/format/cms_format.e | 25 ++- src/kernel/content/format/cms_formats.e | 33 +++- src/service/cms_api.e | 186 ++++++++++++++++-- src/service/cms_execution.e | 6 +- src/service/content/cms_content_type.e | 10 +- 20 files changed, 758 insertions(+), 43 deletions(-) create mode 100644 modules/embedded_video/embedded_video-safe.ecf create mode 100644 modules/embedded_video/src/embedded_video_module.e create mode 100644 modules/embedded_video/src/video_content_filter.e create mode 100644 modules/embedded_video/src/video_html_content_format.e create mode 100644 modules/embedded_video/test/test_content_filter_set.e create mode 100644 modules/embedded_video/test/testing-safe.ecf create mode 100644 modules/embedded_video/test/testing.ecf diff --git a/examples/demo/demo.ecf b/examples/demo/demo.ecf index 8491d47..dcbec04 100644 --- a/examples/demo/demo.ecf +++ b/examples/demo/demo.ecf @@ -42,6 +42,7 @@ +