diff --git a/projects/_standalone/pixabay-sourcer/src/pixabay_sourcer/Background.hx b/projects/_standalone/pixabay-sourcer/src/pixabay_sourcer/Background.hx index b56a9971..9d3d6602 100644 --- a/projects/_standalone/pixabay-sourcer/src/pixabay_sourcer/Background.hx +++ b/projects/_standalone/pixabay-sourcer/src/pixabay_sourcer/Background.hx @@ -4,6 +4,9 @@ import kiss.Prelude; import kiss_firefox.API; import haxe.Constraints; import pixabay_sourcer.Message; +import haxe.io.Path; +import js.html.File; +import js.html.URL; @:build(kiss.Kiss.build()) class Background { diff --git a/projects/_standalone/pixabay-sourcer/src/pixabay_sourcer/Background.kiss b/projects/_standalone/pixabay-sourcer/src/pixabay_sourcer/Background.kiss index f30818fe..fa8ea011 100644 --- a/projects/_standalone/pixabay-sourcer/src/pixabay_sourcer/Background.kiss +++ b/projects/_standalone/pixabay-sourcer/src/pixabay_sourcer/Background.kiss @@ -2,8 +2,18 @@ (API.browser.runtime.onMessage.addListener ->[:Message message sender sendResponse] (let [:Function sendResponse sendResponse] (case message - ((object type "download" data [url]) - // TODO awaitLet the DownloadItem and send a nativemessage with the path and credit info - (API.browser.downloads.download (objectWith [saveAs true] url))) + ((object type "download" data [imageInfo]) + // awaitLet the DownloadItem and make an object url with the source info + (awaitLet [dlItemId (API.browser.downloads.download (object saveAs true url imageInfo.largeImageURL)) + dlItems (API.browser.downloads.search (object id dlItemId))] + (let [dlItem (first dlItems) + fileName dlItem.filename + txtFileName "$(Path.withoutDirectory (Path.withoutExtension fileName)).txt" + txtContent "${imageInfo.pageURL}\t${imageInfo.user}\t${imageInfo.user_id}" + file (new File [txtContent] txtFileName) + txtUrl (URL.createObjectURL file)] + (awaitLet [txtDownloadId (API.browser.downloads.download (object url txtUrl filename txtFileName))] + (catch [e] (sendResponse e)) + (API.browser.downloads.show txtDownloadId))))) (never otherwise)) true))) diff --git a/projects/_standalone/pixabay-sourcer/src/pixabay_sourcer/Main_.kiss b/projects/_standalone/pixabay-sourcer/src/pixabay_sourcer/Main_.kiss index 4a0e8515..d4442a39 100644 --- a/projects/_standalone/pixabay-sourcer/src/pixabay_sourcer/Main_.kiss +++ b/projects/_standalone/pixabay-sourcer/src/pixabay_sourcer/Main_.kiss @@ -29,7 +29,8 @@ (request.send))) (function handleInfo [:Dynamic info] - (API.browser.runtime.sendMessage (object type "download" data [.largeImageURL (first info.hits)]))) + (awaitLet [response (API.browser.runtime.sendMessage (object type "download" data [(first info.hits)]))] + (print response))) (window.addEventListener "load" ->:Void diff --git a/projects/_standalone/pixabay-sourcer/src/pixabay_sourcer/Message.hx b/projects/_standalone/pixabay-sourcer/src/pixabay_sourcer/Message.hx index 18833d64..09559db4 100644 --- a/projects/_standalone/pixabay-sourcer/src/pixabay_sourcer/Message.hx +++ b/projects/_standalone/pixabay-sourcer/src/pixabay_sourcer/Message.hx @@ -2,5 +2,5 @@ package pixabay_sourcer; typedef Message = { type:String, - data:Array + data:Array }; \ No newline at end of file diff --git a/projects/_standalone/tig-spy/haxe_libraries/kiss.hxml b/projects/_standalone/tig-spy/haxe_libraries/kiss.hxml index a05db955..020869d1 100644 --- a/projects/_standalone/tig-spy/haxe_libraries/kiss.hxml +++ b/projects/_standalone/tig-spy/haxe_libraries/kiss.hxml @@ -1,12 +1,10 @@ -# @install: lix --silent download "gh://github.com/kiss-lang/kiss#a6c0cf88c6a02aa7845dca7c5c5025b915b78fbc" into kiss/0.0.1/github/a6c0cf88c6a02aa7845dca7c5c5025b915b78fbc -# @run: haxelib run-dir kiss "${HAXE_LIBCACHE}/kiss/0.0.1/github/a6c0cf88c6a02aa7845dca7c5c5025b915b78fbc" --lib haxe-strings -lib hscript --lib tink_json --lib tink_macro --lib tink_syntaxhub -lib uuid --cp ${HAXE_LIBCACHE}/kiss/0.0.1/github/a6c0cf88c6a02aa7845dca7c5c5025b915b78fbc/src/ +-lib tink_macro +-lib tink_json +-lib tink_syntaxhub +-lib haxe-strings +-cp C:/Users/natqu/repos/kiss/src/ -D kiss=0.0.1 --w -WUnusedPattern ---macro kiss.KissFrontend.use() \ No newline at end of file +C:/Users/natqu/repos/kiss/extraParams.hxml +--macro Sys.println("haxe_libraries/kiss.hxml:8: [Warning] Using dev version of library kiss") \ No newline at end of file