#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:
@@ -4,13 +4,13 @@ ul.cms-nodes {
|
|||||||
border: solid 1px #ccc;
|
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;
|
border-top: dotted 1px #ccc;
|
||||||
}
|
}
|
||||||
li.cms_type_page a::before {
|
li.cms_type_page a::before {
|
||||||
content: "[page] ";
|
content: "[page] ";
|
||||||
}
|
}
|
||||||
li.cms_type_blog a::before {
|
.cms-nodes li.cms_type_blog a::before {
|
||||||
content: "[blog] ";
|
content: "[blog] ";
|
||||||
}
|
}
|
||||||
ul.cms-nodes li:first-child {
|
ul.cms-nodes li:first-child {
|
||||||
@@ -20,4 +20,32 @@ ul.cms-nodes li:first-child {
|
|||||||
.summary{
|
.summary{
|
||||||
margin-top:20px;
|
margin-top:20px;
|
||||||
font-weight:bold;
|
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;
|
||||||
}
|
}
|
||||||
@@ -212,6 +212,12 @@ feature -- Access: Node
|
|||||||
Result := node_storage.nodes
|
Result := node_storage.nodes
|
||||||
end
|
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]
|
recent_nodes (a_offset, a_rows: INTEGER): LIST [CMS_NODE]
|
||||||
-- List of the `a_rows' most recent nodes starting from `a_offset'.
|
-- List of the `a_rows' most recent nodes starting from `a_offset'.
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ feature -- HTTP Methods
|
|||||||
s: STRING
|
s: STRING
|
||||||
n: CMS_NODE
|
n: CMS_NODE
|
||||||
lnk: CMS_LOCAL_LINK
|
lnk: CMS_LOCAL_LINK
|
||||||
|
hdate: HTTP_DATE
|
||||||
do
|
do
|
||||||
-- At the moment the template is hardcoded, but we can
|
-- At the moment the template is hardcoded, but we can
|
||||||
-- get them from the configuration file and load them into
|
-- 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.
|
-- NOTE: for development purposes we have the following hardcode output.
|
||||||
create s.make_from_string ("<h2>Blog entries:</h2>")
|
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
|
-- Filter out blog entries from all nodes
|
||||||
--if n.content_type.is_equal ("blog") then
|
--if n.content_type.is_equal ("blog") then
|
||||||
s.append ("<ul class=%"cms-nodes%">%N")
|
s.append ("<ul class=%"cms-blog-nodes%">%N")
|
||||||
across
|
across
|
||||||
lst as ic
|
lst as ic
|
||||||
loop
|
loop
|
||||||
@@ -47,17 +48,33 @@ feature -- HTTP Methods
|
|||||||
lnk := node_api.node_link (n)
|
lnk := node_api.node_link (n)
|
||||||
s.append ("<li class=%"cms_type_"+ n.content_type +"%">")
|
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
|
-- Title with link
|
||||||
s.append (l_page.link (lnk.title, lnk.location, Void))
|
s.append (l_page.link (lnk.title, lnk.location, Void))
|
||||||
|
|
||||||
-- Summary
|
-- Summary
|
||||||
if attached n.summary as l_summary then
|
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
|
if attached api.format (n.format) as f then
|
||||||
s.append (f.formatted_output (l_summary))
|
s.append (f.formatted_output (l_summary))
|
||||||
else
|
else
|
||||||
s.append (l_page.formats.default_format.formatted_output (l_summary))
|
s.append (l_page.formats.default_format.formatted_output (l_summary))
|
||||||
end
|
end
|
||||||
|
s.append ("<br />")
|
||||||
|
s.append (l_page.link ("More...", lnk.location, Void))
|
||||||
|
s.append ("</p>")
|
||||||
end
|
end
|
||||||
|
|
||||||
s.append ("</li>%N")
|
s.append ("</li>%N")
|
||||||
|
|||||||
@@ -70,6 +70,11 @@ feature -- Access
|
|||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
nodes_order_created_desc: LIST [CMS_NODE]
|
||||||
|
-- List of nodes ordered by creation date (descending).
|
||||||
|
deferred
|
||||||
|
end
|
||||||
|
|
||||||
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
|
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
|
||||||
-- List of recent `a_count' nodes with an offset of `lower'.
|
-- List of recent `a_count' nodes with an offset of `lower'.
|
||||||
deferred
|
deferred
|
||||||
|
|||||||
@@ -41,6 +41,12 @@ feature -- Access: node
|
|||||||
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
nodes_order_created_desc: LIST[CMS_NODE]
|
||||||
|
-- List of nodes ordered descending by creation date
|
||||||
|
do
|
||||||
|
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
||||||
|
end
|
||||||
|
|
||||||
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
|
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
|
||||||
-- List of the `a_count' most recent nodes, starting from `a_lower'.
|
-- List of the `a_count' most recent nodes, starting from `a_lower'.
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -33,6 +33,32 @@ feature -- Access
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
nodes_order_created_desc: LIST [CMS_NODE]
|
||||||
|
-- List of nodes ordered by creation date (descending).
|
||||||
|
do
|
||||||
|
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
||||||
|
|
||||||
|
error_handler.reset
|
||||||
|
write_information_log (generator + ".nodes")
|
||||||
|
|
||||||
|
from
|
||||||
|
sql_query (sql_select_nodes_order_created_desc, Void)
|
||||||
|
sql_start
|
||||||
|
until
|
||||||
|
sql_after
|
||||||
|
loop
|
||||||
|
if attached fetch_node as l_node then
|
||||||
|
Result.force (l_node)
|
||||||
|
end
|
||||||
|
sql_forth
|
||||||
|
end
|
||||||
|
-- across
|
||||||
|
-- Result as ic
|
||||||
|
-- loop
|
||||||
|
-- fill_node (ic.item)
|
||||||
|
-- end
|
||||||
|
end
|
||||||
|
|
||||||
nodes: LIST [CMS_NODE]
|
nodes: LIST [CMS_NODE]
|
||||||
-- List of nodes.
|
-- List of nodes.
|
||||||
do
|
do
|
||||||
@@ -228,6 +254,10 @@ feature {NONE} -- Queries
|
|||||||
-- SQL Query to retrieve all nodes.
|
-- SQL Query to retrieve all nodes.
|
||||||
--| note: {CMS_NODE_API}.trashed = -1
|
--| note: {CMS_NODE_API}.trashed = -1
|
||||||
|
|
||||||
|
sql_select_nodes_order_created_desc: STRING = "SELECT * FROM Nodes WHERE status != -1 ORDER BY created DESC;"
|
||||||
|
-- SQL Query to retrieve all nodes order by descending creation date.
|
||||||
|
--| note: {CMS_NODE_API}.trashed = -1
|
||||||
|
|
||||||
sql_select_node_by_id: STRING = "SELECT nid, revision, type, title, summary, content, format, author, publish, created, changed, status FROM Nodes WHERE nid =:nid ORDER BY revision DESC, publish DESC LIMIT 1;"
|
sql_select_node_by_id: STRING = "SELECT nid, revision, type, title, summary, content, format, author, publish, created, changed, status FROM Nodes WHERE nid =:nid ORDER BY revision DESC, publish DESC LIMIT 1;"
|
||||||
|
|
||||||
sql_select_recent_nodes: STRING = "SELECT nid, revision, type, title, summary, content, format, author, publish, created, changed, status FROM Nodes ORDER BY nid DESC, publish DESC LIMIT :rows OFFSET :offset ;"
|
sql_select_recent_nodes: STRING = "SELECT nid, revision, type, title, summary, content, format, author, publish, created, changed, status FROM Nodes ORDER BY nid DESC, publish DESC LIMIT :rows OFFSET :offset ;"
|
||||||
|
|||||||
Reference in New Issue
Block a user