* Limit Blacklist/Whitelist Online editing to max. 512 KB, approx.
20.000 domains per list
* Automatically refresh the overview page after button onclick event,
e.g. 'Suspend/Resume' or 'Save & Apply'
* cosmetics
Signed-off-by: Dirk Brenken <dev@brenken.org>
return
end
entry({"admin", "services", "adblock"}, firstchild(), _("Adblock"), 30).dependent = false
- entry({"admin", "services", "adblock", "tab_from_cbi"}, cbi("adblock/overview_tab"), _("Overview"), 10).leaf = true
+ entry({"admin", "services", "adblock", "tab_from_cbi"}, cbi("adblock/overview_tab", {hideresetbtn=true, hidesavebtn=true}), _("Overview"), 10).leaf = true
entry({"admin", "services", "adblock", "logfile"}, call("logread"), _("View Logfile"), 20).leaf = true
entry({"admin", "services", "adblock", "advanced"}, firstchild(), _("Advanced"), 100)
entry({"admin", "services", "adblock", "advanced", "blacklist"}, cbi("adblock/blacklist_tab"), _("Edit Blacklist"), 110).leaf = true
local adbinput = uci.get("adblock", "blacklist", "adb_src" or "/etc/adblock/adblock.blacklist")
if not nixio.fs.access(adbinput) then
- m = SimpleForm("error", nil, translate("Input file not found, please check your configuration."))
+ m = SimpleForm("error", nil,
+ translate("Input file not found. Please check your configuration."))
+ m.reset = false
+ m.submit = false
+ return m
+end
+
+if nixio.fs.stat(adbinput).size > 524288 then
+ m = SimpleForm("error", nil,
+ translate("The file size is too large for online editing in LuCI (> 512 KB). ")
+ .. translate("Please edit this file directly in a terminal session."))
+ m.reset = false
+ m.submit = false
return m
end
if not nixio.fs.access(adbinput) then
m = SimpleForm("error", nil, translate("Input file not found, please check your configuration."))
+ m.reset = false
+ m.submit = false
return m
end
m = Map("adblock", translate("Adblock"),
translate("Configuration of the adblock package to block ad/abuse domains by using DNS. ")
- .. translate("For further information ")
- .. [[<a href="https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md" target="_blank">]]
- .. translate("see online documentation")
- .. [[</a>]]
- .. translate("."))
-m.reset = false
+ .. translatef("For further information "
+ .. "<a href=\"%s\" target=\"_blank\">"
+ .. "see online documentation</a>", "https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md"))
+
+function m.on_after_commit(self)
+ luci.sys.call("/etc/init.d/adblock reload >/dev/null 2>&1")
+ luci.http.redirect(luci.dispatcher.build_url("admin", "services", "adblock"))
+end
-- Main adblock options
btn.disabled = false
function btn.write()
luci.sys.call("/etc/init.d/adblock resume >/dev/null 2>&1")
+ luci.http.redirect(luci.dispatcher.build_url("admin", "services", "adblock"))
end
else
btn.inputtitle = translate("Suspend adblock")
btn.disabled = false
function btn.write()
luci.sys.call("/etc/init.d/adblock suspend >/dev/null 2>&1")
+ luci.http.redirect(luci.dispatcher.build_url("admin", "services", "adblock"))
end
end
if not nixio.fs.access(adbinput) then
m = SimpleForm("error", nil, translate("Input file not found, please check your configuration."))
+ m.reset = false
+ m.submit = false
+ return m
+end
+
+if nixio.fs.stat(adbinput).size > 524288 then
+ m = SimpleForm("error", nil,
+ translate("The file size is too large for online editing in LuCI (> 512 KB). ")
+ .. translate("Please edit this file directly in a terminal session."))
+ m.reset = false
+ m.submit = false
return m
end