extended.lua 765 B

123456789101112131415161718192021222324252627282930313233
  1. -- Copyright 2016 Eric Luehrsen <ericluehrsen@gmail.com>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local m4, s4, frm
  4. local filename = "/etc/unbound/unbound_ext.conf"
  5. local fs = require "nixio.fs"
  6. local ut = require "luci.util"
  7. m4 = SimpleForm("editing", nil)
  8. m4:append(Template("unbound/css-editing"))
  9. m4.submit = translate("Save")
  10. m4.reset = false
  11. s4 = m4:section(SimpleSection, "",
  12. translatef(
  13. "Edit clauses such as 'forward-zone:' for 'include: " .. filename .. "'"))
  14. frm = s4: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 m4