luci-app-unbound: clean up presentation of advanced LuCI tabs
[project/luci.git] / applications / luci-app-unbound / luasrc / model / cbi / unbound / server.lua
1 -- Copyright 2016 Eric Luehrsen <ericluehrsen@hotmail.com>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local m3, s3, frm
5 local filename = "/etc/unbound/unbound_srv.conf"
6 local description =  translatef("Here you may edit the 'server:' clause in an internal 'include:'")
7 description = description .. " (" .. filename .. ")"
8
9 m3 = SimpleForm("editing", nil)
10 m3:append(Template("unbound/css-editing"))
11 m3.submit = translate("Save")
12 m3.reset = false
13 s3 = m3:section(SimpleSection, "Unbound Server Conf", description)
14 frm = s3:option(TextValue, "data")
15 frm.datatype = "string"
16 frm.rows = 20
17
18
19 function frm.cfgvalue()
20   return nixio.fs.readfile(filename) or ""
21 end
22
23
24 function frm.write(self, section, data)
25   return nixio.fs.writefile(filename, luci.util.trim(data:gsub("\r\n", "\n")))
26 end
27
28
29 return m3
30