From 2cf4a57bf4ddcd9f2987c5f6b8cb4491585c0089 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 29 Jan 2018 17:19:42 -0500 Subject: [PATCH] first draft toward fixing #30 --- src/_locales/en/messages.json | 22 +- src/background.html | 1 + src/css/dashboard-common.css | 2 +- src/css/hosts-files.css | 40 ++- src/css/popup.css | 102 ++++--- src/css/user-rules.css | 1 - src/hosts-files.html | 27 +- src/js/assets.js | 28 +- src/js/background.js | 10 +- src/js/hosts-files.js | 210 ++++++++------ src/js/messaging.js | 77 ++--- src/js/popup.js | 143 +++++++++- src/js/recipe-manager.js | 217 ++++++++++++++ src/js/start.js | 1 + src/js/storage.js | 513 +++++++++++++++++++++++----------- src/js/usersettings.js | 6 +- src/js/utils.js | 31 +- src/popup.html | 60 ++-- tools/make-assets.sh | 5 +- 19 files changed, 1076 insertions(+), 420 deletions(-) create mode 100644 src/js/recipe-manager.js diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 5ac5b93..c25ff0f 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -32,7 +32,7 @@ "description": "a tab in dashboard" }, "ubiquitousRulesPageName" : { - "message": "Hosts files", + "message": "Assets", "description": "a tab in dashboard" }, "rawSettingsPageName": { @@ -479,6 +479,10 @@ }, + "assetsHostsSection" : { + "message": "Hosts files", + "description": "header to identify the hosts files section" + }, "hostsFilesPrompt" : { "message": "All hostnames in a hosts file are loaded as blacklisted hostnames in the global scope.", "description": "" @@ -500,7 +504,7 @@ "description": "" }, "hostsFilesAutoUpdatePrompt":{ - "message":"Auto-update hosts files.", + "message":"Auto-update assets.", "description":"" }, "hostsFilesUpdateNow":{ @@ -512,7 +516,7 @@ "description":"" }, "hostsFilesExternalListsHint":{ - "message":"One URL per line. Lines prefixed with ‘#’ will be ignored. Invalid URLs will be silently ignored.", + "message":"Import external assets here:\nOne URL per line; invalid URLs will be silently ignored.", "description":"" }, "hostsFilesExternalListsParse":{ @@ -531,6 +535,18 @@ "message":"outdated", "description":"" }, + "assetsRecipesSection" : { + "message": "Ruleset recipes", + "description": "header to identify the ruleset files section" + }, + "assetsRecipesSummary" : { + "message": "Ruleset recipes are imported from the popup panel on demand, i.e. only through user interaction.", + "description": "" + }, + "assetsImportLabel" : { + "message": "Import...", + "description": "" + }, "rawSettingsWarning" : { "message": "Warning! Change these raw configuration settings at your own risk.", diff --git a/src/background.html b/src/background.html index a6e8a1e..6826e6f 100644 --- a/src/background.html +++ b/src/background.html @@ -16,6 +16,7 @@ + diff --git a/src/css/dashboard-common.css b/src/css/dashboard-common.css index 59e24e4..42ae34a 100644 --- a/src/css/dashboard-common.css +++ b/src/css/dashboard-common.css @@ -3,7 +3,7 @@ body { color: #000; margin: 0; padding: 0 0.5em 0 0.5em; - font: 15px/1.4 sans-serif; + font: 14px/1.4 sans-serif; } body > *:first-child { margin-top: 0; diff --git a/src/css/hosts-files.css b/src/css/hosts-files.css index 656535a..2218944 100644 --- a/src/css/hosts-files.css +++ b/src/css/hosts-files.css @@ -18,6 +18,19 @@ ul#options { ul#options li { margin-bottom: 0.5em; } +.assets { + border: 1px solid #ccc; + margin: 0.5em 0 0 0; + padding: 0; + } +.assets > div:first-of-type { + background-color: #eee; + margin: 0; + padding: 0.25em 0.5em; + } +.assets > div + div { + padding: 0.5em 1em; + } ul#lists { margin: 0.5em 0 0 0; padding: 0; @@ -40,7 +53,6 @@ li.listEntry > * { unicode-bidi: embed; } li.listEntry > a:nth-of-type(2) { - font-size: 13px; opacity: 0.5; } li.listEntry.toRemove > input[type="checkbox"] { @@ -59,9 +71,12 @@ li.listEntry > .fa { li.listEntry > a.fa:hover { opacity: 1; } -li.listEntry.support > a.support { +li.listEntry > a.support { display: inline-block; } +li.listEntry > a.support[href=""] { + display: none; + } li.listEntry > a.remove, li.listEntry > a.remove:visited { color: darkred; @@ -124,19 +139,20 @@ body.updating li.listEntry.obsolete > input[type="checkbox"]:checked ~ span.upda .dim { opacity: 0.5; } -#externalLists { - margin: 2em auto 0 auto; - } -body[dir="ltr"] #externalListsDiv { - margin-left: 1em; +li.listEntry.importURL > input[type="checkbox"] ~ textarea { + display: none; + margin-left: 1.6em; } -body[dir="rtl"] #externalListsDiv { - margin-right: 1em; +li.listEntry.importURL > input[type="checkbox"]:checked ~ textarea { + display: block; } -#externalHostsFiles { +li.listEntry.importURL > textarea { + border: 1px solid #ddd; box-sizing: border-box; + display: block; font-size: smaller; - width: 100%; - height: 12em; + width: calc(100% - 4em); + height: 6em; + resize: none; white-space: pre; } diff --git a/src/css/popup.css b/src/css/popup.css index b5a468b..3ef899a 100644 --- a/src/css/popup.css +++ b/src/css/popup.css @@ -210,10 +210,6 @@ body .toolbar button.fa { display: block; } -#buttonReload { - margin-left: 1em; - } - button > span.badge { padding: 1px 1px; display: inline-block; @@ -232,66 +228,66 @@ button.disabled > span.badge { left: 10vw; width: 80vw; } -.presetInfo { - margin: 0.25em 0.5em; - text-align: center; +#dropDownMenuRecipes > .dropdown-menu > ul { + max-height: 70vh; + min-width: 50vw; + overflow: auto; } -.presetEntry { - margin: 0.25em 0.25em; - border-radius: 3px; - padding: 0.5em; - display: inline-block; - cursor: pointer; - background-color: #eee; +#dropDownMenuRecipes li > ul { + margin-left: 1em; + padding: 0; } -.presetEntry .fa { - margin-right: 0.25em; - font-size: 110%; +.recipe { + cursor: pointer; + list-style-type: none; + white-space: nowrap; } -.presetEntry:hover { - background-color: #80e2ff; +.recipe > div { + align-items: baseline; + display: flex; + justify-content: space-between; } -#presetMore > *:first-child { - margin: 0; - padding: 0; - text-align: center; +.recipe > div > span { color: #888; - cursor: pointer; - font-size: 13px; } -#presetMore > *:first-child + div { - margin: 0.25em 0 0 0; - padding: 0.25em 0 0 0; - display: none; - text-align: center; +.recipe > div > span:hover { + color: #000; } -#presetMore > *:first-child + div.show { - display: block; +.recipe .expander { + display: inline-block; + padding: 0.4em; + width: 0.8em; } -#presetMore > *:first-child + div > * { - vertical-align: middle; +.recipe .expander::before { + content: '\2BC8'; } -#presetMoreRecipe { - border: 1px solid #aaa; - width: 75%; - height: 4em; - overflow: hidden; - resize: none; - font-size: 10px; - color: #888; +.recipe.expanded .expander::before { + content: '\2BC6'; + } +.recipe .name { + color: #000; + flex-grow: 1; } -#presetMoreRecipe.bad { - border: 1px solid #fcc; - color: #aaa; +.recipe .committer { + display: none; + font-size: 120%; + padding: 0.4em; + width: 0.8em; } -#presetMoreWrite.bad { - visibility: hidden; +.recipe.mustCommit .committer { + display: inline; } - -/* I think this is obsolete */ -.dropdown-menu > li > a > i { - padding: 0 6px; - font-size: 1.2em; +.recipe:hover { + background-color: #eef; + } +.recipe .ruleset { + display: none; + font: smaller monospace; + padding: 0 0.5em 0.5em 2em; + white-space: pre; + } +.recipe.expanded .ruleset { + display: block; } body .toolbar .scope { @@ -347,7 +343,7 @@ body .toolbar #specificScope > span:first-of-type { body .toolbar #globalScope { justify-content: center; margin-left: 1px; - width: 1.8em; + width: 1.6em; } body .toolbar #globalScope.on { background-color: #000; diff --git a/src/css/user-rules.css b/src/css/user-rules.css index 8142edb..33ecf90 100644 --- a/src/css/user-rules.css +++ b/src/css/user-rules.css @@ -18,7 +18,6 @@ div > p:last-child { padding: 0; position: relative; vertical-align: top; - white-space: normal; width: calc(50% - 2px); } #diff > .pane > div { diff --git a/src/hosts-files.html b/src/hosts-files.html index c5043c2..f07386d 100644 --- a/src/hosts-files.html +++ b/src/hosts-files.html @@ -10,7 +10,6 @@ -

@@ -18,14 +17,28 @@

- +
+
+
+

+

+
    +
  • +
+
+
-
-

- +
+
+
+

+
    +
  • +
+
@@ -94,6 +74,12 @@
+ +
@@ -104,6 +90,30 @@
+ + diff --git a/tools/make-assets.sh b/tools/make-assets.sh index 22d4c05..b29c886 100644 --- a/tools/make-assets.sh +++ b/tools/make-assets.sh @@ -8,7 +8,8 @@ printf "*** Packaging assets in $DES... " rm -rf $DES mkdir $DES -cp ./assets/assets.json $DES/ + +cp ./assets/assets.json $DES/ if [ -n "${TRAVIS_TAG}" ]; then pushd .. > /dev/null @@ -24,5 +25,7 @@ cp -R ../uAssets/thirdparties/publicsuffix.org $DES/thirdparties/ cp -R ../uAssets/thirdparties/someonewhocares.org $DES/thirdparties/ cp -R ../uAssets/thirdparties/winhelp2002.mvps.org $DES/thirdparties/ cp -R ../uAssets/thirdparties/www.malwaredomainlist.com $DES/thirdparties/ +mkdir $DES/umatrix +cp -R ../uAssets/recipes/* $DES/umatrix/ echo "done."