1 -- Copyright 2017-2018 Dirk Brenken (dev@brenken.org)
2 -- This is free software, licensed under the Apache License, Version 2.0
4 local fs = require("nixio.fs")
5 local util = require("luci.util")
6 local adbinput = "/etc/config/adblock"
8 if not fs.access(adbinput) then
9 m = SimpleForm("error", nil, translate("Input file not found, please check your configuration."))
15 if fs.stat(adbinput).size >= 102400 then
16 m = SimpleForm("error", nil,
17 translate("The file size is too large for online editing in LuCI (≥ 100 KB). ")
18 .. translate("Please edit this file directly in a terminal session."))
24 m = SimpleForm("input", nil)
25 m:append(Template("adblock/config_css"))
26 m.submit = translate("Save")
29 s = m:section(SimpleSection, nil,
30 translate("This form allows you to modify the content of the main adblock configuration file (/etc/config/adblock)."))
32 f = s:option(TextValue, "data")
37 return fs.readfile(adbinput) or ""
40 function f.write(self, section, data)
41 return fs.writefile(adbinput, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n")
44 function s.handle(self, state, data)