1 -- Copyright 2016 Eric Luehrsen <ericluehrsen@gmail.com>
2 -- Licensed to the public under the Apache License 2.0.
5 local filename = "/etc/config/unbound"
6 local fs = require "nixio.fs"
7 local ut = require "luci.util"
9 m6 = SimpleForm("editing", nil)
10 m6:append(Template("unbound/css-editing"))
11 m6.submit = translate("Save")
13 s6 = m6:section(SimpleSection, "",
14 translatef("Edit '" .. filename .. "' "
15 .. "and help can be found in OpenWrt "
16 .. "<a href=\"%s\" target=\"_blank\">Guides</a> "
17 .. "and <a href=\"%s\" target=\"_blank\">Github</a>.",
18 "https://openwrt.org/docs/guide-user/services/dns/unbound",
19 "https://github.com/openwrt/packages/blob/master/net/unbound/files/README.md"))
21 frm = s6:option(TextValue, "data")
22 frm.datatype = "string"
26 function frm.cfgvalue()
27 return fs.readfile(filename) or ""
31 function frm.write(self, section, data)
32 return fs.writefile(filename, ut.trim(data:gsub("\r\n", "\n")))