BreaWikiPage added.
This commit is contained in:
parent
f5c76ca62f
commit
6a87402fef
103
repository/Brea/BreaWikiPage.class.st
Normal file
103
repository/Brea/BreaWikiPage.class.st
Normal file
@ -0,0 +1,103 @@
|
||||
"
|
||||
I model a wiki page of a Brea site.
|
||||
"
|
||||
Class {
|
||||
#name : #BreaWikiPage,
|
||||
#superclass : #Object,
|
||||
#instVars : [
|
||||
'shortName',
|
||||
'template',
|
||||
'templateData',
|
||||
'namespace'
|
||||
],
|
||||
#category : #Brea
|
||||
}
|
||||
|
||||
{ #category : #operation }
|
||||
BreaWikiPage >> bodyContentsAsHTML [
|
||||
| sourcePage |
|
||||
self markdownFile ifNil: [ ^ self ].
|
||||
sourcePage := FileLocator temp / 'wikiPage.md'.
|
||||
MarkupFile exportAsFileOn: sourcePage containing: self markdownFile contents.
|
||||
^ Pandoc markdownToHtml: sourcePage
|
||||
]
|
||||
|
||||
{ #category : #operation }
|
||||
BreaWikiPage >> markdownFile [
|
||||
| localFile |
|
||||
self namespace ifNil: [ ^ self ].
|
||||
self shortName ifNil: [ ^ self ].
|
||||
localFile := self namespace / (self shortName, '.md').
|
||||
localFile exists ifFalse: [ ^ self ].
|
||||
^ Markdown fromFile: localFile
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaWikiPage >> namespace [
|
||||
^ namespace
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaWikiPage >> namespace: folderFileReference [
|
||||
namespace := folderFileReference
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
BreaWikiPage >> populateBodyAs2: key [
|
||||
|
||||
[self bodyContentsAsHTML] future
|
||||
andThen: [:result | self templateData at: key put: result contents]
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
BreaWikiPage >> populateBodyAs: key [
|
||||
| allActions result |
|
||||
allActions := TKTFuture all: {
|
||||
[self bodyContentsAsHTML] future.
|
||||
[ self templateData at: key put: FileLocator temp / 'wikiPage.html' contents ]
|
||||
}.
|
||||
allActions onSuccessDo: [ :values |
|
||||
result := values ].
|
||||
^ result.
|
||||
|
||||
|
||||
]
|
||||
|
||||
{ #category : #operation }
|
||||
BreaWikiPage >> populateMetadata [
|
||||
self markdownFile metadata keysAndValuesDo: [ :key :value |
|
||||
self templateData at: key put: value
|
||||
].
|
||||
^ templateData
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaWikiPage >> shortName [
|
||||
^ shortName
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaWikiPage >> shortName: aString [
|
||||
shortName := aString
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaWikiPage >> template [
|
||||
^ template
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaWikiPage >> template: mustacheFileName [
|
||||
"Usually templates and their pages are located in the same folder."
|
||||
template := mustacheFileName
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaWikiPage >> templateData [
|
||||
^ templateData ifNil: [ templateData := Dictionary new ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
BreaWikiPage >> templateData: aDictionary [
|
||||
templateData := aDictionary
|
||||
]
|
Loading…
Reference in New Issue
Block a user