From 2262ebaec2063981d04a149a63ccd06be9519b01 Mon Sep 17 00:00:00 2001 From: ruidajo Date: Mon, 26 Sep 2022 18:04:24 -0500 Subject: [PATCH] Fixing tiddler exporter to JSON and creating a rebuilded common tiddlers exporter for JSON format. --- repository/TiddlyWiki/Tiddler.class.st | 6 ++++-- repository/TiddlyWiki/TiddlyWiki.class.st | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/repository/TiddlyWiki/Tiddler.class.st b/repository/TiddlyWiki/Tiddler.class.st index adfcb29..f38f58c 100644 --- a/repository/TiddlyWiki/Tiddler.class.st +++ b/repository/TiddlyWiki/Tiddler.class.st @@ -167,8 +167,10 @@ Tiddler >> deleteUid [ { #category : #accessing } Tiddler >> exportJSONFile [ - | jsonFile | - jsonFile := self wiki folder / 'tiddlers' / (self title asDashedLowercase,'.', self created asString, '.json'). + + | jsonFile folder | + folder := self wiki folder. + jsonFile := folder / 'tiddlers' / ((self fileName removeSuffix: '.ston'), '.json'). ^ MarkupFile exportAsFileOn: jsonFile containing:self asJson ] diff --git a/repository/TiddlyWiki/TiddlyWiki.class.st b/repository/TiddlyWiki/TiddlyWiki.class.st index fa6fa68..54f3e72 100644 --- a/repository/TiddlyWiki/TiddlyWiki.class.st +++ b/repository/TiddlyWiki/TiddlyWiki.class.st @@ -215,6 +215,16 @@ TiddlyWiki >> exportJSONFileOptimized [ runAndWaitOnExitDo: [ :process :outString | ^ self jsonFile ] ] +{ #category : #accessing } +TiddlyWiki >> exportJSONFromRebuildedCommonTiddlers [ + + | rebuildedTiddlersJSON dateNowString | + dateNowString := (DateAndTime now asLocalStringYMDHM copyReplaceAll: ':' with: '-') copyReplaceAll: ' ' with: '-'. + rebuildedTiddlersJSON := '[', (',' join: (self rebuildTiddlersWithoutLargeTiddlers collect: [ :each | each asJsonString ])), ']'. + ^ MarkupFile exportAsFileOn: self folder / 'rebuildedCommonTiddlers', dateNowString, 'json' containing: rebuildedTiddlersJSON + +] + { #category : #accessing } TiddlyWiki >> exportJSONSubtiddlers: subtiddlersCollection [ @@ -534,6 +544,7 @@ TiddlyWiki >> rebuildTiddlersWithoutLargeTiddlers [ stonTiddlers addAll: (contentTiddlersFiles collect:[ :each | STONJSON fromString: each contents ]). + stonTiddlers collect: [ :tiddler | tiddler wiki: self ]. ^ stonTiddlers ]