diff --git a/repository/Brea/BreaWikiPage.class.st b/repository/Brea/BreaPage.class.st similarity index 79% rename from repository/Brea/BreaWikiPage.class.st rename to repository/Brea/BreaPage.class.st index fff59aa..fd9f959 100644 --- a/repository/Brea/BreaWikiPage.class.st +++ b/repository/Brea/BreaPage.class.st @@ -6,23 +6,23 @@ FossilRepo for that). I can be used for other types of publications, like blog post though. " Class { - #name : #BreaWikiPage, + #name : #BreaPage, #superclass : #Object, #instVars : [ 'shortName', 'template', 'templateData', - 'namespace', 'bodyTag', 'splitters', 'subpages', - 'metadata' + 'metadata', + 'folder' ], #category : #Brea } { #category : #operation } -BreaWikiPage >> bodyContentsAsHTML [ +BreaPage >> bodyContentsAsHTML [ | sourcePage | self markdownFile ifNil: [ ^ self ]. sourcePage := FileLocator temp / 'wikiPage.md'. @@ -31,12 +31,12 @@ BreaWikiPage >> bodyContentsAsHTML [ ] { #category : #accessing } -BreaWikiPage >> bodyTag [ +BreaPage >> bodyTag [ ^ bodyTag ] { #category : #accessing } -BreaWikiPage >> bodyTag: aString [ +BreaPage >> 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 @@ -48,14 +48,14 @@ BreaWikiPage >> bodyTag: aString [ ] { #category : #accessing } -BreaWikiPage >> contents [ +BreaPage >> contents [ | result | self markdownFile ifNil: [ ^ self ]. result := '' writeStream. result nextPutAll: self markdownFile contents. self subpages ifNotNil: [ self subpages do: [ :sp | | markdownTempFile | - markdownTempFile := self namespace / (sp, '.md'). + markdownTempFile := self folder / (sp, '.md'). result nextPutAll: (Markdown fromFile: markdownTempFile) contents. ] ]. @@ -63,7 +63,7 @@ BreaWikiPage >> contents [ ] { #category : #'as yet unclassified' } -BreaWikiPage >> exportAsHTML [ +BreaPage >> exportAsHTML [ | htmlContents allActions semaphore result | self shortName ifNil: [ ^ self ]. self template ifNil: [ ^ self ]. @@ -80,50 +80,50 @@ BreaWikiPage >> exportAsHTML [ ]. semaphore wait. htmlContents := (MustacheTemplate on: result templateFile contents) value: result templateData. - ^ MarkupFile exportAsFileOn: self namespace / (self shortName, '.html' ) containing: htmlContents + ^ MarkupFile exportAsFileOn: self folder / (self shortName, '.html' ) containing: htmlContents +] + +{ #category : #accessing } +BreaPage >> folder [ + ^ folder +] + +{ #category : #accessing } +BreaPage >> folder: folderFileReference [ + folder := folderFileReference ] { #category : #'as yet unclassified' } -BreaWikiPage >> htmlContents [ +BreaPage >> htmlContents [ self shortName ifNil: [ ^ self ]. self template ifNil: [ ^ self ]. ^ (MustacheTemplate on: self templateFile contents) value: self templateData. ] { #category : #operation } -BreaWikiPage >> markdownFile [ +BreaPage >> markdownFile [ | localFile | - self namespace ifNil: [ ^ self ]. + self folder ifNil: [ ^ self ]. self shortName ifNil: [ ^ self ]. - localFile := self namespace / (self shortName, '.md'). + localFile := self folder / (self shortName, '.md'). localFile exists ifFalse: [ ^ self ]. ^ Markdown fromFile: localFile ] { #category : #accessing } -BreaWikiPage >> metadata [ +BreaPage >> metadata [ ^ metadata ] { #category : #accessing } -BreaWikiPage >> metadata: aDictionary [ +BreaPage >> metadata: aDictionary [ "External place where page metadata is located (on Internet or the local file system) in JSON format. If nil, is suposed that is placed in the Markdown file with the page contents." metadata := aDictionary ] -{ #category : #accessing } -BreaWikiPage >> namespace [ - ^ namespace -] - -{ #category : #accessing } -BreaWikiPage >> namespace: folderFileReference [ - namespace := folderFileReference -] - { #category : #'as yet unclassified' } -BreaWikiPage >> populateBodyAs: key [ +BreaPage >> populateBodyAs: key [ | allActions result semaphore | allActions := TKTFuture all: { [ self bodyContentsAsHTML ] future. @@ -138,13 +138,13 @@ BreaWikiPage >> populateBodyAs: key [ ] { #category : #'as yet unclassified' } -BreaWikiPage >> populateExternalMetadata [ +BreaPage >> populateExternalMetadata [ self metadata ifNil: [ ^ self ]. self ] { #category : #operation } -BreaWikiPage >> populateMetadata [ +BreaPage >> populateMetadata [ | metadataTemp | self metadata ifNotNil: [ metadataTemp := self metadata ] @@ -155,24 +155,24 @@ BreaWikiPage >> populateMetadata [ ] { #category : #accessing } -BreaWikiPage >> shortName [ +BreaPage >> shortName [ ^ shortName ] { #category : #accessing } -BreaWikiPage >> shortName: aString [ +BreaPage >> shortName: aString [ "The name of the file tha contains the light markup to produce the web page, without file extension. By default I work with Markdown files." shortName := aString ] { #category : #'as yet unclassified' } -BreaWikiPage >> split [ +BreaPage >> split [ self splitters keysAndValuesDo: [ :key :value | self split: key with: value ]. ] { #category : #'as yet unclassified' } -BreaWikiPage >> split: key with: subkey [ +BreaPage >> split: key with: subkey [ "I split a comma separated collection of subkeys stored in the 'key' field and name each one as 'subkey' to put it indiviudally in a Mustache template." | allSubkeys cleaned data | @@ -185,58 +185,58 @@ BreaWikiPage >> split: key with: subkey [ ] { #category : #'as yet unclassified' } -BreaWikiPage >> splitterAt: key with: subkey [ +BreaPage >> splitterAt: key with: subkey [ self splitters at: key put: subkey ] { #category : #accessing } -BreaWikiPage >> splitters [ +BreaPage >> splitters [ ^ splitters ifNil: [ splitters := Dictionary new ] ] { #category : #accessing } -BreaWikiPage >> splitters: aDictionary [ +BreaPage >> splitters: aDictionary [ "I model the pattern where a Mustache template contains something like {{# key}} {{value}} {{/ key}} and has data that needs to be split before injecting it in the template." splitters := aDictionary ] { #category : #accessing } -BreaWikiPage >> subpages [ +BreaPage >> subpages [ ^ subpages ] { #category : #accessing } -BreaWikiPage >> subpages: shortNamesList [ +BreaPage >> subpages: shortNamesList [ "I am used when a page is composed of other subpages (for example with link aliases) that are shared accross several pages." subpages := shortNamesList ] { #category : #accessing } -BreaWikiPage >> template [ +BreaPage >> template [ ^ template ] { #category : #accessing } -BreaWikiPage >> template: mustacheFileName [ +BreaPage >> template: mustacheFileName [ "Usually templates and their pages are located in the same folder." template := mustacheFileName ] { #category : #accessing } -BreaWikiPage >> templateData [ +BreaPage >> templateData [ ^ templateData ifNil: [ templateData := Dictionary new ] ] { #category : #accessing } -BreaWikiPage >> templateData: aDictionary [ +BreaPage >> templateData: aDictionary [ templateData := aDictionary ] { #category : #'as yet unclassified' } -BreaWikiPage >> templateFile [ - self namespace ifNil: [ ^ self ]. +BreaPage >> templateFile [ + self folder ifNil: [ ^ self ]. self template ifNil: [ ^ self ]. - ^ self namespace / self template + ^ self folder / self template ] diff --git a/repository/Brea/ManifestBrea.class.st b/repository/Brea/ManifestBrea.class.st index 87df9eb..85146e9 100644 --- a/repository/Brea/ManifestBrea.class.st +++ b/repository/Brea/ManifestBrea.class.st @@ -9,5 +9,5 @@ Class { { #category : #'code-critics' } ManifestBrea class >> ruleRBStringConcatenationRuleV1FalsePositive [ - ^ #(#(#(#RGMethodDefinition #(#BreaWikiPage #contents #false)) #'2020-08-28T20:08:20.291489-05:00') ) + ^ #(#(#(#RGMethodDefinition #(#BreaPage #contents #false)) #'2020-08-28T20:08:20.291489-05:00') ) ]