TiddlyWikiPharo/repository/TiddlyWiki/TiddlyWiki.class.st

83 lines
1.6 KiB
Smalltalk
Raw Normal View History

2021-02-23 17:01:54 +00:00
"
I model a TiddlyWiki.
More information:
https://tiddlywiki.com/
"
Class {
#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
],
#category : 'TiddlyWiki-Model'
2021-02-23 17:01:54 +00:00
}
{ #category : 'accessing' }
2021-07-15 22:45:53 +00:00
TiddlyWiki >> file [
^ file
]
{ #category : 'accessing' }
2021-07-15 22:45:53 +00:00
TiddlyWiki >> file: anObject [
file := anObject
]
{ #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.
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
{ #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
]
{ #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
]
{ #category : 'accessing' }
TiddlyWiki >> taggedWith: aTag [
^ self tiddlers select: [:tiddler |
tiddler tags isNotNil and: [tiddler tags includesSubstring: aTag ]
]
]
{ #category : 'accessing' }
2021-02-23 17:01:54 +00:00
TiddlyWiki >> tiddlers [
^ tiddlers ifNil: [ tiddlers := OrderedCollection new ]
]
{ #category : 'accessing' }
2021-02-23 17:01:54 +00:00
TiddlyWiki >> tiddlers: anOrderedCollection [
tiddlers := anOrderedCollection
]
2021-07-15 22:45:53 +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'.
]