restructure for multiple supported source sites

This commit is contained in:
2023-06-06 13:46:40 -06:00
parent 25811da4b5
commit 27662277f7
12 changed files with 32 additions and 26 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,4 @@
node_modules/ node_modules/
externs/ externs/
bin/
*.zip

4
.haxerc Normal file
View File

@@ -0,0 +1,4 @@
{
"version": "4.3.1",
"resolveLibs": "scoped"
}

View File

@@ -4,9 +4,9 @@
-cp src -cp src
-dce full -dce full
--each --each
--main pixabay_sourcer.Main --main hollywoo_sourcer.PixabayMain
--js bin/main.js --js bin/pixabay.js
--next --next
--main pixabay_sourcer.Background --main hollywoo_sourcer.Background
--js bin/background.js --js bin/background.js
-cmd cp node_modules/webextension-polyfill/dist/browser-polyfill.js* bin/ && zip -r template.zip . -x *.git* -x *.hxml -x *.zip -x src/\* -x node_modules/\* -x libs/\* -x test.sh -cmd cp node_modules/webextension-polyfill/dist/browser-polyfill.js* bin/ && zip -r hollywoo-sourcer.zip . -x *.git* -x *.hxml -x *.zip -x src/\* -x node_modules/\* -x libs/\* -x test.sh

View File

@@ -1,5 +1,5 @@
# @install: lix --silent download "haxelib:/haxe-strings#7.0.2" into haxe-strings/7.0.2/haxelib # @install: lix --silent download "haxelib:/haxe-strings#7.0.3" into haxe-strings/7.0.3/haxelib
-cp ${HAXE_LIBCACHE}/haxe-strings/7.0.2/haxelib/src/ -cp ${HAXE_LIBCACHE}/haxe-strings/7.0.3/haxelib/src/
-D haxe-strings=7.0.2 -D haxe-strings=7.0.3
--macro hx.strings.internal.Macros.addDefines() --macro hx.strings.internal.Macros.addDefines()
--macro hx.strings.internal.Macros.configureNullSafety() --macro hx.strings.internal.Macros.configureNullSafety()

View File

@@ -1,12 +1,12 @@
# @install: lix --silent download "gh://github.com/kiss-lang/kiss#a6c0cf88c6a02aa7845dca7c5c5025b915b78fbc" into kiss/0.0.1/github/a6c0cf88c6a02aa7845dca7c5c5025b915b78fbc # @install: lix --silent download "gh://github.com/kiss-lang/kiss#d46e386972dd893a690fd20427613bd9dca5a60d" into kiss/0.0.1/github/d46e386972dd893a690fd20427613bd9dca5a60d
# @run: haxelib run-dir kiss "${HAXE_LIBCACHE}/kiss/0.0.1/github/a6c0cf88c6a02aa7845dca7c5c5025b915b78fbc" # @run: haxelib run-dir kiss "${HAXE_LIBCACHE}/kiss/0.0.1/github/d46e386972dd893a690fd20427613bd9dca5a60d"
-lib haxe-strings -lib haxe-strings
-lib hscript -lib hscript
-lib tink_json -lib tink_json
-lib tink_macro -lib tink_macro
-lib tink_syntaxhub -lib tink_syntaxhub
-lib uuid -lib uuid
-cp ${HAXE_LIBCACHE}/kiss/0.0.1/github/a6c0cf88c6a02aa7845dca7c5c5025b915b78fbc/src/ -cp ${HAXE_LIBCACHE}/kiss/0.0.1/github/d46e386972dd893a690fd20427613bd9dca5a60d/src
-D kiss=0.0.1 -D kiss=0.0.1
-w -WUnusedPattern -w -WUnusedPattern
--macro kiss.KissFrontend.use() --macro kiss.KissFrontend.use()

View File

@@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "pixabay-sourcer", "name": "hollywoo-sourcer",
"version": "0.0", "version": "0.0",
"description": "", "description": "",
@@ -11,8 +11,8 @@
}, },
"content_scripts": [ "content_scripts": [
{ {
"matches": ["https://pixabay.com/photos/*/"], "matches": ["https://pixabay.com/*/*/"],
"js": ["bin/browser-polyfill.js", "bin/main.js"] "js": ["bin/browser-polyfill.js", "bin/pixabay.js"]
} }
], ],
"background": { "background": {

View File

@@ -1,9 +1,9 @@
package pixabay_sourcer; package hollywoo_sourcer;
import kiss.Prelude; import kiss.Prelude;
import kiss_firefox.API; import kiss_firefox.API;
import haxe.Constraints; import haxe.Constraints;
import pixabay_sourcer.Message; import hollywoo_sourcer.Message;
import haxe.io.Path; import haxe.io.Path;
import js.html.File; import js.html.File;
import js.html.URL; import js.html.URL;

View File

@@ -2,7 +2,7 @@
(API.browser.runtime.onMessage.addListener ->[:Message message sender sendResponse] (API.browser.runtime.onMessage.addListener ->[:Message message sender sendResponse]
(let [:Function sendResponse sendResponse] (let [:Function sendResponse sendResponse]
(case message (case message
((object type "download" data [imageInfo]) ((object type "downloadPixabay" data [imageInfo])
// awaitLet the DownloadItem and make an object url with the source info // awaitLet the DownloadItem and make an object url with the source info
(awaitLet [dlItemId (API.browser.downloads.download (object saveAs true url imageInfo.largeImageURL)) (awaitLet [dlItemId (API.browser.downloads.download (object saveAs true url imageInfo.largeImageURL))
dlItems (API.browser.downloads.search (object id dlItemId))] dlItems (API.browser.downloads.search (object id dlItemId))]

View File

@@ -1,4 +1,4 @@
package pixabay_sourcer; package hollywoo_sourcer;
typedef Message = { typedef Message = {
type:String, type:String,

View File

@@ -0,0 +1,7 @@
package hollywoo_sourcer;
class PixabayMain {
static function main() {
PixabayMain_.main();
}
}

View File

@@ -1,7 +1,7 @@
(import kiss_firefox.API) (import kiss_firefox.API)
(import js.lib.Promise) (import js.lib.Promise)
(importAs js.html.XMLHttpRequest XHR) (importAs js.html.XMLHttpRequest XHR)
(import pixabay_sourcer.Message) (import hollywoo_sourcer.Message)
(var :Dynamic document js.Lib.global.document) (var :Dynamic document js.Lib.global.document)
(var :Dynamic window js.Lib.global.window) (var :Dynamic window js.Lib.global.window)
@@ -29,7 +29,7 @@
(request.send))) (request.send)))
(function handleInfo [:Dynamic info] (function handleInfo [:Dynamic info]
(awaitLet [response (API.browser.runtime.sendMessage (object type "download" data [(first info.hits)]))] (awaitLet [response (API.browser.runtime.sendMessage (object type "downloadPixabay" data [(first info.hits)]))]
(print response))) (print response)))
(window.addEventListener "load" (window.addEventListener "load"

View File

@@ -1,7 +0,0 @@
package pixabay_sourcer;
class Main {
static function main() {
Main_.main();
}
}