detached #2
@ -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,57 @@ Tiddler >> deleteUid [
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Tiddler >> downloadAndIndexMediaLinksInto: aFolder [
|
||||
^ self customFieldsWithMediaLinks
|
||||
Tiddler >> downloadAndRelinkExternalMedia [
|
||||
| mediaExtensions|
|
||||
mediaExtensions := Dictionary new
|
||||
at: 'audio' put: #('wav');
|
||||
at: 'video' put: #('mp4');
|
||||
at: 'image' put: #('jpg' 'jpeg' 'png');
|
||||
yourself.
|
||||
self customFieldsWithMediaLinks
|
||||
keysAndValuesDo: [ :k :v |
|
||||
mediaExtensions keysAndValuesDo: [:kind :extensions |
|
||||
(v asLowercase endsWithAnyOf: extensions)
|
||||
ifTrue: [ | localFile|
|
||||
self downloadLink: v for: k into: 'external/', kind , '/'.
|
||||
localFile := (self wiki substitutions at: self title at: k) second.
|
||||
self customFields at: k put: localFile.
|
||||
]
|
||||
]
|
||||
].
|
||||
^ self wiki substitutions
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Tiddler >> downloadLink: v for: k [
|
||||
| filePath fileName semiFilePath |
|
||||
fileName := v asUrl segments last.
|
||||
semiFilePath := 'external/video/' , fileName.
|
||||
filePath := (self wiki folder / semiFilePath) fullName.
|
||||
GtSubprocessWithInMemoryOutput new
|
||||
shellCommand: 'curl -L -# ' , v , ' -o ' , filePath;
|
||||
runAndWait;
|
||||
stdout.
|
||||
^ Dictionary new
|
||||
at: k
|
||||
put: {v.
|
||||
semiFilePath};
|
||||
yourself
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Tiddler >> downloadLink: v for: k into: subfolder [
|
||||
| filePath fileName semiFilePath |
|
||||
fileName := v asUrl segments last.
|
||||
semiFilePath := subfolder , fileName.
|
||||
filePath := (self wiki folder / semiFilePath) fullName.
|
||||
GtSubprocessWithInMemoryOutput new
|
||||
shellCommand: 'curl -L -# ' , v , ' -o ' , filePath;
|
||||
runAndWait;
|
||||
stdout.
|
||||
^ self wiki substitutions
|
||||
at: self title at: k put: {v. semiFilePath};
|
||||
yourself
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
@ -256,12 +256,32 @@ 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.
|
||||
^ MarkupFile exportAsFileOn: self jsonFile containing: rawJsonTiddlers
|
||||
]
|
||||
|
||||
{ #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 }
|
||||
TiddlyWiki >> exportJSONFileOptimized [
|
||||
|
||||
@ -496,8 +516,8 @@ TiddlyWiki >> importJSONLink [
|
||||
{ #category : #accessing }
|
||||
TiddlyWiki >> importSTONFilesFrom: aFolder [
|
||||
| tiddlerFiles |
|
||||
self folder: aFolder parent.
|
||||
tiddlerFiles := aFolder children
|
||||
self folder: aFolder.
|
||||
tiddlerFiles := (aFolder / 'tiddlers') children
|
||||
select: [ :localFile | localFile basename endsWith: '.ston' ].
|
||||
self tiddlers: (tiddlerFiles collect: [ :each | | tempTiddler|
|
||||
tempTiddler := STON fromString: each contents.
|
||||
@ -892,6 +912,11 @@ TiddlyWiki >> shadow [
|
||||
^ self tiddlers select: [:tiddler | tiddler title beginsWith: '$:/']
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
TiddlyWiki >> substitutions [
|
||||
^ self config at: 'substitutions' ifAbsentPut: [ Dictionary new].
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
TiddlyWiki >> syncRemoteLocalDestructive [
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user