html.lua 696 B

12345678910111213141516171819202122232425262728293031
  1. -- Copyright 2012 Manuel Munz <freifunk at somakoma dot de>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local map, section = ...
  4. local utl = require "luci.util"
  5. local fs = require "nixio.fs"
  6. local file = "/usr/share/customtext/" .. arg[1] .. ".html"
  7. local form, ferr = loadfile(utl.libpath() .. "/model/cbi/freifunk/widgets/heightwidth.lua")
  8. if form then
  9. setfenv(form, getfenv(1))(m, wdg)
  10. end
  11. t = wdg:option(TextValue, "_text")
  12. t.rmempty = true
  13. t.rows = 20
  14. function t.cfgvalue()
  15. return fs.readfile(file) or ""
  16. end
  17. function t.write(self, section, value)
  18. return fs.writefile(file, value)
  19. end
  20. function t.remove(self, section)
  21. return fs.unlink(file)
  22. end