From 59fb501686bd574ecab737ad6553996faf4cdd28 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Wed, 3 Nov 2021 20:49:58 -0500 Subject: [PATCH] Improving wikis creation from remote data. --- repository/TiddlyWiki/TiddlyWiki.class.st | 27 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/repository/TiddlyWiki/TiddlyWiki.class.st b/repository/TiddlyWiki/TiddlyWiki.class.st index fc03890..8a65a2f 100644 --- a/repository/TiddlyWiki/TiddlyWiki.class.st +++ b/repository/TiddlyWiki/TiddlyWiki.class.st @@ -16,6 +16,14 @@ Class { #category : #'TiddlyWiki-Model' } +{ #category : #accessing } +TiddlyWiki class >> fromJSONUrl: anUrlString [ + + ^ self new + fromDictionary: (STONJSON fromString: anUrlString asUrl retrieveContents); + name: anUrlString +] + { #category : #accessing } TiddlyWiki >> addToConfigFile [ | cleaned | @@ -72,20 +80,27 @@ TiddlyWiki >> file: anObject [ file := anObject ] +{ #category : #accessing } +TiddlyWiki >> fromDictionary: tiddlersDict [ + + self tiddlers: (tiddlersDict collect: [ :each | + Tiddler new + fromDictionary: each; + wiki: self ]) +] + { #category : #accessing } TiddlyWiki >> importJSONFile [ + "I import a JSON representation of my tiddlers data, that has been previosly exported by the TiddlyWiki HTML self contained file. Such file is called, by convention, 'tiddlers.json' and stored in the same folder where the HTML file is located." + | tiddlersDict | self tiddlersJSONFile ifNil: [ ^ self ]. tiddlersDict := STONJSON fromString: self tiddlersJSONFile contents. - self tiddlers: (tiddlersDict collect: [:each | - Tiddler new - fromDictionary: each; - wiki: self - ]) + self fromDictionary: tiddlersDict ] { #category : #accessing } @@ -147,7 +162,7 @@ TiddlyWiki >> networkView [ TiddlyWiki >> printOn: aStream [ super printOn: aStream. aStream - nextPutAll: '( ', self file basename ,' )' + nextPutAll: '( ', self name ,' )' ] { #category : #accessing }