Nested pages content importation.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2023-10-26 12:42:32 -05:00
parent 92a686de96
commit 55b304581c
2 changed files with 33 additions and 2 deletions

View File

@ -1,5 +1,36 @@
Extension { #name : #LeDatabase } Extension { #name : #LeDatabase }
{ #category : #'*MiniDocs' }
LeDatabase >> addPage2FromMarkdeep: markdeepDocTree withRemote: externalDocLocation [
| remoteMetadata divSnippets dataSnippets snippets page |
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
title: (remoteMetadata at: 'title');
basicUid: (UUID fromString36: (remoteMetadata at: 'id'));
createTime: (LeTime new time: (remoteMetadata at: 'created') asDateAndTime);
editTime: (LeTime new time: (remoteMetadata at: 'modified') asDateAndTime);
latestEditTime: (LeTime new time: (remoteMetadata at: 'modified') asDateAndTime);
createEmail: (remoteMetadata at: 'creator');
editEmail: (remoteMetadata at: 'modifier').
^ { snippets . page }
"snippets do: [ :snippet |
(self hasBlockUID: snippet uid)
ifTrue: [ | existingPage |
existingPage := self pages
detect: [ :pageTemp | pageTemp includesSnippetUid: snippet uid ].
self importErrorForLocal: existingPage withRemote: externalDocLocation.
^ self ]
ifFalse: [ snippet database: self.
self registerSnippet: snippet ] ].
self addPage: page.
^ page"
]
{ #category : #'*MiniDocs' } { #category : #'*MiniDocs' }
LeDatabase >> addPageCopy: aLePage [ LeDatabase >> addPageCopy: aLePage [
| pageTitle timestamp shortID page | | pageTitle timestamp shortID page |
@ -55,7 +86,7 @@ LeDatabase >> addPageFromMarkdeepUrl: aString [
ifNotNil: [ :arg | ifNotNil: [ :arg |
self importErrorForLocal: page withRemote: aString. self importErrorForLocal: page withRemote: aString.
^ self ]. ^ self ].
^ self addPageFromMarkdeep: (self docTreeForLink: aString) withRemote: aString ^ self addPage2FromMarkdeep: (self docTreeForLink: aString) withRemote: aString
] ]
{ #category : #'*MiniDocs' } { #category : #'*MiniDocs' }

View File

@ -92,7 +92,7 @@ LePage >> detectParentSnippetWithUid: uidString [
{ #category : #'*MiniDocs' } { #category : #'*MiniDocs' }
LePage >> exportedFileName [ LePage >> exportedFileName [
| sanitized | | sanitized |
sanitized := self title asDashedLowercase romanizeAccents copyWithoutAll: #($/ $:). sanitized := self title asDashedLowercase romanizeAccents copyWithoutAll: #($/ $: $🢒).
^ sanitized , '--' , (self uidString copyFrom: 1 to: 5) ^ sanitized , '--' , (self uidString copyFrom: 1 to: 5)
] ]