From 7bbf399ae1a15f039461012b210cc714974cfbe0 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Wed, 21 Aug 2024 08:33:34 -0500 Subject: [PATCH] Improving page importation code. --- src/MiniDocs/LeDatabase.extension.st | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/MiniDocs/LeDatabase.extension.st b/src/MiniDocs/LeDatabase.extension.st index 939688e..e44208a 100644 --- a/src/MiniDocs/LeDatabase.extension.st +++ b/src/MiniDocs/LeDatabase.extension.st @@ -41,21 +41,18 @@ LeDatabase >> addPageFromMarkdeep: markdeepDocTree withRemote: externalDocLocati divSnippets := (markdeepDocTree xpath: '//div[@st-class]') asOrderedCollection collect: [ :xmlElement | xmlElement postCopy ]. remoteMetadata := Markdeep new metadataFromXML: markdeepDocTree. + "Ensuring remote metadata has consistent data" remoteMetadata at: 'origin' put: externalDocLocation. + remoteMetadata at: 'title' ifAbsentPut: [ page detectMarkdeepTitleFrom: markdeepDocTree ]. + remoteMetadata at: 'id' ifAbsentPut: [UUID new asString36]. + remoteMetadata at: 'created' ifAbsentPut: [ DateAndTime now] . + remoteMetadata at: 'creator' ifAbsentPut: [ 'unknown' ]. + remoteMetadata at: 'modified' ifAbsentPut: [ DateAndTime now]. + remoteMetadata at: 'modifier' ifAbsentPut: [ 'unknown' ]. dataSnippets := self sanitizeMarkdeepSnippets: divSnippets withMetadata: remoteMetadata. - snippets := dataSnippets collect: [ :each | each asLepiterSnippet ]. page := LePage new. - page - title: (remoteMetadata at: 'title' ifAbsent: [ page detectMarkdeepTitleFrom: markdeepDocTree ]); - basicUid: (UUID fromString36: (remoteMetadata at: 'id' ifAbsent: [UUID new asString36])); - createTime: (LeTime new - time: (remoteMetadata at: 'created' ifAbsent: [ DateAndTime now]) asDateAndTime); - editTime: (LeTime new - time: (remoteMetadata at: 'modified' ifAbsent: [ DateAndTime now]) asDateAndTime); - latestEditTime: (LeTime new - time: (remoteMetadata at: 'modified' ifAbsent: [ DateAndTime now]) asDateAndTime); - createEmail: (remoteMetadata at: 'creator' ifAbsent: [ 'unknown' ]); - editEmail: (remoteMetadata at: 'modifier' ifAbsent: [ 'unknown' ]). + page fromDictionary: remoteMetadata. + snippets := dataSnippets collect: [ :each | each asLepiterSnippet ]. snippets do: [ :snippet | "| currentParent |" page addSnippet: snippet. "currentParent := page detectParentSnippetWithUid: (snippet metadata at: 'parent').