diff options
Diffstat (limited to 'applications/luci-app-simple-adblock/luasrc')
4 files changed, 42 insertions, 25 deletions
diff --git a/applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua b/applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua index 1dbfd1d40c..1c56502480 100644 --- a/applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua +++ b/applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua @@ -8,17 +8,23 @@ end function simple_adblock_action(name) local packageName = "simple-adblock" + local http = require "luci.http" + local sys = require "luci.sys" + local uci = require "luci.model.uci".cursor() + local util = require "luci.util" if name == "start" then - luci.sys.init.start(packageName) + sys.init.start(packageName) elseif name == "action" then - luci.util.exec("/etc/init.d/" .. packageName .. " dl >/dev/null 2>&1") + util.exec("/etc/init.d/" .. packageName .. " dl >/dev/null 2>&1") elseif name == "stop" then - luci.sys.init.stop(packageName) + sys.init.stop(packageName) elseif name == "enable" then - luci.util.exec("uci set " .. packageName .. ".config.enabled=1; uci commit " .. packageName) + uci:set(packageName, "config", "enabled", "1") + uci:commit(packageName) elseif name == "disable" then - luci.util.exec("uci set " .. packageName .. ".config.enabled=0; uci commit " .. packageName) + uci:set(packageName, "config", "enabled", "0") + uci:commit(packageName) end - luci.http.prepare_content("text/plain") - luci.http.write("0") + http.prepare_content("text/plain") + http.write("0") end diff --git a/applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua b/applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua index 4a24897fff..0b38cf73ac 100644 --- a/applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua +++ b/applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua @@ -1,10 +1,8 @@ -- Copyright 2016-2018 Stan Grishin <stangri@melmac.net> -- Licensed to the public under the Apache License 2.0. -local readmeURL = "https://github.com/openwrt/packages/tree/master/net/simple-adblock/files/README.md" --- local readmeURL = "https://github.com/stangri/openwrt_packages/tree/master/simple-adblock/files/README.md" - local packageName = "simple-adblock" +local readmeURL = "https://docs.openwrt.melmac.net/" .. packageName .. "/" local uci = require "luci.model.uci".cursor() local util = require "luci.util" local sys = require "luci.sys" @@ -85,6 +83,10 @@ elseif targetDNS == "dnsmasq.conf" then outputFile="/var/dnsmasq.d/" .. packageName .. "" outputCache="/var/run/" .. packageName .. ".dnsmasq.cache" outputGzip="/etc/" .. packageName .. ".dnsmasq.gz" +elseif targetDNS == "dnsmasq.ipset" then + outputFile="/var/dnsmasq.d/" .. packageName .. ".ipset" + outputCache="/var/run/" .. packageName .. ".ipset.cache" + outputGzip="/etc/" .. packageName .. ".ipset.gz" elseif targetDNS == "dnsmasq.servers" then outputFile="/var/run/" .. packageName .. ".servers" outputCache="/var/run/" .. packageName .. ".servers.cache" @@ -153,7 +155,9 @@ errorTable["errorRestoreCache"] = translatef("failed to move '%s' to '%s'", outp errorTable["errorOhSnap"] = translate("failed to create block-list or restart DNS resolver") errorTable["errorStopping"] = translatef("failed to stop %s", packageName) errorTable["errorDNSReload"] = translate("failed to reload/restart DNS resolver") +errorTable["errorDownloadingConfigUpdate"] = translate("failed to download Config Update file") errorTable["errorDownloadingList"] = translate("failed to download") +errorTable["errorParsingConfigUpdate"] = translate("failed to parse Config Update file") errorTable["errorParsingList"] = translate("failed to parse") errorTable["errorNoSSLSupport"] = translate("no HTTPS/SSL support on device") @@ -195,7 +199,7 @@ else ss = h:option(DummyValue, "_dummy", translate("Service Status")) ss.template = "simple-adblock/status" if tmpfsStatus == "statusSuccess" then - ss.value = translatef("%s is blocking %s domains (with %s).", packageVersion, getFileLines(outputFile), targetDNS) + ss.value = translatef("Blocking %s domains (with %s).", getFileLines(outputFile), targetDNS) else ss.value = statusTable[tmpfsStatus] end @@ -206,7 +210,7 @@ else end if tmpfsError then es = h:option(DummyValue, "_dummy", translate("Collected Errors")) - es.template = "simple-adblock/error" + es.template = "simple-adblock/status" es.value = "" local err, e, url for err in tmpfsError:gmatch("[%p%w]+") do @@ -220,7 +224,7 @@ else end end if packageVersion ~= "" then - buttons = h:option(DummyValue, "_dummy") + buttons = h:option(DummyValue, "_dummy", translate("Service Control")) buttons.template = packageName .. "/buttons" end end @@ -229,16 +233,21 @@ s = m:section(NamedSection, "config", "simple-adblock", translate("Configuration -- General options s:tab("basic", translate("Basic Configuration")) +o1 = s:taboption("basic", ListValue, "config_update_enabled", translate("Automatic Config Update"), translate("Perform config update before downloading the block/allow-lists.")) +o1:value("0", translate("Disable")) +o1:value("1", translate("Enable")) +o1.default = "0" + o2 = s:taboption("basic", ListValue, "verbosity", translate("Output Verbosity Setting"), translate("Controls system log and console output verbosity.")) o2:value("0", translate("Suppress output")) o2:value("1", translate("Some output")) o2:value("2", translate("Verbose output")) -o2.default = 2 +o2.default = "2" o3 = s:taboption("basic", ListValue, "force_dns", translate("Force Router DNS"), translate("Forces Router DNS use on local devices, also known as DNS Hijacking.")) o3:value("0", translate("Let local devices use their own DNS servers if set")) o3:value("1", translate("Force Router DNS server to all local devices")) -o3.default = 1 +o3.default = "1" local sysfs_path = "/sys/class/leds/" local leds = {} @@ -257,7 +266,7 @@ end s:tab("advanced", translate("Advanced Configuration")) -local dns_descr = translatef("Pick the DNS resolution option to create the adblock list for, see the <a href=\"%s#dns-resolution-option\" target=\"_blank\">README</a> for details.", readmeURL) +local dns_descr = translatef("Pick the DNS resolution option to create the adblock list for, see the %sREADME%s for details.", "<a href=\"" .. readmeURL .. "#dns-resolution-option\" target=\"_blank\">", "</a>") if not checkDnsmasq() then dns_descr = dns_descr .. "<br />" .. translatef("Please note that %s is not supported on this system.", "<i>dnsmasq.addnhosts</i>") @@ -307,7 +316,7 @@ o7.datatype = "range(0,30)" o8 = s:taboption("advanced", ListValue, "parallel_downloads", translate("Simultaneous processing"), translate("Launch all lists downloads and processing simultaneously, reducing service start time.")) o8:value("0", translate("Do not use simultaneous processing")) o8:value("1", translate("Use simultaneous processing")) -o8.default = 1 +o8.default = "1" o10 = s:taboption("advanced", ListValue, "compressed_cache", translate("Store compressed cache file on router"), translate("Attempt to create a compressed cache of block-list in the persistent memory.")) o10:value("0", translate("Do not store compressed cache")) diff --git a/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/buttons.htm b/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/buttons.htm index 0651ce459c..131112c8a7 100644 --- a/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/buttons.htm +++ b/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/buttons.htm @@ -47,29 +47,29 @@ end -%> -<div class="cbi-value"><label class="cbi-value-title">Service Control</label> +<%+cbi/valueheader%> <div class="cbi-value-field"> - <input type="button" class="cbi-button cbi-button-apply" id="btn_start" name="start" value="<%:Start%>" + <input type="button" class="btn cbi-button cbi-button-apply" id="btn_start" name="start" value="<%:Start%>" onclick="button_action(this)" /> <span id="btn_start_spinner" class="btn_spinner"></span> - <input type="button" class="cbi-button cbi-button-apply" id="btn_action" name="action" value="<%:Force Re-Download%>" + <input type="button" class="btn cbi-button cbi-button-apply" id="btn_action" name="action" value="<%:Force Re-Download%>" onclick="button_action(this)" /> <span id="btn_action_spinner" class="btn_spinner"></span> - <input type="button" class="cbi-button cbi-button-reset" id="btn_stop" name="stop" value="<%:Stop%>" + <input type="button" class="btn cbi-button cbi-button-reset" id="btn_stop" name="stop" value="<%:Stop%>" onclick="button_action(this)" /> <span id="btn_stop_spinner" class="btn_spinner"></span> - <input type="button" class="cbi-button cbi-button-apply" id="btn_enable" name="enable" value="<%:Enable%>" + <input type="button" class="btn cbi-button cbi-button-apply" id="btn_enable" name="enable" value="<%:Enable%>" onclick="button_action(this)" /> <span id="btn_enable_spinner" class="btn_spinner"></span> - <input type="button" class="cbi-button cbi-button-reset" id="btn_disable" name="disable" value="<%:Disable%>" + <input type="button" class="btn cbi-button cbi-button-reset" id="btn_disable" name="disable" value="<%:Disable%>" onclick="button_action(this)" /> <span id="btn_disable_spinner" class="btn_spinner"></span> </div> -</div> +<%+cbi/valuefooter%> <%-if not btn_start_status then%> <script type="text/javascript">document.getElementById("btn_start").disabled = true;</script> diff --git a/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/status.htm b/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/status.htm index c453428405..b02c7faa82 100644 --- a/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/status.htm +++ b/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/status.htm @@ -5,6 +5,8 @@ This is free software, licensed under the Apache License, Version 2.0 <%+cbi/valueheader%> -<input name="status" id="status" type="text" class="cbi-input-text" style="outline:none;border:none;box-shadow:none;background:transparent;font-weight:bold;line-height:30px;height:30px;width:50em;" value="<%=self:cfgvalue(section)%>" disabled="disabled" /> +<div style="font-weight:bold;"> + <%=self:cfgvalue(section):gsub('\n', '<br />' )%> +</div> <%+cbi/valuefooter%> |