diff --git a/repository/Grafoscopio-Utils/LePage.extension.st b/repository/Grafoscopio-Utils/LePage.extension.st index 910eba8..5c433ca 100644 --- a/repository/Grafoscopio-Utils/LePage.extension.st +++ b/repository/Grafoscopio-Utils/LePage.extension.st @@ -9,7 +9,8 @@ LePage >> asMarkdeep [ ]. markdeep := Markdeep new title: self title; - body: bodyStream contents. + body: bodyStream contents; + navTop: self navTop. self metadata keysAndValuesDo: [:k :v | markdeep head add: ''; @@ -62,13 +63,6 @@ LePage >> fromMarkdeepUrl: aString [ ] -{ #category : #'*Grafoscopio-Utils-Core' } -LePage >> markdeepFileName [ - | sanitized | - sanitized := self title asDashedLowercase copyWithoutAll: #($/). - ^ sanitized, '--',(self uidString copyFrom: 1 to: 5), '.md.html'. -] - { #category : #'*Grafoscopio-Utils-Core' } LePage >> metadata [ @@ -88,6 +82,15 @@ LePage >> metadataInit [ yourself ] +{ #category : #'*Grafoscopio-Utils-Core' } +LePage >> navTop [ + | topNavFile | + topNavFile := ((self optionAt: 'storage') / '_navtop.html'). + topNavFile exists + ifFalse: [ ^ '' ] + ifTrue: [ ^ topNavFile contents ] +] + { #category : #'*Grafoscopio-Utils-Core' } LePage >> options [ ^ options diff --git a/repository/Grafoscopio-Utils/LeSnippet.extension.st b/repository/Grafoscopio-Utils/LeSnippet.extension.st deleted file mode 100644 index 544393d..0000000 --- a/repository/Grafoscopio-Utils/LeSnippet.extension.st +++ /dev/null @@ -1,12 +0,0 @@ -Extension { #name : #LeSnippet } - -{ #category : #'*Grafoscopio-Utils-Core' } -LeSnippet class >> fromMetaMarkdeep: div [ - | className metadata snippet | - className := (div xpath: '@st-class') stringValue. - metadata := STON fromString:(div xpath: '@st-data') stringValue. - snippet := className asClass new. - snippet injectMetadataFrom: metadata. - snippet contentFrom: div. - ^ snippet. -] diff --git a/repository/Grafoscopio-Utils/LeTextualSnippet.extension.st b/repository/Grafoscopio-Utils/LeTextualSnippet.extension.st index 53452e8..04b31c5 100644 --- a/repository/Grafoscopio-Utils/LeTextualSnippet.extension.st +++ b/repository/Grafoscopio-Utils/LeTextualSnippet.extension.st @@ -21,16 +21,6 @@ LeTextualSnippet >> childrenIds [ ^ self children collect: [ :each | each uidString ] ] -{ #category : #'*Grafoscopio-Utils-Core' } -LeTextualSnippet >> markdeepCustomCloser [ - ^ '' -] - -{ #category : #'*Grafoscopio-Utils-Core' } -LeTextualSnippet >> markdeepCustomOpener [ - ^ '' -] - { #category : #'*Grafoscopio-Utils-Core' } LeTextualSnippet >> metadata [ diff --git a/repository/Grafoscopio-Utils/Markdeep.class.st b/repository/Grafoscopio-Utils/Markdeep.class.st deleted file mode 100644 index 2fc2684..0000000 --- a/repository/Grafoscopio-Utils/Markdeep.class.st +++ /dev/null @@ -1,285 +0,0 @@ -" -I model a Mardeep file as described in https://casual-effects.com/markdeep/ -" -Class { - #name : #Markdeep, - #superclass : #Object, - #instVars : [ - 'title', - 'body', - 'tocStyle', - 'comments', - 'tail', - 'language', - 'config', - 'metadata', - 'head' - ], - #category : #'Grafoscopio-Utils-Core' -} - -{ #category : #'as yet unclassified' } -Markdeep class >> fromMarkdownFile: aFileReference [ - ^ self new fromMarkdownFile: aFileReference. -] - -{ #category : #'instance creation' } -Markdeep >> authors [ - self metadata at: 'authors' ifPresent: [:k | ^ '**', k, '**' ]. - ^ ''. -] - -{ #category : #accessing } -Markdeep >> body [ - ^ body -] - -{ #category : #accessing } -Markdeep >> body: anObject [ - body := anObject -] - -{ #category : #accessing } -Markdeep >> comments [ - ^ comments ifNil: [ ^ comments := true ] -] - -{ #category : #accessing } -Markdeep >> comments: aBoolean [ - "I tell if comments are enabled by default or not." - comments := aBoolean -] - -{ #category : #utilities } -Markdeep >> commentsProvider [ - "I return the url of the default service that provides annotation support. - I am used to add such support in the contents of the Markdeep page." - ^ 'https://hypothes.is' -] - -{ #category : #utilities } -Markdeep >> commentsProviderStrings [ - "I associate a comments service provider with the string that is required to be added - to the document to enable such provider." - | providers | - providers := Dictionary new. - providers at: 'https://hypothes.is' put: ' -'. - ^ providers - - -] - -{ #category : #utilities } -Markdeep >> commentsSupport [ - "I enable comments of the page." - - self comments ifFalse: [ ^ self ]. - ^ self commentsProviderStrings at: self commentsProvider -] - -{ #category : #accessing } -Markdeep >> config [ - - ^ config -] - -{ #category : #accessing } -Markdeep >> config: aDictionary [ - - config := aDictionary -] - -{ #category : #'instance creation' } -Markdeep >> contents [ - | output | - output := '' writeStream. - output - nextPutAll: self headContents; lf; lf; - nextPutAll: ' **', self title, '**'; lf; - nextPutAll: ' ', self authors ; lf; - nextPutAll: ' ', self version; lf; lf; - nextPutAll: self body; lf; lf; - nextPutAll: self tail; lf; lf; lf; lf; - nextPutAll: self commentsSupport. - ^ output contents. -] - -{ #category : #persistence } -Markdeep >> exportAsFile [ - | newFile | - self markdownFile ifNil: [ self inform: 'Define an input Markdown file or use #exportAsFileOn: instead.' ]. - newFile := (self markdownFile fullName, '.html') asFileReference. - self exportAsFileOn: newFile. -] - -{ #category : #persistence } -Markdeep >> exportAsFileOn: aFileReference [ - aFileReference ensureDelete. - aFileReference exists ifFalse: [ aFileReference ensureCreateFile ]. - aFileReference writeStreamDo: [ :stream | - stream nextPutAll: self contents ]. - self inform: 'Exported as: ', String cr, aFileReference fullName. - ^ aFileReference -] - -{ #category : #utilities } -Markdeep >> fontAwesomeHeader [ - "I enable the font awesome support in the document header" - - ^ '' -] - -{ #category : #'instance creation' } -Markdeep >> fromMarkdownFile: aFileReference [ - "I create a Markdeep document from a given Markdown file." - self processMarkdownFor: aFileReference. - ^ self. -] - -{ #category : #accessing } -Markdeep >> gtTextFor: aView [ - - ^ aView textEditor - title: 'Text'; - text: [ self contents ] -] - -{ #category : #accessing } -Markdeep >> head [ - ^ head ifNil: [ head := OrderedCollection new. - head add: self fontAwesomeHeader; yourself ] -] - -{ #category : #accessing } -Markdeep >> head: anOrderedCollection [ - head := anOrderedCollection -] - -{ #category : #'instance creation' } -Markdeep >> headContents [ - - ^ String streamContents: [ :stream | - stream - nextPutAll: ''; - nextPut: Character lf. - self head do: [ :line | - stream - nextPutAll: ' '; - nextPutAll: line; - nextPut: Character lf - ]. - stream - nextPutAll: ''; - nextPut: Character lf. - ]. -] - -{ #category : #accessing } -Markdeep >> language [ - ^ language -] - -{ #category : #accessing } -Markdeep >> language: anObject [ - language := anObject -] - -{ #category : #accessing } -Markdeep >> markdeepScriptTag [ - ^ ' -' -] - -{ #category : #accessing } -Markdeep >> markdownFile [ - ^ self config at: 'markdownFile' -] - -{ #category : #accessing } -Markdeep >> markdownFile: aFileReference [ - "Where the Mardown file associated with me is stored. Used for sync. and import/export purposes." - self config at: 'markdownFile' put: aFileReference -] - -{ #category : #'instance creation' } -Markdeep >> metadata [ - ^ metadata ifNil: [ metadata := OrderedDictionary new ] -] - -{ #category : #utilities } -Markdeep >> metadataFromXML: aXMLDocument [ - | metaDict | - - metaDict := OrderedDictionary new. - (aXMLDocument xpath: '//meta') do: [ :each | - metaDict at: (each @ 'name') stringValue put: (each @ 'content') stringValue ]. - ^ metaDict -] - -{ #category : #printing } -Markdeep >> printOn: aStream [ - - super printOn: aStream. - aStream - nextPutAll: '( ', self title, ' )' -] - -{ #category : #'instance creation' } -Markdeep >> processMarkdownFor: aFileReference [ - "comment stating purpose of message" - | markdownContent | - self markdownFile: aFileReference. - markdownContent := Markdown fromFile: aFileReference. - self body: (markdownContent commentYAMLMetadata contents). -] - -{ #category : #accessing } -Markdeep >> tail [ - "I enable the document tail, which, in turn, enables a Markdeep document" - | output | - output := '' writeStream. - output - nextPutAll: ''; lf; lf; - nextPutAll: ''; lf; - nextPutAll: ''; lf; - nextPutAll: self markdeepScriptTag; lf; - nextPutAll: ''. - ^ output contents -] - -{ #category : #accessing } -Markdeep >> tail: anObject [ - tail := anObject -] - -{ #category : #accessing } -Markdeep >> title [ - - ^ title -] - -{ #category : #accessing } -Markdeep >> title: anObject [ - - title := anObject -] - -{ #category : #accessing } -Markdeep >> tocStyle [ - ^ tocStyle ifNil: [ tocStyle := 'short' ] -] - -{ #category : #accessing } -Markdeep >> tocStyle: anObject [ - tocStyle := anObject -] - -{ #category : #'instance creation' } -Markdeep >> version [ - self metadata at: 'version' ifPresent: [:value | ^ 'v',value ]. - ^ '' -] diff --git a/repository/Grafoscopio-Utils/MarkdeepTest.class.st b/repository/Grafoscopio-Utils/MarkdeepTest.class.st index 21a731f..29aa834 100644 --- a/repository/Grafoscopio-Utils/MarkdeepTest.class.st +++ b/repository/Grafoscopio-Utils/MarkdeepTest.class.st @@ -19,10 +19,10 @@ MarkdeepTest >> markdeepTestingPictureSnippet [ { #category : #tests } MarkdeepTest >> testLePictureImport [ - | metadata testSnippet | - metadata := STON fromString: (self markdeepTestingPictureSnippet xpath: 'st-class') stringValue. - testSnippet := LePictureSnippet new injectMetadataFrom: metadata. - self assert: (testSnippet metadata at: 'parent') isNotNil. + | metadata | + metadata := STON fromString: (self markdeepTestingPictureSnippet xpath: '@st-data') stringValue. + self assert: + (LePictureSnippet new injectMetadataFrom: metadata) ] { #category : #tests }