Adding custom metadata to the LePage options and improving Markdeep export.
This commit is contained in:
parent
d5d052dc5a
commit
093dce2946
@ -26,7 +26,24 @@ LePage >> fileName [
|
||||
|
||||
{ #category : #'*Grafoscopio-Utils-Core' }
|
||||
LePage >> markdeepTemporalFile [
|
||||
| fileName |
|
||||
fileName := self title asDashedLowercase, '.',(self uidString copyFrom: 1 to: 5), '.md.html'.
|
||||
| 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 [
|
||||
^ 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: 'editor' put: self editEmail asString;
|
||||
yourself.
|
||||
]
|
||||
|
||||
{ #category : #'*Grafoscopio-Utils-Core' }
|
||||
LePage >> options [
|
||||
^ options
|
||||
]
|
||||
|
@ -2,11 +2,13 @@ Extension { #name : #LeTextualSnippet }
|
||||
|
||||
{ #category : #'*Grafoscopio-Utils-Core' }
|
||||
LeTextualSnippet >> asMarkdeep [
|
||||
"Inspired by Alpine.js and Assembler CSS 'x-' properties, we are going to use
|
||||
'st-' properties as a way to extend divs metadata regarding its contents."
|
||||
| output |
|
||||
output := '' writeStream.
|
||||
output
|
||||
nextPutAll: '<div x-class="', self class asString, '" '; lf;
|
||||
nextPutAll: 'x-data="', (STON toString: self metadata), '">'; lf;
|
||||
nextPutAll: '<div st-class="', self class asString, '"'; lf;
|
||||
nextPutAll: ' st-data="', (STON toString: self metadata), '">'; lf;
|
||||
nextPutAll: self markdeepCustomOpener;
|
||||
nextPutAll: self contentAsString; lf;
|
||||
nextPutAll: self markdeepCustomCloser;
|
||||
@ -16,7 +18,7 @@ LeTextualSnippet >> asMarkdeep [
|
||||
|
||||
{ #category : #'*Grafoscopio-Utils-Core' }
|
||||
LeTextualSnippet >> childrenIds [
|
||||
^ self children select: [ :each | each uidString ]
|
||||
^ self children collect: [ :each | each uidString ]
|
||||
]
|
||||
|
||||
{ #category : #'*Grafoscopio-Utils-Core' }
|
||||
@ -33,6 +35,7 @@ LeTextualSnippet >> markdeepCustomOpener [
|
||||
LeTextualSnippet >> 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;
|
||||
|
@ -88,7 +88,7 @@ Markdeep >> contents [
|
||||
| output |
|
||||
output := '' writeStream.
|
||||
output
|
||||
nextPutAll: self header; lf; lf;
|
||||
nextPutAll: self headerContents; lf; lf;
|
||||
nextPutAll: ' **', self title, '**'; lf; lf;
|
||||
nextPutAll: self body; lf; lf;
|
||||
nextPutAll: self tail; lf; lf; lf; lf;
|
||||
@ -106,6 +106,7 @@ Markdeep >> exportAsFile [
|
||||
|
||||
{ #category : #persistence }
|
||||
Markdeep >> exportAsFileOn: aFileReference [
|
||||
aFileReference ensureDelete.
|
||||
aFileReference exists ifFalse: [ aFileReference ensureCreateFile ].
|
||||
aFileReference writeStreamDo: [ :stream |
|
||||
stream nextPutAll: self contents ].
|
||||
@ -117,8 +118,7 @@ Markdeep >> exportAsFileOn: aFileReference [
|
||||
Markdeep >> fontAwesomeHeader [
|
||||
"I enable the font awesome support in the document header"
|
||||
|
||||
^ ' <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
'
|
||||
^ '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">'
|
||||
]
|
||||
|
||||
{ #category : #'instance creation' }
|
||||
@ -138,12 +138,22 @@ Markdeep >> gtTextFor: aView [
|
||||
|
||||
{ #category : #accessing }
|
||||
Markdeep >> header [
|
||||
^ self fontAwesomeHeader
|
||||
^ header ifNil: [header := OrderedCollection new.
|
||||
header add: self fontAwesomeHeader; yourself ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Markdeep >> header: anObject [
|
||||
header := anObject
|
||||
Markdeep >> header: anOrderedCollection [
|
||||
header := anOrderedCollection
|
||||
]
|
||||
|
||||
{ #category : #'instance creation' }
|
||||
Markdeep >> headerContents [
|
||||
| output |
|
||||
output := '' writeStream.
|
||||
self header do: [:line |
|
||||
output nextPutAll: line; lf ].
|
||||
^ output contents.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
Loading…
Reference in New Issue
Block a user