2015-01-16 22:38:38 +00:00
-- Copyright 2008 Steven Barth <steven@midlink.org>
2015-01-16 22:46:42 +00:00
-- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
2015-01-16 22:38:38 +00:00
-- Copyright 2010 Manuel Munz <freifunk@somakoma.de>
-- Licensed to the public under the Apache License 2.0.
2010-11-17 22:59:08 +00:00
local fs = require " nixio.fs "
2011-10-18 09:23:27 +00:00
2010-11-17 22:59:08 +00:00
local splashtextfile = " /usr/lib/luci-splash/splashtext.html "
2013-07-28 08:15:22 +00:00
local splashtextinclude = " /usr/lib/luci-splash/splashtextinclude.html "
2010-11-17 22:59:08 +00:00
2013-07-28 08:15:22 +00:00
f = SimpleForm ( " splashtext " , translate ( " Edit the complete splash text " ) ,
2011-11-27 21:48:30 +00:00
translate ( " You can enter your own text that is displayed to clients here.<br /> " ..
" It is possible to use the following markers: " ..
" ###COMMUNITY###, ###COMMUNITY_URL###, ###CONTACTURL###, ###LEASETIME###, ###LIMIT### and ###ACCEPT###. " ) )
2010-11-17 22:59:08 +00:00
t = f : field ( TextValue , " text " )
t.rmempty = true
t.rows = 30
function t . cfgvalue ( )
return fs.readfile ( splashtextfile ) or " "
end
function f . handle ( self , state , data )
if state == FORM_VALID then
if data.text then
fs.writefile ( splashtextfile , data.text : gsub ( " \r \n " , " \n " ) )
2012-09-02 19:34:32 +00:00
else
fs.unlink ( splashtextfile )
2010-11-17 22:59:08 +00:00
end
end
return true
end
2013-07-28 08:15:22 +00:00
g = SimpleForm ( " splashtextinclude " , translate ( " Include your own text in the default splash " ) ,
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. " ) )
t = g : field ( TextValue , " text " )
t.rmempty = true
t.rows = 30
function t . cfgvalue ( )
return fs.readfile ( splashtextinclude ) or " "
end
function g . handle ( self , state , data )
if state == FORM_VALID then
if data.text then
fs.writefile ( splashtextinclude , data.text : gsub ( " \r \n " , " \n " ) )
else
fs.unlink ( splashtextinclude )
end
end
return true
end
return f , g