Better control on path alias.

If user has permission to edit, provide a text input, otherwise just a label if path are required.
Reviewed html generated for taxonomy field in node edit form.
Improved the blog entries list by providing (if permitted) link to blog entry creation, and link to the user entries or all entries.
This commit is contained in:
2017-03-06 21:27:35 +01:00
parent 7cde24a439
commit 67f6591851
7 changed files with 152 additions and 71 deletions

View File

@@ -8,6 +8,9 @@ class
inherit
CMS_NODE_TYPE [CMS_BLOG]
redefine
is_path_alias_required
end
feature -- Access
@@ -20,6 +23,11 @@ feature -- Access
description: STRING_32 = "Content published as a blog post."
-- Optional description
feature -- Setting
is_path_alias_required: BOOLEAN = True
-- <Precursor>.
feature -- Factory
new_node_with_title (a_title: READABLE_STRING_32; a_partial_node: detachable CMS_NODE): like new_node

View File

@@ -160,6 +160,8 @@ feature -- HTML Output
-- Output the title. If more than one page, also output the current page number
append_page_title_html_to (page, a_output)
append_user_related_html_to (page, a_output)
-- Get the posts from the current page (given by page number and entries per page)
-- Start list of posts
a_output.append ("<ul class=%"cms_blog_nodes%">%N")
@@ -198,12 +200,23 @@ feature -- HTML Output
append_page_title_html_to (a_page: CMS_RESPONSE; a_output: STRING)
-- Append the title of the page as a html string to `a_output'.
-- It shows the current page number.
local
l_title: STRING
do
a_output.append ("<h2>Blog")
create l_title.make_from_string ("Blog entries")
if multiple_pages_needed then
a_output.append (" (Page " + page_number.out + " of " + pages_count.out + ")")
l_title.append (" (Page " + page_number.out + " of " + pages_count.out + ")")
end
a_page.set_title (l_title)
-- a_output.append ("<h2>" + l_title + "</h2>")
end
append_user_related_html_to (a_page: CMS_RESPONSE; a_output: STRING)
do
if attached api.user as u and api.has_permission ("create blog") then
a_page.add_to_primary_tabs (a_page.local_link ("Create a new blog entry", "node/add/blog"))
a_page.add_to_primary_tabs (a_page.local_link ("View your blog entries", "blog/" + u.id.out))
end
a_output.append ("</h2>")
end
append_creation_date_html_to (n: CMS_NODE; a_output: STRING)

View File

@@ -22,6 +22,7 @@ inherit
posts,
total_entries,
append_page_title_html_to,
append_user_related_html_to,
base_path
end
@@ -116,18 +117,29 @@ feature -- HTML Output
append_page_title_html_to (a_page: CMS_RESPONSE; a_output: STRING)
-- Returns the title of the page as a html string. It shows the current page number and the name of the current user
local
l_title: STRING
do
a_output.append ("<h2>Posts from ")
create l_title.make_from_string ("Blog entries from ")
if attached user as l_user then
a_output.append (html_encoded (a_page.user_profile_name (l_user)))
l_title.append (html_encoded (a_page.user_profile_name (l_user)))
else
a_output.append ("unknown user")
l_title.append ("unknown user")
end
if multiple_pages_needed then
a_output.append (" (Page " + page_number.out + " of " + pages_count.out + ")")
l_title.append (" (Page " + page_number.out + " of " + pages_count.out + ")")
-- Get the posts from the current page (limited by entries per page)
end
a_output.append ("</h2>")
a_page.set_title (l_title)
-- a_output.append ("<h2>" + l_title + "</h2>")
end
append_user_related_html_to (a_page: CMS_RESPONSE; a_output: STRING)
do
if attached api.user as u and api.has_permission ("create blog") then
a_page.add_to_primary_tabs (a_page.local_link ("Create a new blog entry", "node/add/blog"))
end
a_page.add_to_primary_tabs (a_page.local_link ("View all blog entries", "blogs/"))
end
base_path : STRING