From 6a782e412d837fc85a0457aba4d54d3a4632dc0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dario=20B=C3=B6sch?= Date: Thu, 21 May 2015 12:03:09 +0200 Subject: [PATCH] #2 Structure of list of posts (blog)Ordered the posts by creation date. For this, I added a field to the nodes storage and api. Show the creation date and author. Styled the post and added a more link to the detail page --- .../site/themes/bootstrap/assets/css/node.css | 32 +++++++++++++++++-- modules/node/cms_node_api.e | 6 ++++ modules/node/handler/blog_handler.e | 23 +++++++++++-- modules/node/persistence/cms_node_storage_i.e | 5 +++ .../node/persistence/cms_node_storage_null.e | 6 ++++ .../node/persistence/cms_node_storage_sql.e | 30 +++++++++++++++++ 6 files changed, 97 insertions(+), 5 deletions(-) diff --git a/examples/demo/site/themes/bootstrap/assets/css/node.css b/examples/demo/site/themes/bootstrap/assets/css/node.css index 85b78c9..cc105b5 100644 --- a/examples/demo/site/themes/bootstrap/assets/css/node.css +++ b/examples/demo/site/themes/bootstrap/assets/css/node.css @@ -4,13 +4,13 @@ ul.cms-nodes { border: solid 1px #ccc; } -li.cms_type_page, li.cms_type_blog { +.cms-nodes li.cms_type_page, .cms-nodes li.cms_type_blog { border-top: dotted 1px #ccc; } li.cms_type_page a::before { content: "[page] "; } -li.cms_type_blog a::before { +.cms-nodes li.cms_type_blog a::before { content: "[blog] "; } ul.cms-nodes li:first-child { @@ -20,4 +20,32 @@ ul.cms-nodes li:first-child { .summary{ margin-top:20px; font-weight:bold; +} +.cms-blog-nodes{ + padding:0; + margin:0; +} +.cms-blog-nodes li{ + list-style: none; + display: block; + margin-top:20px; + padding-bottom:20px; + border-bottom:1px dotted black; +} + +.cms-blog-nodes li > a{ + color:black; + font-size:18px; + text-decoration: none; + display:block; + margin:6px 0; +} + +.cms-blog-nodes li > a:hover{ + color:#999; +} + +.blog_list_summary a{ + margin-top:20px; + display:block; } \ No newline at end of file diff --git a/modules/node/cms_node_api.e b/modules/node/cms_node_api.e index 8f0a8d9..ab990ea 100644 --- a/modules/node/cms_node_api.e +++ b/modules/node/cms_node_api.e @@ -212,6 +212,12 @@ feature -- Access: Node Result := node_storage.nodes end + nodes_order_created_desc: LIST[CMS_NODE] + -- List of nodes ordered by creation date (descending) + do + Result := node_storage.nodes_order_created_desc + end + recent_nodes (a_offset, a_rows: INTEGER): LIST [CMS_NODE] -- List of the `a_rows' most recent nodes starting from `a_offset'. do diff --git a/modules/node/handler/blog_handler.e b/modules/node/handler/blog_handler.e index 63786b3..58e50cf 100644 --- a/modules/node/handler/blog_handler.e +++ b/modules/node/handler/blog_handler.e @@ -24,6 +24,7 @@ feature -- HTTP Methods s: STRING n: CMS_NODE lnk: CMS_LOCAL_LINK + hdate: HTTP_DATE do -- At the moment the template is hardcoded, but we can -- get them from the configuration file and load them into @@ -35,10 +36,10 @@ feature -- HTTP Methods -- NOTE: for development purposes we have the following hardcode output. create s.make_from_string ("

Blog entries:

") - if attached node_api.nodes as lst then + if attached node_api.nodes_order_created_desc as lst then -- Filter out blog entries from all nodes --if n.content_type.is_equal ("blog") then - s.append ("