TiddlyWikiPharo/repository/TiddlyWiki/TiddlyWiki.class.st

83 lines
1.5 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,
#instVars : [
2021-07-15 22:45:53 +00:00
'tiddlers',
'file'
2021-02-23 17:01:54 +00:00
],
#category : #'TiddlyWiki-Model'
}
2021-07-15 22:45:53 +00:00
{ #category : #accessing }
TiddlyWiki >> file [
^ file
]
{ #category : #accessing }
TiddlyWiki >> file: anObject [
file := anObject
]
2021-08-11 17:10:53 +00:00
{ #category : #accessing }
TiddlyWiki >> importJSONTiddlers [
| 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
2021-08-17 18:24:00 +00:00
{ #category : #accessing }
TiddlyWiki >> networkView [
| view |
view := GtMondrian new.
view nodes
with: self tiddlers.
view edges
connectFromAll: #linkedTiddlers.
view layout force.
^ view
]
2021-08-11 17:10:53 +00:00
{ #category : #accessing }
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 ]
]
]
2021-02-23 17:01:54 +00:00
{ #category : #accessing }
TiddlyWiki >> tiddlers [
^ tiddlers ifNil: [ tiddlers := OrderedCollection new ]
]
{ #category : #accessing }
TiddlyWiki >> tiddlers: anOrderedCollection [
tiddlers := anOrderedCollection
]
2021-07-15 22:45:53 +00:00
{ #category : #accessing }
TiddlyWiki >> tiddlersJSONFile [
file ifNil: [ self inform: 'You need to export tiddlers as JSON from TiddlyWiki'.
^ nil ].
^ file parent / 'tiddlers.json'.
]