Restructured Blog Module
All blog handlers and storage classes are detached from the nodes module. All files of the blog module are in the modules/blog folder
This commit is contained in:
@@ -212,11 +212,6 @@ feature -- Access: Node
|
||||
Result := node_storage.nodes
|
||||
end
|
||||
|
||||
blogs_order_created_desc: LIST[CMS_NODE]
|
||||
-- List of nodes ordered by creation date (descending)
|
||||
do
|
||||
Result := node_storage.blogs
|
||||
end
|
||||
|
||||
recent_nodes (a_offset, a_rows: INTEGER): LIST [CMS_NODE]
|
||||
-- List of the `a_rows' most recent nodes starting from `a_offset'.
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
note
|
||||
description: "Request handler related to /blogs."
|
||||
author: "Dario B<>sch <daboesch@student.ethz.ch"
|
||||
date: "$Date: 2015-05-18 13:49:99 +0100 (lun., 18 mai 2015) $"
|
||||
revision: "$966167$"
|
||||
|
||||
class
|
||||
BLOG_HANDLER
|
||||
|
||||
inherit
|
||||
NODES_HANDLER
|
||||
redefine
|
||||
do_get
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Settings
|
||||
entries_per_page : INTEGER
|
||||
-- The numbers of posts that are shown on one page. If there are more post a pagination is generated
|
||||
do
|
||||
-- For test reasons this is 2, so we don't have to create a lot of blog entries.
|
||||
-- TODO: Set to bigger constant or load from global configuration file.
|
||||
Result := 2
|
||||
end
|
||||
|
||||
feature -- HTTP Methods
|
||||
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
l_page: CMS_RESPONSE
|
||||
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
|
||||
-- the setup class.
|
||||
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
l_page.add_variable (node_api.nodes, "nodes")
|
||||
|
||||
|
||||
-- NOTE: for development purposes we have the following hardcode output.
|
||||
create s.make_from_string ("<h2>Blog</h2>")
|
||||
if attached node_api.blogs_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-blog-nodes%">%N")
|
||||
across
|
||||
lst as ic
|
||||
loop
|
||||
n := ic.item
|
||||
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 ("<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 ("See more...", lnk.location, Void))
|
||||
s.append ("</p>")
|
||||
end
|
||||
|
||||
s.append ("</li>%N")
|
||||
end
|
||||
s.append ("</ul>%N")
|
||||
--end
|
||||
end
|
||||
|
||||
l_page.set_main_content (s)
|
||||
l_page.add_block (create {CMS_CONTENT_BLOCK}.make ("nodes_warning", Void, "/blogs/ is not yet fully implemented<br/>", Void), "highlighted")
|
||||
l_page.execute
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -70,11 +70,6 @@ feature -- Access
|
||||
deferred
|
||||
end
|
||||
|
||||
blogs: LIST [CMS_NODE]
|
||||
-- List of nodes ordered by creation date (descending).
|
||||
deferred
|
||||
end
|
||||
|
||||
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
|
||||
-- List of recent `a_count' nodes with an offset of `lower'.
|
||||
deferred
|
||||
|
||||
@@ -41,12 +41,6 @@ feature -- Access: node
|
||||
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
||||
end
|
||||
|
||||
blogs: 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]
|
||||
-- List of the `a_count' most recent nodes, starting from `a_lower'.
|
||||
do
|
||||
|
||||
@@ -33,31 +33,6 @@ feature -- Access
|
||||
end
|
||||
end
|
||||
|
||||
blogs: 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_blogs_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]
|
||||
-- List of nodes.
|
||||
@@ -254,10 +229,6 @@ feature {NONE} -- Queries
|
||||
-- SQL Query to retrieve all nodes.
|
||||
--| note: {CMS_NODE_API}.trashed = -1
|
||||
|
||||
sql_select_blogs_order_created_desc: STRING = "SELECT * FROM Nodes WHERE status != -1 AND type = %"blog%" ORDER BY created DESC;"
|
||||
-- SQL Query to retrieve all nodes that are from the type "blog" ordered 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_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