2022-01-22 15:23:56 +00:00
|
|
|
Extension { #name : #LePage }
|
|
|
|
|
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
|
|
LePage >> asMarkdeep [
|
2022-01-28 22:01:41 +00:00
|
|
|
| bodyStream markdeep |
|
2022-01-22 15:23:56 +00:00
|
|
|
bodyStream := '' writeStream.
|
|
|
|
self preorderTraversal do: [:snippet |
|
2022-01-24 01:38:07 +00:00
|
|
|
bodyStream nextPutAll: snippet asMarkdeep
|
2022-01-22 15:23:56 +00:00
|
|
|
].
|
2022-01-28 22:01:41 +00:00
|
|
|
markdeep := Markdeep new
|
2022-01-24 01:38:07 +00:00
|
|
|
title: self title;
|
2022-01-28 22:01:41 +00:00
|
|
|
body: bodyStream contents.
|
|
|
|
self metadata keysAndValuesDo: [:k :v |
|
2022-01-31 01:09:17 +00:00
|
|
|
markdeep head
|
2022-01-28 22:01:41 +00:00
|
|
|
add: '<meta name="', k, '" content="', v,'">';
|
|
|
|
yourself.
|
|
|
|
].
|
2022-01-29 03:34:33 +00:00
|
|
|
self metadata at: 'authors' ifPresent: [:author | markdeep metadata at: 'authors' put: author ].
|
|
|
|
self metadata at: 'version' ifPresent: [:version | markdeep metadata at: 'version' put: version ].
|
2022-01-28 22:01:41 +00:00
|
|
|
^ markdeep.
|
2022-01-22 15:23:56 +00:00
|
|
|
]
|
|
|
|
|
2022-01-30 18:57:25 +00:00
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
|
|
LePage >> asMarkdeepFile [
|
|
|
|
| folder |
|
|
|
|
folder := self options at: 'storage' ifAbsent: [ FileLocator temp ].
|
|
|
|
^ self asMarkdeep exportAsFileOn: folder / self markdeepFileName
|
|
|
|
]
|
|
|
|
|
2022-01-22 15:23:56 +00:00
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
|
|
LePage >> asMarkdeepInto: aFileLocator [
|
|
|
|
|
|
|
|
self preorderTraversal
|
|
|
|
]
|
2022-01-24 01:38:07 +00:00
|
|
|
|
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
|
|
LePage >> fileName [
|
|
|
|
^ self title asDashedLowercase, '.', ((self uidString copyFrom: 1 to: 5 ) copyWithoutAll: '/'), '.md.html'
|
|
|
|
]
|
|
|
|
|
2022-01-31 01:09:17 +00:00
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
2022-01-31 02:54:16 +00:00
|
|
|
LePage >> fromMarkdeepUrl: aString [
|
|
|
|
|
|
|
|
| markdeepHelper id remoteMetadata |
|
|
|
|
markdeepHelper := Markdeep new.
|
|
|
|
remoteMetadata := markdeepHelper metadataFromXML: (self xmlFromUrl: aString).
|
|
|
|
id := remoteMetadata at: 'id' ifAbsent: [ ^ false ].
|
|
|
|
|
|
|
|
]
|
|
|
|
|
2022-01-28 19:30:56 +00:00
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
2022-01-30 18:57:25 +00:00
|
|
|
LePage >> markdeepFileName [
|
|
|
|
| sanitized |
|
|
|
|
sanitized := self title asDashedLowercase copyWithoutAll: #($/).
|
|
|
|
^ sanitized, '--',(self uidString copyFrom: 1 to: 5), '.md.html'.
|
2022-01-28 19:30:56 +00:00
|
|
|
]
|
|
|
|
|
2022-01-24 01:38:07 +00:00
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
|
|
LePage >> markdeepTemporalFile [
|
2022-01-30 18:57:25 +00:00
|
|
|
|
|
|
|
^ FileLocator temp / self markdeepFileName.
|
2022-01-24 01:38:07 +00:00
|
|
|
]
|
2022-01-27 14:23:34 +00:00
|
|
|
|
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
|
|
LePage >> metadata [
|
2022-01-28 22:01:41 +00:00
|
|
|
|
|
|
|
^ self options at: 'metadata' ifAbsentPut: [ self metadataInit]
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
|
|
LePage >> metadataInit [
|
|
|
|
|
2022-01-27 14:23:34 +00:00
|
|
|
^ OrderedDictionary new
|
2022-01-28 22:01:41 +00:00
|
|
|
at: 'id' put: self uidString;
|
2022-01-29 03:34:33 +00:00
|
|
|
at: 'title' put: self contentAsString;
|
2022-01-28 22:01:41 +00:00
|
|
|
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
|
2022-01-27 14:23:34 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
|
|
LePage >> options [
|
|
|
|
^ options
|
|
|
|
]
|
2022-01-28 20:33:05 +00:00
|
|
|
|
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
|
|
LePage >> preorderTraversal [
|
|
|
|
| output |
|
|
|
|
output := OrderedCollection new.
|
|
|
|
self withDeepCollect: [:each | each allChildrenBreadthFirstDo: [:child | output add: child ] ].
|
|
|
|
^ output.
|
|
|
|
]
|