diff --git a/repository/Grafoscopio-Utils/LeModel.extension.st b/repository/Grafoscopio-Utils/LeModel.extension.st index 410098f..82c09de 100644 --- a/repository/Grafoscopio-Utils/LeModel.extension.st +++ b/repository/Grafoscopio-Utils/LeModel.extension.st @@ -2,14 +2,7 @@ Extension { #name : #LeModel } { #category : #'*Grafoscopio-Utils-Core' } LeModel >> metadata [ - ^ OrderedDictionary new - at: 'id' put: self uidString; - at: 'parent' put: self parent uidString; - at: 'created' put: self createTime asString; - at: 'edited' put: self latestEditTime asString; - at: 'creator' put: self createEmail asString; - at: 'editor' put: self editEmail asString; - yourself. + ^ self optionAt: 'metadata' ifAbsent: [ self optionAt: 'metadata' put: self metadataInit ] ] @@ -22,3 +15,15 @@ LeModel >> metadataDiv [ nextPutAll: ' st-data="', (STON toString: self metadata), '">'; lf. ^ output contents. ] + +{ #category : #'*Grafoscopio-Utils-Core' } +LeModel >> metadataInit [ + ^ OrderedDictionary new + at: 'id' put: self uidString; + at: 'title' put: self contentAsString; + at: 'created' put: self createTime asString; + at: 'modified' put: self latestEditTime asString; + at: 'creator' put: self createEmail asString; + at: 'modifier' put: self editEmail asString; + yourself +] diff --git a/repository/Grafoscopio-Utils/LePage.extension.st b/repository/Grafoscopio-Utils/LePage.extension.st index 2e5b3ce..f97b517 100644 --- a/repository/Grafoscopio-Utils/LePage.extension.st +++ b/repository/Grafoscopio-Utils/LePage.extension.st @@ -33,6 +33,13 @@ LePage >> asMarkdeepInto: aFileLocator [ self preorderTraversal ] +{ #category : #'*Grafoscopio-Utils-Core' } +LePage >> detectSnippetWithUid: uidString [ + "Answer a boolean indicating whether the supplied uid is present" + + ^ self preorderTraversal detect: [ :snippet | snippet uidString = uidString ] ifNone: [ ^ nil ] +] + { #category : #'*Grafoscopio-Utils-Core' } LePage >> fileName [ ^ self title asDashedLowercase, '.', ((self uidString copyFrom: 1 to: 5 ) copyWithoutAll: '/'), '.md.html' @@ -94,9 +101,11 @@ LePage >> options [ { #category : #'*Grafoscopio-Utils-Core' } LePage >> populateChildrenFrom: docTreeDivs [ - docTreeDivs doWithIndex: [:div :i | + docTreeDivs doWithIndex: [:div :i | | snippet | + snippet := LeSnippet fromMetaMarkdeep:div. self children - addSnippet: (LeSnippet fromMetaMarkdeep:div) beforeIndex: i + addSnippet: snippet beforeIndex: i. + "self detectSnippetWithUid: " ] ] diff --git a/repository/Grafoscopio-Utils/LePictureSnippet.extension.st b/repository/Grafoscopio-Utils/LePictureSnippet.extension.st index c157c20..1ac6079 100644 --- a/repository/Grafoscopio-Utils/LePictureSnippet.extension.st +++ b/repository/Grafoscopio-Utils/LePictureSnippet.extension.st @@ -35,3 +35,21 @@ LePictureSnippet >> contentFrom: markdeepDiv [ optionAt: 'width' put: width. ^ self urlString: (markdeepDiv // 'img' @ 'src') stringValue. ] + +{ #category : #'*Grafoscopio-Utils-Core' } +LePictureSnippet >> metadataInit [ + ^ OrderedDictionary new + at: 'id' put: self uidString; + at: 'parent' put: self parent uidString; + at: 'url' put: self contentAsString; + at: 'created' put: self createTime asString; + at: 'modified' put: self latestEditTime asString; + at: 'creator' put: self createEmail asString; + at: 'modifier' put: self editEmail asString; + yourself +] + +{ #category : #'*Grafoscopio-Utils-Core' } +LePictureSnippet >> metatada [ + self optionAt: 'metadata' ifAbsent: [ self metadataInit ] +] diff --git a/repository/Grafoscopio-Utils/LeTextSnippet.extension.st b/repository/Grafoscopio-Utils/LeTextSnippet.extension.st index 538fe3f..59de0ac 100644 --- a/repository/Grafoscopio-Utils/LeTextSnippet.extension.st +++ b/repository/Grafoscopio-Utils/LeTextSnippet.extension.st @@ -8,3 +8,20 @@ LeTextSnippet >> contentFrom: markdeepDiv [ sanitized := sanitized allButLast. self string: sanitized. ] + +{ #category : #'*Grafoscopio-Utils-Core' } +LeTextSnippet >> metadata [ + ^ self optionAt: 'metadata' ifAbsentPut: [ self metadataInit ] +] + +{ #category : #'*Grafoscopio-Utils-Core' } +LeTextSnippet >> metadataInit [ + ^ OrderedDictionary new + at: 'id' put: self uidString; + at: 'title' put: self contentAsString; + at: 'created' put: self createTime asString; + at: 'modified' put: self latestEditTime asString; + at: 'creator' put: self createEmail asString; + at: 'modifier' put: self editEmail asString; + yourself +]