From 1a6c46840a23d2c0ac559df508f6c97960651a9d Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Mon, 27 Jul 2020 21:00:53 -0500 Subject: [PATCH] Resync after some image de-synchronization. --- repository/Brea/BreaWikiPage.class.st | 76 +++++++++++++++++++++------ 1 file changed, 61 insertions(+), 15 deletions(-) diff --git a/repository/Brea/BreaWikiPage.class.st b/repository/Brea/BreaWikiPage.class.st index 2e6471e..94c36ed 100644 --- a/repository/Brea/BreaWikiPage.class.st +++ b/repository/Brea/BreaWikiPage.class.st @@ -8,7 +8,8 @@ Class { 'shortName', 'template', 'templateData', - 'namespace' + 'namespace', + 'bodyTag' ], #category : #Brea } @@ -22,6 +23,50 @@ BreaWikiPage >> bodyContentsAsHTML [ ^ Pandoc markdownToHtml: sourcePage ] +{ #category : #accessing } +BreaWikiPage >> bodyTag [ + ^ bodyTag +] + +{ #category : #accessing } +BreaWikiPage >> bodyTag: aString [ + "I represent the Mustache Template tag used to denote the body part of a page. + While the metadata is self describing via YAML metadata blocks in Markddown, so + they map where ever they are needed in a template, the Markdown file that will be converted + in HTML via a template doesn't know which part should occupy once the conversion is done. + I provide such knowledge. So if a page template puts the body content under the mustache tag + {{content}}, I should use bodyTag: 'content'. + bodyTag: is template dependant." + bodyTag := aString +] + +{ #category : #'as yet unclassified' } +BreaWikiPage >> exportAsHTML [ + | htmlContents allActions semaphore result | + self shortName ifNil: [ ^ self ]. + self template ifNil: [ ^ self ]. + self bodyTag ifNil: [ ^ self ]. + allActions := TKTFuture all: { + [ self populateMetadata ] future. + [ self populateBodyAs: self bodyTag ] future. + }. + semaphore := Semaphore new. + allActions onSuccessDo: [ :values | + result := values last. + semaphore signal. + ]. + semaphore wait. + htmlContents := (MustacheTemplate on: result templateFile contents) value: result templateData. + ^ MarkupFile exportAsFileOn: self namespace / (self shortName, '.html' ) containing: htmlContents +] + +{ #category : #'as yet unclassified' } +BreaWikiPage >> htmlContents [ + self shortName ifNil: [ ^ self ]. + self template ifNil: [ ^ self ]. + ^ (MustacheTemplate on: self templateFile contents) value: self templateData. +] + { #category : #operation } BreaWikiPage >> markdownFile [ | localFile | @@ -42,25 +87,19 @@ 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 result semaphore | allActions := TKTFuture all: { - [self bodyContentsAsHTML] future. - [ self templateData at: key put: FileLocator temp / 'wikiPage.html' contents ] future + [ self bodyContentsAsHTML ] future. }. + semaphore := Semaphore new. allActions onSuccessDo: [ :values | - result := values ]. - ^ result. - - + result := values last. + semaphore signal ]. + semaphore wait. + self templateData at: key put: result contents. + ^ self. ] { #category : #operation } @@ -101,3 +140,10 @@ BreaWikiPage >> templateData [ BreaWikiPage >> templateData: aDictionary [ templateData := aDictionary ] + +{ #category : #'as yet unclassified' } +BreaWikiPage >> templateFile [ + self namespace ifNil: [ ^ self ]. + self template ifNil: [ ^ self ]. + ^ self namespace / self template +]