Improved downloading wikis.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-09-21 19:09:37 -05:00
parent 3d75e2729d
commit 62fb3fca65

View File

@ -312,6 +312,14 @@ TiddlyWiki >> fromDictionary: tiddlersDict [
wiki: self ]) wiki: self ])
] ]
{ #category : #accessing }
TiddlyWiki >> fromString: aJSONString [
| tiddlersDict |
tiddlersDict := STONJSON fromString: aJSONString.
self fromDictionary: tiddlersDict
]
{ #category : #accessing } { #category : #accessing }
TiddlyWiki >> fromUrl: anUrlString [ TiddlyWiki >> fromUrl: anUrlString [
| docTree rawJsonTiddlers tiddlersDictionary | | docTree rawJsonTiddlers tiddlersDictionary |
@ -336,11 +344,15 @@ TiddlyWiki >> importJSONFile [
"I import a JSON representation of my tiddlers data, "I import a JSON representation of my tiddlers data,
that has been previosly exported by that has been previosly exported by
#exportJSONFileOptimized or #exportJSONFile" #exportJSONFileOptimized or #exportJSONFile"
| tiddlersDict |
self tiddlersJSONFile ifNil: [ ^ self ]. self tiddlersJSONFile ifNil: [ ^ self ].
tiddlersDict := STONJSON fromString: self tiddlersJSONFile contents. self fromString: self tiddlersJSONFile contents.
self fromDictionary: tiddlersDict
]
{ #category : #accessing }
TiddlyWiki >> importJSONLink [
^ self fromString: (self remote asString, '/tiddlers.json') asUrl retrieveContents
] ]
{ #category : #accessing } { #category : #accessing }
@ -636,7 +648,7 @@ TiddlyWiki >> taggedWith: aTag [
{ #category : #accessing } { #category : #accessing }
TiddlyWiki >> tiddlers [ TiddlyWiki >> tiddlers [
(self isInTiddlyHost and: [^ tiddlers isNil]) ifTrue: [ ^ self importJSONLink].
^ tiddlers ifNil: [ tiddlers := OrderedCollection new ] ^ tiddlers ifNil: [ tiddlers := OrderedCollection new ]
] ]