From 0f6bcbe6b2451a1fc671acc53cbe049e1c4c180b Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Tue, 28 Nov 2023 13:39:43 -0500 Subject: [PATCH] Using templates for wiki creation. --- repository/TiddlyWiki/TiddlyWiki.class.st | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/repository/TiddlyWiki/TiddlyWiki.class.st b/repository/TiddlyWiki/TiddlyWiki.class.st index ba13817..edab059 100644 --- a/repository/TiddlyWiki/TiddlyWiki.class.st +++ b/repository/TiddlyWiki/TiddlyWiki.class.st @@ -440,6 +440,13 @@ TiddlyWiki >> getRemoteTiddlers [ ^ self recentCommonTiddlersChanged ] +{ #category : #accessing } +TiddlyWiki >> hasTemplateInTiddlyHost [ + + self template ifNil: [ ^ false ]. + ^ self template asZnUrl host endsWith: 'tiddlyhost.com' +] + { #category : #accessing } TiddlyWiki >> htmlFileExists [ self file ifNil: [ @@ -802,11 +809,29 @@ TiddlyWiki >> taggedWith: aTag [ ] ] +{ #category : #accessing } +TiddlyWiki >> template [ + ^ template +] + { #category : #accessing } TiddlyWiki >> template: anUrl [ template := anUrl ] +{ #category : #accessing } +TiddlyWiki >> templateTiddlersContentsString [ + self hasTemplateInTiddlyHost ifFalse: [ ^ self ]. + ^ (self template asString, '/tiddlers.json') asZnUrl retrieveContents. +] + +{ #category : #accessing } +TiddlyWiki >> templateWiki [ + ^ (TiddlyWiki new fromString: self templateTiddlersContentsString) + name: 'Template Wiki'; + remote: self template +] + { #category : #accessing } TiddlyWiki >> tiddlers [ tiddlers ifNotNil: [ ^ tiddlers ].