From 4f126632a542f9e8948cd58a03c3ccbdee1c0d9e Mon Sep 17 00:00:00 2001 From: Manuel Munz Date: Sun, 2 Sep 2012 19:34:32 +0000 Subject: applications/splash: Fix error when replacing markers, delete file which contains the custom text if it is empty, #477 --- .../luci-splash/luasrc/model/cbi/splash/splashtext.lua | 2 ++ applications/luci-splash/luasrc/view/splash/splash.htm | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'applications/luci-splash/luasrc') diff --git a/applications/luci-splash/luasrc/model/cbi/splash/splashtext.lua b/applications/luci-splash/luasrc/model/cbi/splash/splashtext.lua index 82ba0b9db..5b744e1cc 100644 --- a/applications/luci-splash/luasrc/model/cbi/splash/splashtext.lua +++ b/applications/luci-splash/luasrc/model/cbi/splash/splashtext.lua @@ -33,6 +33,8 @@ function f.handle(self, state, data) if state == FORM_VALID then if data.text then fs.writefile(splashtextfile, data.text:gsub("\r\n", "\n")) + else + fs.unlink(splashtextfile) end end return true diff --git a/applications/luci-splash/luasrc/view/splash/splash.htm b/applications/luci-splash/luasrc/view/splash/splash.htm index 18acf30a7..fbb9c8b75 100644 --- a/applications/luci-splash/luasrc/view/splash/splash.htm +++ b/applications/luci-splash/luasrc/view/splash/splash.htm @@ -14,11 +14,11 @@ You may obtain a copy of the License at local fs = require "luci.fs" local has_custom_splash = fs.access("/usr/lib/luci-splash/splashtext.html") -function expand (e) +function expand (e, R) return (string.gsub(e, "###([A-Z_]+)###", R)) end -local community, homepage, leasetime, limit_up, limit_down, R +local community, homepage, leasetime, limit_up, limit_down local contacturl = luci.dispatcher.build_url("freifunk", "contact") @@ -50,8 +50,7 @@ if limit_up and limit_down then end if has_custom_splash then - - R = { + local R = { COMMUNITY = community, COMMUNITY_URL = homepage, LEASETIME = leasetime, @@ -59,8 +58,7 @@ if has_custom_splash then LIMIT = limit_text, CONTACTURL = contacturl } - - local splashtext = expand(fs.readfile("/usr/lib/luci-splash/splashtext.html")) + local splashtext = expand(fs.readfile("/usr/lib/luci-splash/splashtext.html"), R) %> <%=splashtext%> -- cgit v1.2.3