From 62fb3fca6587c723eb1eaef90e6e30f48e0410e7 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Wed, 21 Sep 2022 19:09:37 -0500 Subject: [PATCH] Improved downloading wikis. --- repository/TiddlyWiki/TiddlyWiki.class.st | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/repository/TiddlyWiki/TiddlyWiki.class.st b/repository/TiddlyWiki/TiddlyWiki.class.st index 6ea0085..3a637b4 100644 --- a/repository/TiddlyWiki/TiddlyWiki.class.st +++ b/repository/TiddlyWiki/TiddlyWiki.class.st @@ -312,6 +312,14 @@ TiddlyWiki >> fromDictionary: tiddlersDict [ wiki: self ]) ] +{ #category : #accessing } +TiddlyWiki >> fromString: aJSONString [ + + | tiddlersDict | + tiddlersDict := STONJSON fromString: aJSONString. + self fromDictionary: tiddlersDict +] + { #category : #accessing } TiddlyWiki >> fromUrl: anUrlString [ | docTree rawJsonTiddlers tiddlersDictionary | @@ -336,11 +344,15 @@ TiddlyWiki >> importJSONFile [ "I import a JSON representation of my tiddlers data, that has been previosly exported by #exportJSONFileOptimized or #exportJSONFile" - - | tiddlersDict | + self tiddlersJSONFile ifNil: [ ^ self ]. - tiddlersDict := STONJSON fromString: self tiddlersJSONFile contents. - self fromDictionary: tiddlersDict + self fromString: self tiddlersJSONFile contents. + +] + +{ #category : #accessing } +TiddlyWiki >> importJSONLink [ + ^ self fromString: (self remote asString, '/tiddlers.json') asUrl retrieveContents ] { #category : #accessing } @@ -636,7 +648,7 @@ TiddlyWiki >> taggedWith: aTag [ { #category : #accessing } TiddlyWiki >> tiddlers [ - + (self isInTiddlyHost and: [^ tiddlers isNil]) ifTrue: [ ^ self importJSONLink]. ^ tiddlers ifNil: [ tiddlers := OrderedCollection new ] ]