From 41ce14934cf526021f827dab88888ecd20651555 Mon Sep 17 00:00:00 2001 From: ruidajo Date: Fri, 9 Jun 2023 15:13:11 -0500 Subject: [PATCH] Creating a method to populate tiddlers from de html file and a method to get the core tiddler of the wiki. --- repository/TiddlyWiki/TiddlyWiki.class.st | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/repository/TiddlyWiki/TiddlyWiki.class.st b/repository/TiddlyWiki/TiddlyWiki.class.st index 9a0edff..4a478e8 100644 --- a/repository/TiddlyWiki/TiddlyWiki.class.st +++ b/repository/TiddlyWiki/TiddlyWiki.class.st @@ -184,6 +184,12 @@ TiddlyWiki >> contentTiddlers [ ^ self tiddlers copyWithoutAll: self shadow ] +{ #category : #accessing } +TiddlyWiki >> core [ + + ^ STONJSON fromString:(self shadow select: [ :tid | tid title = '$:/core']) first text +] + { #category : #accessing } TiddlyWiki >> detectRepositoryLocal [ @@ -813,6 +819,21 @@ TiddlyWiki >> tiddlersFolder [ ^ self folder / 'tiddlers' ] +{ #category : #accessing } +TiddlyWiki >> tiddlersFromHTMLFile [ +"I process and set the tiddlers from de HTML wiki file." + | html tiddlerStore tiddlerDict | + + self file isNil + ifTrue: [ ^ self inform: 'This wiki HTML file is nil.', + (Character cr asString), 'Please provide an HTML file to the TW.' ]. + + html := XMLHTMLParser parse: self file. + tiddlerStore := (html xpath: '//script[@class="tiddlywiki-tiddler-store"]') stringValue. + tiddlerDict := STONJSON fromString: tiddlerStore. + ^ self tiddlers: (tiddlerDict collect: [ :dic | Tiddler new fromDictionary: dic ]) +] + { #category : #accessing } TiddlyWiki >> tiddlersJSONFile [