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
|
||||
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').
|
||||
|
Loading…
Reference in New Issue
Block a user