Creating exporter for specific tagged tiddlers in JSON format.
This commit is contained in:
parent
110b5460dd
commit
c8f819e8b9
@ -247,6 +247,16 @@ TiddlyWiki >> exportJSONFromRebuildedCommonTiddlers [
|
|||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
TiddlyWiki >> exportJSONFromTiddlersInSubfolder: subfolder [
|
||||||
|
|
||||||
|
| rebuildedTiddlersJSON dateNowString |
|
||||||
|
dateNowString := (DateAndTime now asLocalStringYMDHM copyReplaceAll: ':' with: '-') copyReplaceAll: ' ' with: '-'.
|
||||||
|
rebuildedTiddlersJSON := '[', (',' join: ((self rebuildTiddlersFromSubfolder: subfolder) collect: [ :each | each asJsonString ])), ']'.
|
||||||
|
^ MarkupFile exportAsFileOn: subfolder / 'rebuildedTiddlers', dateNowString, 'json' containing: rebuildedTiddlersJSON
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
TiddlyWiki >> exportJSONSubtiddlers: subtiddlersCollection [
|
TiddlyWiki >> exportJSONSubtiddlers: subtiddlersCollection [
|
||||||
|
|
||||||
@ -259,6 +269,23 @@ TiddlyWiki >> exportJSONSubtiddlers: subtiddlersCollection as: aName [
|
|||||||
^ MarkupFile exportAsFileOn: self file parent / aName, 'json' containing: (self jsonSubtiddlers: subtiddlersCollection)
|
^ MarkupFile exportAsFileOn: self file parent / aName, 'json' containing: (self jsonSubtiddlers: subtiddlersCollection)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
TiddlyWiki >> exportJSONTiddlersTagged: aTag in: aFolder [
|
||||||
|
|
||||||
|
| dateNowString |
|
||||||
|
dateNowString := (DateAndTime now asLocalStringYMDHM copyReplaceAll: ':' with: '-') copyReplaceAll: ' ' with: '-'.
|
||||||
|
self exportJSONTiddlersTagged: aTag in: aFolder named: (self name, '-', aTag, '-', dateNowString)
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
TiddlyWiki >> exportJSONTiddlersTagged: aTag in: aFolder named: aFileName [
|
||||||
|
|
||||||
|
| taggedTiddlers jsonString |
|
||||||
|
taggedTiddlers := self taggedWith: aTag.
|
||||||
|
jsonString := '[', (',' join: (taggedTiddlers collect: [ :each | each asJsonString ])), ']'.
|
||||||
|
^ MarkupFile exportAsFileOn: aFolder / (aFileName, '.json') containing: jsonString
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
TiddlyWiki >> exportJSTiddlers [
|
TiddlyWiki >> exportJSTiddlers [
|
||||||
|
|
||||||
@ -403,6 +430,7 @@ TiddlyWiki >> importJSONLink [
|
|||||||
| tiddlersJson |
|
| tiddlersJson |
|
||||||
tiddlersJson := (self remote asString, '/tiddlers.json') asUrl retrieveContents.
|
tiddlersJson := (self remote asString, '/tiddlers.json') asUrl retrieveContents.
|
||||||
jsonFile := self folder / 'tiddlers.json'.
|
jsonFile := self folder / 'tiddlers.json'.
|
||||||
|
self name; file.
|
||||||
MarkupFile exportAsFileOn: jsonFile containing: tiddlersJson.
|
MarkupFile exportAsFileOn: jsonFile containing: tiddlersJson.
|
||||||
^ self fromString: tiddlersJson
|
^ self fromString: tiddlersJson
|
||||||
]
|
]
|
||||||
@ -507,7 +535,6 @@ TiddlyWiki >> local: aFileRefence [
|
|||||||
TiddlyWiki >> name [
|
TiddlyWiki >> name [
|
||||||
| tempName suffix |
|
| tempName suffix |
|
||||||
name ifNotNil: [ ^ name ].
|
name ifNotNil: [ ^ name ].
|
||||||
self file ifNotNil: [ ^ name := self file basenameWithoutExtension ].
|
|
||||||
self remote ifNil: [ ^ name := nil ].
|
self remote ifNil: [ ^ name := nil ].
|
||||||
(self remote host endsWith: 'tiddlyhost.com')
|
(self remote host endsWith: 'tiddlyhost.com')
|
||||||
ifTrue: [ ^ name := (self remote host splitOn: '.') first ].
|
ifTrue: [ ^ name := (self remote host splitOn: '.') first ].
|
||||||
@ -568,6 +595,21 @@ TiddlyWiki >> rebuildTiddlers [
|
|||||||
^ stonTiddlers
|
^ stonTiddlers
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
TiddlyWiki >> rebuildTiddlersFromSubfolder: subfolder [
|
||||||
|
|
||||||
|
| stonTiddlers contentTiddlersFiles |
|
||||||
|
contentTiddlersFiles := subfolder children
|
||||||
|
select: [ :each | each basename endsWith: 'ston' ].
|
||||||
|
|
||||||
|
stonTiddlers := OrderedCollection new.
|
||||||
|
stonTiddlers
|
||||||
|
addAll: (contentTiddlersFiles
|
||||||
|
collect:[ :each | STONJSON fromString: each contents ]).
|
||||||
|
stonTiddlers collect: [ :tiddler | tiddler wiki: self ].
|
||||||
|
^ stonTiddlers
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
TiddlyWiki >> rebuildTiddlersJSON [
|
TiddlyWiki >> rebuildTiddlersJSON [
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user