External page metadata and subpages support.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2020-08-28 20:25:35 -05:00
parent 60c94d23e5
commit bdd1813efb
2 changed files with 71 additions and 6 deletions

View File

@ -14,7 +14,9 @@ Class {
'templateData',
'namespace',
'bodyTag',
'splitters'
'splitters',
'subpages',
'metadata'
],
#category : #Brea
}
@ -24,7 +26,7 @@ BreaWikiPage >> bodyContentsAsHTML [
| 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

View File

@ -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') )
]