Compare commits

..

12 Commits

2 changed files with 67 additions and 21 deletions

View File

@ -526,8 +526,13 @@ Tiddler >> rawAliasedLinks [
{ #category : #accessing } { #category : #accessing }
Tiddler >> rawLinks [ Tiddler >> rawLinks [
self text ifNil: [ ^ Set new ]. ^ self rawLinksIn: self text
^ (WikiTextGrammar new linkSea star parse: self text) asSet ]
{ #category : #accessing }
Tiddler >> rawLinksIn: aText [
aText ifNil: [ ^ Set new ].
^ (WikiTextGrammar new linkSea star parse: aText) asSet
] ]
{ #category : #accessing } { #category : #accessing }
@ -589,13 +594,25 @@ Tiddler >> tagsAsString [
^ response contents ^ response contents
] ]
{ #category : #accessing }
Tiddler >> tagsInBrackets [
| tagsInBrackets |
tagsInBrackets := self rawLinksIn: self tags.
^ tagsInBrackets
]
{ #category : #accessing } { #category : #accessing }
Tiddler >> tagsReformating [ Tiddler >> tagsReformating [
| response | | response sanitized |
self tags class ~= ByteString ifTrue: [ ^ self ]. self tags class ~= ByteString ifTrue: [ ^ self ].
response := Set new. response := Set new.
response add: self tags. sanitized := self tags.
self tags: response. self tagsInBrackets ifNotEmpty: [
self tagsInBrackets do: [:tag | sanitized := sanitized copyReplaceAll: tag with: ''. ].
sanitized := sanitized copyReplaceAll: '[[]] ' with: ''.
].
response addAll: (sanitized trimmed splitOn: Character space) asSet.
self tags: (response union: self tagsInBrackets).
] ]

View File

@ -54,6 +54,14 @@ TiddlyWiki class >> fromJSONUrl: anUrlString [
name: anUrlString name: anUrlString
] ]
{ #category : #accessing }
TiddlyWiki class >> fromMindMapFile: mindmapFile [
"mindmapFile is a FileReference to a Mind map created in Freeplane."
| mindMapXML mindMapNodes |
mindMapXML := (XMLDOMParser on: mindmapFile contents) parseDocument.
mindMapNodes := mindMapXML xpath: '//node'.
]
{ #category : #accessing } { #category : #accessing }
TiddlyWiki class >> loadFromLocalFolder: aFolder [ TiddlyWiki class >> loadFromLocalFolder: aFolder [
@ -228,6 +236,18 @@ TiddlyWiki >> downloadHTML [
^ self folder ^ self folder
] ]
{ #category : #accessing }
TiddlyWiki >> downloadLink: v into: subfolder [
| filePath fileName |
fileName := v asUrl segments last.
filePath := subfolder / fileName.
GtSubprocessWithInMemoryOutput new
shellCommand: 'curl -L -# ' , v asString, ' -o ' , filePath fullName;
runAndWait;
stdout.
^ filePath
]
{ #category : #accessing } { #category : #accessing }
TiddlyWiki >> exportCommonTiddlers [ TiddlyWiki >> exportCommonTiddlers [
@ -290,10 +310,11 @@ TiddlyWiki >> exportJSONFileOptimized [
exporter := wikiFolder / 'scripts' / 'exportJsonFile'. exporter := wikiFolder / 'scripts' / 'exportJsonFile'.
exporter exists ifFalse: [ self installJsonExporter ]. exporter exists ifFalse: [ self installJsonExporter ].
OSSUnixSubprocess new GtSubprocessWithInMemoryOutput new
command: exporter fullName; command: exporter fullName;
workingDirectory: exporter parent fullName; workingDirectory: exporter parent fullName;
runAndWaitOnExitDo: [ :process :outString | ^ self jsonFile ] runAndWait.
^ self jsonFile
] ]
{ #category : #accessing } { #category : #accessing }
@ -342,7 +363,7 @@ TiddlyWiki >> exportJSONTiddlersTagged: aTag in: aFolder named: aFileName [
| taggedTiddlers jsonString | | taggedTiddlers jsonString |
self tiddlers. self tiddlers.
taggedTiddlers := self taggedWith: aTag. taggedTiddlers := self tagWith: aTag.
jsonString := '[', (',' join: (taggedTiddlers collect: [ :each | each asJsonString ])), ']'. jsonString := '[', (',' join: (taggedTiddlers collect: [ :each | each asJsonString ])), ']'.
^ MarkupFile exportAsFileOn: aFolder / (aFileName, '.json') containing: jsonString ^ MarkupFile exportAsFileOn: aFolder / (aFileName, '.json') containing: jsonString
] ]
@ -528,22 +549,20 @@ TiddlyWiki >> importSTONFilesFrom: aFolder [
{ #category : #accessing } { #category : #accessing }
TiddlyWiki >> installJsonExporter [ TiddlyWiki >> installJsonExporter [
| folder | | subfolder |
folder := (self file parent / 'scripts') ensureCreateDirectory. subfolder := (self folder / 'scripts') ensureCreateDirectory.
ZnClient new ZnClient new
url: 'https://mutabit.com/repos.fossil/mutabit/uv/wiki/scripts/exportJsonFile'; url: 'https://mutabit.com/repos.fossil/mutabit/uv/wiki/scripts/exportJsonFile';
downloadTo: folder / 'exportJsonFile'. downloadTo: subfolder / 'exportJsonFile'.
ZnClient new ZnClient new
url: 'https://mutabit.com/repos.fossil/mutabit/doc/trunk/wiki/scripts/exportJsonFile.nim'; url: 'https://mutabit.com/repos.fossil/mutabit/doc/trunk/wiki/scripts/exportJsonFile.nim';
downloadTo: folder / 'exportJsonFile.nim'. downloadTo: subfolder / 'exportJsonFile.nim'.
OSSUnixSubprocess new ^ GtSubprocessWithInMemoryOutput new
command: 'chmod'; command: 'chmod +x ' , ((subfolder / 'exportJsonFile') fullName);
arguments: { '+x' . (folder / 'exportJsonFile') fullName }; workingDirectory: subfolder fullName;
workingDirectory: folder fullName; runAndWait;
redirectStdout; stdout
redirectStderr;
runAndWaitOnExitDo: [ :process :outString | ^ outString ]
] ]
{ #category : #accessing } { #category : #accessing }
@ -553,6 +572,12 @@ TiddlyWiki >> isInTiddlyHost [
^ self remote host endsWith: 'tiddlyhost.com' ^ self remote host endsWith: 'tiddlyhost.com'
] ]
{ #category : #accessing }
TiddlyWiki >> jsonCache [
self downloadLink: self tiddlersJSONUrl into: self folder.
^ (self folder / 'tiddlers.json') contents
]
{ #category : #accessing } { #category : #accessing }
TiddlyWiki >> jsonFile [ TiddlyWiki >> jsonFile [
^ jsonFile ifNil: [ ^ jsonFile ifNil: [
@ -851,8 +876,11 @@ TiddlyWiki >> remote: aUrlString [
{ #category : #accessing } { #category : #accessing }
TiddlyWiki >> remoteTiddlersContentsString [ TiddlyWiki >> remoteTiddlersContentsString [
| jsonAddress |
self isInTiddlyHost ifFalse: [ ^ self ]. self isInTiddlyHost ifFalse: [ ^ self ].
^ (self remote asString, '/tiddlers.json') asZnUrl retrieveContents. jsonAddress := self remote asString, '/tiddlers.json'.
^ [jsonAddress asZnUrl retrieveContents]
onErrorDo: [ self jsonCache ].
] ]
{ #category : #accessing } { #category : #accessing }
@ -938,7 +966,7 @@ TiddlyWiki >> syncRemoteLocalDestructive [
] ]
{ #category : #accessing } { #category : #accessing }
TiddlyWiki >> taggedWith: aTag [ TiddlyWiki >> tagWith: aTag [
^ self tiddlers select: [:tiddler | ^ self tiddlers select: [:tiddler |
tiddler tags isNotNil and: [tiddler tags includesSubstring: aTag ] tiddler tags isNotNil and: [tiddler tags includesSubstring: aTag ]
] ]
@ -1013,6 +1041,7 @@ TiddlyWiki >> tiddlersJSONFile [
{ #category : #accessing } { #category : #accessing }
TiddlyWiki >> tiddlersJSONUrl [ TiddlyWiki >> tiddlersJSONUrl [
self isInTiddlyHost ifTrue: [^ self remote / 'tiddlers.json' ].
self remote ifNil: [^ nil]. self remote ifNil: [^ nil].
] ]