Adding custom metadata to the LePage options and improving Markdeep export.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-01-27 09:23:34 -05:00
parent d5d052dc5a
commit 093dce2946
3 changed files with 42 additions and 12 deletions

View File

@ -26,7 +26,24 @@ LePage >> fileName [
{ #category : #'*Grafoscopio-Utils-Core' } { #category : #'*Grafoscopio-Utils-Core' }
LePage >> markdeepTemporalFile [ LePage >> markdeepTemporalFile [
| fileName | | fileName sanitized |
fileName := self title asDashedLowercase, '.',(self uidString copyFrom: 1 to: 5), '.md.html'. sanitized := self title asDashedLowercase copyWithoutAll: #($/).
fileName := sanitized, '--',(self uidString copyFrom: 1 to: 5), '.md.html'.
^ FileLocator temp / fileName. ^ 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
]

View File

@ -2,11 +2,13 @@ Extension { #name : #LeTextualSnippet }
{ #category : #'*Grafoscopio-Utils-Core' } { #category : #'*Grafoscopio-Utils-Core' }
LeTextualSnippet >> asMarkdeep [ 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 |
output := '' writeStream. output := '' writeStream.
output output
nextPutAll: '<div x-class="', self class asString, '" '; lf; nextPutAll: '<div st-class="', self class asString, '"'; lf;
nextPutAll: 'x-data="', (STON toString: self metadata), '">'; lf; nextPutAll: ' st-data="', (STON toString: self metadata), '">'; lf;
nextPutAll: self markdeepCustomOpener; nextPutAll: self markdeepCustomOpener;
nextPutAll: self contentAsString; lf; nextPutAll: self contentAsString; lf;
nextPutAll: self markdeepCustomCloser; nextPutAll: self markdeepCustomCloser;
@ -16,7 +18,7 @@ LeTextualSnippet >> asMarkdeep [
{ #category : #'*Grafoscopio-Utils-Core' } { #category : #'*Grafoscopio-Utils-Core' }
LeTextualSnippet >> childrenIds [ LeTextualSnippet >> childrenIds [
^ self children select: [ :each | each uidString ] ^ self children collect: [ :each | each uidString ]
] ]
{ #category : #'*Grafoscopio-Utils-Core' } { #category : #'*Grafoscopio-Utils-Core' }
@ -33,6 +35,7 @@ LeTextualSnippet >> markdeepCustomOpener [
LeTextualSnippet >> metadata [ LeTextualSnippet >> metadata [
^ OrderedDictionary new ^ OrderedDictionary new
at: 'id' put: self uidString; at: 'id' put: self uidString;
at: 'parent' put: self parent uidString;
at: 'created' put: self createTime asString; at: 'created' put: self createTime asString;
at: 'edited' put: self latestEditTime asString; at: 'edited' put: self latestEditTime asString;
at: 'creator' put: self createEmail asString; at: 'creator' put: self createEmail asString;

View File

@ -88,7 +88,7 @@ Markdeep >> contents [
| output | | output |
output := '' writeStream. output := '' writeStream.
output output
nextPutAll: self header; lf; lf; nextPutAll: self headerContents; lf; lf;
nextPutAll: ' **', self title, '**'; lf; lf; nextPutAll: ' **', self title, '**'; lf; lf;
nextPutAll: self body; lf; lf; nextPutAll: self body; lf; lf;
nextPutAll: self tail; lf; lf; lf; lf; nextPutAll: self tail; lf; lf; lf; lf;
@ -106,6 +106,7 @@ Markdeep >> exportAsFile [
{ #category : #persistence } { #category : #persistence }
Markdeep >> exportAsFileOn: aFileReference [ Markdeep >> exportAsFileOn: aFileReference [
aFileReference ensureDelete.
aFileReference exists ifFalse: [ aFileReference ensureCreateFile ]. aFileReference exists ifFalse: [ aFileReference ensureCreateFile ].
aFileReference writeStreamDo: [ :stream | aFileReference writeStreamDo: [ :stream |
stream nextPutAll: self contents ]. stream nextPutAll: self contents ].
@ -117,8 +118,7 @@ Markdeep >> exportAsFileOn: aFileReference [
Markdeep >> fontAwesomeHeader [ Markdeep >> fontAwesomeHeader [
"I enable the font awesome support in the document header" "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' } { #category : #'instance creation' }
@ -138,12 +138,22 @@ Markdeep >> gtTextFor: aView [
{ #category : #accessing } { #category : #accessing }
Markdeep >> header [ Markdeep >> header [
^ self fontAwesomeHeader ^ header ifNil: [header := OrderedCollection new.
header add: self fontAwesomeHeader; yourself ]
] ]
{ #category : #accessing } { #category : #accessing }
Markdeep >> header: anObject [ Markdeep >> header: anOrderedCollection [
header := anObject header := anOrderedCollection
]
{ #category : #'instance creation' }
Markdeep >> headerContents [
| output |
output := '' writeStream.
self header do: [:line |
output nextPutAll: line; lf ].
^ output contents.
] ]
{ #category : #accessing } { #category : #accessing }