Creating TW updater for remote files and loader form local folder.
This commit is contained in:
parent
0ff99de896
commit
37741df191
@ -25,9 +25,9 @@ TiddlyWiki class >> createFromRemote: aRemoteTWUrl in: aFolder [
|
||||
aFolder hasChildren ifTrue: [ ^ nil ].
|
||||
wiki := TiddlyWiki new
|
||||
remote: aRemoteTWUrl;
|
||||
folder: aFolder;
|
||||
file: (aFolder / 'index.html') ensureCreateFile.
|
||||
folder: (aFolder ensureCreateDirectory).
|
||||
^ wiki downloadHTML;
|
||||
file: (aFolder / 'index.html');
|
||||
tiddlers.
|
||||
]
|
||||
|
||||
@ -52,6 +52,33 @@ TiddlyWiki class >> fromJSONUrl: anUrlString [
|
||||
name: anUrlString
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
TiddlyWiki class >> loadFromLocalFolder: aFolder [
|
||||
|
||||
| wiki |
|
||||
wiki := TiddlyWiki new
|
||||
folder: aFolder;
|
||||
file: aFolder / 'index.html';
|
||||
jsonFile: aFolder / 'tiddlers.json'.
|
||||
^ wiki fromString: wiki jsonFile.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
TiddlyWiki class >> loadFromLocalFolder: aFolder named: aName [
|
||||
|
||||
| wiki |
|
||||
wiki := TiddlyWiki loadFromLocalFolder: aFolder.
|
||||
^ wiki name: aName
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
TiddlyWiki class >> loadFromLocalFolder: aFolder named: aName withRemote: aRemoteURL [
|
||||
|
||||
| wiki |
|
||||
wiki := self loadFromLocalFolder: aFolder named: aName.
|
||||
^ wiki remote: aRemoteURL
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
TiddlyWiki >> addRecentChangesToRepo [
|
||||
|
||||
@ -181,7 +208,7 @@ TiddlyWiki >> downloadHTML [
|
||||
localCopy := self folder / 'index.html'.
|
||||
localCopy exists ifTrue: [ | timestamp |
|
||||
timestamp := (DateAndTime now asString) copyReplaceAll: ':' with: '_'.
|
||||
localCopy renameTo: 'index', timestamp, '.html'].
|
||||
localCopy renameTo: 'index-', timestamp, '.html'].
|
||||
ZnClient new
|
||||
url: htmlLink;
|
||||
downloadTo: self folder / 'index.html'.
|
||||
@ -427,7 +454,12 @@ TiddlyWiki >> importJSONFile [
|
||||
{ #category : #accessing }
|
||||
TiddlyWiki >> importJSONLink [
|
||||
|
||||
self jsonFile: self folder / 'tiddlers.json'.
|
||||
| localCopy |
|
||||
self jsonFile ifNil: [ self jsonFile: self folder / 'tiddlers.json' ].
|
||||
localCopy := self folder / 'tiddlers.json'.
|
||||
localCopy exists ifTrue: [ | timestamp |
|
||||
timestamp := (DateAndTime now asString) copyReplaceAll: ':' with: '_'.
|
||||
localCopy renameTo: 'tiddlers-', timestamp, '.json'].
|
||||
MarkupFile exportAsFileOn: jsonFile containing: self remoteTiddlersContentsString.
|
||||
^ self fromString: self remoteTiddlersContentsString
|
||||
]
|
||||
@ -795,6 +827,15 @@ TiddlyWiki >> tiddlersJSONUrl [
|
||||
self remote ifNil: [^ nil].
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
TiddlyWiki >> updateFilesFromRemote [
|
||||
|
||||
self remote ifNil: [ self inform: 'No remote found. If you have one, please provide its URL.'.
|
||||
^ self ].
|
||||
^ self downloadHTML;
|
||||
importJSONLink
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
TiddlyWiki >> updateFromHtml [
|
||||
self
|
||||
|
Loading…
Reference in New Issue
Block a user