From 28d0e1eb20b6e218a068f9fe7fa9d5d277f742f9 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Wed, 8 Sep 2021 20:00:14 -0500 Subject: [PATCH] Fixing JSON exportation. --- repository/TiddlyWiki/Tiddler.class.st | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/repository/TiddlyWiki/Tiddler.class.st b/repository/TiddlyWiki/Tiddler.class.st index e284779..f79bb5f 100644 --- a/repository/TiddlyWiki/Tiddler.class.st +++ b/repository/TiddlyWiki/Tiddler.class.st @@ -49,9 +49,16 @@ Tiddler >> asDictionary [ yourself. ] +{ #category : 'accessing' } +Tiddler >> asJSONFile [ + | jsonFile | + jsonFile := self wiki file parent / 'tiddlers' / (self title asLowercase, '.json'). + ^ MarkupFile exportAsFileOn: jsonFile containing:self asJson +] + { #category : 'converting' } Tiddler >> asJson [ - ^ STON toStringPretty: { self asDictionary } + ^ STONJSON toStringPretty: { self asDictionary } ] { #category : 'converting' } @@ -68,7 +75,7 @@ Tiddler >> asJsonTempFile [ { #category : 'accessing' } Tiddler >> asStonStringPretty [ | output temp | - temp := self. + temp := self copy. temp wiki: nil. output := '' writeStream. (STON writer on: output) @@ -130,6 +137,13 @@ Tiddler >> customFields [ ^ customFields ifNil: [ customFields := Dictionary new] ] +{ #category : 'accessing' } +Tiddler >> exportSTONFile [ + | stonFile output | + stonFile := self wiki file parent / 'tiddlers' / (self title asLowercase, '.ston') . + ^ MarkupFile exportAsFileOn: stonFile containing: self asStonStringPretty +] + { #category : 'accessing' } Tiddler >> exportWithTemplate: aTemplate [ ^ aTemplate asMustacheTemplate value: self asDictionary