diff --git a/examples/demo/site/modules/node/files/css/node.css b/examples/demo/site/modules/node/files/css/node.css index f4277ee..36d829d 100644 --- a/examples/demo/site/modules/node/files/css/node.css +++ b/examples/demo/site/modules/node/files/css/node.css @@ -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] "; } diff --git a/examples/demo/site/modules/node/files/scss/node.scss b/examples/demo/site/modules/node/files/scss/node.scss index 34d5e20..edd453d 100644 --- a/examples/demo/site/modules/node/files/scss/node.scss +++ b/examples/demo/site/modules/node/files/scss/node.scss @@ -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] "; diff --git a/modules/admin/handler/cms_admin_import_handler.e b/modules/admin/handler/cms_admin_import_handler.e index 39285d6..05d31ce 100644 --- a/modules/admin/handler/cms_admin_import_handler.e +++ b/modules/admin/handler/cms_admin_import_handler.e @@ -67,25 +67,26 @@ feature -- Execution if attached fd.string_item ("op") as l_op and then l_op.same_string (text_import_all_data) then if attached fd.string_item ("folder") as l_folder then create p.make_from_string (l_folder) - if p.is_absolute then - create l_importation.make (p) + create l_importation.make (api.site_location.extended (import_folder_name).extended (l_folder)) + if l_importation.location_exists then + l_response.add_notice_message ("Import all data (if permitted)!") + api.hooks.invoke_import_from (Void, l_importation, l_response) + create s.make_empty + across + l_importation.logs as ic + loop + s.append (ic.item) + s.append ("
") + s.append_character ('%N') + end + l_response.add_notice_message (s) else - create l_importation.make (api.site_location.extended ("import").extended (l_folder)) + l_response.add_error_message ("Specified import folder is not found!") + fd.report_invalid_field ("folder", "Folder not found!") end else - create l_importation.make (api.site_location.extended ("import").extended ("default")) + fd.report_error ("Invalid form data!") end - api.hooks.invoke_import_from (Void, l_importation, l_response) - l_response.add_notice_message ("All data imported (if allowed)!") - create s.make_empty - across - l_importation.logs as ic - loop - s.append (ic.item) - s.append ("
") - s.append_character ('%N') - end - l_response.add_notice_message (s) else fd.report_error ("Invalid form data!") end @@ -107,14 +108,16 @@ feature -- Widget Result.extend_raw_text ("Import CMS data from ") create f_name.make_with_text ("folder", "default") f_name.set_label ("Import folder name") - f_name.set_description ("Folder name under 'imports' folder.") + f_name.set_description ("Folder name under '" + a_response.html_encoded (import_folder_name) + "' folder.") f_name.set_is_required (True) Result.extend (f_name) create but.make_with_text ("op", text_import_all_data) Result.extend (but) end -feature -- Interface text. +feature -- Interface text. + + import_folder_name: STRING_32 = "import" text_import_all_data: STRING_32 = "Import all data" diff --git a/modules/blog/cms_blog_api.e b/modules/blog/cms_blog_api.e index 8c2608b..3e7c1e8 100644 --- a/modules/blog/cms_blog_api.e +++ b/modules/blog/cms_blog_api.e @@ -126,6 +126,12 @@ feature -- Commit node_api.save_node (a_blog) end + import_blog (a_blog: CMS_BLOG) + -- Same as `save_blog` but keep modification_date unchanged. + do + node_api.import_node (a_blog) + end + feature {NONE} -- Helpers nodes_to_blogs (a_nodes: LIST [CMS_NODE]): ARRAYED_LIST [CMS_BLOG] diff --git a/modules/blog/cms_blog_module.e b/modules/blog/cms_blog_module.e index f00f513..9534e7d 100644 --- a/modules/blog/cms_blog_module.e +++ b/modules/blog/cms_blog_module.e @@ -290,7 +290,7 @@ feature -- Hooks a_import_ctx.log (l_node_type.name + " %"" + fp.utf_8_name + "%" skipped (already exists for user #" + l_author.id.out + ")!") else a_import_ctx.log (l_node_type.name + " %"" + fp.utf_8_name + "%" imported for user #" + l_author.id.out + ".") - l_blog_api.save_blog (l_entity) + l_blog_api.import_blog (l_entity) apply_taxonomy_to_node (j, l_entity, l_blog_api.cms_api) if attached {CMS_LOCAL_LINK} l_entity.link as l_link then loc := l_node_api.node_path (l_entity) @@ -315,6 +315,8 @@ feature -- Hooks end end end + else + a_import_ctx.log ("Importing [" + l_node_type.name + "] NOT ALLOWED!") end end end diff --git a/modules/node/cms_node_api.e b/modules/node/cms_node_api.e index 3e45e10..e173130 100644 --- a/modules/node/cms_node_api.e +++ b/modules/node/cms_node_api.e @@ -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 diff --git a/modules/node/content/cms_node.e b/modules/node/content/cms_node.e index 0368c0e..a301210 100644 --- a/modules/node/content/cms_node.e +++ b/modules/node/content/cms_node.e @@ -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 diff --git a/modules/node/handler/nodes_handler.e b/modules/node/handler/nodes_handler.e index b129341..11d5c4e 100644 --- a/modules/node/handler/nodes_handler.e +++ b/modules/node/handler/nodes_handler.e @@ -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 (" (not-published)") + s.append (" (not-published)") elseif n.is_trashed then - s.append (" (trashed)") + s.append (" (trashed)") end + s.append (" ("+ api.formatted_date_time_ago (n.modification_date) +")") + s.append (" #"+ n.id.out +"") + debug if attached node_api.node_type (n.content_type) as ct then s.append ("") diff --git a/modules/node/persistence/cms_node_storage_sql.e b/modules/node/persistence/cms_node_storage_sql.e index aa958b8..e1b8de4 100644 --- a/modules/node/persistence/cms_node_storage_sql.e +++ b/modules/node/persistence/cms_node_storage_sql.e @@ -340,10 +340,8 @@ feature -- Change: Node -- 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 ;" diff --git a/modules/node/site/files/css/node.css b/modules/node/site/files/css/node.css index f4277ee..36d829d 100644 --- a/modules/node/site/files/css/node.css +++ b/modules/node/site/files/css/node.css @@ -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] "; } diff --git a/modules/node/site/files/scss/node.scss b/modules/node/site/files/scss/node.scss index 34d5e20..edd453d 100644 --- a/modules/node/site/files/scss/node.scss +++ b/modules/node/site/files/scss/node.scss @@ -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] "; diff --git a/modules/node/submodules/page/cms_page_api.e b/modules/node/submodules/page/cms_page_api.e index 4f4a782..66dbe80 100644 --- a/modules/node/submodules/page/cms_page_api.e +++ b/modules/node/submodules/page/cms_page_api.e @@ -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 diff --git a/modules/node/submodules/page/cms_page_module.e b/modules/node/submodules/page/cms_page_module.e index e563aa8..f177235 100644 --- a/modules/node/submodules/page/cms_page_module.e +++ b/modules/node/submodules/page/cms_page_module.e @@ -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 diff --git a/src/hooks/import/cms_import_context.e b/src/hooks/import/cms_import_context.e index 1ae42e0..8e1ae8b 100644 --- a/src/hooks/import/cms_import_context.e +++ b/src/hooks/import/cms_import_context.e @@ -15,14 +15,22 @@ feature {NONE} -- Initialization make (a_location: PATH) do - location := a_location + location := a_location.absolute_path.canonical_path create logs.make (10) end feature -- Access location: PATH - -- Location of import folder. + -- Location of import folder. + + location_exists: BOOLEAN + -- Does location of import folder exist? + local + ut: FILE_UTILITIES + do + Result := ut.directory_path_exists (location) + end feature -- Logs diff --git a/src/service/cms_api.e b/src/service/cms_api.e index ff5460f..c76050f 100644 --- a/src/service/cms_api.e +++ b/src/service/cms_api.e @@ -336,6 +336,16 @@ feature -- Internationalization (i18n) Result := l_formatter.formatted_string (a_text, args) end + formatted_date_time_ago (dt: DATE_TIME): STRING_32 + -- Output date `dt` using time ago duration. + local + ago: DATE_TIME_AGO_CONVERTER + do + create ago.make + create Result.make (10) + Result.append_string_general (ago.smart_date_duration (dt)) + end + feature -- Emails new_email (a_to_address: READABLE_STRING_8; a_subject: READABLE_STRING_8; a_content: READABLE_STRING_8): CMS_EMAIL