Merge b5a7d079e2
This commit is contained in:
commit
d72f4df6fe
@ -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,57 @@ Tiddler >> deleteUid [
|
|||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
Tiddler >> downloadAndIndexMediaLinksInto: aFolder [
|
Tiddler >> downloadAndRelinkExternalMedia [
|
||||||
^ self customFieldsWithMediaLinks
|
| 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 }
|
{ #category : #accessing }
|
||||||
|
@ -260,12 +260,32 @@ 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.
|
||||||
^ MarkupFile exportAsFileOn: self jsonFile containing: rawJsonTiddlers
|
^ 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 }
|
{ #category : #accessing }
|
||||||
TiddlyWiki >> exportJSONFileOptimized [
|
TiddlyWiki >> exportJSONFileOptimized [
|
||||||
|
|
||||||
@ -500,8 +520,8 @@ TiddlyWiki >> importJSONLink [
|
|||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
TiddlyWiki >> importSTONFilesFrom: aFolder [
|
TiddlyWiki >> importSTONFilesFrom: aFolder [
|
||||||
| tiddlerFiles |
|
| tiddlerFiles |
|
||||||
self folder: aFolder parent.
|
self folder: aFolder.
|
||||||
tiddlerFiles := aFolder children
|
tiddlerFiles := (aFolder / 'tiddlers') children
|
||||||
select: [ :localFile | localFile basename endsWith: '.ston' ].
|
select: [ :localFile | localFile basename endsWith: '.ston' ].
|
||||||
self tiddlers: (tiddlerFiles collect: [ :each | | tempTiddler|
|
self tiddlers: (tiddlerFiles collect: [ :each | | tempTiddler|
|
||||||
tempTiddler := STON fromString: each contents.
|
tempTiddler := STON fromString: each contents.
|
||||||
@ -899,6 +919,11 @@ TiddlyWiki >> shadow [
|
|||||||
^ self tiddlers select: [:tiddler | tiddler title beginsWith: '$:/']
|
^ self tiddlers select: [:tiddler | tiddler title beginsWith: '$:/']
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #'as yet unclassified' }
|
||||||
|
TiddlyWiki >> substitutions [
|
||||||
|
^ self config at: 'substitutions' ifAbsentPut: [ Dictionary new].
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
TiddlyWiki >> syncRemoteLocalDestructive [
|
TiddlyWiki >> syncRemoteLocalDestructive [
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user