pass a UI to NAT entryProcessors
This commit is contained in:
@@ -7,7 +7,7 @@ import haxe.Json;
|
||||
|
||||
using haxe.io.Path;
|
||||
|
||||
typedef AttachmentProcessor = (Archive, Entry, Array<FileRef>) -> Dynamic;
|
||||
typedef AttachmentProcessor = (Archive, Entry, Array<FileRef>, ?ArchiveUI) -> Dynamic;
|
||||
|
||||
/**
|
||||
* Base System that processes Entries based on whether they have file attachments
|
||||
|
||||
@@ -12,5 +12,5 @@
|
||||
(return true)))
|
||||
false
|
||||
}
|
||||
->[archive e]
|
||||
(processor archive e (filter e.files ->file !(= -1 (extensions.indexOf (file.extension)))))))
|
||||
->[archive e &opt ui]
|
||||
(processor archive e (filter e.files ->file !(= -1 (extensions.indexOf (file.extension)))) ui)))
|
||||
@@ -3,7 +3,7 @@
|
||||
(defNew []
|
||||
(super
|
||||
["jpg" "jpeg" "png"]
|
||||
->[archive e imageFiles]
|
||||
->[archive e imageFiles &opt ui]
|
||||
(unless (hasComponent e Images)
|
||||
(addComponent archive e Images
|
||||
(object
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
(defNew []
|
||||
(super
|
||||
->[archive e] (hasComponent e Name)
|
||||
->[archive e] (let [name (readComponent e Name)]
|
||||
->[archive e &opt ui] (let [name (readComponent e Name)]
|
||||
(if (entriesByName.exists (name.toLowerCase))
|
||||
(.push (dictGet entriesByName (name.toLowerCase)) e)
|
||||
(dictSet entriesByName (name.toLowerCase) [e]))
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
(defNew []
|
||||
(super
|
||||
->[archive e] false
|
||||
->[archive e] null)
|
||||
->[archive e &opt ui] null)
|
||||
|
||||
~(#extern String js
|
||||
(object
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
1))
|
||||
|
||||
// named method in case a user will want to run it on selectedEntries instead of on media entries
|
||||
(method scrapeForImages [archive e]
|
||||
(method scrapeForImages [archive e &opt ui]
|
||||
(let [:String title
|
||||
(readComponent e Name)
|
||||
:Array<String> wikipediaImageUrls
|
||||
@@ -21,7 +21,9 @@
|
||||
(.urlDecode (url.withoutDirectory))
|
||||
// Some symbols shouldn't be decoded because they're invalid in file systems!
|
||||
"\"" "%22"))]
|
||||
// TODO do this with ui.displayMessage
|
||||
// TODO write a macro that either does both print and displayMessage if a ui is available
|
||||
(when ui
|
||||
(ui.displayMessage "Downloading $title image: $url"))
|
||||
(print url "downloading")
|
||||
(assertProcess "curl" ["--output" filePath url])
|
||||
filePath)))
|
||||
|
||||
Reference in New Issue
Block a user