diff --git a/repository/TiddlyWiki/Tiddler.class.st b/repository/TiddlyWiki/Tiddler.class.st index 902297a..06fc91e 100644 --- a/repository/TiddlyWiki/Tiddler.class.st +++ b/repository/TiddlyWiki/Tiddler.class.st @@ -180,7 +180,7 @@ Tiddler >> customFieldsWithMediaLinks [ | response | response := OrderedDictionary new. self customFields keysAndValuesDo: [:k :v | - (v endsWithAnyOf: #('mp4' 'jpg' 'jpeg' 'png')) + (v endsWithAnyOf: #('mp4' 'wav' 'jpg' 'jpeg' 'png')) ifTrue: [response at: k put: v ] ]. ^ response @@ -192,8 +192,19 @@ Tiddler >> deleteUid [ ] { #category : #accessing } -Tiddler >> downloadAndIndexMediaLinksInto: aFolder [ - ^ self customFieldsWithMediaLinks +Tiddler >> downloadAndRelinkExternalMedia [ + 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 } diff --git a/repository/TiddlyWiki/TiddlyWiki.class.st b/repository/TiddlyWiki/TiddlyWiki.class.st index 7d77d8b..1830e8b 100644 --- a/repository/TiddlyWiki/TiddlyWiki.class.st +++ b/repository/TiddlyWiki/TiddlyWiki.class.st @@ -256,6 +256,7 @@ TiddlyWiki >> exportContentType: aMimeType [ { #category : #accessing } TiddlyWiki >> exportJSONFile [ | docTree rawJsonTiddlers | + self tiddlers isNotEmpty ifTrue: [^ self exportJSONFileFromTiddlers ]. self htmlFileExists. docTree := XMLHTMLParser parse: self file contents. rawJsonTiddlers := (docTree xpath: '//script[@class="tiddlywiki-tiddler-store"]') stringValue. @@ -264,6 +265,21 @@ TiddlyWiki >> exportJSONFile [ { #category : #accessing } 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 }