Improving Markdeep exportation.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-01-30 13:57:25 -05:00
parent c5f71e8230
commit abbafcf4e5
4 changed files with 63 additions and 18 deletions

View File

@ -0,0 +1,24 @@
Extension { #name : #LeModel }
{ #category : #'*Grafoscopio-Utils-Core' }
LeModel >> 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;
at: 'editor' put: self editEmail asString;
yourself.
]
{ #category : #'*Grafoscopio-Utils-Core' }
LeModel >> metadataDiv [
| output |
output := '' writeStream.
output
nextPutAll: '<div st-class="', self class asString, '"'; lf;
nextPutAll: ' st-data="', (STON toString: self metadata), '">'; lf.
^ output contents.
]

View File

@ -20,6 +20,13 @@ LePage >> asMarkdeep [
^ markdeep. ^ markdeep.
] ]
{ #category : #'*Grafoscopio-Utils-Core' }
LePage >> asMarkdeepFile [
| folder |
folder := self options at: 'storage' ifAbsent: [ FileLocator temp ].
^ self asMarkdeep exportAsFileOn: folder / self markdeepFileName
]
{ #category : #'*Grafoscopio-Utils-Core' } { #category : #'*Grafoscopio-Utils-Core' }
LePage >> asMarkdeepInto: aFileLocator [ LePage >> asMarkdeepInto: aFileLocator [
@ -32,16 +39,16 @@ LePage >> fileName [
] ]
{ #category : #'*Grafoscopio-Utils-Core' } { #category : #'*Grafoscopio-Utils-Core' }
LePage >> markdeepPreview [ LePage >> markdeepFileName [
^ self asMarkdeep exportAsFileOn: self markdeepTemporalFile | sanitized |
sanitized := self title asDashedLowercase copyWithoutAll: #($/).
^ sanitized, '--',(self uidString copyFrom: 1 to: 5), '.md.html'.
] ]
{ #category : #'*Grafoscopio-Utils-Core' } { #category : #'*Grafoscopio-Utils-Core' }
LePage >> markdeepTemporalFile [ LePage >> markdeepTemporalFile [
| fileName sanitized |
sanitized := self title asDashedLowercase copyWithoutAll: #($/). ^ FileLocator temp / self markdeepFileName.
fileName := sanitized, '--',(self uidString copyFrom: 1 to: 5), '.md.html'.
^ FileLocator temp / fileName.
] ]
{ #category : #'*Grafoscopio-Utils-Core' } { #category : #'*Grafoscopio-Utils-Core' }

View File

@ -0,0 +1,26 @@
Extension { #name : #LePictureSnippet }
{ #category : #'*Grafoscopio-Utils-Core' }
LePictureSnippet >> asMarkdeep [
| output |
output := '' writeStream.
output
nextPutAll: self metadataDiv;
nextPutAll: self centeredFigure; lf;
nextPutAll: '</div>'; lf; lf.
^ output contents
]
{ #category : #'*Grafoscopio-Utils-Core' }
LePictureSnippet >> centeredFigure [
^ '<center>
<figure>
<img src="' , self urlString , '"
width="' , (self optionAt: 'width' ifAbsent: [ '75%' ]) , '"
/>
<figcaption>*' , (self optionAt: 'caption' ifAbsent: [ '' ]) , '*
</figcaption>
</figure>
</center>'
]

View File

@ -30,15 +30,3 @@ LeTextualSnippet >> markdeepCustomCloser [
LeTextualSnippet >> markdeepCustomOpener [ LeTextualSnippet >> markdeepCustomOpener [
^ '' ^ ''
] ]
{ #category : #'*Grafoscopio-Utils-Core' }
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;
at: 'editor' put: self editEmail asString;
yourself.
]