From 37741df19142ca4abc5e1669db71c4f906f5fd7c Mon Sep 17 00:00:00 2001 From: ruidajo Date: Sun, 30 Oct 2022 19:31:59 -0500 Subject: [PATCH 1/3] Creating TW updater for remote files and loader form local folder. --- repository/TiddlyWiki/TiddlyWiki.class.st | 49 +++++++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/repository/TiddlyWiki/TiddlyWiki.class.st b/repository/TiddlyWiki/TiddlyWiki.class.st index 6486d2e..b825077 100644 --- a/repository/TiddlyWiki/TiddlyWiki.class.st +++ b/repository/TiddlyWiki/TiddlyWiki.class.st @@ -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 From fbfb5fbf7d0fcb20ccb45abd1752aa92cb4201e1 Mon Sep 17 00:00:00 2001 From: ruidajo Date: Sun, 30 Oct 2022 22:20:36 -0500 Subject: [PATCH 2/3] Creating tiddler uid test and TW tiddlers missing uid collection. --- repository/TiddlyWiki/Tiddler.class.st | 6 ++++++ repository/TiddlyWiki/TiddlyWiki.class.st | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/repository/TiddlyWiki/Tiddler.class.st b/repository/TiddlyWiki/Tiddler.class.st index 28ab1b0..5585cc2 100644 --- a/repository/TiddlyWiki/Tiddler.class.st +++ b/repository/TiddlyWiki/Tiddler.class.st @@ -267,6 +267,12 @@ Tiddler >> gtTextFor: aView [ text: [ text ] ] +{ #category : #testing } +Tiddler >> hasUID [ + + ^ self customFields includesKey: 'uid' +] + { #category : #accessing } Tiddler >> importFedWikiPage: pageViewUrlString [ | pageTitle pageViewUrl pageData | diff --git a/repository/TiddlyWiki/TiddlyWiki.class.st b/repository/TiddlyWiki/TiddlyWiki.class.st index b825077..b18a4cf 100644 --- a/repository/TiddlyWiki/TiddlyWiki.class.st +++ b/repository/TiddlyWiki/TiddlyWiki.class.st @@ -827,6 +827,12 @@ TiddlyWiki >> tiddlersJSONUrl [ self remote ifNil: [^ nil]. ] +{ #category : #accessing } +TiddlyWiki >> tiddlersMissingUID [ + + ^ self tiddlers reject: [ :tiddler | (tiddler customFields includesKey: 'uid') or: [ (tiddler title beginsWith:'$') ] ]. +] + { #category : #accessing } TiddlyWiki >> updateFilesFromRemote [ From cdd8607532c48a3a4fd488a36db4f93fe581418a Mon Sep 17 00:00:00 2001 From: ruidajo Date: Sun, 30 Oct 2022 23:33:01 -0500 Subject: [PATCH 3/3] Improving tiddler testing for image type. --- repository/TiddlyWiki/Tiddler.class.st | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repository/TiddlyWiki/Tiddler.class.st b/repository/TiddlyWiki/Tiddler.class.st index 5585cc2..ecdcb90 100644 --- a/repository/TiddlyWiki/Tiddler.class.st +++ b/repository/TiddlyWiki/Tiddler.class.st @@ -308,7 +308,8 @@ Tiddler >> installTiddlerExporter [ { #category : #testing } Tiddler >> isImage [ - ^ self type = 'image/' + ^ self type ifNil: [ ^ false ]; + beginsWith: 'image/' ] { #category : #testing }