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 {
#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
]

View File

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

View File

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

View File

@ -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 ].

View File

@ -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.

View File

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

View File

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

View File

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