Multihosted wiki syncronization started: preparations.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-09-13 13:04:56 -05:00
parent f083d7df47
commit 3d75e2729d
1 changed files with 38 additions and 4 deletions

View File

@ -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
]