2021-02-23 17:01:54 +00:00
|
|
|
"
|
|
|
|
I model a TiddlyWiki.
|
|
|
|
More information:
|
|
|
|
|
|
|
|
https://tiddlywiki.com/
|
|
|
|
"
|
|
|
|
Class {
|
2021-08-29 22:50:17 +00:00
|
|
|
#name : 'TiddlyWiki',
|
|
|
|
#superclass : 'Object',
|
2021-02-23 17:01:54 +00:00
|
|
|
#instVars : [
|
2021-07-15 22:45:53 +00:00
|
|
|
'tiddlers',
|
|
|
|
'file'
|
2021-02-23 17:01:54 +00:00
|
|
|
],
|
2021-08-29 22:50:17 +00:00
|
|
|
#category : 'TiddlyWiki-Model'
|
2021-02-23 17:01:54 +00:00
|
|
|
}
|
|
|
|
|
2021-09-01 23:58:15 +00:00
|
|
|
{ #category : 'accessing' }
|
|
|
|
TiddlyWiki >> exportSTONTiddlersFile [
|
|
|
|
| stonFile |
|
|
|
|
stonFile := self tiddlersJSONFile withoutExtension, 'ston'.
|
|
|
|
^ MarkupFile exportAsFileOn: stonFile containing:(STON toStringPretty: self)
|
|
|
|
]
|
|
|
|
|
2021-08-29 22:50:17 +00:00
|
|
|
{ #category : 'accessing' }
|
2021-07-15 22:45:53 +00:00
|
|
|
TiddlyWiki >> file [
|
|
|
|
^ file
|
|
|
|
]
|
|
|
|
|
2021-08-29 22:50:17 +00:00
|
|
|
{ #category : 'accessing' }
|
2021-07-15 22:45:53 +00:00
|
|
|
TiddlyWiki >> file: anObject [
|
|
|
|
file := anObject
|
|
|
|
]
|
|
|
|
|
2021-08-29 22:50:17 +00:00
|
|
|
{ #category : 'accessing' }
|
2021-09-01 22:42:21 +00:00
|
|
|
TiddlyWiki >> importJSONTiddlersFile [
|
2021-08-11 17:10:53 +00:00
|
|
|
| tiddlersDict |
|
|
|
|
self tiddlersJSONFile ifNil: [ ^ self ].
|
|
|
|
tiddlersDict := STONJSON fromString: self tiddlersJSONFile contents.
|
2021-08-17 17:03:53 +00:00
|
|
|
self tiddlers: (tiddlersDict collect: [:each |
|
|
|
|
Tiddler new
|
|
|
|
fromDictionary: each;
|
|
|
|
wiki: self
|
|
|
|
])
|
2021-08-11 17:10:53 +00:00
|
|
|
]
|
2021-02-23 17:01:54 +00:00
|
|
|
|
2021-08-29 22:50:17 +00:00
|
|
|
{ #category : 'accessing' }
|
2021-08-17 18:24:00 +00:00
|
|
|
TiddlyWiki >> networkView [
|
|
|
|
| view |
|
|
|
|
view := GtMondrian new.
|
|
|
|
view nodes
|
|
|
|
with: self tiddlers.
|
|
|
|
view edges
|
|
|
|
connectFromAll: #linkedTiddlers.
|
|
|
|
view layout force.
|
|
|
|
^ view
|
|
|
|
]
|
|
|
|
|
2021-08-29 22:50:17 +00:00
|
|
|
{ #category : 'accessing' }
|
2021-08-11 17:10:53 +00:00
|
|
|
TiddlyWiki >> printOn: aStream [
|
|
|
|
super printOn: aStream.
|
|
|
|
aStream
|
|
|
|
nextPutAll: '( ', self file basename ,' )'
|
2021-02-23 17:01:54 +00:00
|
|
|
]
|
|
|
|
|
2021-08-29 22:50:17 +00:00
|
|
|
{ #category : 'accessing' }
|
2021-08-17 17:03:53 +00:00
|
|
|
TiddlyWiki >> taggedWith: aTag [
|
|
|
|
^ self tiddlers select: [:tiddler |
|
|
|
|
tiddler tags isNotNil and: [tiddler tags includesSubstring: aTag ]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
2021-08-29 22:50:17 +00:00
|
|
|
{ #category : 'accessing' }
|
2021-02-23 17:01:54 +00:00
|
|
|
TiddlyWiki >> tiddlers [
|
|
|
|
|
|
|
|
^ tiddlers ifNil: [ tiddlers := OrderedCollection new ]
|
|
|
|
]
|
|
|
|
|
2021-08-29 22:50:17 +00:00
|
|
|
{ #category : 'accessing' }
|
2021-02-23 17:01:54 +00:00
|
|
|
TiddlyWiki >> tiddlers: anOrderedCollection [
|
|
|
|
|
|
|
|
tiddlers := anOrderedCollection
|
|
|
|
]
|
2021-07-15 22:45:53 +00:00
|
|
|
|
2021-08-29 22:50:17 +00:00
|
|
|
{ #category : 'accessing' }
|
2021-07-15 22:45:53 +00:00
|
|
|
TiddlyWiki >> tiddlersJSONFile [
|
|
|
|
file ifNil: [ self inform: 'You need to export tiddlers as JSON from TiddlyWiki'.
|
|
|
|
^ nil ].
|
|
|
|
^ file parent / 'tiddlers.json'.
|
|
|
|
]
|