When importing, do not change modification date.

Display /nodes sorted by changed date.
Improved the import form, and report wrong import folder. Only import from folder inside site/import for security reason.
This commit is contained in:
2017-01-27 23:12:02 +01:00
parent 2568e85c59
commit 32a47fbba3
15 changed files with 95 additions and 48 deletions

View File

@@ -299,6 +299,18 @@ feature -- Change: Node
save_node (a_node: CMS_NODE)
-- Save `a_node'.
local
now: DATE_TIME
do
reset_error
create now.make_now_utc
a_node.set_modification_date (now)
node_storage.save_node (a_node)
error_handler.append (node_storage.error_handler)
end
import_node (a_node: CMS_NODE)
-- Same as `save_node` but keep modification_date unchanged.
do
reset_error
node_storage.save_node (a_node)
@@ -326,14 +338,6 @@ feature -- Change: Node
end
end
update_node (a_node: CMS_NODE)
-- Update node `a_node' data.
do
reset_error
node_storage.update_node (a_node)
error_handler.append (node_storage.error_handler)
end
trash_node (a_node: CMS_NODE)
-- Trash node `a_node'.
-- Soft delete

View File

@@ -30,13 +30,13 @@ feature{NONE} -- Initialization
make (a_title: READABLE_STRING_32)
-- Create current node with `a_title'.
local
l_time: DATE_TIME
now: DATE_TIME
do
create l_time.make_now_utc
create now.make_now_utc
set_title (a_title)
set_creation_date (l_time)
set_modification_date (l_time)
set_publication_date (l_time)
set_creation_date (now)
set_modification_date (now)
set_publication_date (now)
mark_not_published
ensure
title_set: title = a_title

View File

@@ -91,10 +91,13 @@ feature -- HTTP Methods
s.append ("%">")
s.append (l_response.link (lnk.title, lnk.location, Void))
if not n.is_published then
s.append (" <em>(not-published)</em>")
s.append (" <span class=%"info%">(not-published)</span>")
elseif n.is_trashed then
s.append (" <em>(trashed)</em>")
s.append (" <span class=%"info%">(trashed)</span>")
end
s.append (" <span class=%"info%"> ("+ api.formatted_date_time_ago (n.modification_date) +")</span>")
s.append (" <span class=%"info%"> #"+ n.id.out +"</span>")
debug
if attached node_api.node_type (n.content_type) as ct then
s.append ("<span class=%"description%">")

View File

@@ -340,10 +340,8 @@ feature -- Change: Node
-- <Precursor>
local
l_parameters: STRING_TABLE [ANY]
l_time: DATE_TIME
do
sql_begin_transaction
create l_time.make_now_utc
write_information_log (generator + ".delete_node_base {" + a_node.id.out + "}")
error_handler.reset
@@ -391,9 +389,7 @@ feature {NONE} -- Implementation
l_copy_parameters: STRING_TABLE [detachable ANY]
l_parameters: STRING_TABLE [detachable ANY]
l_rev: like last_inserted_node_revision
now: DATE_TIME
do
create now.make_now_utc
error_handler.reset
write_information_log (generator + ".store_node")
@@ -404,7 +400,7 @@ feature {NONE} -- Implementation
l_parameters.put (a_node.content, "content")
l_parameters.put (a_node.format, "format")
l_parameters.put (a_node.publication_date, "publish")
l_parameters.put (now, "changed")
l_parameters.put (a_node.modification_date, "changed")
l_parameters.put (a_node.status, "status")
if attached a_node.author as l_author then
check valid_author: l_author.has_id end
@@ -436,10 +432,6 @@ feature {NONE} -- Implementation
l_parameters.put (a_node.revision, "revision")
sql_modify (sql_update_node, l_parameters)
sql_finalize
if not error_handler.has_error then
a_node.set_modification_date (now)
end
end
else
-- Store new node
@@ -450,7 +442,6 @@ feature {NONE} -- Implementation
sql_finalize
if not error_handler.has_error then
a_node.set_modification_date (now)
a_node.set_id (last_inserted_node_id)
a_node.set_revision (l_rev) -- New object.
-- check a_node.revision = last_inserted_node_revision (a_node) end
@@ -510,7 +501,7 @@ feature {NONE} -- Queries
sql_select_node_by_id_and_revision: STRING = "SELECT nodes.nid, node_revisions.revision, nodes.type, node_revisions.title, node_revisions.summary, node_revisions.content, node_revisions.format, node_revisions.author, nodes.publish, nodes.created, node_revisions.changed, node_revisions.status FROM nodes INNER JOIN node_revisions ON nodes.nid = node_revisions.nid WHERE nodes.nid = :nid AND node_revisions.revision = :revision ORDER BY node_revisions.revision DESC;"
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 :size OFFSET :offset ;"
sql_select_recent_nodes: STRING = "SELECT nid, revision, type, title, summary, content, format, author, publish, created, changed, status FROM nodes ORDER BY changed DESC, publish DESC LIMIT :size OFFSET :offset ;"
sql_select_recent_node_changes_before: STRING = "SELECT nid, revision, type, title, summary, content, format, author, publish, created, changed, status FROM nodes WHERE changed <= :date ORDER BY changed DESC, nid DESC LIMIT :size OFFSET :offset ;"

View File

@@ -9,6 +9,9 @@ ul.cms-nodes li {
ul.cms-nodes li:first-child {
border-top: none;
}
ul.cms-nodes li span.author, ul.cms-nodes li span.info {
float: right;
}
ul.cms-nodes li.cms_type_page a::before {
content: "[page] ";
}

View File

@@ -8,6 +8,9 @@ ul.cms-nodes {
&:first-child {
border-top: none;
}
span.author, span.info {
float: right;
}
}
li.cms_type_page a::before {
content: "[page] ";

View File

@@ -147,6 +147,12 @@ feature -- Commit
node_api.save_node (a_page)
end
import_page (a_page: CMS_PAGE)
-- Save `a_page` without changing the modification date.
do
node_api.import_node (a_page)
end
feature {CMS_MODULE} -- Access nodes storage.
page_storage: CMS_PAGE_STORAGE_I

View File

@@ -295,7 +295,7 @@ feature -- Hooks
l_parentable_list.extend ([l_entity, l_parent])
l_entity.set_parent (Void)
end
l_page_api.save_page (l_entity)
l_page_api.import_page (l_entity)
apply_taxonomy_to_node (j, l_entity, l_page_api.cms_api)
l_new_pages.force (l_entity, l_node_api.node_path (l_entity))
a_import_ctx.log (l_node_type.name + " %"" + fp.utf_8_name + "%" imported as "+ l_entity.id.out +" for user #" + l_author.id.out + ".")
@@ -329,12 +329,14 @@ feature -- Hooks
update_page_parent (l_entity, ic.item.parent, l_new_pages)
if attached l_entity.parent as l_parent then
a_import_ctx.log (l_node_type.name + " #" + l_entity.id.out + " assigned to parent #" + l_parent.id.out)
l_page_api.save_page (l_entity)
l_page_api.import_page (l_entity)
else
a_import_ctx.log (l_node_type.name + " #" + l_entity.id.out + " : unable to find parent!")
end
end
end
else
a_import_ctx.log ("Importing [" + l_node_type.name + "] NOT ALLOWED!")
end
end
end