Fixing LePicture importing from Markdeep.
This commit is contained in:
parent
64b12c4aad
commit
0ff9bf1add
@ -101,11 +101,12 @@ LePage >> options [
|
|||||||
|
|
||||||
{ #category : #'*Grafoscopio-Utils-Core' }
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
||||||
LePage >> populateChildrenFrom: docTreeDivs [
|
LePage >> populateChildrenFrom: docTreeDivs [
|
||||||
docTreeDivs doWithIndex: [:div :i | | snippet |
|
docTreeDivs doWithIndex: [:div :i | | snippet parent |
|
||||||
snippet := LeSnippet fromMetaMarkdeep:div.
|
snippet := LeSnippet fromMetaMarkdeep:div.
|
||||||
self children
|
self children
|
||||||
addSnippet: snippet beforeIndex: i.
|
addSnippet: snippet beforeIndex: i.
|
||||||
"self detectSnippetWithUid: "
|
parent := self detectSnippetWithUid: (snippet metadata at: 'parent').
|
||||||
|
snippet parent: parent.
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -116,3 +117,8 @@ LePage >> preorderTraversal [
|
|||||||
self withDeepCollect: [:each | each allChildrenBreadthFirstDo: [:child | output add: child ] ].
|
self withDeepCollect: [:each | each allChildrenBreadthFirstDo: [:child | output add: child ] ].
|
||||||
^ output.
|
^ output.
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
||||||
|
LePage >> removeSnippetsMetadata [
|
||||||
|
self preorderTraversal do: [ :snippet | snippet options removeKey: 'metadata' ]
|
||||||
|
]
|
||||||
|
@ -33,14 +33,23 @@ LePictureSnippet >> contentFrom: markdeepDiv [
|
|||||||
self
|
self
|
||||||
optionAt: 'caption' put: caption;
|
optionAt: 'caption' put: caption;
|
||||||
optionAt: 'width' put: width.
|
optionAt: 'width' put: width.
|
||||||
^ self urlString: (markdeepDiv // 'img' @ 'src') stringValue.
|
self urlString: (markdeepDiv // 'img' @ 'src') stringValue.
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
||||||
|
LePictureSnippet >> metadata [
|
||||||
|
^ self optionAt: 'metadata' ifAbsentPut: [ self metadataInit ]
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'*Grafoscopio-Utils-Core' }
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
||||||
LePictureSnippet >> metadataInit [
|
LePictureSnippet >> metadataInit [
|
||||||
|
| surrogate |
|
||||||
|
self parent
|
||||||
|
ifNil: [ surrogate := nil]
|
||||||
|
ifNotNil: [ surrogate := self parent uidString ].
|
||||||
^ OrderedDictionary new
|
^ OrderedDictionary new
|
||||||
at: 'id' put: self uidString;
|
at: 'id' put: self uidString;
|
||||||
at: 'parent' put: self parent uidString;
|
at: 'parent' put: surrogate;
|
||||||
at: 'url' put: self contentAsString;
|
at: 'url' put: self contentAsString;
|
||||||
at: 'created' put: self createTime asString;
|
at: 'created' put: self createTime asString;
|
||||||
at: 'modified' put: self latestEditTime asString;
|
at: 'modified' put: self latestEditTime asString;
|
||||||
@ -48,8 +57,3 @@ LePictureSnippet >> metadataInit [
|
|||||||
at: 'modifier' put: self editEmail asString;
|
at: 'modifier' put: self editEmail asString;
|
||||||
yourself
|
yourself
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
||||||
LePictureSnippet >> metatada [
|
|
||||||
self optionAt: 'metadata' ifAbsent: [ self metadataInit ]
|
|
||||||
]
|
|
||||||
|
@ -8,20 +8,3 @@ LeTextSnippet >> contentFrom: markdeepDiv [
|
|||||||
sanitized := sanitized allButLast.
|
sanitized := sanitized allButLast.
|
||||||
self string: sanitized.
|
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: 'parent' put: self parent uid asString;
|
|
||||||
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
|
|
||||||
]
|
|
||||||
|
@ -30,3 +30,19 @@ LeTextualSnippet >> markdeepCustomCloser [
|
|||||||
LeTextualSnippet >> markdeepCustomOpener [
|
LeTextualSnippet >> markdeepCustomOpener [
|
||||||
^ ''
|
^ ''
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
||||||
|
LeTextualSnippet >> metadataInit [
|
||||||
|
| surrogate |
|
||||||
|
self parent
|
||||||
|
ifNil: [ surrogate := nil]
|
||||||
|
ifNotNil: [ surrogate := self parent uidString ].
|
||||||
|
^ OrderedDictionary new
|
||||||
|
at: 'id' put: self uidString;
|
||||||
|
at: 'parent' put: surrogate;
|
||||||
|
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
|
||||||
|
]
|
||||||
|
38
repository/Grafoscopio-Utils/MarkdeepTest.class.st
Normal file
38
repository/Grafoscopio-Utils/MarkdeepTest.class.st
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
Class {
|
||||||
|
#name : #MarkdeepTest,
|
||||||
|
#superclass : #TestCase,
|
||||||
|
#category : #'Grafoscopio-Utils-Tests'
|
||||||
|
}
|
||||||
|
|
||||||
|
{ #category : #tests }
|
||||||
|
MarkdeepTest >> markdeepTestingPictureSnippet [
|
||||||
|
^ (XMLHTMLParser on: '<div st-class="LePictureSnippet" st-data="OrderedDictionary{''id'':''77774yaTDQC8sESSDssMzQ=='',''parent'':''RBSKVeCRDQCTTfVoCYJWrg=='',''url'':''https://i.imgur.com/OD9P0vG.png'',''created'':''29 January 2022 11:32:19.996608 pm'',''modified'':''29 January 2022 11:32:23.781937 pm'',''creator'':''<unknown>'',''modifier'':''<unknown>''}">
|
||||||
|
<center>
|
||||||
|
<figure>
|
||||||
|
<img src="https://i.imgur.com/OD9P0vG.png" width="60%"/>
|
||||||
|
<figcaption>*Network view of the Malleable Systems TiddlyWiki*
|
||||||
|
</figcaption>
|
||||||
|
</figure>
|
||||||
|
</center>
|
||||||
|
</div>') parseDocument
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #tests }
|
||||||
|
MarkdeepTest >> testLePictureImport [
|
||||||
|
| metadata testSnippet |
|
||||||
|
metadata := STON fromString: (self markdeepTestingPictureSnippet xpath: 'st-class') stringValue.
|
||||||
|
testSnippet := LePictureSnippet new injectMetadataFrom: metadata.
|
||||||
|
self assert: (testSnippet metadata at: 'parent') isNotNil.
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #tests }
|
||||||
|
MarkdeepTest >> testMetadaIncludesParentId [
|
||||||
|
|
||||||
|
| aPage aSnippetOne aSnippetTwo |
|
||||||
|
aPage := LeUIExamples new database pageBuilder title: 'Test Page'; add.
|
||||||
|
aSnippetOne := aPage snippetBuilder string: 'Parent snippet'; add.
|
||||||
|
aSnippetTwo := aPage snippetBuilder string: 'Child Snippet'; add.
|
||||||
|
aSnippetTwo parent: aSnippetOne.
|
||||||
|
self assert: (aSnippetTwo metadata values includes: aSnippetOne uidString)
|
||||||
|
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user