Document tree metadata now from current state of the snippet.
This commit is contained in:
parent
5c4f6ab55b
commit
372c6a6a55
@ -2,41 +2,20 @@ Extension { #name : #LeDatabase }
|
|||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
LeDatabase >> addPage2FromMarkdeep: markdeepDocTree withRemote: externalDocLocation [
|
LeDatabase >> addPage2FromMarkdeep: markdeepDocTree withRemote: externalDocLocation [
|
||||||
| remoteMetadata divSnippets dataSnippets snippets newPage |
|
| 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 ].
|
|
||||||
newPage := 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 . page }"
|
||||||
"Rebulding partial subtrees"
|
"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"
|
"Adding unrooted subtrees to the page"
|
||||||
snippets
|
|
||||||
select: [:each | each parent = 'unrooted']
|
|
||||||
thenDo: [:unrooted | newPage addSnippet: unrooted ].
|
|
||||||
"^ newPage"
|
"^ newPage"
|
||||||
newPage childrenDo: [ :snippet |
|
newPage := self
|
||||||
(self hasBlockUID: snippet uid)
|
rebuildPageFromMarkdeep: markdeepDocTree
|
||||||
ifTrue: [ | existingPage |
|
withRemote: externalDocLocation.
|
||||||
existingPage := self pages
|
newPage
|
||||||
detect: [ :pageTemp | pageTemp includesSnippetUid: snippet uid ].
|
childrenDo: [ :snippet |
|
||||||
|
(self hasBlockUID: snippet uid)
|
||||||
|
ifTrue: [ | existingPage |
|
||||||
|
existingPage := self pages
|
||||||
|
detect: [ :pageTemp | pageTemp includesSnippetUid: snippet uid ].
|
||||||
self importErrorForLocal: existingPage withRemote: externalDocLocation.
|
self importErrorForLocal: existingPage withRemote: externalDocLocation.
|
||||||
^ self ]
|
^ self ]
|
||||||
ifFalse: [ snippet database: self.
|
ifFalse: [ snippet database: self.
|
||||||
@ -250,6 +229,41 @@ LeDatabase >> previewSanitizedPageFromMarkdeep: markdeepDocTree withRemote: exte
|
|||||||
^ { divSnippets . divSnippetsSanitized . remoteMetadata }
|
^ { divSnippets . divSnippetsSanitized . remoteMetadata }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #'*MiniDocs' }
|
||||||
|
LeDatabase >> rebuildPageFromMarkdeep: markdeepDocTree withRemote: externalDocLocation [
|
||||||
|
| newPage snippets divSnippets remoteMetadata dataSnippets |
|
||||||
|
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 ].
|
||||||
|
newPage := 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 }" "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"
|
||||||
|
"^ { unrooted . newPage }."
|
||||||
|
snippets
|
||||||
|
select: [ :each | each parent = 'unrooted' ]
|
||||||
|
thenDo: [ :unrooted | newPage addSnippet: unrooted ].
|
||||||
|
^ newPage
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
LeDatabase >> sanitizeMarkdeepSnippets: divSnippets withMetadata: remoteMetadata [
|
LeDatabase >> sanitizeMarkdeepSnippets: divSnippets withMetadata: remoteMetadata [
|
||||||
^ divSnippets collectWithIndex: [:markdeepDiv :i | | snippetData creationTime modificationTime timestampWarning |
|
^ divSnippets collectWithIndex: [:markdeepDiv :i | | snippetData creationTime modificationTime timestampWarning |
|
||||||
|
@ -148,11 +148,11 @@ LePage >> markdownFileName [
|
|||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
LePage >> metadata [
|
LePage >> metadata [
|
||||||
|
|
||||||
^ self options at: 'metadata' ifAbsentPut: [ self metadataInit]
|
^ self options at: 'metadata' ifAbsentPut: [ self metadataUpdate]
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
LePage >> metadataInit [
|
LePage >> metadataUpdate [
|
||||||
|
|
||||||
^ OrderedDictionary new
|
^ OrderedDictionary new
|
||||||
at: 'id' put: self uidString;
|
at: 'id' put: self uidString;
|
||||||
|
@ -47,7 +47,7 @@ LePictureSnippet >> fromString: aString [
|
|||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
LePictureSnippet >> metadata [
|
LePictureSnippet >> metadata [
|
||||||
^ self optionAt: 'metadata' ifAbsentPut: [ self metadataInit ]
|
^ self optionAt: 'metadata' ifAbsentPut: [ self metadataUpdate ]
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
@ -64,7 +64,7 @@ LePictureSnippet >> metadataDiv [
|
|||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
LePictureSnippet >> metadataInit [
|
LePictureSnippet >> metadataUpdate [
|
||||||
| surrogate |
|
| surrogate |
|
||||||
self parent
|
self parent
|
||||||
ifNil: [ surrogate := nil]
|
ifNil: [ surrogate := nil]
|
||||||
|
@ -21,20 +21,22 @@ LeTextSnippet >> fromMarkdeep: markdeepDiv [
|
|||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
LeTextSnippet >> metadata [
|
LeTextSnippet >> metadata [
|
||||||
|
|
||||||
^ self optionAt: 'metadata' ifAbsentPut: [ self metadataInit ]
|
^ self metadataUpdate
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
LeTextSnippet >> metadataInit [
|
LeTextSnippet >> metadataUpdate [
|
||||||
|
| createEmailSanitized editEmailSanitized |
|
||||||
|
createEmailSanitized := self createEmail asString withoutXMLTagDelimiters.
|
||||||
|
editEmailSanitized := self editEmail asString withoutXMLTagDelimiters.
|
||||||
^ OrderedDictionary new
|
^ OrderedDictionary new
|
||||||
at: 'id' put: self uidString;
|
at: 'id' put: self uidString;
|
||||||
at: 'parent' put: self parentId;
|
at: 'parent' put: self parentId;
|
||||||
at: 'created' put: self createTime asString;
|
at: 'created' put: self createTime asString;
|
||||||
at: 'modified' put: self latestEditTime asString;
|
at: 'modified' put: self latestEditTime asString;
|
||||||
at: 'creator' put: self createEmail asString;
|
at: 'creator' put: createEmailSanitized;
|
||||||
at: 'modifier' put: self editEmail asString;
|
at: 'modifier' put: editEmailSanitized;
|
||||||
yourself
|
yourself
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -66,11 +66,11 @@ LeTextualSnippet >> markdownCustomOpener [
|
|||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
LeTextualSnippet >> metadata [
|
LeTextualSnippet >> metadata [
|
||||||
|
|
||||||
^ self optionAt: 'metadata' ifAbsentPut: [ self metadataInit ]
|
^ self optionAt: 'metadata' ifAbsentPut: [ self metadataUpdate ]
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
LeTextualSnippet >> metadataInit [
|
LeTextualSnippet >> metadataUpdate [
|
||||||
| surrogate |
|
| surrogate |
|
||||||
self parent
|
self parent
|
||||||
ifNil: [ surrogate := nil]
|
ifNil: [ surrogate := nil]
|
||||||
|
@ -16,7 +16,7 @@ LeYoutubeReferenceSnippet >> asMarkdeep [
|
|||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
LeYoutubeReferenceSnippet >> metadata [
|
LeYoutubeReferenceSnippet >> metadata [
|
||||||
^ self optionAt: 'metadata' ifAbsentPut: [ self metadataInit ]
|
^ self optionAt: 'metadata' ifAbsentPut: [ self metadataUpdate ]
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
@ -31,7 +31,7 @@ LeYoutubeReferenceSnippet >> metadataDiv [
|
|||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
LeYoutubeReferenceSnippet >> metadataInit [
|
LeYoutubeReferenceSnippet >> metadataUpdate [
|
||||||
| surrogate |
|
| surrogate |
|
||||||
self parent
|
self parent
|
||||||
ifNil: [ surrogate := nil]
|
ifNil: [ surrogate := nil]
|
||||||
|
Loading…
Reference in New Issue
Block a user