From bdd1813efb8d97faea2d139c4cff42eca9439b00 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Fri, 28 Aug 2020 20:25:35 -0500 Subject: [PATCH] External page metadata and subpages support. --- repository/Brea/BreaWikiPage.class.st | 64 ++++++++++++++++++++++++--- repository/Brea/ManifestBrea.class.st | 13 ++++++ 2 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 repository/Brea/ManifestBrea.class.st diff --git a/repository/Brea/BreaWikiPage.class.st b/repository/Brea/BreaWikiPage.class.st index bfda608..fff59aa 100644 --- a/repository/Brea/BreaWikiPage.class.st +++ b/repository/Brea/BreaWikiPage.class.st @@ -14,17 +14,19 @@ Class { 'templateData', 'namespace', 'bodyTag', - 'splitters' + 'splitters', + 'subpages', + 'metadata' ], #category : #Brea } { #category : #operation } BreaWikiPage >> bodyContentsAsHTML [ - | sourcePage | + | sourcePage | self markdownFile ifNil: [ ^ self ]. sourcePage := FileLocator temp / 'wikiPage.md'. - MarkupFile exportAsFileOn: sourcePage containing: self markdownFile contents. + MarkupFile exportAsFileOn: sourcePage containing: self contents. ^ Pandoc markdownToHtml: sourcePage ] @@ -45,6 +47,21 @@ BreaWikiPage >> bodyTag: aString [ bodyTag := aString ] +{ #category : #accessing } +BreaWikiPage >> 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'). + result nextPutAll: (Markdown fromFile: markdownTempFile) contents. + ] + ]. + ^ result contents. +] + { #category : #'as yet unclassified' } BreaWikiPage >> exportAsHTML [ | htmlContents allActions semaphore result | @@ -83,6 +100,18 @@ BreaWikiPage >> markdownFile [ ^ Markdown fromFile: localFile ] +{ #category : #accessing } +BreaWikiPage >> metadata [ + ^ metadata +] + +{ #category : #accessing } +BreaWikiPage >> 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 @@ -108,11 +137,20 @@ BreaWikiPage >> populateBodyAs: key [ ^ self. ] +{ #category : #'as yet unclassified' } +BreaWikiPage >> populateExternalMetadata [ + self metadata ifNil: [ ^ self ]. + self +] + { #category : #operation } BreaWikiPage >> populateMetadata [ - self markdownFile metadata keysAndValuesDo: [ :key :value | - self templateData at: key put: value - ]. + | metadataTemp | + self metadata + ifNotNil: [ metadataTemp := self metadata ] + ifNil: [ metadataTemp := self markdownFile metadata]. + metadataTemp keysAndValuesDo: [ :key :value | + self templateData at: key put: value ]. ^ templateData ] @@ -123,6 +161,8 @@ BreaWikiPage >> shortName [ { #category : #accessing } BreaWikiPage >> 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 ] @@ -161,6 +201,18 @@ BreaWikiPage >> splitters: aDictionary [ splitters := aDictionary ] +{ #category : #accessing } +BreaWikiPage >> subpages [ + ^ subpages +] + +{ #category : #accessing } +BreaWikiPage >> 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 [ ^ template diff --git a/repository/Brea/ManifestBrea.class.st b/repository/Brea/ManifestBrea.class.st new file mode 100644 index 0000000..87df9eb --- /dev/null +++ b/repository/Brea/ManifestBrea.class.st @@ -0,0 +1,13 @@ +" +I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser +" +Class { + #name : #ManifestBrea, + #superclass : #PackageManifest, + #category : #'Brea-Manifest' +} + +{ #category : #'code-critics' } +ManifestBrea class >> ruleRBStringConcatenationRuleV1FalsePositive [ + ^ #(#(#(#RGMethodDefinition #(#BreaWikiPage #contents #false)) #'2020-08-28T20:08:20.291489-05:00') ) +]