Improving tiddlers filtering and exporting.
This commit is contained in:
parent
21e593707c
commit
a5759d886d
@ -145,11 +145,18 @@ Tiddler >> exportJSONFile [
|
||||
|
||||
{ #category : #accessing }
|
||||
Tiddler >> exportSTONFile [
|
||||
|
||||
self exportSTONFileInto: 'tiddlers'
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Tiddler >> exportSTONFileInto: subfolder [
|
||||
|
||||
| stonFile output dashedTitle sanitized date |
|
||||
dashedTitle := '-' join: (self title substrings collect: [ :each | each ]).
|
||||
sanitized := dashedTitle copyWithoutAll: #($¿ $? $! $¡ $/).
|
||||
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
|
||||
]
|
||||
|
||||
|
@ -80,6 +80,15 @@ TiddlyWiki >> contentTiddlers [
|
||||
^ 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 }
|
||||
TiddlyWiki >> exportJSONFile [
|
||||
| docTree rawJsonTiddlers |
|
||||
@ -91,7 +100,14 @@ TiddlyWiki >> exportJSONFile [
|
||||
|
||||
{ #category : #accessing }
|
||||
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 }
|
||||
@ -105,7 +121,7 @@ TiddlyWiki >> exportSTONFiles [
|
||||
stonFile := FileLocator temp / 'tiddlers.ston' ]
|
||||
ifNotNil: [
|
||||
stonFile := self tiddlersJSONFile withoutExtension , 'ston' ].
|
||||
shadowFile := self shadowsFolder / '_shadow.ston'.
|
||||
shadowFile := self largeTiddlersFolder / '_shadow.ston'.
|
||||
wikiTemp := self copy.
|
||||
wikiTemp tiddlers: self contentTiddlers.
|
||||
wikiTemp := wikiTemp withoutImages.
|
||||
@ -190,6 +206,24 @@ TiddlyWiki >> jsonSubtiddlers: subtiddlersCollection [
|
||||
^ 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 }
|
||||
TiddlyWiki >> loadFromConfig: wikiname [
|
||||
^ (self configDictonary at: wikiname) importJSONFile.
|
||||
@ -245,6 +279,17 @@ TiddlyWiki >> printOn: aStream [
|
||||
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 }
|
||||
TiddlyWiki >> remote [
|
||||
|
||||
@ -257,6 +302,12 @@ TiddlyWiki >> remote: aUrlString [
|
||||
remote := aUrlString asZnUrl
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
TiddlyWiki >> selectContentType: mimeType [
|
||||
|
||||
^ self tiddlers select: [ :tiddler | tiddler type isNotNil and: [tiddler type beginsWith: mimeType ]]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
TiddlyWiki >> shadow [
|
||||
"Shadow tiddlers are tiddlers that are loaded from plugins.
|
||||
@ -267,14 +318,6 @@ TiddlyWiki >> shadow [
|
||||
^ 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 }
|
||||
TiddlyWiki >> taggedWith: aTag [
|
||||
^ self tiddlers select: [:tiddler |
|
||||
|
Loading…
Reference in New Issue
Block a user