diff --git a/repository/TiddlyWiki/Tiddler.class.st b/repository/TiddlyWiki/Tiddler.class.st index 3b79573..67a56a1 100644 --- a/repository/TiddlyWiki/Tiddler.class.st +++ b/repository/TiddlyWiki/Tiddler.class.st @@ -86,6 +86,20 @@ Tiddler >> creator: anObject [ creator := anObject ] +{ #category : #accessing } +Tiddler >> fromDictionary: aDictionary [ + self + title: (aDictionary at: 'title'); + text: (aDictionary at: 'text'); + tags: (aDictionary at: 'tags' ifAbsentPut: [ nil ]); + created: (aDictionary at: 'created' ifAbsentPut: [ nil ]); + creator: (aDictionary at: 'creator' ifAbsentPut: [ nil ]); + modified: (aDictionary at: 'modified' ifAbsentPut: [ nil ]); + modifier: (aDictionary at: 'modifier' ifAbsentPut: [ nil ]); + type: (aDictionary at: 'type' ifAbsentPut: [ nil ]); + caption: (aDictionary at: 'caption' ifAbsentPut: [ nil ]). +] + { #category : #'instance creation' } Tiddler >> fromMarkdownParsedItems: aCollection [ | outputStream | diff --git a/repository/TiddlyWiki/TiddlyWiki.class.st b/repository/TiddlyWiki/TiddlyWiki.class.st index 14bb2fe..ba5821f 100644 --- a/repository/TiddlyWiki/TiddlyWiki.class.st +++ b/repository/TiddlyWiki/TiddlyWiki.class.st @@ -24,23 +24,19 @@ TiddlyWiki >> file: anObject [ file := anObject ] -{ #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 >> importJSONTiddlers [ + | tiddlersDict | + self tiddlersJSONFile ifNil: [ ^ self ]. + tiddlersDict := STONJSON fromString: self tiddlersJSONFile contents. + self tiddlers: (tiddlersDict collect: [:each | Tiddler new fromDictionary: each ]) +] +{ #category : #accessing } +TiddlyWiki >> printOn: aStream [ + super printOn: aStream. + aStream + nextPutAll: '( ', self file basename ,' )' ] { #category : #accessing }