Fixing tiddlers, Improving the json file importer from link and creating instace creation class methods.
This commit is contained in:
parent
27fbfe25b0
commit
c1ff0e0243
@ -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 ]
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user