Improving tiddlers filtering and exporting.
This commit is contained in:
parent
21e593707c
commit
a5759d886d
@ -145,11 +145,18 @@ Tiddler >> exportJSONFile [
|
|||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
Tiddler >> exportSTONFile [
|
Tiddler >> exportSTONFile [
|
||||||
|
|
||||||
|
self exportSTONFileInto: 'tiddlers'
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
Tiddler >> exportSTONFileInto: subfolder [
|
||||||
|
|
||||||
| stonFile output dashedTitle sanitized date |
|
| stonFile output dashedTitle sanitized date |
|
||||||
dashedTitle := '-' join: (self title substrings collect: [ :each | each ]).
|
dashedTitle := '-' join: (self title substrings collect: [ :each | each ]).
|
||||||
sanitized := dashedTitle copyWithoutAll: #($¿ $? $! $¡ $/).
|
sanitized := dashedTitle copyWithoutAll: #($¿ $? $! $¡ $/).
|
||||||
date := self created hash hex copyFrom: 1 to: 5.
|
date := self created hash hex copyFrom: 1 to: 5.
|
||||||
stonFile := self wiki file parent / 'tiddlers' / (sanitized, '--', date, '.ston').
|
stonFile := self wiki file parent / subfolder / (sanitized, '--', date, '.ston').
|
||||||
^ MarkupFile exportAsFileOn: stonFile containing: self asStonStringPretty
|
^ MarkupFile exportAsFileOn: stonFile containing: self asStonStringPretty
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -80,6 +80,15 @@ TiddlyWiki >> contentTiddlers [
|
|||||||
^ self tiddlers copyWithoutAll: self shadow
|
^ self tiddlers copyWithoutAll: self shadow
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
TiddlyWiki >> exportContentType: aMimeType [
|
||||||
|
|
||||||
|
| filteredTiddlers tempWiki |
|
||||||
|
filteredTiddlers := self selectContentType: aMimeType.
|
||||||
|
filteredTiddlers do: [ :each | each exportSTONFileInto: self largeTiddlersFolderName ].
|
||||||
|
^ self largeTiddlersFolder
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
TiddlyWiki >> exportJSONFile [
|
TiddlyWiki >> exportJSONFile [
|
||||||
| docTree rawJsonTiddlers |
|
| docTree rawJsonTiddlers |
|
||||||
@ -91,7 +100,14 @@ TiddlyWiki >> exportJSONFile [
|
|||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
TiddlyWiki >> exportJSONSubtiddlers: subtiddlersCollection [
|
TiddlyWiki >> exportJSONSubtiddlers: subtiddlersCollection [
|
||||||
^ MarkupFile exportAsFileOn: self file parent / 'subtiddlers.json' containing: (self jsonSubtiddlers: subtiddlersCollection)
|
|
||||||
|
^ self exportJSONSubtiddlers: subtiddlersCollection as: 'subtiddlers'
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
TiddlyWiki >> exportJSONSubtiddlers: subtiddlersCollection as: aName [
|
||||||
|
|
||||||
|
^ MarkupFile exportAsFileOn: self file parent / aName, 'json' containing: (self jsonSubtiddlers: subtiddlersCollection)
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
@ -105,7 +121,7 @@ TiddlyWiki >> exportSTONFiles [
|
|||||||
stonFile := FileLocator temp / 'tiddlers.ston' ]
|
stonFile := FileLocator temp / 'tiddlers.ston' ]
|
||||||
ifNotNil: [
|
ifNotNil: [
|
||||||
stonFile := self tiddlersJSONFile withoutExtension , 'ston' ].
|
stonFile := self tiddlersJSONFile withoutExtension , 'ston' ].
|
||||||
shadowFile := self shadowsFolder / '_shadow.ston'.
|
shadowFile := self largeTiddlersFolder / '_shadow.ston'.
|
||||||
wikiTemp := self copy.
|
wikiTemp := self copy.
|
||||||
wikiTemp tiddlers: self contentTiddlers.
|
wikiTemp tiddlers: self contentTiddlers.
|
||||||
wikiTemp := wikiTemp withoutImages.
|
wikiTemp := wikiTemp withoutImages.
|
||||||
@ -190,6 +206,24 @@ TiddlyWiki >> jsonSubtiddlers: subtiddlersCollection [
|
|||||||
^ STONJSON toStringPretty: subtiddlersDict
|
^ STONJSON toStringPretty: subtiddlersDict
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
TiddlyWiki >> largeTiddlersFolder [
|
||||||
|
"I store all shadow tiddlers, i.e. tiddlers that provide functionality to TiddlyWiki,
|
||||||
|
for example the ones that come in the plugins or in system tiddlers.
|
||||||
|
For more information about shadow tiddlers, see #shadow method."
|
||||||
|
|
||||||
|
| folder |
|
||||||
|
folder := self file parent / self largeTiddlersFolderName.
|
||||||
|
folder ensureCreateDirectory.
|
||||||
|
^ folder
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
TiddlyWiki >> largeTiddlersFolderName [
|
||||||
|
|
||||||
|
^ 'largeTiddlers'
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
TiddlyWiki >> loadFromConfig: wikiname [
|
TiddlyWiki >> loadFromConfig: wikiname [
|
||||||
^ (self configDictonary at: wikiname) importJSONFile.
|
^ (self configDictonary at: wikiname) importJSONFile.
|
||||||
@ -245,6 +279,17 @@ TiddlyWiki >> printOn: aStream [
|
|||||||
nextPutAll: '( ', self name ,' )'
|
nextPutAll: '( ', self name ,' )'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
TiddlyWiki >> rebuildTiddlersJSON [
|
||||||
|
|
||||||
|
| stonTiddlers stonTiddlerFiles |
|
||||||
|
stonTiddlerFiles := self tiddlersFolder asFileReference children
|
||||||
|
select: [ :each | each fullName endsWith: 'ston' ].
|
||||||
|
stonTiddlers := stonTiddlerFiles collect: [ :each | STON fromString: each contents ].
|
||||||
|
self tiddlers: stonTiddlers.
|
||||||
|
^ self exportJSONSubtiddlers: self tiddlers as: 'rebuildedTiddlers'.
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
TiddlyWiki >> remote [
|
TiddlyWiki >> remote [
|
||||||
|
|
||||||
@ -257,6 +302,12 @@ TiddlyWiki >> remote: aUrlString [
|
|||||||
remote := aUrlString asZnUrl
|
remote := aUrlString asZnUrl
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
TiddlyWiki >> selectContentType: mimeType [
|
||||||
|
|
||||||
|
^ self tiddlers select: [ :tiddler | tiddler type isNotNil and: [tiddler type beginsWith: mimeType ]]
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
TiddlyWiki >> shadow [
|
TiddlyWiki >> shadow [
|
||||||
"Shadow tiddlers are tiddlers that are loaded from plugins.
|
"Shadow tiddlers are tiddlers that are loaded from plugins.
|
||||||
@ -267,14 +318,6 @@ TiddlyWiki >> shadow [
|
|||||||
^ self tiddlers select: [:tiddler | tiddler title beginsWith: '$:/']
|
^ self tiddlers select: [:tiddler | tiddler title beginsWith: '$:/']
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
|
||||||
TiddlyWiki >> shadowsFolder [
|
|
||||||
"I store all shadow tiddlers, i.e. tiddlers that provide functionality to TiddlyWiki,
|
|
||||||
for example the ones that come in the plugins or in system tiddlers.
|
|
||||||
For more information about shadow tiddlers, see #shadow method."
|
|
||||||
^ self file parent / 'shadow'
|
|
||||||
]
|
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
TiddlyWiki >> taggedWith: aTag [
|
TiddlyWiki >> taggedWith: aTag [
|
||||||
^ self tiddlers select: [:tiddler |
|
^ self tiddlers select: [:tiddler |
|
||||||
|
Loading…
Reference in New Issue
Block a user