1
0

splashtext.lua 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. -- Copyright 2008 Steven Barth <steven@midlink.org>
  2. -- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
  3. -- Copyright 2010 Manuel Munz <freifunk@somakoma.de>
  4. -- Licensed to the public under the Apache License 2.0.
  5. local fs = require "nixio.fs"
  6. local splashtextfile = "/usr/lib/luci-splash/splashtext.html"
  7. local splashtextinclude = "/usr/lib/luci-splash/splashtextinclude.html"
  8. f = SimpleForm("splashtext", translate("Edit the complete splash text"),
  9. translate("You can enter your own text that is displayed to clients here.<br />" ..
  10. "It is possible to use the following markers: " ..
  11. "###COMMUNITY###, ###COMMUNITY_URL###, ###CONTACTURL###, ###LEASETIME###, ###LIMIT### and ###ACCEPT###."))
  12. t = f:field(TextValue, "text")
  13. t.rmempty = true
  14. t.rows = 30
  15. function t.cfgvalue()
  16. return fs.readfile(splashtextfile) or ""
  17. end
  18. function f.handle(self, state, data)
  19. if state == FORM_VALID then
  20. if data.text then
  21. fs.writefile(splashtextfile, data.text:gsub("\r\n", "\n"))
  22. else
  23. fs.unlink(splashtextfile)
  24. end
  25. end
  26. return true
  27. end
  28. g = SimpleForm("splashtextinclude", translate("Include your own text in the default splash"),
  29. translate("As an alternative to editing the complete splash text you can also just include some custom text in the default splash page by entering it here."))
  30. t = g:field(TextValue, "text")
  31. t.rmempty = true
  32. t.rows = 30
  33. function t.cfgvalue()
  34. return fs.readfile(splashtextinclude) or ""
  35. end
  36. function g.handle(self, state, data)
  37. if state == FORM_VALID then
  38. if data.text then
  39. fs.writefile(splashtextinclude, data.text:gsub("\r\n", "\n"))
  40. else
  41. fs.unlink(splashtextinclude)
  42. end
  43. end
  44. return true
  45. end
  46. return f, g