Renamed node_api and node_storage by blog_api and blog_storage in related CMS_BLOG_* classes. Mainly to avoid confusion with NODE_ classes.

Merged CMS_BLOG_CONFIG with CMS_BLOG_API.
In CMS_BLOG_API, prefer argument of type CMS_USER, rather than using directly user id.
Added a CMS_EDITOR_CONTENT_FORMAT for now, to be the format editable by the WYSIWYG editor.
Added CMS_MODULE.is_initialized: BOOLEAN to equip router, and module_api with expected preconditions.

Fixed typo, especially in log output.
Corrected a few routine names such as add_authors that should not be a function according to its name.
Converted various function returning html content, to procedure appending html content to an output string to minimize temporary string object creation.
Cosmetic: added spaces to make code easier to read, and indentation.
This commit is contained in:
2015-05-27 19:00:32 +02:00
parent e35893fdb9
commit c871eae10e
20 changed files with 376 additions and 303 deletions

View File

@@ -0,0 +1,31 @@
note
description: "HTML Content format editable with WYSIWYG editor."
date: "$Date$"
revision: "$Revision$"
class
CMS_EDITOR_CONTENT_FORMAT
inherit
CONTENT_FORMAT
redefine
default_create
end
feature {NONE} -- Initialization
default_create
do
Precursor
create filters.make (0)
end
feature -- Access
name: STRING = "cms_editor"
title: STRING_8 = "CMS HTML content"
filters: ARRAYED_LIST [CONTENT_FILTER]
end

View File

@@ -27,10 +27,11 @@ feature -- Access
once
-- Can we provide an external file to read the
-- supported formats?
create {ARRAYED_LIST [CONTENT_FORMAT]} Result.make (3)
create {ARRAYED_LIST [CONTENT_FORMAT]} Result.make (4)
Result.force (plain_text)
Result.force (full_html)
Result.force (filtered_html)
Result.force (cms_html)
end
default_format: CONTENT_FORMAT
@@ -43,6 +44,11 @@ feature -- Access
create Result
end
cms_html: CMS_EDITOR_CONTENT_FORMAT
once
create Result
end
full_html: FULL_HTML_CONTENT_FORMAT
once
create Result
@@ -53,7 +59,6 @@ feature -- Access
create Result
end
note
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -27,8 +27,6 @@ feature -- Javascript
javascript_textarea_to_editor(a_textarea : WSF_FORM_TEXTAREA) : STRING
-- Javascript code to display the textarea as a WYSIWIG editor as soon as the document is loaded
local
l_code : STRING
do
Result := javascript_ready(javascript_replace_textarea (a_textarea))
end

View File

@@ -21,22 +21,22 @@ create
feature -- Initialisation
make (a_name: like name)
-- <Precursor>
do
precursor(a_name)
make (a_name: like name)
-- <Precursor>
do
precursor(a_name)
-- By default we don't replace the textarea by an editor
editor := False;
end
-- By default we don't replace the textarea by an editor
editor := False;
end
feature -- Access
editor : BOOLEAN
-- True if the textarea should be replaced by the editor. Default is false.
-- True if the textarea should be replaced by the editor. Default is false.
format_field : detachable WSF_FORM_SELECT
-- Selection field for the format on that it depends, if the editor is shown or not.
-- Selection field for the format on that it depends, if the editor is shown or not.
condition_value : detachable STRING
@@ -58,7 +58,6 @@ feature -- Editor
feature -- Conversion
append_item_to_html (a_theme: WSF_THEME; a_html: STRING_8)
do
-- Add javascript to replace textarea with editor
@@ -67,16 +66,12 @@ feature -- Conversion
a_html.append (load_assets)
a_html.append ("<script type=%"text/javascript%">");
if attached format_field as l_field and then attached condition_value as l_value then
a_html.append (javascript_textarea_to_editor_if_selected(current, l_field, l_value))
a_html.append (javascript_textarea_to_editor_if_selected (Current, l_field, l_value))
else
a_html.append (javascript_textarea_to_editor(current))
a_html.append (javascript_textarea_to_editor (Current))
end
a_html.append ("</script>")
end
end
feature -- Javascript Output
javascript_show_editor_on_full_html_select : STRING = ""
end

View File

@@ -185,8 +185,10 @@ feature -- Query: module
module_api (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE_API
-- Enabled module API associated with module typed `a_type'.
do
if attached module (a_type) as mod then
Result := mod.module_api
if attached {CMS_MODULE} module (a_type) as mod then
if mod.is_enabled then
Result := mod.module_api
end
end
end

View File

@@ -32,10 +32,19 @@ feature {CMS_API} -- Module Initialization
-- Initialize Current module with `api'.
require
is_enabled: is_enabled
is_not_initialized: not is_initialized
do
-- Redefine to process specific module initialization.
is_initialized := True
ensure
is_initialized: is_initialized
end
feature -- Status
is_initialized: BOOLEAN
-- Is Current module initialized?
feature {CMS_API} -- Access: API
module_api: detachable CMS_MODULE_API
@@ -68,6 +77,8 @@ feature -- Router
setup_router (a_router: WSF_ROUTER; a_api: CMS_API)
-- Setup url dispatching for Current module.
require
is_initialized: is_initialized
deferred
end