Adding fields to support GeoTiddlers and custom data.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2021-08-29 17:50:17 -05:00
parent 069617d4db
commit c1b4ec2209
8 changed files with 137 additions and 101 deletions

View File

@ -1,34 +1,34 @@
Class { Class {
#name : #FedWikiItem, #name : 'FedWikiItem',
#superclass : #Object, #superclass : 'Object',
#instVars : [ #instVars : [
'text', 'text',
'id', 'id',
'type' 'type'
], ],
#category : #'TiddlyWiki-Model' #category : 'TiddlyWiki-Model'
} }
{ #category : #accessing } { #category : 'accessing' }
FedWikiItem >> fromDictionary: aDictionary [ FedWikiItem >> fromDictionary: aDictionary [
text := aDictionary at: 'text'. text := aDictionary at: 'text'.
id := aDictionary at: 'id'. id := aDictionary at: 'id'.
type := aDictionary at: 'type'. type := aDictionary at: 'type'.
] ]
{ #category : #accessing } { #category : 'accessing' }
FedWikiItem >> printOn: aStream [ FedWikiItem >> printOn: aStream [
super printOn: aStream. super printOn: aStream.
aStream aStream
nextPutAll: '( ',self type, ' | ', self text, ' )' nextPutAll: '( ',self type, ' | ', self text, ' )'
] ]
{ #category : #accessing } { #category : 'accessing' }
FedWikiItem >> text [ FedWikiItem >> text [
^ text ^ text
] ]
{ #category : #accessing } { #category : 'accessing' }
FedWikiItem >> type [ FedWikiItem >> type [
^ type ^ type
] ]

View File

@ -1,6 +1,6 @@
Class { Class {
#name : #FedWikiPage, #name : 'FedWikiPage',
#superclass : #Object, #superclass : 'Object',
#instVars : [ #instVars : [
'url', 'url',
'title', 'title',
@ -8,10 +8,10 @@ Class {
'journal', 'journal',
'importJournal' 'importJournal'
], ],
#category : #'TiddlyWiki-Model' #category : 'TiddlyWiki-Model'
} }
{ #category : #accessing } { #category : 'accessing' }
FedWikiPage >> dataDictionary [ FedWikiPage >> dataDictionary [
| dataUrl | | dataUrl |
self isView ifFalse: [ self isView ifFalse: [
@ -21,34 +21,34 @@ FedWikiPage >> dataDictionary [
^ STONJSON fromString: dataUrl asUrl retrieveContents ^ STONJSON fromString: dataUrl asUrl retrieveContents
] ]
{ #category : #accessing } { #category : 'accessing' }
FedWikiPage >> fromDataDictionary [ FedWikiPage >> fromDataDictionary [
title := self dataDictionary at: 'title'. title := self dataDictionary at: 'title'.
story := self dataDictionary at: 'story'. story := self dataDictionary at: 'story'.
self importJournal ifTrue: [ journal := self dataDictionary at: 'journal']. self importJournal ifTrue: [ journal := self dataDictionary at: 'journal'].
] ]
{ #category : #accessing } { #category : 'accessing' }
FedWikiPage >> host [ FedWikiPage >> host [
^ self url host ^ self url host
] ]
{ #category : #accessing } { #category : 'accessing' }
FedWikiPage >> importJournal [ FedWikiPage >> importJournal [
^ importJournal ifNil: [ importJournal := false ] ^ importJournal ifNil: [ importJournal := false ]
] ]
{ #category : #accessing } { #category : 'accessing' }
FedWikiPage >> importJournal: aBoolean [ FedWikiPage >> importJournal: aBoolean [
importJournal := aBoolean importJournal := aBoolean
] ]
{ #category : #accessing } { #category : 'accessing' }
FedWikiPage >> isView [ FedWikiPage >> isView [
^ self url firstPathSegment = 'view' ^ self url firstPathSegment = 'view'
] ]
{ #category : #accessing } { #category : 'accessing' }
FedWikiPage >> jsonData [ FedWikiPage >> jsonData [
| dataUrl | | dataUrl |
self isView ifFalse: [ self isView ifFalse: [
@ -57,29 +57,29 @@ FedWikiPage >> jsonData [
dataUrl := self scheme , '://', self host, self titleSegmentUrl, '.json' dataUrl := self scheme , '://', self host, self titleSegmentUrl, '.json'
] ]
{ #category : #accessing } { #category : 'accessing' }
FedWikiPage >> printOn: aStream [ FedWikiPage >> printOn: aStream [
super printOn: aStream. super printOn: aStream.
aStream aStream
nextPutAll: '( ', self title, ' | ', self story size asString, ' items story )' nextPutAll: '( ', self title, ' | ', self story size asString, ' items story )'
] ]
{ #category : #accessing } { #category : 'accessing' }
FedWikiPage >> scheme [ FedWikiPage >> scheme [
^ self url scheme ^ self url scheme
] ]
{ #category : #accessing } { #category : 'accessing' }
FedWikiPage >> story [ FedWikiPage >> story [
^ story ^ story
] ]
{ #category : #accessing } { #category : 'accessing' }
FedWikiPage >> title [ FedWikiPage >> title [
^ title. ^ title.
] ]
{ #category : #accessing } { #category : 'accessing' }
FedWikiPage >> titleSegmentUrl [ FedWikiPage >> titleSegmentUrl [
self isView ifFalse: [ self isView ifFalse: [
self inform: 'Please provide a view url for the FedWiki page.'. self inform: 'Please provide a view url for the FedWiki page.'.
@ -87,12 +87,12 @@ FedWikiPage >> titleSegmentUrl [
^ self url segments last. ^ self url segments last.
] ]
{ #category : #accessing } { #category : 'accessing' }
FedWikiPage >> url [ FedWikiPage >> url [
^ url ^ url
] ]
{ #category : #accessing } { #category : 'accessing' }
FedWikiPage >> url: aString [ FedWikiPage >> url: aString [
url := aString asZnUrl url := aString asZnUrl
] ]

View File

@ -5,8 +5,8 @@ I implement the standard fields as described in the standard documentation at: <
" "
Class { Class {
#name : #Tiddler, #name : 'Tiddler',
#superclass : #Object, #superclass : 'Object',
#instVars : [ #instVars : [
'title', 'title',
'text', 'text',
@ -18,18 +18,21 @@ Class {
'list', 'list',
'caption', 'caption',
'modifier', 'modifier',
'wiki' 'wiki',
'customFields',
'bag',
'revision'
], ],
#category : #'TiddlyWiki-Model' #category : 'TiddlyWiki-Model'
} }
{ #category : #'instance creation' } { #category : 'instance creation' }
Tiddler class >> nowLocal [ Tiddler class >> nowLocal [
^ (ZTimestampFormat fromString: '200102031605067') ^ (ZTimestampFormat fromString: '200102031605067')
format: (ZTimestamp fromString: Time nowLocal asDateAndTime asString) format: (ZTimestamp fromString: Time nowLocal asDateAndTime asString)
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> asDictionary [ Tiddler >> asDictionary [
^ Dictionary new ^ Dictionary new
at: 'title' put: self title; at: 'title' put: self title;
@ -40,55 +43,71 @@ Tiddler >> asDictionary [
yourself. yourself.
] ]
{ #category : #converting } { #category : 'converting' }
Tiddler >> asJson [ Tiddler >> asJson [
^ STONJSON toStringPretty: self asDictionary ^ STONJSON toStringPretty: self asDictionary
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> asJsonTempFile [ Tiddler >> asJsonTempFile [
^ MarkupFile exportAsFileOn: FileLocator temp / self title, 'json' containing:self asJson ^ 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 [ Tiddler >> caption [
^ caption ^ caption
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> caption: anObject [ Tiddler >> caption: anObject [
caption := anObject caption := anObject
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> created [ Tiddler >> created [
^ created ifNil: [ created := DateAndTime now ] ^ created ifNil: [ created := DateAndTime now ]
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> created: anObject [ Tiddler >> created: anObject [
created := anObject created := anObject
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> creator [ Tiddler >> creator [
^ creator ^ creator
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> creator: anObject [ Tiddler >> creator: anObject [
creator := anObject creator := anObject
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> customFields [
^ customFields ifNil: [ customFields := Dictionary new]
]
{ #category : 'accessing' }
Tiddler >> fromDictionary: aDictionary [ Tiddler >> fromDictionary: aDictionary [
| customKeys |
self self
title: (aDictionary at: 'title'); title: (aDictionary at: 'title');
text: (aDictionary at: 'text'); text: (aDictionary at: 'text');
@ -99,9 +118,16 @@ Tiddler >> fromDictionary: aDictionary [
modifier: (aDictionary at: 'modifier' ifAbsentPut: [ nil ]); modifier: (aDictionary at: 'modifier' ifAbsentPut: [ nil ]);
type: (aDictionary at: 'type' ifAbsentPut: [ nil ]); type: (aDictionary at: 'type' ifAbsentPut: [ nil ]);
caption: (aDictionary at: 'caption' 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 [ Tiddler >> fromMarkdownParsedItems: aCollection [
| outputStream | | outputStream |
outputStream := '' writeStream. outputStream := '' writeStream.
@ -114,7 +140,7 @@ Tiddler >> fromMarkdownParsedItems: aCollection [
] ]
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> importFedWikiPage: pageViewUrlString [ Tiddler >> importFedWikiPage: pageViewUrlString [
| pageTitle pageViewUrl pageData | | pageTitle pageViewUrl pageData |
pageViewUrl := pageViewUrlString asZnUrl. pageViewUrl := pageViewUrlString asZnUrl.
@ -123,7 +149,7 @@ Tiddler >> importFedWikiPage: pageViewUrlString [
^ STONJSON fromString: pageData retrieveContents ^ STONJSON fromString: pageData retrieveContents
] ]
{ #category : #utilities } { #category : 'utilities' }
Tiddler >> itemContentsStringFor: item into: stream [ Tiddler >> itemContentsStringFor: item into: stream [
stream stream
nextPutAll: item text; nextPutAll: item text;
@ -131,7 +157,7 @@ Tiddler >> itemContentsStringFor: item into: stream [
nextPut: Character cr nextPut: Character cr
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> linkedTiddlers [ Tiddler >> linkedTiddlers [
"At the begining we are going to introduce 'pureTiddlers' as thos included in the wiki which are not linked "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." 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 ]. ^ self wiki tiddlers select: [:tiddler | pureTiddlersTitles includes: tiddler title ].
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> list [ Tiddler >> list [
^ list ^ list
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> list: anObject [ Tiddler >> list: anObject [
list := anObject list := anObject
] ]
{ #category : #utilities } { #category : 'utilities' }
Tiddler >> markdownLinksAsWikiText [ Tiddler >> markdownLinksAsWikiText [
"I'm useful to convert _internal_ links between formats, as is a common pattern "I'm useful to convert _internal_ links between formats, as is a common pattern
found when migrating content from Markdown to TiddlyWiki's WikiText. found when migrating content from Markdown to TiddlyWiki's WikiText.
@ -166,101 +192,111 @@ Tiddler >> markdownLinksAsWikiText [
^ markdownLinks ^ markdownLinks
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> modified [ Tiddler >> modified [
^ modified ^ modified
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> modified: anObject [ Tiddler >> modified: anObject [
modified := anObject modified := anObject
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> modifier [ Tiddler >> modifier [
^ modifier ^ modifier
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> modifier: anObject [ Tiddler >> modifier: anObject [
modifier := anObject modifier := anObject
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> printOn: aStream [ Tiddler >> printOn: aStream [
super printOn: aStream. super printOn: aStream.
aStream aStream
nextPutAll: '( ', self title, ' )' nextPutAll: '( ', self title, ' )'
] ]
{ #category : #'as yet unclassified' } { #category : 'as yet unclassified' }
Tiddler >> rawAliasedLinks [ Tiddler >> rawAliasedLinks [
^ self rawLinks select: [ :each | each includesSubstring: '|' ] ^ self rawLinks select: [ :each | each includesSubstring: '|' ]
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> rawLinks [ Tiddler >> rawLinks [
^ (WikiTextGrammar new linkSea star parse: self text) asSet ^ (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 [ Tiddler >> tags [
^ tags ^ tags
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> tags: anObject [ Tiddler >> tags: anObject [
tags := anObject tags := anObject
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> text [ Tiddler >> text [
^ text ^ text
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> text: anObject [ Tiddler >> text: anObject [
text := anObject text := anObject
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> title [ Tiddler >> title [
^ title ^ title
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> title: anObject [ Tiddler >> title: anObject [
title := anObject title := anObject
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> type [ Tiddler >> type [
^ type ^ type
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> type: anObject [ Tiddler >> type: anObject [
type := anObject type := anObject
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> wiki [ Tiddler >> wiki [
^ wiki ^ wiki
] ]
{ #category : #accessing } { #category : 'accessing' }
Tiddler >> wiki: aTiddlyWiki [ Tiddler >> wiki: aTiddlyWiki [
wiki := aTiddlyWiki wiki := aTiddlyWiki
] ]

View File

@ -5,26 +5,26 @@ More information:
https://tiddlywiki.com/ https://tiddlywiki.com/
" "
Class { Class {
#name : #TiddlyWiki, #name : 'TiddlyWiki',
#superclass : #Object, #superclass : 'Object',
#instVars : [ #instVars : [
'tiddlers', 'tiddlers',
'file' 'file'
], ],
#category : #'TiddlyWiki-Model' #category : 'TiddlyWiki-Model'
} }
{ #category : #accessing } { #category : 'accessing' }
TiddlyWiki >> file [ TiddlyWiki >> file [
^ file ^ file
] ]
{ #category : #accessing } { #category : 'accessing' }
TiddlyWiki >> file: anObject [ TiddlyWiki >> file: anObject [
file := anObject file := anObject
] ]
{ #category : #accessing } { #category : 'accessing' }
TiddlyWiki >> importJSONTiddlers [ TiddlyWiki >> importJSONTiddlers [
| tiddlersDict | | tiddlersDict |
self tiddlersJSONFile ifNil: [ ^ self ]. self tiddlersJSONFile ifNil: [ ^ self ].
@ -36,7 +36,7 @@ TiddlyWiki >> importJSONTiddlers [
]) ])
] ]
{ #category : #accessing } { #category : 'accessing' }
TiddlyWiki >> networkView [ TiddlyWiki >> networkView [
| view | | view |
view := GtMondrian new. view := GtMondrian new.
@ -48,33 +48,33 @@ TiddlyWiki >> networkView [
^ view ^ view
] ]
{ #category : #accessing } { #category : 'accessing' }
TiddlyWiki >> printOn: aStream [ TiddlyWiki >> printOn: aStream [
super printOn: aStream. super printOn: aStream.
aStream aStream
nextPutAll: '( ', self file basename ,' )' nextPutAll: '( ', self file basename ,' )'
] ]
{ #category : #accessing } { #category : 'accessing' }
TiddlyWiki >> taggedWith: aTag [ TiddlyWiki >> taggedWith: aTag [
^ self tiddlers select: [:tiddler | ^ self tiddlers select: [:tiddler |
tiddler tags isNotNil and: [tiddler tags includesSubstring: aTag ] tiddler tags isNotNil and: [tiddler tags includesSubstring: aTag ]
] ]
] ]
{ #category : #accessing } { #category : 'accessing' }
TiddlyWiki >> tiddlers [ TiddlyWiki >> tiddlers [
^ tiddlers ifNil: [ tiddlers := OrderedCollection new ] ^ tiddlers ifNil: [ tiddlers := OrderedCollection new ]
] ]
{ #category : #accessing } { #category : 'accessing' }
TiddlyWiki >> tiddlers: anOrderedCollection [ TiddlyWiki >> tiddlers: anOrderedCollection [
tiddlers := anOrderedCollection tiddlers := anOrderedCollection
] ]
{ #category : #accessing } { #category : 'accessing' }
TiddlyWiki >> tiddlersJSONFile [ TiddlyWiki >> tiddlersJSONFile [
file ifNil: [ self inform: 'You need to export tiddlers as JSON from TiddlyWiki'. file ifNil: [ self inform: 'You need to export tiddlers as JSON from TiddlyWiki'.
^ nil ]. ^ nil ].

View File

@ -1,34 +1,34 @@
Class { Class {
#name : #WikiText, #name : 'WikiText',
#superclass : #Object, #superclass : 'Object',
#instVars : [ #instVars : [
'content' 'content'
], ],
#category : #'TiddlyWiki-Model' #category : 'TiddlyWiki-Model'
} }
{ #category : #accessing } { #category : 'accessing' }
WikiText >> content [ WikiText >> content [
^ content ^ content
] ]
{ #category : #accessing } { #category : 'accessing' }
WikiText >> content: aString [ WikiText >> content: aString [
content := aString content := aString
] ]
{ #category : #conversions } { #category : 'conversions' }
WikiText >> converMarkdownBold [ WikiText >> converMarkdownBold [
self content: (self content copyReplaceAll: '**' with: ''''''). self content: (self content copyReplaceAll: '**' with: '''''').
] ]
{ #category : #conversions } { #category : 'conversions' }
WikiText >> convertMarkdownBold [ WikiText >> convertMarkdownBold [
self content: (self content copyReplaceAll: '**' with: ''''''). self content: (self content copyReplaceAll: '**' with: '''''').
^ self. ^ self.
] ]
{ #category : #conversions } { #category : 'conversions' }
WikiText >> convertMarkdownLinks [ WikiText >> convertMarkdownLinks [
| markdownLinks markdownLinksRegex | | markdownLinks markdownLinksRegex |
markdownLinksRegex := '\[([\w|\s]+)\]\((\S+)\)'. markdownLinksRegex := '\[([\w|\s]+)\]\((\S+)\)'.
@ -44,7 +44,7 @@ WikiText >> convertMarkdownLinks [
^ self content ^ self content
] ]
{ #category : #accessing } { #category : 'accessing' }
WikiText >> sample [ WikiText >> sample [
^ 'The ''quick'' brown ~~flea~~ fox //jumps// over the `lazy` dog. ^ 'The ''quick'' brown ~~flea~~ fox //jumps// over the `lazy` dog.

View File

@ -1,6 +1,6 @@
Class { Class {
#name : #WikiTextGrammar, #name : 'WikiTextGrammar',
#superclass : #PP2CompositeNode, #superclass : 'PP2CompositeNode',
#instVars : [ #instVars : [
'document', 'document',
'link', 'link',
@ -8,40 +8,40 @@ Class {
'linkContent', 'linkContent',
'linkClose' 'linkClose'
], ],
#category : #'TiddlyWiki-Model' #category : 'TiddlyWiki-Model'
} }
{ #category : #accessing } { #category : 'accessing' }
WikiTextGrammar >> document [ WikiTextGrammar >> document [
^ link islandInSea star ^ link islandInSea star
] ]
{ #category : #accessing } { #category : 'accessing' }
WikiTextGrammar >> link [ WikiTextGrammar >> link [
^ linkOpen, linkContent, linkClose ==> #second ^ linkOpen, linkContent, linkClose ==> #second
] ]
{ #category : #accessing } { #category : 'accessing' }
WikiTextGrammar >> linkClose [ WikiTextGrammar >> linkClose [
^ ']]' asPParser ^ ']]' asPParser
] ]
{ #category : #accessing } { #category : 'accessing' }
WikiTextGrammar >> linkContent [ WikiTextGrammar >> linkContent [
^ #any asPParser starLazy flatten ^ #any asPParser starLazy flatten
] ]
{ #category : #accessing } { #category : 'accessing' }
WikiTextGrammar >> linkOpen [ WikiTextGrammar >> linkOpen [
^ '[[' asPParser ^ '[[' asPParser
] ]
{ #category : #accessing } { #category : 'accessing' }
WikiTextGrammar >> linkSea [ WikiTextGrammar >> linkSea [
^ link sea ==> #second ^ link sea ==> #second
] ]
{ #category : #accessing } { #category : 'accessing' }
WikiTextGrammar >> start [ WikiTextGrammar >> start [
^ document ^ document
] ]

View File

@ -1,15 +1,15 @@
Class { Class {
#name : #WikiTextGrammarTest, #name : 'WikiTextGrammarTest',
#superclass : #PP2CompositeNodeTest, #superclass : 'PP2CompositeNodeTest',
#category : #'TiddlyWiki-Model' #category : 'TiddlyWiki-Model'
} }
{ #category : #accessing } { #category : 'accessing' }
WikiTextGrammarTest >> parserClass [ WikiTextGrammarTest >> parserClass [
^ WikiTextGrammar ^ WikiTextGrammar
] ]
{ #category : #accessing } { #category : 'accessing' }
WikiTextGrammarTest >> testDocument [ WikiTextGrammarTest >> testDocument [
| input | | input |
input := WikiText new sample. input := WikiText new sample.
@ -17,7 +17,7 @@ WikiTextGrammarTest >> testDocument [
self assert: result size equals: 2 self assert: result size equals: 2
] ]
{ #category : #accessing } { #category : 'accessing' }
WikiTextGrammarTest >> testLink [ WikiTextGrammarTest >> testLink [
self self
parse: '[[Just testing]]' parse: '[[Just testing]]'

View File

@ -1 +1 @@
Package { #name : #TiddlyWiki } Package { #name : 'TiddlyWiki' }