From b7ed444cbb2428150688b2842e95491a740b1156 Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Sat, 28 Jul 2018 16:47:19 +0200 Subject: [PATCH] luci-app-adblock: small fixes * fix possible controller error during json parsing * remaining code cleanup Signed-off-by: Dirk Brenken --- .../luasrc/controller/adblock.lua | 12 +++----- .../luasrc/view/adblock/blocklist.htm | 28 +++++++++---------- .../luasrc/view/adblock/runtime.htm | 11 ++++---- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/applications/luci-app-adblock/luasrc/controller/adblock.lua b/applications/luci-app-adblock/luasrc/controller/adblock.lua index fad8834870..4c77244710 100644 --- a/applications/luci-app-adblock/luasrc/controller/adblock.lua +++ b/applications/luci-app-adblock/luasrc/controller/adblock.lua @@ -6,11 +6,9 @@ module("luci.controller.adblock", package.seeall) local sys = require("luci.sys") local util = require("luci.util") local http = require("luci.http") -local templ = require("luci.template") local i18n = require("luci.i18n") local json = require("luci.jsonc") local uci = require("luci.model.uci").cursor() -local fs = require("nixio.fs") function index() if not nixio.fs.access("/etc/config/adblock") then @@ -48,12 +46,10 @@ function status_update() rt_file = uci:get("adblock", "global", "adb_rtfile") or "/tmp/adb_runtime.json" - if fs.access(rt_file) then - content = json.parse(fs.readfile(rt_file)) - if content then - http.prepare_content("application/json") - http.write_json(content) - end + if nixio.fs.access(rt_file) then + content = json.parse(nixio.fs.readfile(rt_file) or "") + http.prepare_content("application/json") + http.write_json(content) end end diff --git a/applications/luci-app-adblock/luasrc/view/adblock/blocklist.htm b/applications/luci-app-adblock/luasrc/view/adblock/blocklist.htm index f59e518574..a6f2286513 100644 --- a/applications/luci-app-adblock/luasrc/view/adblock/blocklist.htm +++ b/applications/luci-app-adblock/luasrc/view/adblock/blocklist.htm @@ -14,39 +14,39 @@ local anonclass = (not self.anonymous or self.sectiontitle) and "named" or "ano .cbi-section-table-row, .tr[data-title]::before { - text-align:left; - vertical-align:top; - margin-left:0px; - padding-left:2px; + text-align: left; + vertical-align: top; + margin-left: 0px; + padding-left: 2px; } .table.cbi-section-table .th { - white-space:nowrap; + white-space: nowrap; } .table.cbi-section-table input { - width:7em; + width: 7em; } .cbi-section-table-row > .cbi-value-field [data-dynlist] > input, .table.cbi-section-table input { - width:7em; + width: 7em; } .cbi-input-text { - text-align:left; - padding-left:2px; - outline:none; - box-shadow:none; - background:transparent; - width:7em; + text-align: left; + padding-left: 2px; + outline: none; + box-shadow: none; + background: transparent; + width: 7em; }
<% if self.title then -%> - <%=self.title%> +

<%=self.title%>

<%- end %>
<%=self.description%>
diff --git a/applications/luci-app-adblock/luasrc/view/adblock/runtime.htm b/applications/luci-app-adblock/luasrc/view/adblock/runtime.htm index 7609ba5e66..05cdde73b9 100644 --- a/applications/luci-app-adblock/luasrc/view/adblock/runtime.htm +++ b/applications/luci-app-adblock/luasrc/view/adblock/runtime.htm @@ -1,16 +1,15 @@ <%# Copyright 2017-2018 Dirk Brenken (dev@brenken.org) This is free software, licensed under the Apache License, Version 2.0 -local sys = require("luci.sys") - -%> + -- 2.30.2