applications/luci-splash: Finish translation work and move translation strings to...
[project/luci.git] / applications / luci-splash / luasrc / model / cbi / splash / splashtext.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
6 Copyright 2010 Manuel Munz <freifunk@somakoma.de>
7
8 Licensed under the Apache License, Version 2.0 (the "License");
9 you may not use this file except in compliance with the License.
10 You may obtain a copy of the License at
11
12         http://www.apache.org/licenses/LICENSE-2.0
13 ]]--
14
15 local fs = require "nixio.fs"
16 luci.i18n.loadc("splash")
17
18 local splashtextfile = "/usr/lib/luci-splash/splashtext.html" 
19
20 f = SimpleForm("splashtext", translate("Edit Splash text"), translate("You can change the text that is displayed to clients here.<br /> It is possible to use the following markers: ###COMMUNITY###, ###COMMUNITY_URL###, ###LEASETIME### and ###ACCEPT###.<br />Click here to <a href='/luci/splash/'>test the splash page</a> after you saved it."))
21
22 t = f:field(TextValue, "text")
23 t.rmempty = true
24 t.rows = 30
25 function t.cfgvalue()
26         return fs.readfile(splashtextfile) or ""
27 end
28
29 function f.handle(self, state, data)
30         if state == FORM_VALID then
31                 if data.text then
32                         fs.writefile(splashtextfile, data.text:gsub("\r\n", "\n"))
33                 end
34         end
35         return true
36 end
37
38 return f