diff --git a/examples/demo/site/themes/bootstrap/assets/scss/style.scss b/examples/demo/site/themes/bootstrap/assets/scss/style.scss
index 8debd65..3783a7a 100644
--- a/examples/demo/site/themes/bootstrap/assets/scss/style.scss
+++ b/examples/demo/site/themes/bootstrap/assets/scss/style.scss
@@ -41,6 +41,16 @@ ul.horizontal {
}
#content {
margin-left: 20px;
+ #highlighted {
+ position: relative;
+ border: solid 1px #ddd;
+ background-color: #ffc;
+ width: 70%;
+ left: 15%;
+ right: 15%;
+ padding: 5px;
+ font-style: italic;
+ }
}
.sidebar {
padding: 5px;
diff --git a/library/model/src/content/cms_content_type.e b/library/model/src/content/cms_content_type.e
index 695f3f3..fd5e175 100644
--- a/library/model/src/content/cms_content_type.e
+++ b/library/model/src/content/cms_content_type.e
@@ -21,6 +21,11 @@ feature -- Access
deferred
end
+ description: detachable READABLE_STRING_32
+ -- Optional description
+ deferred
+ end
+
feature -- Factory
new_node (a_partial_node: detachable CMS_NODE): CMS_NODE
diff --git a/src/modules/node/cms_node_api.e b/src/modules/node/cms_node_api.e
index e94851d..51f11f0 100644
--- a/src/modules/node/cms_node_api.e
+++ b/src/modules/node/cms_node_api.e
@@ -59,6 +59,34 @@ feature -- Content type
end
end
+feature -- URL
+
+ new_content_path (ct: detachable CMS_CONTENT_TYPE): STRING
+ -- URI path for new content of type `ct'
+ -- or URI of path for selection of new content possibilities if ct is Void.
+ do
+ if ct /= Void then
+ Result := "/node/new/" + ct.name
+ else
+ Result := "/node/new"
+ end
+ end
+
+ node_path (a_node: CMS_NODE): STRING
+ -- URI path for node `a_node'.
+ -- using the /node/{nid} url.
+ require
+ a_node.has_id
+ do
+ Result := "/node/" + a_node.id.out
+ end
+
+ nodes_path: STRING
+ -- URI path for list of nodes.
+ do
+ Result := "/nodes"
+ end
+
feature -- Access: Node
nodes_count: INTEGER_64
diff --git a/src/modules/node/content_type/cms_page_content_type.e b/src/modules/node/content_type/cms_page_content_type.e
index bb2383f..588dda3 100644
--- a/src/modules/node/content_type/cms_page_content_type.e
+++ b/src/modules/node/content_type/cms_page_content_type.e
@@ -18,6 +18,9 @@ feature -- Access
title: STRING_32 = "Page"
-- Human readable name.
+ description: STRING_32 = "Use basic pages for your content, such as an 'About us' page."
+ -- Optional description
+
feature -- Factory
new_node (a_partial_node: detachable CMS_NODE): CMS_PAGE
diff --git a/src/modules/node/handler/node_handler.e b/src/modules/node/handler/node_handler.e
index 25ed87c..5eb9cb3 100644
--- a/src/modules/node/handler/node_handler.e
+++ b/src/modules/node/handler/node_handler.e
@@ -1,5 +1,5 @@
note
- description: "Summary description for {NODE_HANDLER}."
+ description: "CMS handler for a node."
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
revision: "$Revision: 96616 $"
@@ -76,9 +76,6 @@ feature -- HTTP Methods
l_page.add_variable (l_node, "node")
create s.make_empty
- s.append ("
")
- s.append (html_encoded (l_node.title))
- s.append ("
")
s.append (" ")
if attached l_node.author as l_author then
s.append (" by ")
@@ -99,13 +96,11 @@ feature -- HTTP Methods
if attached {CMS_PAGE} l_node as l_node_page then
if attached l_node_page.parent as l_parent_node then
s.append ("
")
+ s.append (l_page.link (l_parent_node.title + " (#" + l_parent_node.id.out + ")", node_api.node_path (l_parent_node), Void))
+ s.append ("
")
end
end
+ l_page.set_title (l_node.title)
l_page.set_main_content (s)
l_page.execute
else
diff --git a/src/modules/node/handler/nodes_handler.e b/src/modules/node/handler/nodes_handler.e
index 2adb58a..2619a90 100644
--- a/src/modules/node/handler/nodes_handler.e
+++ b/src/modules/node/handler/nodes_handler.e
@@ -58,14 +58,7 @@ feature -- HTTP Methods
loop
n := ic.item
s.append ("")
- s.append ("")
- s.append (api.html_encoded (n.title))
- s.append (" (")
- s.append (n.id.out)
- s.append (")")
- s.append ("")
+ s.append (l_page.link (n.title + " (#" + n.id.out + ")", node_api.node_path (n), Void))
s.append ("%N")
end
s.append ("%N")
diff --git a/src/modules/node/node_module.e b/src/modules/node/node_module.e
index 7c690cb..a972a48 100644
--- a/src/modules/node/node_module.e
+++ b/src/modules/node/node_module.e
@@ -42,10 +42,32 @@ feature {CMS_API} -- Module Initialization
initialize (api: CMS_API)
--
+ local
+ p1,p2: CMS_PAGE
+ ct: CMS_PAGE_CONTENT_TYPE
do
Precursor (api)
if attached {CMS_NODE_STORAGE_SQL} api.storage as l_sql_storage then
l_sql_storage.register_node_storage_extension (create {CMS_NODE_STORAGE_SQL_PAGE_EXTENSION}.make (l_sql_storage))
+ if l_sql_storage.sql_table_items_count ("page_nodes") = 0 then
+ -- Data
+ -- FIXME: for test purpose, remove later
+ if attached api.user_api.user_by_id (1) as u then
+ create ct
+ p1 := ct.new_node (Void)
+ p1.set_title ("Welcome")
+ p1.set_content ("Welcome, you are using the ROC Eiffel CMS", "Welcome Eiffel ROC user", Void) -- Use default format
+ p1.set_author (u)
+ api.storage.save_node (p1)
+
+ p2 := ct.new_node (Void)
+ p2.set_title ("A new page example")
+ p2.set_content ("This is the content of a page", "This is a new page", Void) -- Use default format
+ p2.set_author (u)
+ p2.set_parent (p1)
+ api.storage.save_node (p2)
+ end
+ end
else
-- FIXME: maybe provide a default solution based on file system, when no SQL storage is available.
end
@@ -63,32 +85,11 @@ feature {CMS_API} -- Module management
end
install (api: CMS_API)
- local
- p1,p2: CMS_PAGE
- ct: CMS_PAGE_CONTENT_TYPE
do
-- Schema
if attached {CMS_STORAGE_SQL} api.storage as l_sql_storage then
l_sql_storage.sql_execute_file_script (api.setup.layout.path.extended ("scripts").extended (name).appended_with_extension ("sql"))
end
-
- -- Data
- -- FIXME: for test purpose, remove later
- if attached api.user_api.user_by_id (1) as u then
- create ct
- p1 := ct.new_node (Void)
- p1.set_title ("Welcome")
- p1.set_content ("Welcome, you are using the ROC Eiffel CMS", "Welcome Eiffel ROC user", Void) -- Use default format
- p1.set_author (u)
- api.storage.save_node (p1)
-
- p2 := ct.new_node (Void)
- p2.set_title ("A new page example")
- p2.set_content ("This is the content of a page", "This is a new page", Void) -- Use default format
- p2.set_author (u)
- p2.set_parent (p1)
- api.storage.save_node (p2)
- end
end
feature -- Access: router
@@ -121,7 +122,7 @@ feature -- Access: router
create l_new_node_handler.make (a_api, a_node_api)
a_router.handle_with_request_methods ("/node/new/{type}", create {WSF_URI_AGENT_HANDLER}.make (agent do_get_node_creation_by_type (?,?, "type", a_node_api)), a_router.methods_get)
- a_router.handle_with_request_methods ("/node/new", create {WSF_URI_AGENT_HANDLER}.make (agent do_get_node_creation_selection (?,?, a_api)), a_router.methods_get)
+ a_router.handle_with_request_methods ("/node/new", create {WSF_URI_AGENT_HANDLER}.make (agent do_get_node_creation_selection (?,?, a_node_api)), a_router.methods_get)
create l_edit_node_handler.make (a_api, a_node_api)
a_router.handle_with_request_methods ("/node/{id}/edit", l_edit_node_handler, a_router.methods_get_post)
@@ -245,11 +246,30 @@ feature -- Hooks
feature -- Handler
- do_get_node_creation_selection (req: WSF_REQUEST; res: WSF_RESPONSE; a_api: CMS_API)
+ do_get_node_creation_selection (req: WSF_REQUEST; res: WSF_RESPONSE; a_node_api: CMS_NODE_API)
local
- l_page: NOT_IMPLEMENTED_ERROR_CMS_RESPONSE
+ l_page: GENERIC_VIEW_CMS_RESPONSE
+ s: STRING
do
- create l_page.make (req, res, a_api)
+ create l_page.make (req, res, a_node_api.cms_api)
+
+ create s.make_empty
+ s.append ("")
+ l_page.set_title ("Create new content ...")
+ l_page.set_main_content (s)
l_page.execute
end
diff --git a/src/persistence/cms_storage_sql.e b/src/persistence/cms_storage_sql.e
index 3d37eb3..752a3a3 100644
--- a/src/persistence/cms_storage_sql.e
+++ b/src/persistence/cms_storage_sql.e
@@ -163,6 +163,20 @@ feature -- Helper
-- FIXME: find better solution
end
+ sql_table_items_count (a_table_name: READABLE_STRING_8): INTEGER_64
+ -- Number of items in table `a_table_name'?
+ local
+ l_params: STRING_TABLE [detachable ANY]
+ do
+ reset_error
+ create l_params.make (1)
+ l_params.force (a_table_name, "tbname")
+ sql_query ("SELECT count(*) FROM :tbname ;", l_params)
+ if not has_error then
+ Result := sql_read_integer_64 (1)
+ end
+ end
+
feature -- Access
sql_rows_count: INTEGER
diff --git a/src/persistence/node/cms_node_storage_sql_page_extension.e b/src/persistence/node/cms_node_storage_sql_page_extension.e
index 31f049d..a6d70d2 100644
--- a/src/persistence/node/cms_node_storage_sql_page_extension.e
+++ b/src/persistence/node/cms_node_storage_sql_page_extension.e
@@ -48,7 +48,7 @@ feature -- Persistence
l_parameters.put (a_node.revision, "revision")
sql_query (sql_select_page_data, l_parameters)
- if has_error then
+ if not has_error then
if sql_rows_count = 1 then
l_previous_parent_id := sql_read_integer_64 (3)
l_update := True
diff --git a/src/service/misc/cms_url_utilities.e b/src/service/misc/cms_url_utilities.e
index d6d30ed..73feb92 100644
--- a/src/service/misc/cms_url_utilities.e
+++ b/src/service/misc/cms_url_utilities.e
@@ -39,6 +39,62 @@ feature -- Core
end
end
+feature -- Link
+
+ link (a_text: detachable READABLE_STRING_GENERAL; a_path: READABLE_STRING_8; opts: detachable CMS_API_OPTIONS): STRING
+ do
+ create Result.make (32)
+ append_link_to_html (a_text, a_path, opts, Result)
+ end
+
+ link_with_raw_text (a_raw_text: detachable READABLE_STRING_8; a_path: READABLE_STRING_8; opts: detachable CMS_API_OPTIONS): STRING
+ do
+ create Result.make (32)
+ append_link_with_raw_text_to_html (a_raw_text, a_path, opts, Result)
+ end
+
+ append_link_to_html (a_text: detachable READABLE_STRING_GENERAL; a_path: READABLE_STRING_8; opts: detachable CMS_API_OPTIONS; a_html: STRING_8)
+ local
+ l_html: BOOLEAN
+ t: READABLE_STRING_GENERAL
+ do
+ l_html := True
+ if opts /= Void then
+ l_html := opts.boolean_item ("html", l_html)
+ end
+ a_html.append ("")
+ if a_text = Void then
+ t := a_path
+ else
+ t := a_text
+ end
+ if l_html then
+ a_html.append (html_encoded (t))
+ else
+ a_html.append (checked_plain (t))
+ end
+ a_html.append ("")
+ end
+
+ append_link_with_raw_text_to_html (a_raw_text: detachable READABLE_STRING_8; a_path: READABLE_STRING_8; opts: detachable CMS_API_OPTIONS; a_html: STRING_8)
+ local
+ l_html: BOOLEAN
+ t: READABLE_STRING_8
+ do
+ l_html := True
+ if opts /= Void then
+ l_html := opts.boolean_item ("html", l_html)
+ end
+ a_html.append ("")
+ if a_raw_text = Void then
+ t := a_path
+ else
+ t := a_raw_text
+ end
+ a_html.append (t)
+ a_html.append ("")
+ end
+
feature -- Url
absolute_url (a_path: STRING; opts: detachable CMS_API_OPTIONS): STRING
@@ -126,4 +182,9 @@ feature -- Url
Result := a_url
end
+ checked_plain (a_text: READABLE_STRING_GENERAL): STRING_8
+ do
+ Result := html_encoded (a_text)
+ end
+
end