#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

This commit is contained in:
Dario Bösch
2015-05-21 12:03:09 +02:00
parent 0e0cd131a5
commit 6a782e412d
6 changed files with 97 additions and 5 deletions

View File

@@ -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 ("<h2>Blog entries:</h2>")
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 ("<ul class=%"cms-nodes%">%N")
s.append ("<ul class=%"cms-blog-nodes%">%N")
across
lst as ic
loop
@@ -47,17 +48,33 @@ feature -- HTTP Methods
lnk := node_api.node_link (n)
s.append ("<li class=%"cms_type_"+ n.content_type +"%">")
-- Post date (creation)
if attached n.creation_date as l_modified then
create hdate.make_from_date_time (l_modified)
s.append (hdate.yyyy_mmm_dd_string)
s.append (" ")
end
-- Author
if attached n.author as l_author then
s.append ("by ")
s.append (l_author.name)
end
-- Title with link
s.append (l_page.link (lnk.title, lnk.location, Void))
-- Summary
if attached n.summary as l_summary then
s.append ("<br />")
s.append ("<p class=%"blog_list_summary%">")
if attached api.format (n.format) as f then
s.append (f.formatted_output (l_summary))
else
s.append (l_page.formats.default_format.formatted_output (l_summary))
end
s.append ("<br />")
s.append (l_page.link ("More...", lnk.location, Void))
s.append ("</p>")
end
s.append ("</li>%N")