Compare commits

..

12 Commits

2 changed files with 67 additions and 21 deletions

View File

@ -526,8 +526,13 @@ Tiddler >> rawAliasedLinks [
{ #category : #accessing }
Tiddler >> rawLinks [
self text ifNil: [ ^ Set new ].
^ (WikiTextGrammar new linkSea star parse: self text) asSet
^ self rawLinksIn: self text
]
{ #category : #accessing }
Tiddler >> rawLinksIn: aText [
aText ifNil: [ ^ Set new ].
^ (WikiTextGrammar new linkSea star parse: aText) asSet
]
{ #category : #accessing }
@ -589,13 +594,25 @@ Tiddler >> tagsAsString [
^ response contents
]
{ #category : #accessing }
Tiddler >> tagsInBrackets [
| tagsInBrackets |
tagsInBrackets := self rawLinksIn: self tags.
^ tagsInBrackets
]
{ #category : #accessing }
Tiddler >> tagsReformating [
| response |
| response sanitized |
self tags class ~= ByteString ifTrue: [ ^ self ].
response := Set new.
response add: self tags.
self tags: response.
sanitized := self tags.
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
]
{ #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 }
TiddlyWiki class >> loadFromLocalFolder: aFolder [
@ -228,6 +236,18 @@ TiddlyWiki >> downloadHTML [
^ 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 }
TiddlyWiki >> exportCommonTiddlers [
@ -290,10 +310,11 @@ TiddlyWiki >> exportJSONFileOptimized [
exporter := wikiFolder / 'scripts' / 'exportJsonFile'.
exporter exists ifFalse: [ self installJsonExporter ].
OSSUnixSubprocess new
GtSubprocessWithInMemoryOutput new
command: exporter fullName;
workingDirectory: exporter parent fullName;
runAndWaitOnExitDo: [ :process :outString | ^ self jsonFile ]
runAndWait.
^ self jsonFile
]
{ #category : #accessing }
@ -342,7 +363,7 @@ TiddlyWiki >> exportJSONTiddlersTagged: aTag in: aFolder named: aFileName [
| taggedTiddlers jsonString |
self tiddlers.
taggedTiddlers := self taggedWith: aTag.
taggedTiddlers := self tagWith: aTag.
jsonString := '[', (',' join: (taggedTiddlers collect: [ :each | each asJsonString ])), ']'.
^ MarkupFile exportAsFileOn: aFolder / (aFileName, '.json') containing: jsonString
]
@ -528,22 +549,20 @@ TiddlyWiki >> importSTONFilesFrom: aFolder [
{ #category : #accessing }
TiddlyWiki >> installJsonExporter [
| folder |
folder := (self file parent / 'scripts') ensureCreateDirectory.
| subfolder |
subfolder := (self folder / 'scripts') ensureCreateDirectory.
ZnClient new
url: 'https://mutabit.com/repos.fossil/mutabit/uv/wiki/scripts/exportJsonFile';
downloadTo: folder / 'exportJsonFile'.
downloadTo: subfolder / 'exportJsonFile'.
ZnClient new
url: 'https://mutabit.com/repos.fossil/mutabit/doc/trunk/wiki/scripts/exportJsonFile.nim';
downloadTo: folder / 'exportJsonFile.nim'.
downloadTo: subfolder / 'exportJsonFile.nim'.
OSSUnixSubprocess new
command: 'chmod';
arguments: { '+x' . (folder / 'exportJsonFile') fullName };
workingDirectory: folder fullName;
redirectStdout;
redirectStderr;
runAndWaitOnExitDo: [ :process :outString | ^ outString ]
^ GtSubprocessWithInMemoryOutput new
command: 'chmod +x ' , ((subfolder / 'exportJsonFile') fullName);
workingDirectory: subfolder fullName;
runAndWait;
stdout
]
{ #category : #accessing }
@ -553,6 +572,12 @@ TiddlyWiki >> isInTiddlyHost [
^ self remote host endsWith: 'tiddlyhost.com'
]
{ #category : #accessing }
TiddlyWiki >> jsonCache [
self downloadLink: self tiddlersJSONUrl into: self folder.
^ (self folder / 'tiddlers.json') contents
]
{ #category : #accessing }
TiddlyWiki >> jsonFile [
^ jsonFile ifNil: [
@ -851,8 +876,11 @@ TiddlyWiki >> remote: aUrlString [
{ #category : #accessing }
TiddlyWiki >> remoteTiddlersContentsString [
| jsonAddress |
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 }
@ -938,7 +966,7 @@ TiddlyWiki >> syncRemoteLocalDestructive [
]
{ #category : #accessing }
TiddlyWiki >> taggedWith: aTag [
TiddlyWiki >> tagWith: aTag [
^ self tiddlers select: [:tiddler |
tiddler tags isNotNil and: [tiddler tags includesSubstring: aTag ]
]
@ -1013,6 +1041,7 @@ TiddlyWiki >> tiddlersJSONFile [
{ #category : #accessing }
TiddlyWiki >> tiddlersJSONUrl [
self isInTiddlyHost ifTrue: [^ self remote / 'tiddlers.json' ].
self remote ifNil: [^ nil].
]