Merge pull request #1063 from stangri/luci-app-simple-adblock

luci-app-simple-adblock: initial commit
This commit is contained in:
Hannu Nyman 2017-03-18 16:56:41 +02:00 committed by GitHub
commit c69622e5af
5 changed files with 192 additions and 0 deletions

View file

@ -0,0 +1,16 @@
# Copyright (c) 2017 Stan Grishin (stangri@melmac.net)
# This is free software, licensed under the GNU General Public License v3.
include $(TOPDIR)/rules.mk
PKG_LICENSE:=GPL-3.0+
PKG_MAINTAINER:=Stan Grishin <stangri@melmac.net>
LUCI_TITLE:=Simple Adblock Web UI
LUCI_DEPENDS:=+simple-adblock
LUCI_PKGARCH:=all
PKG_RELEASE:=2
include ../../luci.mk
# call BuildPackage - OpenWrt buildroot signature

View file

@ -0,0 +1,7 @@
module("luci.controller.simpleadblock", package.seeall)
function index()
if not nixio.fs.access("/etc/config/simple-adblock") then
return
end
entry({"admin", "services", "simpleadblock"}, cbi("simpleadblock"), _("Simple AdBlock"))
end

View file

@ -0,0 +1,79 @@
m = Map("simple-adblock", translate("Simple AdBlock Settings"))
s = m:section(NamedSection, "config", "simple-adblock")
-- General options
e = s:option(Flag, "enabled", translate("Enable/start service"))
e.rmempty = false
function e.cfgvalue(self, section)
return self.map:get(section, "enabled") == "1" and luci.sys.init.enabled("simple-adblock") and self.enabled or self.disabled
end
function e.write(self, section, value)
if value == "1" then
luci.sys.call("/etc/init.d/simple-adblock enable >/dev/null")
luci.sys.call("/etc/init.d/simple-adblock start >/dev/null")
else
luci.sys.call("/etc/init.d/simple-adblock stop >/dev/null")
end
return Flag.write(self, section, value)
end
o2 = s:option(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.rmempty = false
o2.default = 2
o3 = s:option(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.rmempty = false
o3.default = 1
local sysfs_path = "/sys/class/leds/"
local leds = {}
if nixio.fs.access(sysfs_path) then
leds = nixio.util.consume((nixio.fs.dir(sysfs_path)))
end
if #leds ~= 0 then
o3 = s:option(Value, "led", translate("LED to indicate status"), translate("Pick the LED not already used in ")
.. [[<a href="]] .. luci.dispatcher.build_url("admin/system/leds") .. [[">]]
.. translate("System LED Configuration") .. [[</a>]])
o3.rmempty = true
o3:value("", translate("none"))
for k, v in ipairs(leds) do
o3:value(v)
end
end
s2 = m:section(NamedSection, "config", "simple-adblock")
-- Whitelisted Domains
d1 = s2:option(DynamicList, "whitelist_domain", translate("Whitelisted Domains"), translate("Individual domains to be whitelisted"))
d1.addremove = false
d1.optional = false
-- Blacklisted Domains
d3 = s2:option(DynamicList, "blacklist_domain", translate("Blacklisted Domains"), translate("Individual domains to be blacklisted"))
d3.addremove = false
d3.optional = false
-- Whitelisted Domains URLs
d2 = s2:option(DynamicList, "whitelist_domains_url", translate("Whitelisted Domain URLs"), translate("URLs to lists of domains to be whitelisted"))
d2.addremove = false
d2.optional = false
-- Blacklisted Domains URLs
d4 = s2:option(DynamicList, "blacklist_domains_url", translate("Blacklisted Domain URLs"), translate("URLs to lists of domains to be blacklisted"))
d4.addremove = false
d4.optional = false
-- Blacklisted Hosts URLs
d5 = s2:option(DynamicList, "blacklist_hosts_url", translate("Blacklisted Hosts URLs"), translate("URLs to lists of hosts to be blacklisted"))
d5.addremove = false
d5.optional = false
return m

View file

@ -0,0 +1,80 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
msgid "Blacklisted Domain URLs"
msgstr ""
msgid "Blacklisted Domains"
msgstr ""
msgid "Blacklisted Hosts URLs"
msgstr ""
msgid "Controls system log and console output verbosity"
msgstr ""
msgid "Enable/start service"
msgstr ""
msgid "Force Router DNS"
msgstr ""
msgid "Force Router DNS server to all local devices"
msgstr ""
msgid "Forces Router DNS use on local devices, also known as DNS Hijacking"
msgstr ""
msgid "Individual domains to be blacklisted"
msgstr ""
msgid "Individual domains to be whitelisted"
msgstr ""
msgid "LED to indicate status"
msgstr ""
msgid "Let local devices use their own DNS servers if set"
msgstr ""
msgid "Output Verbosity Setting"
msgstr ""
msgid "Pick the LED not already used in"
msgstr ""
msgid "Simple AdBlock"
msgstr ""
msgid "Simple AdBlock Settings"
msgstr ""
msgid "Some output"
msgstr ""
msgid "Suppress output"
msgstr ""
msgid "System LED Configuration"
msgstr ""
msgid "URLs to lists of domains to be blacklisted"
msgstr ""
msgid "URLs to lists of domains to be whitelisted"
msgstr ""
msgid "URLs to lists of hosts to be blacklisted"
msgstr ""
msgid "Verbose output"
msgstr ""
msgid "Whitelisted Domain URLs"
msgstr ""
msgid "Whitelisted Domains"
msgstr ""
msgid "none"
msgstr ""

View file

@ -0,0 +1,10 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@simple-adblock[-1]
add ucitrack simple-adblock
set ucitrack.@simple-adblock[-1].init=simple-adblock
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0