TiddlyWikiPharo/repository/TiddlyWiki/TiddlyWiki.class.st

64 lines
1.3 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-02-23 17:01:54 +00:00
{ #category : #'instance creation' }
TiddlyWiki >> fromJSONString: aString [
| rawData |
rawData := NeoJSONReader fromString: aString.
rawData do: [ :data | | temp |
temp := Tiddler new.
temp
modified: (data at: 'modified');
created: (data at: 'created' ifAbsent: [ temp created: nil ]);
title: (data at: 'title');
tags: (data at: 'tags' ifAbsent: [ temp tags: nil ]);
type: (data at: 'type' ifAbsent: [ temp type: nil ]);
caption: (data at: 'caption' ifAbsent: [ temp caption: nil ]);
text: (data at: 'text').
self tiddlers add: temp.
].
]
{ #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'.
]