Minimal working example of nesting page contents importation.
This commit is contained in:
parent
55b304581c
commit
253a5df692
@ -2,14 +2,14 @@ Extension { #name : #LeDatabase }
|
||||
|
||||
{ #category : #'*MiniDocs' }
|
||||
LeDatabase >> addPage2FromMarkdeep: markdeepDocTree withRemote: externalDocLocation [
|
||||
| remoteMetadata divSnippets dataSnippets snippets page |
|
||||
| remoteMetadata divSnippets dataSnippets snippets newPage |
|
||||
divSnippets := (markdeepDocTree xpath: '//div[@st-class]') asOrderedCollection
|
||||
collect: [ :xmlElement | xmlElement postCopy ].
|
||||
remoteMetadata := Markdeep new metadataFromXML: markdeepDocTree.
|
||||
remoteMetadata at: 'origin' put: externalDocLocation.
|
||||
dataSnippets := self sanitizeMarkdeepSnippets: divSnippets withMetadata: remoteMetadata.
|
||||
snippets := dataSnippets collect: [ :each | each asLepiterSnippet ].
|
||||
page := LePage new
|
||||
newPage := LePage new
|
||||
title: (remoteMetadata at: 'title');
|
||||
basicUid: (UUID fromString36: (remoteMetadata at: 'id'));
|
||||
createTime: (LeTime new time: (remoteMetadata at: 'created') asDateAndTime);
|
||||
@ -17,8 +17,22 @@ LeDatabase >> addPage2FromMarkdeep: markdeepDocTree withRemote: externalDocLocat
|
||||
latestEditTime: (LeTime new time: (remoteMetadata at: 'modified') asDateAndTime);
|
||||
createEmail: (remoteMetadata at: 'creator');
|
||||
editEmail: (remoteMetadata at: 'modifier').
|
||||
^ { snippets . page }
|
||||
"snippets do: [ :snippet |
|
||||
"^ { snippets . page }"
|
||||
"Rebulding partial subtrees"
|
||||
snippets do: [:currentSnippet | |parentSnippet|
|
||||
parentSnippet := snippets
|
||||
detect: [:item | item uid asString = currentSnippet parent]
|
||||
ifNone: [ parentSnippet := 'unrooted' ].
|
||||
currentSnippet parent: parentSnippet.
|
||||
(parentSnippet class = ByteString)
|
||||
ifFalse: [ parentSnippet children addChild: currentSnippet ]
|
||||
].
|
||||
"Adding unrooted subtrees to the page"
|
||||
snippets
|
||||
select: [:each | each parent = 'unrooted']
|
||||
thenDo: [:unrooted | newPage addSnippet: unrooted ].
|
||||
"^ newPage"
|
||||
newPage childrenDo: [ :snippet |
|
||||
(self hasBlockUID: snippet uid)
|
||||
ifTrue: [ | existingPage |
|
||||
existingPage := self pages
|
||||
@ -27,8 +41,8 @@ LeDatabase >> addPage2FromMarkdeep: markdeepDocTree withRemote: externalDocLocat
|
||||
^ self ]
|
||||
ifFalse: [ snippet database: self.
|
||||
self registerSnippet: snippet ] ].
|
||||
self addPage: page.
|
||||
^ page"
|
||||
self addPage: newPage.
|
||||
^ newPage
|
||||
]
|
||||
|
||||
{ #category : #'*MiniDocs' }
|
||||
@ -86,7 +100,7 @@ LeDatabase >> addPageFromMarkdeepUrl: aString [
|
||||
ifNotNil: [ :arg |
|
||||
self importErrorForLocal: page withRemote: aString.
|
||||
^ self ].
|
||||
^ self addPage2FromMarkdeep: (self docTreeForLink: aString) withRemote: aString
|
||||
^ self addPageFromMarkdeep: (self docTreeForLink: aString) withRemote: aString
|
||||
]
|
||||
|
||||
{ #category : #'*MiniDocs' }
|
||||
|
Loading…
Reference in New Issue
Block a user