75 lines
1.9 KiB
Smalltalk
75 lines
1.9 KiB
Smalltalk
Extension { #name : #LePage }
|
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
LePage >> asMarkdeep [
|
|
| bodyStream markdeep |
|
|
bodyStream := '' writeStream.
|
|
self preorderTraversal do: [:snippet |
|
|
bodyStream nextPutAll: snippet asMarkdeep
|
|
].
|
|
markdeep := Markdeep new
|
|
title: self title;
|
|
body: bodyStream contents.
|
|
self metadata keysAndValuesDo: [:k :v |
|
|
markdeep header
|
|
add: '<meta name="', k, '" content="', v,'">';
|
|
yourself.
|
|
].
|
|
^ markdeep.
|
|
]
|
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
LePage >> asMarkdeepInto: aFileLocator [
|
|
|
|
self preorderTraversal
|
|
]
|
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
LePage >> fileName [
|
|
^ self title asDashedLowercase, '.', ((self uidString copyFrom: 1 to: 5 ) copyWithoutAll: '/'), '.md.html'
|
|
]
|
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
LePage >> markdeepPreview [
|
|
^ self asMarkdeep exportAsFileOn: self markdeepTemporalFile
|
|
]
|
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
LePage >> markdeepTemporalFile [
|
|
| fileName sanitized |
|
|
sanitized := self title asDashedLowercase copyWithoutAll: #($/).
|
|
fileName := sanitized, '--',(self uidString copyFrom: 1 to: 5), '.md.html'.
|
|
^ FileLocator temp / fileName.
|
|
]
|
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
LePage >> metadata [
|
|
|
|
^ self options at: 'metadata' ifAbsentPut: [ self metadataInit]
|
|
]
|
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
LePage >> metadataInit [
|
|
|
|
^ OrderedDictionary new
|
|
at: 'id' put: self uidString;
|
|
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' }
|
|
LePage >> options [
|
|
^ options
|
|
]
|
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
LePage >> preorderTraversal [
|
|
| output |
|
|
output := OrderedCollection new.
|
|
self withDeepCollect: [:each | each allChildrenBreadthFirstDo: [:child | output add: child ] ].
|
|
^ output.
|
|
]
|