From 093dce2946eff770e3fd91667fa63e873841f61d Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Thu, 27 Jan 2022 09:23:34 -0500 Subject: [PATCH] Adding custom metadata to the LePage options and improving Markdeep export. --- .../Grafoscopio-Utils/LePage.extension.st | 21 ++++++++++++++++-- .../LeTextualSnippet.extension.st | 11 ++++++---- .../Grafoscopio-Utils/Markdeep.class.st | 22 ++++++++++++++----- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/repository/Grafoscopio-Utils/LePage.extension.st b/repository/Grafoscopio-Utils/LePage.extension.st index 260d2de..646355e 100644 --- a/repository/Grafoscopio-Utils/LePage.extension.st +++ b/repository/Grafoscopio-Utils/LePage.extension.st @@ -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 +] diff --git a/repository/Grafoscopio-Utils/LeTextualSnippet.extension.st b/repository/Grafoscopio-Utils/LeTextualSnippet.extension.st index 7821bde..b201e4c 100644 --- a/repository/Grafoscopio-Utils/LeTextualSnippet.extension.st +++ b/repository/Grafoscopio-Utils/LeTextualSnippet.extension.st @@ -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: '
'; lf; + nextPutAll: '
'; 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' } @@ -32,7 +34,8 @@ LeTextualSnippet >> markdeepCustomOpener [ { #category : #'*Grafoscopio-Utils-Core' } LeTextualSnippet >> metadata [ ^ 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: 'edited' put: self latestEditTime asString; at: 'creator' put: self createEmail asString; diff --git a/repository/Grafoscopio-Utils/Markdeep.class.st b/repository/Grafoscopio-Utils/Markdeep.class.st index 7e67181..a07e283 100644 --- a/repository/Grafoscopio-Utils/Markdeep.class.st +++ b/repository/Grafoscopio-Utils/Markdeep.class.st @@ -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" - ^ ' -' + ^ '' ] { #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 }