Initial implementation with Hooks, Regions and Templates
Updated Modules to support hooks, still work in progress.
This commit is contained in:
97
cms/src/kernel/cms_common_api.e
Normal file
97
cms/src/kernel/cms_common_api.e
Normal file
@@ -0,0 +1,97 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CMS_COMMON_API}."
|
||||
author: ""
|
||||
date: "$Date: 2014-08-28 08:21:49 -0300 (ju. 28 de ago. de 2014) $"
|
||||
revision: "$Revision: 95708 $"
|
||||
|
||||
deferred class
|
||||
CMS_COMMON_API
|
||||
|
||||
inherit
|
||||
WSF_API_UTILITIES
|
||||
|
||||
feature {NONE} -- Access
|
||||
|
||||
site_url: READABLE_STRING_8
|
||||
do
|
||||
Result := ""
|
||||
end
|
||||
|
||||
base_url: detachable READABLE_STRING_8
|
||||
-- Base url if any.
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
user_link (u: CMS_USER): like link
|
||||
do
|
||||
Result := link (u.name, "/user/" + u.id.out, Void)
|
||||
end
|
||||
|
||||
node_link (n: CMS_NODE): like link
|
||||
do
|
||||
Result := link (n.title, "/node/" + n.id.out, Void)
|
||||
end
|
||||
|
||||
user_url (u: CMS_USER): like url
|
||||
do
|
||||
Result := url ("/user/" + u.id.out, Void)
|
||||
end
|
||||
|
||||
node_url (n: CMS_NODE): like url
|
||||
do
|
||||
Result := url ("/node/" + n.id.out, Void)
|
||||
end
|
||||
|
||||
feature -- Helper
|
||||
|
||||
is_empty (s: detachable READABLE_STRING_GENERAL): BOOLEAN
|
||||
-- Is `s' is Void or empty ?
|
||||
do
|
||||
Result := s = Void or else s.is_empty
|
||||
end
|
||||
|
||||
unix_timestamp (dt: DATE_TIME): INTEGER_64
|
||||
do
|
||||
Result := (create {HTTP_DATE_TIME_UTILITIES}).unix_time_stamp (dt)
|
||||
end
|
||||
|
||||
unix_timestamp_to_date_time (t: INTEGER_64): DATE_TIME
|
||||
do
|
||||
Result := (create {HTTP_DATE_TIME_UTILITIES}).unix_time_stamp_to_date_time (t)
|
||||
end
|
||||
|
||||
string_unix_timestamp_to_date_time (s: READABLE_STRING_8): DATE_TIME
|
||||
do
|
||||
if s.is_integer_64 then
|
||||
Result := (create {HTTP_DATE_TIME_UTILITIES}).unix_time_stamp_to_date_time (s.to_integer_64)
|
||||
else
|
||||
Result := (create {HTTP_DATE_TIME_UTILITIES}).unix_time_stamp_to_date_time (0)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
options_boolean (opts: HASH_TABLE [detachable ANY, STRING]; k: STRING; dft: BOOLEAN): BOOLEAN
|
||||
do
|
||||
if attached {BOOLEAN} opts.item (k) as h then
|
||||
Result := h
|
||||
else
|
||||
Result := dft
|
||||
end
|
||||
end
|
||||
|
||||
options_string (opts: HASH_TABLE [detachable ANY, STRING]; k: STRING): detachable STRING
|
||||
do
|
||||
if attached {STRING} opts.item (k) as s then
|
||||
Result := s
|
||||
end
|
||||
end
|
||||
|
||||
-- html_encoder: HTML_ENCODER
|
||||
-- once ("thread")
|
||||
-- create Result
|
||||
-- end
|
||||
|
||||
end
|
||||
28
cms/src/kernel/content/cms_block.e
Normal file
28
cms/src/kernel/content/cms_block.e
Normal file
@@ -0,0 +1,28 @@
|
||||
note
|
||||
description: "Summary description for {CMS_BLOCK}."
|
||||
date: "$Date: 2014-08-28 08:21:49 -0300 (ju. 28 de ago. de 2014) $"
|
||||
|
||||
deferred class
|
||||
CMS_BLOCK
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: READABLE_STRING_8
|
||||
deferred
|
||||
end
|
||||
|
||||
title: detachable READABLE_STRING_32
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- status report
|
||||
|
||||
is_enabled: BOOLEAN
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
to_html (a_theme: CMS_THEME): STRING_8
|
||||
deferred
|
||||
end
|
||||
|
||||
end
|
||||
42
cms/src/kernel/content/cms_block_region.e
Normal file
42
cms/src/kernel/content/cms_block_region.e
Normal file
@@ -0,0 +1,42 @@
|
||||
note
|
||||
description: "Summary description for {CMS_BLOCK_REGION}."
|
||||
date: "$Date: 2014-10-30 12:55:33 -0300 (ju. 30 de oct. de 2014) $"
|
||||
|
||||
class
|
||||
CMS_BLOCK_REGION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_name: like name)
|
||||
do
|
||||
name := a_name
|
||||
create blocks.make (1)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: READABLE_STRING_8
|
||||
|
||||
blocks: ARRAYED_LIST [CMS_BLOCK]
|
||||
|
||||
feature -- Element change
|
||||
|
||||
extend (b: CMS_BLOCK)
|
||||
do
|
||||
blocks.force (b)
|
||||
end
|
||||
|
||||
;note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
74
cms/src/kernel/content/cms_content_block.e
Normal file
74
cms/src/kernel/content/cms_content_block.e
Normal file
@@ -0,0 +1,74 @@
|
||||
note
|
||||
description: "Summary description for {CMS_CONTENT_BLOCK}."
|
||||
author: ""
|
||||
date: "$Date: 2014-10-30 12:55:33 -0300 (ju. 30 de oct. de 2014) $"
|
||||
revision: "$Revision: 96018 $"
|
||||
|
||||
class
|
||||
CMS_CONTENT_BLOCK
|
||||
|
||||
inherit
|
||||
CMS_BLOCK
|
||||
|
||||
create
|
||||
make,
|
||||
make_raw
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_name: like name; a_title: like title; a_content: like content; a_format: like format)
|
||||
do
|
||||
is_enabled := True
|
||||
name := a_name
|
||||
title := a_title
|
||||
content := a_content
|
||||
format := a_format
|
||||
end
|
||||
|
||||
make_raw (a_name: like name; a_title: like title; a_content: like content; a_format: like format)
|
||||
do
|
||||
make (a_name, a_title, a_content, a_format)
|
||||
set_is_raw (True)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: READABLE_STRING_8
|
||||
|
||||
title: detachable READABLE_STRING_32
|
||||
|
||||
content: READABLE_STRING_8
|
||||
|
||||
format: CONTENT_FORMAT
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_raw: BOOLEAN
|
||||
-- Is raw?
|
||||
-- If True, do not get wrapped it with block specific div
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_is_raw (b: BOOLEAN)
|
||||
do
|
||||
is_raw := b
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
to_html (a_theme: CMS_THEME): STRING_8
|
||||
do
|
||||
Result := content
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
41
cms/src/kernel/content/cms_menu_block.e
Normal file
41
cms/src/kernel/content/cms_menu_block.e
Normal file
@@ -0,0 +1,41 @@
|
||||
note
|
||||
description: "Summary description for {CMS_MENU_BLOCK}."
|
||||
date: "$Date: 2014-08-28 08:21:49 -0300 (ju. 28 de ago. de 2014) $"
|
||||
|
||||
class
|
||||
CMS_MENU_BLOCK
|
||||
|
||||
inherit
|
||||
CMS_BLOCK
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_menu: like menu)
|
||||
do
|
||||
is_enabled := True
|
||||
menu := a_menu
|
||||
name := a_menu.name
|
||||
title := a_menu.title
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
menu: CMS_MENU
|
||||
|
||||
name: READABLE_STRING_8
|
||||
|
||||
title: detachable READABLE_STRING_32
|
||||
|
||||
is_horizontal: BOOLEAN
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
to_html (a_theme: CMS_THEME): STRING_8
|
||||
do
|
||||
Result := a_theme.menu_html (menu, is_horizontal)
|
||||
end
|
||||
|
||||
end
|
||||
89
cms/src/kernel/content/cms_value_table.e
Normal file
89
cms/src/kernel/content/cms_value_table.e
Normal file
@@ -0,0 +1,89 @@
|
||||
note
|
||||
description: "Summary description for {CMS_VALUE_TABLE}."
|
||||
date: "$Date: 2014-10-23 08:30:11 -0300 (ju. 23 de oct. de 2014) $"
|
||||
revision: "$Revision: 95980 $"
|
||||
|
||||
class
|
||||
CMS_VALUE_TABLE
|
||||
|
||||
inherit
|
||||
TABLE_ITERABLE [detachable ANY, READABLE_STRING_GENERAL]
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (nb: INTEGER)
|
||||
do
|
||||
create table.make (nb)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
count: INTEGER
|
||||
-- Number of items.
|
||||
do
|
||||
Result := table.count
|
||||
end
|
||||
|
||||
item (key: READABLE_STRING_GENERAL): detachable ANY
|
||||
-- Item associated with `key', if present
|
||||
-- otherwise default value of type `G'.
|
||||
note
|
||||
option: stable
|
||||
do
|
||||
Result := table.item (key)
|
||||
end
|
||||
|
||||
has (key: READABLE_STRING_GENERAL): BOOLEAN
|
||||
-- Has item associated with key `key'?
|
||||
do
|
||||
Result := table.has (key)
|
||||
end
|
||||
|
||||
new_cursor: TABLE_ITERATION_CURSOR [detachable ANY, READABLE_STRING_GENERAL]
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := table.new_cursor
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
put (new: detachable ANY; key: READABLE_STRING_GENERAL)
|
||||
-- Insert `new' with `key' if there is no other item
|
||||
-- associated with the same key.
|
||||
do
|
||||
table.put (new, key)
|
||||
end
|
||||
|
||||
force (new: detachable ANY; key: READABLE_STRING_GENERAL)
|
||||
-- Update table so that `new' will be the item associated
|
||||
-- with `key'.
|
||||
do
|
||||
table.force (new, key)
|
||||
end
|
||||
|
||||
remove (key: READABLE_STRING_GENERAL)
|
||||
do
|
||||
table.remove (key)
|
||||
end
|
||||
|
||||
feature {NONE} -- Duplication
|
||||
|
||||
table: STRING_TABLE [detachable ANY]
|
||||
|
||||
invariant
|
||||
table_set: table /= Void
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
64
cms/src/kernel/content/format/cms_formats.e
Normal file
64
cms/src/kernel/content/format/cms_formats.e
Normal file
@@ -0,0 +1,64 @@
|
||||
note
|
||||
description: "Summary description for {CMS_FORMATS}."
|
||||
author: ""
|
||||
date: "$Date: 2014-10-16 04:45:23 -0300 (ju. 16 de oct. de 2014) $"
|
||||
revision: "$Revision: 95932 $"
|
||||
|
||||
class
|
||||
CMS_FORMATS
|
||||
|
||||
feature -- Access
|
||||
|
||||
format (a_name: like {CONTENT_FORMAT}.name): detachable CONTENT_FORMAT
|
||||
do
|
||||
across
|
||||
all_formats as c
|
||||
until
|
||||
Result /= Void
|
||||
loop
|
||||
if c.item.name.same_string (a_name) then
|
||||
Result := c.item
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
all_formats: LIST [CONTENT_FORMAT]
|
||||
once
|
||||
create {ARRAYED_LIST [CONTENT_FORMAT]} Result.make (3)
|
||||
Result.force (plain_text)
|
||||
Result.force (full_html)
|
||||
Result.force (filtered_html)
|
||||
end
|
||||
|
||||
default_format: CONTENT_FORMAT
|
||||
do
|
||||
Result := plain_text --FIXME
|
||||
end
|
||||
|
||||
plain_text: PLAIN_TEXT_CONTENT_FORMAT
|
||||
once
|
||||
create Result
|
||||
end
|
||||
|
||||
full_html: FULL_HTML_CONTENT_FORMAT
|
||||
once
|
||||
create Result
|
||||
end
|
||||
|
||||
filtered_html: FILTERED_HTML_CONTENT_FORMAT
|
||||
once
|
||||
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)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
42
cms/src/kernel/form/cms_form.e
Normal file
42
cms/src/kernel/form/cms_form.e
Normal file
@@ -0,0 +1,42 @@
|
||||
note
|
||||
description: "Summary description for {CMS_FORM}."
|
||||
date: "$Date: 2014-08-28 08:21:49 -0300 (ju. 28 de ago. de 2014) $"
|
||||
revision: "$Revision: 95708 $"
|
||||
|
||||
class
|
||||
CMS_FORM
|
||||
|
||||
inherit
|
||||
WSF_FORM
|
||||
rename
|
||||
process as process_form
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Basic operation
|
||||
|
||||
prepare (a_response: CMS_RESPONSE)
|
||||
do
|
||||
a_response.call_form_alter_hooks (Current, Void)
|
||||
end
|
||||
|
||||
process (a_response: CMS_RESPONSE)
|
||||
do
|
||||
process_form (a_response.request, agent on_prepared (a_response, ?), agent on_processed (a_response, ?))
|
||||
end
|
||||
|
||||
on_prepared (a_response: CMS_RESPONSE; fd: WSF_FORM_DATA)
|
||||
do
|
||||
a_response.call_form_alter_hooks (Current, fd)
|
||||
end
|
||||
|
||||
on_processed (a_response: CMS_RESPONSE; fd: WSF_FORM_DATA)
|
||||
do
|
||||
if not fd.is_valid or fd.has_error then
|
||||
a_response.report_form_errors (fd)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
88
cms/src/kernel/link/cms_menu_system.e
Normal file
88
cms/src/kernel/link/cms_menu_system.e
Normal file
@@ -0,0 +1,88 @@
|
||||
note
|
||||
description: "Describe the navigation menus."
|
||||
date: "$Date: 2014-08-28 08:21:49 -0300 (ju. 28 de ago. de 2014) $"
|
||||
revision: "$Revision: 95708 $"
|
||||
|
||||
class
|
||||
CMS_MENU_SYSTEM
|
||||
|
||||
inherit
|
||||
ITERABLE [CMS_MENU]
|
||||
|
||||
REFACTORING_HELPER
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Create a predefined manu system
|
||||
do
|
||||
to_implement ("Refactor, take the info from a Database or Configuration file.")
|
||||
create items.make (5)
|
||||
force (create {CMS_MENU}.make ("main-menu", 3))
|
||||
force (create {CMS_MENU}.make_with_title ("management", "Management", 3))
|
||||
force (create {CMS_MENU}.make_with_title ("navigation", "Navigation", 3))
|
||||
force (create {CMS_MENU}.make_with_title ("user", "User", 3))
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
item (n: like {CMS_MENU}.name): CMS_MENU
|
||||
local
|
||||
m: detachable CMS_MENU
|
||||
do
|
||||
m := items.item (n)
|
||||
if m = Void then
|
||||
create m.make (n, 3)
|
||||
force (m)
|
||||
end
|
||||
Result := m
|
||||
end
|
||||
|
||||
main_menu: CMS_MENU
|
||||
do
|
||||
Result := item ("main-menu")
|
||||
end
|
||||
|
||||
management_menu: CMS_MENU
|
||||
do
|
||||
Result := item ("management")
|
||||
end
|
||||
|
||||
navigation_menu: CMS_MENU
|
||||
do
|
||||
Result := item ("navigation")
|
||||
end
|
||||
|
||||
user_menu: CMS_MENU
|
||||
do
|
||||
Result := item ("user")
|
||||
end
|
||||
|
||||
primary_tabs: CMS_MENU
|
||||
do
|
||||
Result := item ("primary-tabs")
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
force (m: CMS_MENU)
|
||||
do
|
||||
items.force (m, m.name)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: ITERATION_CURSOR [CMS_MENU]
|
||||
-- Fresh cursor associated with current structure.
|
||||
do
|
||||
Result := items.new_cursor
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
items: HASH_TABLE [CMS_MENU, like {CMS_MENU}.name]
|
||||
-- items: ARRAYED_LIST [CMS_MENU]
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user