From c0657044ff4e07002d91932d7608da2f63fc8870 Mon Sep 17 00:00:00 2001 From: ruidajo Date: Wed, 16 Feb 2022 09:34:11 -0500 Subject: [PATCH] Creating tiddler testing methods and improving filtering-exporting. --- repository/TiddlyWiki/Tiddler.class.st | 24 +++++++++++++ repository/TiddlyWiki/TiddlyWiki.class.st | 42 +++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/repository/TiddlyWiki/Tiddler.class.st b/repository/TiddlyWiki/Tiddler.class.st index 29c95e1..30238ef 100644 --- a/repository/TiddlyWiki/Tiddler.class.st +++ b/repository/TiddlyWiki/Tiddler.class.st @@ -223,6 +223,30 @@ Tiddler >> importFedWikiPage: pageViewUrlString [ ^ STONJSON fromString: pageData retrieveContents ] +{ #category : #testing } +Tiddler >> isJavascript [ + + ^ self type = 'application/javascript' +] + +{ #category : #testing } +Tiddler >> isNilType [ + + ^ self type = nil +] + +{ #category : #testing } +Tiddler >> isShadow [ + + ^ self title beginsWith: '$:/' +] + +{ #category : #testing } +Tiddler >> isTW5Type [ + + ^ self type = 'text/vnd.tiddlywiki' +] + { #category : #utilities } Tiddler >> itemContentsStringFor: item into: stream [ stream diff --git a/repository/TiddlyWiki/TiddlyWiki.class.st b/repository/TiddlyWiki/TiddlyWiki.class.st index 732ab19..669a076 100644 --- a/repository/TiddlyWiki/TiddlyWiki.class.st +++ b/repository/TiddlyWiki/TiddlyWiki.class.st @@ -110,6 +110,22 @@ TiddlyWiki >> exportJSONSubtiddlers: subtiddlersCollection as: aName [ ^ MarkupFile exportAsFileOn: self file parent / aName, 'json' containing: (self jsonSubtiddlers: subtiddlersCollection) ] +{ #category : #accessing } +TiddlyWiki >> exportJSTiddlers [ + + | jsTiddlers jsNotShadow | + jsTiddlers := self tiddlers select: [ :each | each isJavascript ]. + jsNotShadow := jsTiddlers reject: [ :each | each isShadow ]. + ^ jsNotShadow do: [ :each | each exportSTONFileInto: 'tiddlers' ] +] + +{ #category : #accessing } +TiddlyWiki >> exportLargeTiddlers [ + + ^ self largeTiddlers do: [ :each | + each exportSTONFileInto: self largeTiddlersFolderName ]. +] + { #category : #accessing } TiddlyWiki >> exportSTONFiles [ @@ -135,6 +151,19 @@ TiddlyWiki >> exportSTONTiddlers: aCollection [ aCollection do: [:each | each exportSTONFile ] ] +{ #category : #accessing } +TiddlyWiki >> exportTW5Tiddlers [ + + | tw5Tiddlers tw5ExplicitTiddlers notShadowTiddlers | + tw5Tiddlers := self tiddlers select: [ :each | each isNilType ]. + tw5ExplicitTiddlers := self tiddlers select: [ :each | each isTW5Type ]. + + notShadowTiddlers := OrderedCollection new. + notShadowTiddlers addAll: (tw5ExplicitTiddlers reject: [ :each | each isShadow ]). + notShadowTiddlers addAll: (tw5Tiddlers reject: [ :each | each isShadow ]). + ^ notShadowTiddlers do: [ :each | each exportSTONFileInto: 'tiddlers' ] +] + { #category : #accessing } TiddlyWiki >> file [ ^ file @@ -206,6 +235,19 @@ TiddlyWiki >> jsonSubtiddlers: subtiddlersCollection [ ^ STONJSON toStringPretty: subtiddlersDict ] +{ #category : #accessing } +TiddlyWiki >> largeTiddlers [ + + | wikiImages wikiPDFs wikiLargeTiddlers | + wikiImages := self selectContentType: 'image/'. + wikiPDFs := self selectContentType: 'application/pdf'. + wikiLargeTiddlers := OrderedCollection new. + wikiLargeTiddlers + addAll: wikiImages; + addAll: wikiPDFs. + ^ wikiLargeTiddlers +] + { #category : #accessing } TiddlyWiki >> largeTiddlersFolder [ "I store all shadow tiddlers, i.e. tiddlers that provide functionality to TiddlyWiki,