detached #2
@ -193,18 +193,56 @@ Tiddler >> deleteUid [
|
||||
|
||||
{ #category : #accessing }
|
||||
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 |
|
||||
(v endsWithAnyOf: #('mp4'))
|
||||
ifTrue: [ | fileName filePath |
|
||||
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.
|
||||
filePath := (FileLocator temp / fileName) fullName.
|
||||
semiFilePath := 'external/video/' , fileName.
|
||||
filePath := (self wiki folder / semiFilePath) fullName.
|
||||
GtSubprocessWithInMemoryOutput new
|
||||
shellCommand: 'curl -# ', v, ' -o ', filePath;
|
||||
shellCommand: 'curl -L -# ' , v , ' -o ' , filePath;
|
||||
runAndWait;
|
||||
stdout
|
||||
]
|
||||
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 }
|
||||
|
@ -516,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.
|
||||
@ -912,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