Merge pull request #2043 from Ansuel/materialfix
[project/luci.git] / applications / luci-app-unbound / luasrc / model / cbi / unbound / uciedit.lua
1 -- Copyright 2016 Eric Luehrsen <ericluehrsen@gmail.com>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local m6, s6, frm
5 local filename = "/etc/config/unbound"
6 local fs = require "nixio.fs"
7 local ut = require "luci.util"
8
9 m6 = SimpleForm("editing", nil)
10 m6:append(Template("unbound/css-editing"))
11 m6.submit = translate("Save")
12 m6.reset = false
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"))
20
21 frm = s6:option(TextValue, "data")
22 frm.datatype = "string"
23 frm.rows = 20
24
25
26 function frm.cfgvalue()
27 return fs.readfile(filename) or ""
28 end
29
30
31 function frm.write(self, section, data)
32 return fs.writefile(filename, ut.trim(data:gsub("\r\n", "\n")))
33 end
34
35
36 return m6
37