applications/luci-splash: Add TOS, Fix Community Name, add possibility to just add some custom text to the splash page instead of replacing the whole page

This commit is contained in:
Manuel Munz 2013-07-28 08:15:22 +00:00
parent 022970ec49
commit 37bf7b0217
3 changed files with 70 additions and 6 deletions

View file

@ -15,8 +15,10 @@ You may obtain a copy of the License at
local fs = require "nixio.fs" local fs = require "nixio.fs"
local splashtextfile = "/usr/lib/luci-splash/splashtext.html" local splashtextfile = "/usr/lib/luci-splash/splashtext.html"
local splashtextinclude = "/usr/lib/luci-splash/splashtextinclude.html"
f = SimpleForm("splashtext", translate("Edit Splash text"),
f = SimpleForm("splashtext", translate("Edit the complete splash text"),
translate("You can enter your own text that is displayed to clients here.<br />" .. translate("You can enter your own text that is displayed to clients here.<br />" ..
"It is possible to use the following markers: " .. "It is possible to use the following markers: " ..
"###COMMUNITY###, ###COMMUNITY_URL###, ###CONTACTURL###, ###LEASETIME###, ###LIMIT### and ###ACCEPT###.")) "###COMMUNITY###, ###COMMUNITY_URL###, ###CONTACTURL###, ###LEASETIME###, ###LIMIT### and ###ACCEPT###."))
@ -39,4 +41,26 @@ function f.handle(self, state, data)
return true return true
end end
return f 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

View file

@ -13,6 +13,7 @@ You may obtain a copy of the License at
<% <%
local fs = require "luci.fs" local fs = require "luci.fs"
local has_custom_splash = fs.access("/usr/lib/luci-splash/splashtext.html") local has_custom_splash = fs.access("/usr/lib/luci-splash/splashtext.html")
local has_custom_splashinclude = fs.access("/usr/lib/luci-splash/splashtextinclude.html")
function expand (e, R) function expand (e, R)
return (string.gsub(e, "###([A-Z_]+)###", R)) return (string.gsub(e, "###([A-Z_]+)###", R))
@ -24,7 +25,12 @@ local contacturl = luci.dispatcher.build_url("freifunk", "contact")
local c = luci.model.uci.cursor():get_all("freifunk", "community") local c = luci.model.uci.cursor():get_all("freifunk", "community")
if c and c.name then if c and c.name then
community = c.name name = luci.model.uci.cursor():get('profile_' .. c.name, 'profile', 'name')
if name then
community = name
else
community = c.name
end
else else
community = "Freifunk" community = "Freifunk"
end end
@ -49,6 +55,10 @@ if limit_up and limit_down then
"to this project.") .. "</p>" "to this project.") .. "</p>"
end end
contact = translatef('Get in %s with the operator of this access point.' % ('<a href="' .. contacturl .. '">' .. translatef('Contact') .. '</a>'))
accepttext = translatef('By accepting these rules you can use this network for %s hour(s). After this time you need to accept these rules again.' % leasetime)
if has_custom_splash then if has_custom_splash then
local R = { local R = {
COMMUNITY = community, COMMUNITY = community,
@ -85,12 +95,41 @@ if has_custom_splash then
<p><%:If you use this network on a regular basis we ask for your support:%></p> <p><%:If you use this network on a regular basis we ask for your support:%></p>
<ul> <ul>
<li><a href="<%=homepage%>"><%:Become an active member of this community and help by operating your own node%></a></li> <li><a href="<%=homepage%>"><%:Become an active member of this community and help by operating your own node%></a></li>
<li><a href="<%=contacturl%>"><%:Contact%></a> <%:the owner of this access point.%></li> <li><%=contact%></li>
<li><%:Donate some money to help us keep this project alive.%></li> <li><%:Donate some money to help us keep this project alive.%></li>
<li><%:If you operate your own wifi equipment use channels different from ours.%></li> <li><%:If you operate your own wifi equipment use channels different from ours.%></li>
</ul> </ul>
<br/><p><%:By accepting these rules you can use this network for%> <%=leasetime%>
<%:hour(s). After this time you need to accept these rules again.%></p> <%
if has_custom_splashinclude then
local splashtextinclude = fs.readfile("/usr/lib/luci-splash/splashtextinclude.html")
%>
<%=splashtextinclude%>
<% end %>
<h2><%:Usage Agreement%></h2>
<p>
<%:The open and free wireless network of volunteers ("Operators") provides the necessary equipment and Internet connections ("Infrastructure") at their own expense.%>
<%:These Terms of Use govern the use of the network by its participants' computer, PDA, or similar device ("Devices") within the network.%>
<%:Access to the network is not guaranteed. It can be interrupted at any time without notice for any reason, for certain devices, and/or may be blocked for certain users.%>
</p>
<h3><%:Legally Prohibited Activities%></h3>
<p><%:The participant agrees to not perform any action and refrain from acts which may violate the law or infringe upon the rights of third parties.%></p>
<h3><%:Legally Prohibited content%></h3>
<p><%:The participant agrees to not transfer content over the network which violates the law.%></p>
<h3><%:Fair Use Policy%></h3>
<p><%:The participant agrees to not use the network in any way which will harm the infrastructure, the network itself, its operators or other participants.%></p>
<h3><%:Safety%></h3>
<p>The network, like the Internet, is unencrypted and open. Each participant is responsible for the safety of their own connections and devices.</p>
<h3>Disclaimer</h3>
<p><%:The operator claims no liability for loss of data, unauthorized access/damage to devices, or financial losses that participants may suffer from the use of the network.%></p>
<br /><p><b><%=accepttext%></b></p>
<% end %> <% end %>

View file

@ -297,6 +297,7 @@ endef
define Package/luci-app-splash/conffiles define Package/luci-app-splash/conffiles
/etc/config/luci_splash /etc/config/luci_splash
/usr/lib/luci-splash/splashtext.html /usr/lib/luci-splash/splashtext.html
/usr/lib/luci-splash/splashtextinclude.html
endef endef
define Package/luci-app-statistics/conffiles define Package/luci-app-statistics/conffiles