added some commments

This commit is contained in:
Dario Bösch
2015-05-22 17:58:46 +02:00
parent 0bd75e7c59
commit e8ff313c28
5 changed files with 19 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
note
description: "API to handle nodes of type blog"
description: "API to handle nodes of type blog. Extends the node API."
author: "Dario B<>sch <daboesch@student.ethz.ch"
date: "$Date: 2015-05-21 14:46:00 +0100$"
revision: "$Revision: 96616 $"
@@ -23,6 +23,7 @@ feature {NONE} -- Implementation
-- <Precursor>
do
Precursor
-- Create the node storage for type blog
if attached {CMS_STORAGE_SQL_I} storage as l_storage_sql then
create {CMS_BLOG_STORAGE_SQL} node_storage.make (l_storage_sql)
else

View File

@@ -1,5 +1,5 @@
note
description: "Request handler related to /blogs."
description: "Request handler related to /blogs and /blogs/{page}. Displays all posts in the blog."
author: "Dario B<>sch <daboesch@student.ethz.ch>"
date: "$Date: 2015-05-18 13:49:00 +0100 (lun., 18 mai 2015) $"
revision: "$9661667$"
@@ -67,13 +67,11 @@ feature -- HTTP Methods
local
l_page: CMS_RESPONSE
do
-- At the moment the template is hardcoded, but we can
-- get them from the configuration file and load them into
-- the setup class.
-- Read the page number from get variable
page_number := page_number_path_parameter (req)
-- execute response by setting the main content
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
l_page.set_main_content (main_content_html(l_page))
l_page.execute
@@ -83,7 +81,7 @@ feature -- Query
posts : LIST[CMS_NODE]
-- The posts to list on the given page
-- The posts to list on the given page ordered by date (descending)
do
Result := node_api.blogs_order_created_desc_limited (entries_per_page, (page_number-1) * entries_per_page)
end
@@ -142,7 +140,7 @@ feature -- HTML Output
-- Get the posts from the current page (given by page number and entries per page)
if attached posts as lst then
-- List all posts of the blog
-- Start list of posts
Result.append ("<ul class=%"cms_blog_nodes%">%N")
across
lst as ic
@@ -169,7 +167,7 @@ feature -- HTML Output
-- End of post list
Result.append ("</ul>%N")
-- Pagination
-- Pagination (older and newer links)
Result.append (pagination_html)
--end
@@ -182,13 +180,12 @@ feature -- HTML Output
create Result.make_from_string ("<h2>Blog")
if more_than_one_page then
Result.append (" (Page " + page_number.out + " of " + pages.out + ")")
-- Get the posts from the current page (limited by entries per page)
end
Result.append ("</h2>")
end
creation_date_html (n: CMS_NODE) : STRING
-- returns the creation date. At the moment hard coded as html
-- returns the creation date as a html string
local
hdate: HTTP_DATE
do

View File

@@ -1,5 +1,5 @@
note
description: "Request handler related to /blogs/user/{id}/. Displays all posts of the given user"
description: "Request handler related to /blogs/user/{id}/ or /blogs/user/{id}/page/{page}. Displays all posts of the given user"
author: "Dario B<>sch <daboesch@student.ethz.ch>"
date: "$Date: 2015-05-22 15:13:00 +0100 (lun., 18 mai 2015) $"
revision: "$Revision 96616$"
@@ -35,9 +35,10 @@ feature -- HTTP Methods
-- Check if userID valid
if user_valid (req) then
user := load_user(req)
-- Output the results, similar as in the blog hanlder (but with other queries)
precursor(req, res)
else
-- Throw a bad request error if the user is not valid
-- Throw a bad request error because the user is not valid
create l_error.make (req, res, api)
l_error.set_main_content ("<h1>Error</h1>User with id " + user_path_parameter(req).out + " doesn't exist!")
l_error.execute
@@ -88,7 +89,7 @@ feature -- Query
end
posts : LIST[CMS_NODE]
-- The posts to list on the given page
-- The posts to list on the given page. Filters out the posts of the current user
do
if attached user as l_user then
Result := node_api.blogs_from_user_order_created_desc_limited (l_user.id.to_integer_32, entries_per_page, (page_number-1) * entries_per_page)
@@ -98,7 +99,7 @@ feature -- Query
end
total_entries : NATURAL_32
-- Returns the number of total entries/posts
-- Returns the number of total entries/posts of the current user
do
if attached user as l_user then
Result := node_api.blogs_count_from_user(l_user.id).to_natural_32
@@ -111,7 +112,7 @@ feature -- Query
feature -- HTML Output
page_title_html : STRING
-- Returns the title of the page as a html string. It shows the current page number
-- Returns the title of the page as a html string. It shows the current page number and the name of the current user
do
create Result.make_from_string ("<h2>Posts from ")
if attached user as l_user then
@@ -127,7 +128,7 @@ feature -- HTML Output
end
base_path : STRING
-- the path to the page that lists all blogs
-- the path to the page that lists all blogs. It must include the user id
do
if attached user as l_user then
Result := "/blogs/user/" + l_user.id.out

View File

@@ -1,8 +1,8 @@
note
description: "Summary description for {CMS_NODE_HANDLER}."
author: ""
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
revision: "$Revision: 96616 $"
description: "Deferred request handler related to /blogs/... Has an own blog api."
author: "Dario B<>sch <daboesch@student.ethz.ch>"
date: "$Date: 2015-05-18 13:49:00 +0100 (lun., 18 mai 2015) $"
revision: "$9661667$"
deferred class
CMS_BLOG_HANDLER

View File

@@ -36,11 +36,6 @@ feature -- Initialization
create u.make ("admin")
u.set_password ("istrator#")
u.set_email (a_setup.site_email)
a_storage.new_user (u)
create u.make ("daboesch")
u.set_password ("eiffel")
u.set_email ("daboesch@student.ethz.ch")
a_storage.new_user (u)
--| Node