manual.lua 741 B

123456789101112131415161718192021222324252627282930313233
  1. -- Copyright 2016 Eric Luehrsen <ericluehrsen@gmail.com>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local m2, s2, frm
  4. local filename = "/etc/unbound/unbound.conf"
  5. local fs = require "nixio.fs"
  6. local ut = require "luci.util"
  7. m2 = SimpleForm("editing", nil)
  8. m2:append(Template("unbound/css-editing"))
  9. m2.submit = translate("Save")
  10. m2.reset = false
  11. s2 = m2:section(SimpleSection, "",
  12. translatef(
  13. "Edit '" .. filename .. "' when you do not use UCI."))
  14. frm = s2:option(TextValue, "data")
  15. frm.datatype = "string"
  16. frm.rows = 20
  17. function frm.cfgvalue()
  18. return fs.readfile(filename) or ""
  19. end
  20. function frm.write(self, section, data)
  21. return fs.writefile(filename, ut.trim(data:gsub("\r\n", "\n")))
  22. end
  23. return m2