diff --git a/cms/src/kernel/content/cms_encoders.e b/cms/src/kernel/content/cms_encoders.e new file mode 100644 index 0000000..36b60fc --- /dev/null +++ b/cms/src/kernel/content/cms_encoders.e @@ -0,0 +1,35 @@ +note + description: "Summary description for {CMS_ENCODERS}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + CMS_ENCODERS + +feature -- Encoders + + url_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8 + local + enc: URL_ENCODER + do + create enc + if s /= Void then + Result := enc.general_encoded_string (s) + else + create Result.make_empty + end + end + + html_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8 + local + enc: HTML_ENCODER + do + create enc + if s /= Void then + Result := enc.general_encoded_string (s) + else + create Result.make_empty + end + end +end diff --git a/cms/src/modules/node/node_module.e b/cms/src/modules/node/node_module.e index f435b04..e1e59a5 100644 --- a/cms/src/modules/node/node_module.e +++ b/cms/src/modules/node/node_module.e @@ -152,8 +152,8 @@ feature -- Hooks lnk: CMS_LOCAL_LINK perms: detachable ARRAYED_LIST [READABLE_STRING_8] do - create lnk.make ("node", "/node") - a_menu_system.navigation_menu.extend (lnk) + create lnk.make ("List of nodes", "/nodes") + a_menu_system.main_menu.extend (lnk) end end diff --git a/cms/src/service/response/cms_response.e b/cms/src/service/response/cms_response.e index 56500a0..8927719 100644 --- a/cms/src/service/response/cms_response.e +++ b/cms/src/service/response/cms_response.e @@ -7,6 +7,7 @@ deferred class CMS_RESPONSE inherit + CMS_ENCODERS CMS_REQUEST_UTIL @@ -139,9 +140,10 @@ feature -- Blocks initialization local l_table: like block_region_settings do + fixme ("CHECK:Can we use the same structure as in theme.info?") create regions.make_caseless (5) - -- FIXME: let the user choose ... + fixme ("let the user choose ...") create l_table.make_caseless (10) l_table["top"] := "top" l_table["header"] := "header" @@ -202,7 +204,7 @@ feature -- Blocks get_blocks do fixme ("find a way to have this in configuration or database, and allow different order") - add_block (top_header_block, "header") + add_block (top_header_block, "top") add_block (header_block, "header") if attached message_block as m then add_block (m, "content") @@ -275,22 +277,46 @@ feature -- Blocks local s: STRING do - fixme ("Avoid Hardcoded HTML!!!") - -- create s.make_from_string ("
" + html_encoded (site_name) + "
") create s.make_empty - s.append ("
") - s.append (theme.menu_html (main_menu, True)) - s.append ("
") - create Result.make ("header", Void, s, formats.full_html) + create Result.make ("page_top", Void, s, formats.full_html) Result.set_is_raw (True) end header_block: CMS_CONTENT_BLOCK local s: STRING + tpl: SMARTY_CMS_PAGE_TEMPLATE + l_page: CMS_HTML_PAGE + l_hb: STRING do - create s.make_empty - create Result.make ("header", Void, s, formats.full_html) + create s.make_from_string (theme.menu_html (main_menu, True)) + create l_hb.make_empty + to_implement ("Check if the tpl does not exist, provide a default implementation") + if attached {SMARTY_CMS_THEME} theme as l_theme then + create tpl.make ("block/header_test", l_theme) + -- Change to "block/header_block" to use the template code. + create l_page.make + l_page.register_variable (s, "header_block") + tpl.prepare (l_page) + l_hb := tpl.to_html (l_page) + end + if l_hb.starts_with ("ERROR") then + l_hb.wipe_out + to_implement ("Hardcoded HTML with CSS, find a better way to define defaults!!!.") + l_hb := "[ + + ]") + + end + create Result.make ("header", Void, l_hb, formats.full_html) Result.set_is_raw (True) end @@ -447,6 +473,25 @@ feature -- Hook: block end end + +feature -- Menu: change + + add_to_main_menu (lnk: CMS_LINK) + do +-- if attached {CMS_LOCAL_LINK} lnk as l_local then +-- l_local.get_is_active (request) +-- end + main_menu.extend (lnk) + end + + add_to_menu (lnk: CMS_LINK; m: CMS_MENU) + do +-- if attached {CMS_LOCAL_LINK} lnk as l_local then +-- l_local.get_is_active (request) +-- end + m.extend (lnk) + end + feature -- Message add_message (a_msg: READABLE_STRING_8; a_category: detachable READABLE_STRING_8) @@ -567,6 +612,7 @@ feature -- Generation -- Additional lines in + add_to_main_menu (create {CMS_LOCAL_LINK}.make ("Home", "/")) call_menu_alter_hooks (menu_system) prepare_menu_system (menu_system) @@ -619,11 +665,11 @@ feature -- Generation prepare_menu_system (a_menu_system: CMS_MENU_SYSTEM) do - across - a_menu_system as c - loop - prepare_links (c.item) - end +-- across +-- a_menu_system as c +-- loop +-- prepare_links (c.item) +-- end end prepare_links (a_menu: CMS_LINK_COMPOSITE) diff --git a/cms/src/theme/cms_theme.e b/cms/src/theme/cms_theme.e index 441f925..14b1d9d 100644 --- a/cms/src/theme/cms_theme.e +++ b/cms/src/theme/cms_theme.e @@ -7,6 +7,7 @@ deferred class CMS_THEME inherit + CMS_ENCODERS REFACTORING_HELPER @@ -88,33 +89,6 @@ feature {NONE} -- Implementation s.append ("") end - -feature -- Encoders - - url_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8 - local - enc: URL_ENCODER - do - create enc - if s /= Void then - Result := enc.general_encoded_string (s) - else - create Result.make_empty - end - end - - html_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8 - local - enc: HTML_ENCODER - do - create enc - if s /= Void then - Result := enc.general_encoded_string (s) - else - create Result.make_empty - end - end - note copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/cms/src/theme/smarty_theme/smarty_cms_theme.e b/cms/src/theme/smarty_theme/smarty_cms_theme.e index 88ee5aa..39ea5df 100644 --- a/cms/src/theme/smarty_theme/smarty_cms_theme.e +++ b/cms/src/theme/smarty_theme/smarty_cms_theme.e @@ -79,20 +79,21 @@ feature -- Conversion menu_html (a_menu: CMS_MENU; is_horizontal: BOOLEAN): STRING_8 -- Render Menu as HTML. -- A theme will define a menu.tpl + local + tpl: SMARTY_CMS_PAGE_TEMPLATE + l_page: CMS_HTML_PAGE do - create Result.make_from_string ("
") - if is_horizontal then - Result.append ("
") + to_implement ("Proof of concept to load a Menu from a tpl/menu.tpl.") + to_implement ("In this case the template only take care of links.") + to_implement ("Maybe we need a SMARTY_CMS_REGION_TEMPLATE") + to_implement ("Provide a default Menu using HTML hardcoded, maybe using the Default or providing a default implementation in CMS_THEME.menu_html") + -- Use the similar pattern to SMARTY_CMS_PAGE_TEMPLATE, with a different prepare + -- feature. + create tpl.make ("tpl/menu", Current) + create l_page.make + l_page.register_variable (a_menu, "menu") + tpl.prepare (l_page) + Result := tpl.to_html (l_page) end diff --git a/examples/roc_api/site/www/themes/bootstrap/block/header_block.tpl b/examples/roc_api/site/www/themes/bootstrap/block/header_block.tpl new file mode 100644 index 0000000..4a3b24c --- /dev/null +++ b/examples/roc_api/site/www/themes/bootstrap/block/header_block.tpl @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/examples/roc_api/site/www/themes/bootstrap/page.tpl b/examples/roc_api/site/www/themes/bootstrap/page.tpl index 54e6aaa..8ee484d 100644 --- a/examples/roc_api/site/www/themes/bootstrap/page.tpl +++ b/examples/roc_api/site/www/themes/bootstrap/page.tpl @@ -23,8 +23,8 @@
- {$region_header/} - + {$region_header/} +
diff --git a/examples/roc_api/site/www/themes/bootstrap/tpl/menu.tpl b/examples/roc_api/site/www/themes/bootstrap/tpl/menu.tpl new file mode 100644 index 0000000..c91d22c --- /dev/null +++ b/examples/roc_api/site/www/themes/bootstrap/tpl/menu.tpl @@ -0,0 +1,3 @@ + {foreach item="item" from="$menu.items"} +
  • {$item.title/}
  • + {/foreach} diff --git a/examples/roc_api/site/www/themes/bootstrap/tpl/page_header.tpl b/examples/roc_api/site/www/themes/bootstrap/tpl/page_header.tpl index 4cd6c4b..b0c3d8f 100644 --- a/examples/roc_api/site/www/themes/bootstrap/tpl/page_header.tpl +++ b/examples/roc_api/site/www/themes/bootstrap/tpl/page_header.tpl @@ -1,4 +1,4 @@ -

    ROC Layout with Default Regions

    +

    {$page_title/}