diff --git a/repository/TiddlyWiki/TiddlyWiki.class.st b/repository/TiddlyWiki/TiddlyWiki.class.st index 73bd140..1942d45 100644 --- a/repository/TiddlyWiki/TiddlyWiki.class.st +++ b/repository/TiddlyWiki/TiddlyWiki.class.st @@ -18,6 +18,26 @@ Class { #category : #'TiddlyWiki-Model' } +{ #category : #'instance - creation' } +TiddlyWiki class >> createFromRemote: aRemoteTWUrl in: aFolder [ + + | wiki | + wiki := TiddlyWiki new + remote: aRemoteTWUrl; + folder: aFolder; + file: (aFolder / 'index.html') ensureCreateFile. + ^ wiki downloadHTML; + tiddlers. +] + +{ #category : #'instance - creation' } +TiddlyWiki class >> createFromRemote: aRemoteTWUrl in: aFolder named: aNameString [ + + | wiki | + wiki := self createFromRemote: aRemoteTWUrl in: aFolder. + ^ wiki name: aNameString +] + { #category : #accessing } TiddlyWiki class >> fromJSONUrl: anUrlString [ | rawContents contentsString | @@ -363,7 +383,12 @@ TiddlyWiki >> importJSONFile [ { #category : #accessing } TiddlyWiki >> importJSONLink [ - ^ self fromString: (self remote asString, '/tiddlers.json') asUrl retrieveContents + + | tiddlersJson | + tiddlersJson := (self remote asString, '/tiddlers.json') asUrl retrieveContents. + jsonFile := self folder / 'tiddlers.json'. + MarkupFile exportAsFileOn: jsonFile containing: tiddlersJson. + ^ self fromString: tiddlersJson ] { #category : #accessing } @@ -397,8 +422,9 @@ TiddlyWiki >> isInTiddlyHost [ { #category : #accessing } TiddlyWiki >> jsonFile [ ^ jsonFile ifNil: [ - self htmlFileExists. - jsonFile := file parent / 'tiddlers.json'.] + self htmlFileExists ifNotNil: + [ jsonFile := file parent / 'tiddlers.json' ] + ] ] { #category : #accessing } @@ -662,7 +688,7 @@ TiddlyWiki >> taggedWith: aTag [ { #category : #accessing } TiddlyWiki >> tiddlers [ - (self isInTiddlyHost and: [^ tiddlers isNil]) ifTrue: [ ^ self importJSONLink]. + (self isInTiddlyHost and: [ tiddlers isNil ]) ifTrue: [ ^ self importJSONLink]. ^ tiddlers ifNil: [ tiddlers := OrderedCollection new ] ]