Freifunk: Make the splash page editable
authorManuel Munz <freifunk@somakoma.de>
Wed, 17 Nov 2010 22:59:08 +0000 (22:59 +0000)
committerManuel Munz <freifunk@somakoma.de>
Wed, 17 Nov 2010 22:59:08 +0000 (22:59 +0000)
applications/luci-splash/ipkg/postinst
applications/luci-splash/ipkg/postrm [new file with mode: 0644]
applications/luci-splash/luasrc/controller/splash/splash.lua
applications/luci-splash/luasrc/model/cbi/splash/splashtext.lua [new file with mode: 0644]
applications/luci-splash/luasrc/view/splash/splash.htm
applications/luci-splash/root/usr/lib/luci-splash/splashtext.html [new file with mode: 0644]

index a87729e..b35f163 100755 (executable)
@@ -2,5 +2,6 @@
 
 [ -n "${IPKG_INSTROOT}" ] || {
        /etc/init.d/luci_splash enabled || /etc/init.d/luci_splash enable
+       uci set luci.flash_keep.splashtext="/usr/lib/luci-splash/splashtext.html";uci commit
        exit 0
 }
diff --git a/applications/luci-splash/ipkg/postrm b/applications/luci-splash/ipkg/postrm
new file mode 100644 (file)
index 0000000..4c92415
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+uci del luci.flash_keep.splashtext;uci commit
index 362ad9d..27eff65 100644 (file)
@@ -1,7 +1,11 @@
 module("luci.controller.splash.splash", package.seeall)
 
 function index()
-       entry({"admin", "services", "splash"}, cbi("splash/splash"), "Client-Splash")
+       require("luci.i18n")
+       luci.i18n.loadc("freifunk")
+
+       entry({"admin", "services", "splash"}, cbi("splash/splash"), luci.i18n.translate("Client-Splash"), 90)
+       entry({"admin", "services", "splash", "splashtext" }, form("splash/splashtext"), luci.i18n.translate("Splashtext"), 10)
 
        node("splash").target = call("action_dispatch")
        node("splash", "activate").target = call("action_activate")
diff --git a/applications/luci-splash/luasrc/model/cbi/splash/splashtext.lua b/applications/luci-splash/luasrc/model/cbi/splash/splashtext.lua
new file mode 100644 (file)
index 0000000..5f75e80
--- /dev/null
@@ -0,0 +1,36 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+Copyright 2010 Manuel Munz <freifunk@somakoma.de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+]]--
+
+local fs = require "nixio.fs"
+local splashtextfile = "/usr/lib/luci-splash/splashtext.html" 
+
+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."))
+
+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"))
+               end
+       end
+       return true
+end
+
+return f
index b659275..72f58c2 100644 (file)
@@ -12,36 +12,37 @@ You may obtain a copy of the License at
 $Id$
 
 -%>
-<% local c = luci.model.uci.cursor():get_all("freifunk", "community") %>
-
-<h2><a id="content" name="content">Willkommen!</a></h2>
-<p>
-Du bist jetzt mit dem freien Funknetz 
-<a href="<%=c.homepage%>"><%=c.name%></a> verbunden.<br />
-Wir sind ein experimentelles Gemeinschaftsnetzwerk, aber kein Internetanbieter.
-</p>
-
-<p>
-Ein Zugang <strong>ins Internet</strong> ist trotzdem möglich,
-da einige Freifunker ihre privaten Internetzugänge zur Verfügung stellen.
-Diese Zugänge müssen sich hier alle teilen.
-Bitte sei Dir dessen bewusst und verhalte Dich dementsprechend:
-<ul>
-<li>bitte <strong>keine Filesharing-Programme</strong> betreiben!</li>
-<li>bitte <strong>keine unnötigen Downloads oder Streams</strong> starten!</li>
-<li>bitte <strong>keine illegalen Aktivitäten</strong>!</li>
-</ul>
-</p>
-
-<p>
-Wenn Du unsere Idee gut findest, kannst Du uns unterstützen:
-<ul>
-<li><a href="<%=c.homepage%>">Werde selbst Freifunker oder teile deinen Internetzugang!</a></li>
-<li>Betreibe deine anderen WLAN-Geräte <em>NICHT</em> auf den Kanälen 1-5, diese stören oft unser Netz.</li>
-</ul>
-</p>
-
-<p>
-Mit einem Klick auf <em><%:Accept%></em> kannst du für <%=c.leasetime%> Stunden
-über unser Netz das Internet verwenden. Dann wirst du erneut aufgefordet, diese Bedingungen zu akzeptieren.
-</p>
+<%
+require("luci.fs")
+
+function expand (e)        
+       return (string.gsub(e, "###([A-Z_]+)###", R))
+end
+
+local c = luci.model.uci.cursor():get_all("freifunk", "community")
+if c and c.name then
+       community = c.name
+else
+       community = "Freifunk"
+end
+
+if c and c.homepage then
+       homepage = c.homepage
+else
+       homepage = "http://freifunk.net"
+end
+
+local s = luci.model.uci.cursor():get_all("luci_splash", "general")
+if s and s.leasetime then
+       leasetime = s.leasetime
+else
+       leasetime = ""
+end
+
+R = {COMMUNITY = community, COMMUNITY_URL = homepage, LEASETIME = leasetime, ACCEPT = tostring(translate("Accept"))}
+
+splashtext = expand(luci.fs.readfile("/usr/lib/luci-splash/splashtext.html"))
+%>
+
+<%=splashtext%>
+
diff --git a/applications/luci-splash/root/usr/lib/luci-splash/splashtext.html b/applications/luci-splash/root/usr/lib/luci-splash/splashtext.html
new file mode 100644 (file)
index 0000000..96f0b05
--- /dev/null
@@ -0,0 +1,31 @@
+<h2><a id="content" name="content">Willkommen!</a></h2>
+<p>
+Du bist jetzt mit dem freien Funknetz <a href="###COMMUNITY_URL###">###COMMUNITY###</a> verbunden.<br />
+Wir sind ein experimentelles Gemeinschaftsnetzwerk, aber kein Internetanbieter.
+</p>
+
+<p>
+Ein Zugang <strong>ins Internet</strong> ist trotzdem möglich,
+da einige Freifunker ihre privaten Internetzugänge zur Verfügung stellen.
+Diese Zugänge müssen sich hier alle teilen.
+Bitte sei Dir dessen bewusst und verhalte Dich dementsprechend:
+<ul>
+<li>bitte <strong>keine Filesharing-Programme</strong> betreiben!</li>
+<li>bitte <strong>keine unnötigen Downloads oder Streams</strong> starten!</li>
+<li>bitte <strong>keine illegalen Aktivitäten</strong>!</li>
+</ul>
+</p>
+
+<p>
+Wenn Du unsere Idee gut findest und das Netz regelmässig benutzt, dann bitten wir Dich um Unterstützung:
+<ul>
+<li><a href="###COMMUNITY_URL###">Werde selbst Freifunker oder teile deinen Internetzugang!</a></li>
+<li>Spende ein paar Euro, damit wir unser Netz weiter betreiben und ausbauen können.</li>
+<li>Wenn Du selbst privat genutzte WLAN-Geräte betreibst nutze dafür bitte andere Kanäle als wir.</li>
+</ul>
+</p>
+
+<p>
+Mit einem Klick auf <em>###ACCEPT###</em> kannst du für ###LEASETIME### Stunde(n)
+unser Netz verwenden. Dann wirst du erneut aufgefordet, diese Bedingungen zu akzeptieren.
+</p>