From c1b4ec220910173a71b2b6f49345c09592e10f29 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Sun, 29 Aug 2021 17:50:17 -0500 Subject: [PATCH] Adding fields to support GeoTiddlers and custom data. --- repository/TiddlyWiki/FedWikiItem.class.st | 14 +-- repository/TiddlyWiki/FedWikiPage.class.st | 34 +++--- repository/TiddlyWiki/Tiddler.class.st | 114 ++++++++++++------ repository/TiddlyWiki/TiddlyWiki.class.st | 24 ++-- repository/TiddlyWiki/WikiText.class.st | 18 +-- .../TiddlyWiki/WikiTextGrammar.class.st | 20 +-- .../TiddlyWiki/WikiTextGrammarTest.class.st | 12 +- repository/TiddlyWiki/package.st | 2 +- 8 files changed, 137 insertions(+), 101 deletions(-) diff --git a/repository/TiddlyWiki/FedWikiItem.class.st b/repository/TiddlyWiki/FedWikiItem.class.st index b4ce69c..33fd548 100644 --- a/repository/TiddlyWiki/FedWikiItem.class.st +++ b/repository/TiddlyWiki/FedWikiItem.class.st @@ -1,34 +1,34 @@ Class { - #name : #FedWikiItem, - #superclass : #Object, + #name : 'FedWikiItem', + #superclass : 'Object', #instVars : [ 'text', 'id', 'type' ], - #category : #'TiddlyWiki-Model' + #category : 'TiddlyWiki-Model' } -{ #category : #accessing } +{ #category : 'accessing' } FedWikiItem >> fromDictionary: aDictionary [ text := aDictionary at: 'text'. id := aDictionary at: 'id'. type := aDictionary at: 'type'. ] -{ #category : #accessing } +{ #category : 'accessing' } FedWikiItem >> printOn: aStream [ super printOn: aStream. aStream nextPutAll: '( ',self type, ' | ', self text, ' )' ] -{ #category : #accessing } +{ #category : 'accessing' } FedWikiItem >> text [ ^ text ] -{ #category : #accessing } +{ #category : 'accessing' } FedWikiItem >> type [ ^ type ] diff --git a/repository/TiddlyWiki/FedWikiPage.class.st b/repository/TiddlyWiki/FedWikiPage.class.st index b884a92..630450d 100644 --- a/repository/TiddlyWiki/FedWikiPage.class.st +++ b/repository/TiddlyWiki/FedWikiPage.class.st @@ -1,6 +1,6 @@ Class { - #name : #FedWikiPage, - #superclass : #Object, + #name : 'FedWikiPage', + #superclass : 'Object', #instVars : [ 'url', 'title', @@ -8,10 +8,10 @@ Class { 'journal', 'importJournal' ], - #category : #'TiddlyWiki-Model' + #category : 'TiddlyWiki-Model' } -{ #category : #accessing } +{ #category : 'accessing' } FedWikiPage >> dataDictionary [ | dataUrl | self isView ifFalse: [ @@ -21,34 +21,34 @@ FedWikiPage >> dataDictionary [ ^ STONJSON fromString: dataUrl asUrl retrieveContents ] -{ #category : #accessing } +{ #category : 'accessing' } FedWikiPage >> fromDataDictionary [ title := self dataDictionary at: 'title'. story := self dataDictionary at: 'story'. self importJournal ifTrue: [ journal := self dataDictionary at: 'journal']. ] -{ #category : #accessing } +{ #category : 'accessing' } FedWikiPage >> host [ ^ self url host ] -{ #category : #accessing } +{ #category : 'accessing' } FedWikiPage >> importJournal [ ^ importJournal ifNil: [ importJournal := false ] ] -{ #category : #accessing } +{ #category : 'accessing' } FedWikiPage >> importJournal: aBoolean [ importJournal := aBoolean ] -{ #category : #accessing } +{ #category : 'accessing' } FedWikiPage >> isView [ ^ self url firstPathSegment = 'view' ] -{ #category : #accessing } +{ #category : 'accessing' } FedWikiPage >> jsonData [ | dataUrl | self isView ifFalse: [ @@ -57,29 +57,29 @@ FedWikiPage >> jsonData [ dataUrl := self scheme , '://', self host, self titleSegmentUrl, '.json' ] -{ #category : #accessing } +{ #category : 'accessing' } FedWikiPage >> printOn: aStream [ super printOn: aStream. aStream nextPutAll: '( ', self title, ' | ', self story size asString, ' items story )' ] -{ #category : #accessing } +{ #category : 'accessing' } FedWikiPage >> scheme [ ^ self url scheme ] -{ #category : #accessing } +{ #category : 'accessing' } FedWikiPage >> story [ ^ story ] -{ #category : #accessing } +{ #category : 'accessing' } FedWikiPage >> title [ ^ title. ] -{ #category : #accessing } +{ #category : 'accessing' } FedWikiPage >> titleSegmentUrl [ self isView ifFalse: [ self inform: 'Please provide a view url for the FedWiki page.'. @@ -87,12 +87,12 @@ FedWikiPage >> titleSegmentUrl [ ^ self url segments last. ] -{ #category : #accessing } +{ #category : 'accessing' } FedWikiPage >> url [ ^ url ] -{ #category : #accessing } +{ #category : 'accessing' } FedWikiPage >> url: aString [ url := aString asZnUrl ] diff --git a/repository/TiddlyWiki/Tiddler.class.st b/repository/TiddlyWiki/Tiddler.class.st index 6acd68d..94682aa 100644 --- a/repository/TiddlyWiki/Tiddler.class.st +++ b/repository/TiddlyWiki/Tiddler.class.st @@ -5,8 +5,8 @@ I implement the standard fields as described in the standard documentation at: < " Class { - #name : #Tiddler, - #superclass : #Object, + #name : 'Tiddler', + #superclass : 'Object', #instVars : [ 'title', 'text', @@ -18,18 +18,21 @@ Class { 'list', 'caption', 'modifier', - 'wiki' + 'wiki', + 'customFields', + 'bag', + 'revision' ], - #category : #'TiddlyWiki-Model' + #category : 'TiddlyWiki-Model' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } Tiddler class >> nowLocal [ ^ (ZTimestampFormat fromString: '200102031605067') format: (ZTimestamp fromString: Time nowLocal asDateAndTime asString) ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> asDictionary [ ^ Dictionary new at: 'title' put: self title; @@ -40,55 +43,71 @@ Tiddler >> asDictionary [ yourself. ] -{ #category : #converting } +{ #category : 'converting' } Tiddler >> asJson [ ^ STONJSON toStringPretty: self asDictionary ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> asJsonTempFile [ ^ MarkupFile exportAsFileOn: FileLocator temp / self title, 'json' containing:self asJson ] -{ #category : #accessing } +{ #category : 'accessing' } +Tiddler >> bag [ + ^ bag +] + +{ #category : 'accessing' } +Tiddler >> bag: aString [ + bag := aString +] + +{ #category : 'accessing' } Tiddler >> caption [ ^ caption ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> caption: anObject [ caption := anObject ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> created [ ^ created ifNil: [ created := DateAndTime now ] ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> created: anObject [ created := anObject ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> creator [ ^ creator ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> creator: anObject [ creator := anObject ] -{ #category : #accessing } +{ #category : 'accessing' } +Tiddler >> customFields [ + ^ customFields ifNil: [ customFields := Dictionary new] +] + +{ #category : 'accessing' } Tiddler >> fromDictionary: aDictionary [ + | customKeys | self title: (aDictionary at: 'title'); text: (aDictionary at: 'text'); @@ -99,9 +118,16 @@ Tiddler >> fromDictionary: aDictionary [ modifier: (aDictionary at: 'modifier' ifAbsentPut: [ nil ]); type: (aDictionary at: 'type' ifAbsentPut: [ nil ]); caption: (aDictionary at: 'caption' ifAbsentPut: [ nil ]). + self + bag: (aDictionary at: 'bag'); + revision: (aDictionary at: 'revision' ifAbsentPut: [ nil ]). + customKeys := aDictionary keys copyWithoutAll: (self class instanceVariables collect: [ :each | each name ]). + customKeys ifEmpty: [ ^ self ]. + customKeys do: [:key | + self customFields at: key put: (aDictionary at: key) ]. ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } Tiddler >> fromMarkdownParsedItems: aCollection [ | outputStream | outputStream := '' writeStream. @@ -114,7 +140,7 @@ Tiddler >> fromMarkdownParsedItems: aCollection [ ] ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> importFedWikiPage: pageViewUrlString [ | pageTitle pageViewUrl pageData | pageViewUrl := pageViewUrlString asZnUrl. @@ -123,7 +149,7 @@ Tiddler >> importFedWikiPage: pageViewUrlString [ ^ STONJSON fromString: pageData retrieveContents ] -{ #category : #utilities } +{ #category : 'utilities' } Tiddler >> itemContentsStringFor: item into: stream [ stream nextPutAll: item text; @@ -131,7 +157,7 @@ Tiddler >> itemContentsStringFor: item into: stream [ nextPut: Character cr ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> linkedTiddlers [ "At the begining we are going to introduce 'pureTiddlers' as thos included in the wiki which are not linked via aliases. Future versions of this method sould included internal aliased tiddlers." @@ -140,19 +166,19 @@ Tiddler >> linkedTiddlers [ ^ self wiki tiddlers select: [:tiddler | pureTiddlersTitles includes: tiddler title ]. ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> list [ ^ list ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> list: anObject [ list := anObject ] -{ #category : #utilities } +{ #category : 'utilities' } Tiddler >> markdownLinksAsWikiText [ "I'm useful to convert _internal_ links between formats, as is a common pattern found when migrating content from Markdown to TiddlyWiki's WikiText. @@ -166,101 +192,111 @@ Tiddler >> markdownLinksAsWikiText [ ^ markdownLinks ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> modified [ ^ modified ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> modified: anObject [ modified := anObject ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> modifier [ ^ modifier ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> modifier: anObject [ modifier := anObject ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> printOn: aStream [ super printOn: aStream. aStream nextPutAll: '( ', self title, ' )' ] -{ #category : #'as yet unclassified' } +{ #category : 'as yet unclassified' } Tiddler >> rawAliasedLinks [ ^ self rawLinks select: [ :each | each includesSubstring: '|' ] ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> rawLinks [ ^ (WikiTextGrammar new linkSea star parse: self text) asSet ] -{ #category : #accessing } +{ #category : 'accessing' } +Tiddler >> revision [ + ^ revision +] + +{ #category : 'accessing' } +Tiddler >> revision: aNumberString [ + revision := aNumberString +] + +{ #category : 'accessing' } Tiddler >> tags [ ^ tags ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> tags: anObject [ tags := anObject ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> text [ ^ text ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> text: anObject [ text := anObject ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> title [ ^ title ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> title: anObject [ title := anObject ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> type [ ^ type ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> type: anObject [ type := anObject ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> wiki [ ^ wiki ] -{ #category : #accessing } +{ #category : 'accessing' } Tiddler >> wiki: aTiddlyWiki [ wiki := aTiddlyWiki ] diff --git a/repository/TiddlyWiki/TiddlyWiki.class.st b/repository/TiddlyWiki/TiddlyWiki.class.st index da96a10..c7be54b 100644 --- a/repository/TiddlyWiki/TiddlyWiki.class.st +++ b/repository/TiddlyWiki/TiddlyWiki.class.st @@ -5,26 +5,26 @@ More information: https://tiddlywiki.com/ " Class { - #name : #TiddlyWiki, - #superclass : #Object, + #name : 'TiddlyWiki', + #superclass : 'Object', #instVars : [ 'tiddlers', 'file' ], - #category : #'TiddlyWiki-Model' + #category : 'TiddlyWiki-Model' } -{ #category : #accessing } +{ #category : 'accessing' } TiddlyWiki >> file [ ^ file ] -{ #category : #accessing } +{ #category : 'accessing' } TiddlyWiki >> file: anObject [ file := anObject ] -{ #category : #accessing } +{ #category : 'accessing' } TiddlyWiki >> importJSONTiddlers [ | tiddlersDict | self tiddlersJSONFile ifNil: [ ^ self ]. @@ -36,7 +36,7 @@ TiddlyWiki >> importJSONTiddlers [ ]) ] -{ #category : #accessing } +{ #category : 'accessing' } TiddlyWiki >> networkView [ | view | view := GtMondrian new. @@ -48,33 +48,33 @@ TiddlyWiki >> networkView [ ^ view ] -{ #category : #accessing } +{ #category : 'accessing' } TiddlyWiki >> printOn: aStream [ super printOn: aStream. aStream nextPutAll: '( ', self file basename ,' )' ] -{ #category : #accessing } +{ #category : 'accessing' } TiddlyWiki >> taggedWith: aTag [ ^ self tiddlers select: [:tiddler | tiddler tags isNotNil and: [tiddler tags includesSubstring: aTag ] ] ] -{ #category : #accessing } +{ #category : 'accessing' } TiddlyWiki >> tiddlers [ ^ tiddlers ifNil: [ tiddlers := OrderedCollection new ] ] -{ #category : #accessing } +{ #category : 'accessing' } TiddlyWiki >> tiddlers: anOrderedCollection [ tiddlers := anOrderedCollection ] -{ #category : #accessing } +{ #category : 'accessing' } TiddlyWiki >> tiddlersJSONFile [ file ifNil: [ self inform: 'You need to export tiddlers as JSON from TiddlyWiki'. ^ nil ]. diff --git a/repository/TiddlyWiki/WikiText.class.st b/repository/TiddlyWiki/WikiText.class.st index 39c063a..7f05e24 100644 --- a/repository/TiddlyWiki/WikiText.class.st +++ b/repository/TiddlyWiki/WikiText.class.st @@ -1,34 +1,34 @@ Class { - #name : #WikiText, - #superclass : #Object, + #name : 'WikiText', + #superclass : 'Object', #instVars : [ 'content' ], - #category : #'TiddlyWiki-Model' + #category : 'TiddlyWiki-Model' } -{ #category : #accessing } +{ #category : 'accessing' } WikiText >> content [ ^ content ] -{ #category : #accessing } +{ #category : 'accessing' } WikiText >> content: aString [ content := aString ] -{ #category : #conversions } +{ #category : 'conversions' } WikiText >> converMarkdownBold [ self content: (self content copyReplaceAll: '**' with: ''''''). ] -{ #category : #conversions } +{ #category : 'conversions' } WikiText >> convertMarkdownBold [ self content: (self content copyReplaceAll: '**' with: ''''''). ^ self. ] -{ #category : #conversions } +{ #category : 'conversions' } WikiText >> convertMarkdownLinks [ | markdownLinks markdownLinksRegex | markdownLinksRegex := '\[([\w|\s]+)\]\((\S+)\)'. @@ -44,7 +44,7 @@ WikiText >> convertMarkdownLinks [ ^ self content ] -{ #category : #accessing } +{ #category : 'accessing' } WikiText >> sample [ ^ 'The ''quick'' brown ~~flea~~ fox //jumps// over the `lazy` dog. diff --git a/repository/TiddlyWiki/WikiTextGrammar.class.st b/repository/TiddlyWiki/WikiTextGrammar.class.st index b7a61fb..338b88b 100644 --- a/repository/TiddlyWiki/WikiTextGrammar.class.st +++ b/repository/TiddlyWiki/WikiTextGrammar.class.st @@ -1,6 +1,6 @@ Class { - #name : #WikiTextGrammar, - #superclass : #PP2CompositeNode, + #name : 'WikiTextGrammar', + #superclass : 'PP2CompositeNode', #instVars : [ 'document', 'link', @@ -8,40 +8,40 @@ Class { 'linkContent', 'linkClose' ], - #category : #'TiddlyWiki-Model' + #category : 'TiddlyWiki-Model' } -{ #category : #accessing } +{ #category : 'accessing' } WikiTextGrammar >> document [ ^ link islandInSea star ] -{ #category : #accessing } +{ #category : 'accessing' } WikiTextGrammar >> link [ ^ linkOpen, linkContent, linkClose ==> #second ] -{ #category : #accessing } +{ #category : 'accessing' } WikiTextGrammar >> linkClose [ ^ ']]' asPParser ] -{ #category : #accessing } +{ #category : 'accessing' } WikiTextGrammar >> linkContent [ ^ #any asPParser starLazy flatten ] -{ #category : #accessing } +{ #category : 'accessing' } WikiTextGrammar >> linkOpen [ ^ '[[' asPParser ] -{ #category : #accessing } +{ #category : 'accessing' } WikiTextGrammar >> linkSea [ ^ link sea ==> #second ] -{ #category : #accessing } +{ #category : 'accessing' } WikiTextGrammar >> start [ ^ document ] diff --git a/repository/TiddlyWiki/WikiTextGrammarTest.class.st b/repository/TiddlyWiki/WikiTextGrammarTest.class.st index 9113c7b..1800252 100644 --- a/repository/TiddlyWiki/WikiTextGrammarTest.class.st +++ b/repository/TiddlyWiki/WikiTextGrammarTest.class.st @@ -1,15 +1,15 @@ Class { - #name : #WikiTextGrammarTest, - #superclass : #PP2CompositeNodeTest, - #category : #'TiddlyWiki-Model' + #name : 'WikiTextGrammarTest', + #superclass : 'PP2CompositeNodeTest', + #category : 'TiddlyWiki-Model' } -{ #category : #accessing } +{ #category : 'accessing' } WikiTextGrammarTest >> parserClass [ ^ WikiTextGrammar ] -{ #category : #accessing } +{ #category : 'accessing' } WikiTextGrammarTest >> testDocument [ | input | input := WikiText new sample. @@ -17,7 +17,7 @@ WikiTextGrammarTest >> testDocument [ self assert: result size equals: 2 ] -{ #category : #accessing } +{ #category : 'accessing' } WikiTextGrammarTest >> testLink [ self parse: '[[Just testing]]' diff --git a/repository/TiddlyWiki/package.st b/repository/TiddlyWiki/package.st index e18b041..8685590 100644 --- a/repository/TiddlyWiki/package.st +++ b/repository/TiddlyWiki/package.st @@ -1 +1 @@ -Package { #name : #TiddlyWiki } +Package { #name : 'TiddlyWiki' }