#1: Added the summary field to all nodes. It gets saved if we edit the node. On a node page the summary is shown first, then the main content. In the blog list the title and the summry is shown

This commit is contained in:
Dario Bösch
2015-05-21 10:18:03 +02:00
parent 202253e414
commit 0e0cd131a5
3 changed files with 56 additions and 7 deletions

View File

@@ -16,3 +16,8 @@ li.cms_type_blog a::before {
ul.cms-nodes li:first-child {
border-top: none;
}
.summary{
margin-top:20px;
font-weight:bold;
}

View File

@@ -46,8 +46,20 @@ feature -- HTTP Methods
if n.content_type.is_equal ("blog") then
lnk := node_api.node_link (n)
s.append ("<li class=%"cms_type_"+ n.content_type +"%">")
-- Title with link
s.append (l_page.link (lnk.title, lnk.location, Void))
--s.append (l_page.link (n.title + " (#" + n.id.out + ")", node_api.node_path (n), Void))
-- Summary
if attached n.summary as l_summary then
s.append ("<br />")
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
end
s.append ("</li>%N")
end
end

View File

@@ -37,7 +37,7 @@ feature -- Forms ...
if a_node /= Void then
ta.set_text_value (a_node.content)
end
-- ta.set_label ("Body")
ta.set_label ("Content")
ta.set_description ("This is the main content")
ta.set_is_required (False)
@@ -48,7 +48,7 @@ feature -- Forms ...
if a_node /= Void then
sum.set_text_value (a_node.summary)
end
-- sum.set_label ("Summary")
sum.set_label ("Summary")
sum.set_description ("This is the summary")
sum.set_is_required (False)
@@ -104,7 +104,7 @@ feature -- Forms ...
update_node (response: NODE_RESPONSE; fd: WSF_FORM_DATA; a_node: CMS_NODE)
local
b: detachable READABLE_STRING_8
b,s: detachable READABLE_STRING_8
f: detachable CONTENT_FORMAT
do
if attached fd.integer_item ("id") as l_id and then l_id > 0 then
@@ -117,6 +117,12 @@ feature -- Forms ...
if attached fd.string_item ("body") as l_body then
b := l_body
end
-- Read out the summary field from the form data
if attached fd.string_item ("summary") as l_summary then
s := l_summary
end
if attached fd.string_item ("format") as s_format and then attached response.api.format (s_format) as f_format then
f := f_format
elseif a_node /= Void and then attached a_node.format as s_format and then attached response.api.format (s_format) as f_format then
@@ -124,15 +130,19 @@ feature -- Forms ...
else
f := response.formats.default_format
end
-- Update node with summary and body content
if b /= Void then
a_node.set_content (b, Void, f.name) -- FIXME: summary
a_node.set_content (b, s, f.name)
end
end
new_node (response: NODE_RESPONSE; fd: WSF_FORM_DATA; a_node: detachable CMS_NODE): G
-- <Precursor>
local
b: detachable READABLE_STRING_8
b,s: detachable READABLE_STRING_8
f: detachable CONTENT_FORMAT
l_node: detachable like new_node
do
@@ -166,9 +176,16 @@ feature -- Forms ...
end
l_node.set_author (response.user)
--Summary
if attached fd.string_item ("summary") as l_summary then
s := l_summary
end
--Content
if attached fd.string_item ("body") as l_body then
b := l_body
end
if attached fd.string_item ("format") as s_format and then attached response.api.format (s_format) as f_format then
f := f_format
elseif a_node /= Void and then attached a_node.format as s_format and then attached response.api.format (s_format) as f_format then
@@ -176,8 +193,10 @@ feature -- Forms ...
else
f := response.formats.default_format
end
-- Update node with summary and content
if b /= Void then
l_node.set_content (b, Void, f.name)
l_node.set_content (b, s, f.name)
end
Result := l_node
end
@@ -216,6 +235,19 @@ feature -- Output
s.append (")")
end
s.append ("</div>")
if attached a_node.summary as l_summary then
s.append ("<p class=%"summary%">")
if attached node_api.cms_api.format (a_node.format) as f then
s.append (f.formatted_output (l_summary))
else
s.append (a_response.formats.default_format.formatted_output (l_summary))
end
s.append ("</p>")
end
if attached a_node.content as l_content then
s.append ("<p class=%"content%">")
if attached node_api.cms_api.format (a_node.format) as f then