#3: Calculate and show number of total pages
This commit is contained in:
@@ -62,7 +62,6 @@ feature -- HTTP Methods
|
|||||||
-- <Precursor>
|
-- <Precursor>
|
||||||
local
|
local
|
||||||
l_page: CMS_RESPONSE
|
l_page: CMS_RESPONSE
|
||||||
l_posts: LIST[CMS_NODE]
|
|
||||||
s: STRING
|
s: STRING
|
||||||
n: CMS_NODE
|
n: CMS_NODE
|
||||||
lnk: CMS_LOCAL_LINK
|
lnk: CMS_LOCAL_LINK
|
||||||
@@ -92,7 +91,7 @@ feature -- HTTP Methods
|
|||||||
-- Output the title. If more than one page, also output the current page number
|
-- Output the title. If more than one page, also output the current page number
|
||||||
create s.make_from_string ("<h2>Blog")
|
create s.make_from_string ("<h2>Blog")
|
||||||
if more_than_one_page then
|
if more_than_one_page then
|
||||||
s.append (" (Page " + page_number.out + ")")
|
s.append (" (Page " + page_number.out + " of " + pages.out + ")")
|
||||||
-- Get the posts from the current page (limited by entries per page)
|
-- Get the posts from the current page (limited by entries per page)
|
||||||
end
|
end
|
||||||
s.append ("</h2>")
|
s.append ("</h2>")
|
||||||
@@ -141,6 +140,12 @@ feature -- HTTP Methods
|
|||||||
s.append ("</li>%N")
|
s.append ("</li>%N")
|
||||||
end
|
end
|
||||||
s.append ("</ul>%N")
|
s.append ("</ul>%N")
|
||||||
|
|
||||||
|
-- Show the pagination if there are more than one page
|
||||||
|
if more_than_one_page then
|
||||||
|
s.append ("<ul class=%"pagination%">")
|
||||||
|
|
||||||
|
end
|
||||||
--end
|
--end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -149,7 +154,7 @@ feature -- HTTP Methods
|
|||||||
l_page.execute
|
l_page.execute
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Query
|
feature {NONE} -- Query
|
||||||
|
|
||||||
more_than_one_page : BOOLEAN
|
more_than_one_page : BOOLEAN
|
||||||
-- Checks if all posts fit on one page (FALSE) or if more than one page is needed (TRUE)
|
-- Checks if all posts fit on one page (FALSE) or if more than one page is needed (TRUE)
|
||||||
@@ -157,6 +162,18 @@ feature -- Query
|
|||||||
Result := entries_per_page < node_api.blogs_count
|
Result := entries_per_page < node_api.blogs_count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
pages : NATURAL_16
|
||||||
|
-- Returns the number of pages needed to display all posts
|
||||||
|
require
|
||||||
|
entries_per_page > 0
|
||||||
|
local
|
||||||
|
tmp: REAL_32
|
||||||
|
do
|
||||||
|
tmp := node_api.blogs_count.to_real / entries_per_page.to_real;
|
||||||
|
Result := tmp.ceiling.to_natural_16
|
||||||
|
end
|
||||||
|
|
||||||
page_number_path_parameter (req: WSF_REQUEST): NATURAL_16
|
page_number_path_parameter (req: WSF_REQUEST): NATURAL_16
|
||||||
-- Returns the page number from the path /blogs/{page}. It's an unsigned integere since negative pages are not allowed
|
-- Returns the page number from the path /blogs/{page}. It's an unsigned integere since negative pages are not allowed
|
||||||
local
|
local
|
||||||
|
|||||||
Reference in New Issue
Block a user