Improving page importation code.
This commit is contained in:
parent
fb64d5c1ae
commit
7bbf399ae1
@ -41,21 +41,18 @@ LeDatabase >> addPageFromMarkdeep: markdeepDocTree withRemote: externalDocLocati
|
|||||||
divSnippets := (markdeepDocTree xpath: '//div[@st-class]') asOrderedCollection
|
divSnippets := (markdeepDocTree xpath: '//div[@st-class]') asOrderedCollection
|
||||||
collect: [ :xmlElement | xmlElement postCopy ].
|
collect: [ :xmlElement | xmlElement postCopy ].
|
||||||
remoteMetadata := Markdeep new metadataFromXML: markdeepDocTree.
|
remoteMetadata := Markdeep new metadataFromXML: markdeepDocTree.
|
||||||
|
"Ensuring remote metadata has consistent data"
|
||||||
remoteMetadata at: 'origin' put: externalDocLocation.
|
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.
|
dataSnippets := self sanitizeMarkdeepSnippets: divSnippets withMetadata: remoteMetadata.
|
||||||
snippets := dataSnippets collect: [ :each | each asLepiterSnippet ].
|
|
||||||
page := LePage new.
|
page := LePage new.
|
||||||
page
|
page fromDictionary: remoteMetadata.
|
||||||
title: (remoteMetadata at: 'title' ifAbsent: [ page detectMarkdeepTitleFrom: markdeepDocTree ]);
|
snippets := dataSnippets collect: [ :each | each asLepiterSnippet ].
|
||||||
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' ]).
|
|
||||||
snippets do: [ :snippet | "| currentParent |"
|
snippets do: [ :snippet | "| currentParent |"
|
||||||
page addSnippet: snippet.
|
page addSnippet: snippet.
|
||||||
"currentParent := page detectParentSnippetWithUid: (snippet metadata at: 'parent').
|
"currentParent := page detectParentSnippetWithUid: (snippet metadata at: 'parent').
|
||||||
|
Loading…
Reference in New Issue
Block a user