From 3d75e2729d013a0da4ed230ae95561e450d98db7 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Tue, 13 Sep 2022 13:04:56 -0500 Subject: [PATCH] Multihosted wiki syncronization started: preparations. --- repository/TiddlyWiki/TiddlyWiki.class.st | 42 ++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/repository/TiddlyWiki/TiddlyWiki.class.st b/repository/TiddlyWiki/TiddlyWiki.class.st index 06fee98..6ea0085 100644 --- a/repository/TiddlyWiki/TiddlyWiki.class.st +++ b/repository/TiddlyWiki/TiddlyWiki.class.st @@ -12,7 +12,8 @@ Class { 'file', 'remote', 'jsonFile', - 'tiddlers' + 'tiddlers', + 'folder' ], #category : #'TiddlyWiki-Model' } @@ -150,6 +151,22 @@ TiddlyWiki >> detectRepositoryLocal [ ^ folder ] +{ #category : #accessing } +TiddlyWiki >> downloadHTML [ + | htmlLink localCopy | + self isInTiddlyHost ifTrue: [ + htmlLink := self remote asString + ]. + localCopy := self folder / 'index.html'. + localCopy exists ifTrue: [ | timestamp | + timestamp := (DateAndTime now asString) copyReplaceAll: ':' with: '_'. + localCopy renameTo: 'index', timestamp, '.html']. + ZnClient new + url: htmlLink; + downloadTo: self folder / 'index.html'. + ^ self folder +] + { #category : #accessing } TiddlyWiki >> exportCommonTiddlers [ @@ -274,7 +291,16 @@ TiddlyWiki >> file: anObject [ { #category : #accessing } TiddlyWiki >> folder [ - ^ self file parent + folder ifNotNil: [ ^ folder ]. + self file + ifNotNil: [ folder := self file parent ] + ifNil: [ folder := FileLocator temp ] + +] + +{ #category : #accessing } +TiddlyWiki >> folder: anObject [ + folder := anObject ] { #category : #accessing } @@ -338,6 +364,11 @@ TiddlyWiki >> installJsonExporter [ runAndWaitOnExitDo: [ :process :outString | ^ outString ] ] +{ #category : #accessing } +TiddlyWiki >> isInTiddlyHost [ + ^ self remote host endsWith: 'tiddlyhost.com' +] + { #category : #accessing } TiddlyWiki >> jsonFile [ ^ jsonFile ifNil: [ @@ -411,11 +442,14 @@ TiddlyWiki >> name [ name ifNotNil: [ ^ name ]. self file ifNotNil: [ ^ name := self file basenameWithoutExtension ]. self remote ifNil: [ ^ name := nil ]. + (self remote host endsWith: 'tiddlyhost.com') + ifTrue: [ ^ name := (self remote host splitOn: '.') first ]. tempName := self remote file. - (tempName endsWithAnyOf: #('.html' '.htm')) ifTrue: [ + (tempName endsWithAnyOf: #('.html' '.htm')) + ifTrue: [ suffix := (tempName splitOn: '.') last. tempName := tempName removeSuffix: '.', suffix. - ]. + ]. name := tempName ]