From b70eb7f2b060f8dfd7b2c3613339c98bc539e21b Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Fri, 8 Jun 2018 15:16:49 +0800 Subject: [PATCH] update adbyby plus+ to fit new luci --- .../luasrc/controller/adbyby.lua | 8 ++++ .../luasrc/model/cbi/adbyby.lua | 44 +++---------------- .../luasrc/view/adbyby/adbyby_status.htm | 22 ++++++++++ 3 files changed, 37 insertions(+), 37 deletions(-) create mode 100644 package/lean/luci-app-adbyby-plus/luasrc/view/adbyby/adbyby_status.htm diff --git a/package/lean/luci-app-adbyby-plus/luasrc/controller/adbyby.lua b/package/lean/luci-app-adbyby-plus/luasrc/controller/adbyby.lua index ee37e26da..9d986d344 100644 --- a/package/lean/luci-app-adbyby-plus/luasrc/controller/adbyby.lua +++ b/package/lean/luci-app-adbyby-plus/luasrc/controller/adbyby.lua @@ -7,4 +7,12 @@ function index() end entry({"admin", "services", "adbyby"}, cbi("adbyby"), _("ADBYBY Plus +"), 10).dependent = true + entry({"admin","services","adbyby","status"},call("act_status")).leaf=true +end + +function act_status() + local e={} + e.running=luci.sys.call("pgrep adbyby >/dev/null")==0 + luci.http.prepare_content("application/json") + luci.http.write_json(e) end diff --git a/package/lean/luci-app-adbyby-plus/luasrc/model/cbi/adbyby.lua b/package/lean/luci-app-adbyby-plus/luasrc/model/cbi/adbyby.lua index 87b9971d4..963f9e90f 100644 --- a/package/lean/luci-app-adbyby-plus/luasrc/model/cbi/adbyby.lua +++ b/package/lean/luci-app-adbyby-plus/luasrc/model/cbi/adbyby.lua @@ -4,23 +4,14 @@ local SYS = require "luci.sys" local HTTP = require "luci.http" local DISP = require "luci.dispatcher" -local m,s,o -local Status - -if SYS.call("pidof adbyby >/dev/null") == 0 then - Status = translate("Adbyby Plus + is Running") -else - Status = translate("Adbyby Plus + is Not Running") -end - m = Map("adbyby") m.title = translate("Adbyby Plus +") m.description = translate("Adbyby Plus + can filter all kinds of banners, popups, video ads, and prevent tracking, privacy theft and a variety of malicious websites
Plus + version combination mode can operation with Adblock Plus Host,filtering ads without losing bandwidth") +m:section(SimpleSection).template = "adbyby/adbyby_status" + s = m:section(TypedSection, "adbyby") s.anonymous = true -s.description = translate(string.format("%s

", Status)) - s:tab("basic", translate("Base Setting")) @@ -37,24 +28,11 @@ o:value("2", translate("No filter Mode (Must set in Client Filter Mode Settings o.default = 1 o.rmempty = false -o = s:taboption("basic", Button, "proxy") -o.title = translate("Transparent proxy") -if SYS.call("iptables-save | grep ADBYBY >/dev/null") == 0 then - o.inputtitle = translate("Click to disable") - o.inputstyle = "reset" - o.write = function() - SYS.call("/etc/init.d/adbyby del_rule") - HTTP.redirect(DISP.build_url("admin", "services", "adbyby")) - end -else - o.inputtitle = translate("Click to enable") - o.inputstyle = "apply" - o.write = function() - SYS.call('[ -n "$(pgrep adbyby)" ] && /etc/init.d/adbyby add_rule') - HTTP.redirect(DISP.build_url("admin", "services", "adbyby")) - end -end - +mem = s:taboption("basic", Flag, "mem_mode") +mem.title = translate("RAM Running Mode") +mem.default = 1 +mem.rmempty = false +mem.description = translate("Running Adbyby in RAM.More speed,less disk consumption") local DL = SYS.exec("head -1 /usr/share/adbyby/data/lazy.txt | awk -F' ' '{print $3,$4}'") local DV = SYS.exec("head -1 /usr/share/adbyby/data/video.txt | awk -F' ' '{print $3,$4}'") @@ -66,7 +44,6 @@ local ND = SYS.exec("cat /usr/share/adbyby/dnsmasq.adblock | wc -l") o = s:taboption("basic", Button, "restart") o.title = translate("Adbyby and Rule state") o.inputtitle = translate("Restart Adbyby") -o.description = translate(string.format("%s

", Status)) o.description = translate(string.format("Lazy Rule:%s   Video Rule:%s
Third Party Subscription Rule:%d lines  User-defined Rule:%d lines", DL, DV, math.abs(NR-NU), NR)) o.inputstyle = "reload" o.write = function() @@ -100,13 +77,6 @@ o.title = translate("Block Apple iOS OTA update") o.default = 0 o.rmempty = false -mem = s:taboption("advanced", Flag, "mem_mode") -mem.title = translate("RAM Running Mode") -mem.default = 1 -mem.rmempty = false -mem.description = translate("Running Adbyby in RAM.More speed,less disk consumption") - - s:tab("help", translate("Plus+ Domain List")) local conf = "/usr/share/adbyby/adhost.conf" diff --git a/package/lean/luci-app-adbyby-plus/luasrc/view/adbyby/adbyby_status.htm b/package/lean/luci-app-adbyby-plus/luasrc/view/adbyby/adbyby_status.htm new file mode 100644 index 000000000..8191b63a6 --- /dev/null +++ b/package/lean/luci-app-adbyby-plus/luasrc/view/adbyby/adbyby_status.htm @@ -0,0 +1,22 @@ + + +
+

+ <%:Collecting data...%> +

+
\ No newline at end of file