From 5da3e251c074b0c88e08bb0000518f6febee4744 Mon Sep 17 00:00:00 2001 From: Manuel Munz Date: Wed, 17 Nov 2010 22:59:08 +0000 Subject: [PATCH] Freifunk: Make the splash page editable --- applications/luci-splash/ipkg/postinst | 1 + applications/luci-splash/ipkg/postrm | 2 + .../luasrc/controller/splash/splash.lua | 6 +- .../luasrc/model/cbi/splash/splashtext.lua | 36 ++++++++++ .../luci-splash/luasrc/view/splash/splash.htm | 67 ++++++++++--------- .../root/usr/lib/luci-splash/splashtext.html | 31 +++++++++ 6 files changed, 109 insertions(+), 34 deletions(-) create mode 100644 applications/luci-splash/ipkg/postrm create mode 100644 applications/luci-splash/luasrc/model/cbi/splash/splashtext.lua create mode 100644 applications/luci-splash/root/usr/lib/luci-splash/splashtext.html diff --git a/applications/luci-splash/ipkg/postinst b/applications/luci-splash/ipkg/postinst index a87729e431..b35f1636e2 100755 --- a/applications/luci-splash/ipkg/postinst +++ b/applications/luci-splash/ipkg/postinst @@ -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 index 0000000000..4c92415d94 --- /dev/null +++ b/applications/luci-splash/ipkg/postrm @@ -0,0 +1,2 @@ +#!/bin/sh +uci del luci.flash_keep.splashtext;uci commit diff --git a/applications/luci-splash/luasrc/controller/splash/splash.lua b/applications/luci-splash/luasrc/controller/splash/splash.lua index 362ad9def4..27eff65796 100644 --- a/applications/luci-splash/luasrc/controller/splash/splash.lua +++ b/applications/luci-splash/luasrc/controller/splash/splash.lua @@ -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 index 0000000000..5f75e80156 --- /dev/null +++ b/applications/luci-splash/luasrc/model/cbi/splash/splashtext.lua @@ -0,0 +1,36 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Steven Barth +Copyright 2008 Jo-Philipp Wich +Copyright 2010 Manuel Munz + +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.
It is possible to use the following markers: ###COMMUNITY###, ###COMMUNITY_URL###, ###LEASETIME### and ###ACCEPT###.
Click here to test the splash page 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 diff --git a/applications/luci-splash/luasrc/view/splash/splash.htm b/applications/luci-splash/luasrc/view/splash/splash.htm index b659275050..72f58c2f10 100644 --- a/applications/luci-splash/luasrc/view/splash/splash.htm +++ b/applications/luci-splash/luasrc/view/splash/splash.htm @@ -12,36 +12,37 @@ You may obtain a copy of the License at $Id$ -%> -<% local c = luci.model.uci.cursor():get_all("freifunk", "community") %> - -

Willkommen!

-

-Du bist jetzt mit dem freien Funknetz -<%=c.name%> verbunden.
-Wir sind ein experimentelles Gemeinschaftsnetzwerk, aber kein Internetanbieter. -

- -

-Ein Zugang ins Internet 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: -

    -
  • bitte keine Filesharing-Programme betreiben!
  • -
  • bitte keine unnötigen Downloads oder Streams starten!
  • -
  • bitte keine illegalen Aktivitäten!
  • -
-

- -

-Wenn Du unsere Idee gut findest, kannst Du uns unterstützen: -

-

- -

-Mit einem Klick auf <%:Accept%> kannst du für <%=c.leasetime%> Stunden -über unser Netz das Internet verwenden. Dann wirst du erneut aufgefordet, diese Bedingungen zu akzeptieren. -

+<% +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 index 0000000000..96f0b05e25 --- /dev/null +++ b/applications/luci-splash/root/usr/lib/luci-splash/splashtext.html @@ -0,0 +1,31 @@ +

Willkommen!

+

+Du bist jetzt mit dem freien Funknetz ###COMMUNITY### verbunden.
+Wir sind ein experimentelles Gemeinschaftsnetzwerk, aber kein Internetanbieter. +

+ +

+Ein Zugang ins Internet 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: +

    +
  • bitte keine Filesharing-Programme betreiben!
  • +
  • bitte keine unnötigen Downloads oder Streams starten!
  • +
  • bitte keine illegalen Aktivitäten!
  • +
+

+ +

+Wenn Du unsere Idee gut findest und das Netz regelmässig benutzt, dann bitten wir Dich um Unterstützung: +

+

+ +

+Mit einem Klick auf ###ACCEPT### kannst du für ###LEASETIME### Stunde(n) +unser Netz verwenden. Dann wirst du erneut aufgefordet, diese Bedingungen zu akzeptieren. +

-- 2.30.2