detached #2

Merged
Offray merged 4 commits from detached into master 2024-07-28 15:39:47 +00:00
2 changed files with 30 additions and 3 deletions
Showing only changes of commit 9663e41d22 - Show all commits

View File

@ -180,7 +180,7 @@ Tiddler >> customFieldsWithMediaLinks [
| response | | response |
response := OrderedDictionary new. response := OrderedDictionary new.
self customFields keysAndValuesDo: [:k :v | self customFields keysAndValuesDo: [:k :v |
(v endsWithAnyOf: #('mp4' 'jpg' 'jpeg' 'png')) (v endsWithAnyOf: #('mp4' 'wav' 'jpg' 'jpeg' 'png'))
ifTrue: [response at: k put: v ] ifTrue: [response at: k put: v ]
]. ].
^ response ^ response
@ -192,8 +192,19 @@ Tiddler >> deleteUid [
] ]
{ #category : #accessing } { #category : #accessing }
Tiddler >> downloadAndIndexMediaLinksInto: aFolder [ Tiddler >> downloadAndRelinkExternalMedia [
^ self customFieldsWithMediaLinks self customFieldsWithMediaLinks
keysAndValuesDo: [:k :v |
(v endsWithAnyOf: #('mp4'))
ifTrue: [ | fileName filePath |
fileName := v asUrl segments last.
filePath := (FileLocator temp / fileName) fullName.
GtSubprocessWithInMemoryOutput new
shellCommand: 'curl -# ', v, ' -o ', filePath;
runAndWait;
stdout
]
]
] ]
{ #category : #accessing } { #category : #accessing }

View File

@ -256,6 +256,7 @@ TiddlyWiki >> exportContentType: aMimeType [
{ #category : #accessing } { #category : #accessing }
TiddlyWiki >> exportJSONFile [ TiddlyWiki >> exportJSONFile [
| docTree rawJsonTiddlers | | docTree rawJsonTiddlers |
self tiddlers isNotEmpty ifTrue: [^ self exportJSONFileFromTiddlers ].
self htmlFileExists. self htmlFileExists.
docTree := XMLHTMLParser parse: self file contents. docTree := XMLHTMLParser parse: self file contents.
rawJsonTiddlers := (docTree xpath: '//script[@class="tiddlywiki-tiddler-store"]') stringValue. rawJsonTiddlers := (docTree xpath: '//script[@class="tiddlywiki-tiddler-store"]') stringValue.
@ -264,6 +265,21 @@ TiddlyWiki >> exportJSONFile [
{ #category : #accessing } { #category : #accessing }
TiddlyWiki >> exportJSONFileFromTiddlers [ TiddlyWiki >> exportJSONFileFromTiddlers [
| response |
response := '' writeStream.
response
nextPutAll: '['; cr.
self tiddlers allButLastDo: [:tiddler |
response
nextPutAll: tiddler asJsonString;
nextPutAll: ','; cr
].
response
nextPutAll: self tiddlers last asJsonString; cr;
nextPutAll: ']'; cr.
^ MarkupFile
exportAsFileOn: self folder / 'tiddlers.json'
containing: response contents
] ]
{ #category : #accessing } { #category : #accessing }