From 1bc2e313eb3d1acc8d1729eac5c0c966c6b0d0e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Sola?= Date: Fri, 18 Oct 2019 21:35:52 +0200 Subject: [PATCH 1/8] User own settings injection custom settings template creation --- conf.cust.example.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 conf.cust.example.js diff --git a/conf.cust.example.js b/conf.cust.example.js new file mode 100644 index 0000000..f50430d --- /dev/null +++ b/conf.cust.example.js @@ -0,0 +1,42 @@ +/* +Place for any custom settings/mappings (mostly documented on https://github.com/brookhong/Surfingkeys + */ + +// const { categories } = require("./help") +// mappings must go in this specific format +const maps = { + /* + define mappings in format: + "domain.com": [ // or just "general" + { + alias: "", // here keybinding + category: 0, // best from the categories requirement + description: "The description of the mapping", // self explanatory + // Now either of the: + map: "", // the key remapping, of: + callback: () => {} // the callback + } + ] + */ + +} +// note that every alias key has to be present in the maps keys +const aliases = { + /* + "domain.com": [ + "example.com" // also known as + ] + */ +} +// custom settings (for example: theme) +const conf = { + /* + theme: 'body: { bg-color: "black" }' + */ +} + +module.exports = { + maps, + aliases, + conf, +} From ac6853424577f3e1e412941d929253564a1b6d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Sola?= Date: Fri, 18 Oct 2019 21:36:21 +0200 Subject: [PATCH 2/8] User own settings injection custom settings template in gulpfile.js registration --- gulpfile.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index ddf0cba..aabf1e6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -37,7 +37,7 @@ const requireSrcFiles = () => { } const paths = { - scripts: ["conf.priv.js", "completions.js", "conf.js", "actions.js", "help.js", "keys.js", "util.js"], + scripts: ["conf.priv.js", "conf.cust.js", "completions.js", "conf.js", "actions.js", "help.js", "keys.js", "util.js"], entry: "conf.js", gulpfile: "gulpfile.js", readme: "README.tmpl.md", @@ -88,6 +88,17 @@ task("check-priv", async () => { return Promise.resolve() }) +task("check-cust", async () => { + try { + await fs.stat("./conf.cust.js") + } catch (e) { + // eslint-disable-next-line no-console + console.log("Notice: Initializing ./conf.cust.js - configure your custom settings & mappings here.") + return fs.copyFile("./conf.cust.example.js", "./conf.cust.js", COPYFILE_EXCL) + } + return Promise.resolve() +}) + task("docs", parallel(async () => { requireSrcFiles() @@ -236,6 +247,7 @@ task("build", series( parallel( "check-priv", + "check-cust", "clean", ), parallel( From e65cd279d6e92797753d21e93eae9c7c860ea357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Sola?= Date: Fri, 18 Oct 2019 21:37:31 +0200 Subject: [PATCH 3/8] User own settings injection custom settings injection into conf.js for settings merge --- conf.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conf.js b/conf.js index e2a5451..e094ca9 100644 --- a/conf.js +++ b/conf.js @@ -1,6 +1,7 @@ const util = require("./util") const keys = require("./keys") const completions = require("./completions") +const custom = require("./conf.cust") // ---- Settings ----// util.addSettings({ @@ -18,6 +19,8 @@ util.addSettings({ `, }) +util.addSettings(custom.conf || {}) + if (typeof Hints !== "undefined") { Hints.characters = "qwertasdfgzxcvb" } From 6563fcafda2c2607b5a326da5d1f104fa869dff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Sola?= Date: Fri, 18 Oct 2019 21:39:57 +0200 Subject: [PATCH 4/8] User own settings injection custom settings template in keys.js injectiono --- keys.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/keys.js b/keys.js index 4a59edd..d563e51 100644 --- a/keys.js +++ b/keys.js @@ -1,5 +1,6 @@ const actions = require("./actions") const { categories } = require("./help") +const custom = require("./conf.cust") // Remove undesired default mappings const unmaps = { @@ -608,6 +609,12 @@ const maps = { ], } +const customMaps = Object.entries(custom.maps || {}) + +customMaps.forEach((m) => { + maps[m[0]] = (maps[m[0]] || []).concat(m[1]) +}) + // Aliases const aliases = { "wikipedia.org": [ @@ -637,6 +644,8 @@ const aliases = { ], } +Object.assign(aliases, custom.aliases || {}) + module.exports = { unmaps, maps, From bf0a028f108920b705dd428001f9c520008416aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Sola?= Date: Fri, 18 Oct 2019 22:17:46 +0200 Subject: [PATCH 5/8] User own settings injection add another build step into documentation --- README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b8359e2..b5d0e90 100644 --- a/README.md +++ b/README.md @@ -604,8 +604,23 @@ Building `surfingkeys-conf` requires a few dependencies to be installed: ```shell $ vim ./conf.priv.js ``` + +4. __*(Optional)* Own Custom Mappings & Settings Configuration__ + Own custom settings & mappings can be placed in one file without touching + the core files. + Copy the example custom configuration: -4. __Gulp Build/Install__ + ```shell + $ cp ./conf.cust.example.js ./conf.cust.js + ``` + + Open `./conf.cust.js` in your favorite editor and follow the instructions inside: + + ```shell + $ vim ./conf.cust.js + ``` + +5. __Gulp Build/Install__ ```shell $ gulp install # OR "gulp build" to build to ./build/surfingkeys.js without installing ``` @@ -613,7 +628,7 @@ Building `surfingkeys-conf` requires a few dependencies to be installed: This will build the final configuration file and place it at `~/.config/surfingkeys.js`. If you already have a file in that location, make sure you back it up first! -5. __Load your configuration into the SurfingKeys Extension__ +6. __Load your configuration into the SurfingKeys Extension__
Option A (recommended): Configure SurfingKeys to automatically load configuration file from disk From 57626336727ddc03666748894438cae897859944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Sola?= Date: Fri, 18 Oct 2019 22:21:01 +0200 Subject: [PATCH 6/8] User own settings injection add the cust.js file to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a301e4d..0b939ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.priv.js +*.cust.js ### Node ### # Logs From 3af9bd76768ca0408b19b3b34856454a9a7b6ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Sola?= Date: Mon, 21 Oct 2019 21:03:45 +0200 Subject: [PATCH 7/8] User own settings injection add leaders and hints custom configurations --- conf.cust.example.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/conf.cust.example.js b/conf.cust.example.js index f50430d..94cd3af 100644 --- a/conf.cust.example.js +++ b/conf.cust.example.js @@ -35,8 +35,20 @@ const conf = { */ } +// miscellanous entries +const leaders = { + /* + site: "", + search: "", + */ +} + +const hints = "" + module.exports = { maps, aliases, conf, + leaders, + hints } From 6cfb056d79422f3983a9646b8ef95c27d5523de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Sola?= Date: Mon, 21 Oct 2019 21:04:53 +0200 Subject: [PATCH 8/8] User own settings injection inject the leaders and hints settings into conf.js --- conf.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf.js b/conf.js index e094ca9..22c3159 100644 --- a/conf.js +++ b/conf.js @@ -22,14 +22,14 @@ util.addSettings({ util.addSettings(custom.conf || {}) if (typeof Hints !== "undefined") { - Hints.characters = "qwertasdfgzxcvb" + Hints.characters = custom.hints || "qwertasdfgzxcvb" } // Leader for site-specific mappings -const siteleader = "" +const siteleader = custom.leaders.site || "" // Leader for OmniBar searchEngines -const searchleader = "a" +const searchleader = custom.leaders.search || "a" // Process mappings and completions // See ./keys.js and ./completions.js