white-space fixes

This commit is contained in:
Nils Schneider 2012-07-24 00:23:26 +02:00 committed by Matthias Schiffer
parent 53a322be54
commit 7ce4cf07f6
13 changed files with 203 additions and 203 deletions

View File

@ -1,29 +1,29 @@
module("luci.controller.ffhl.wizard", package.seeall) module("luci.controller.ffhl.wizard", package.seeall)
function index() function index()
local uci = luci.model.uci.cursor() local uci = luci.model.uci.cursor()
if uci:get_first("ffhl", "wizard", "enabled") == "1" then if uci:get_first("ffhl", "wizard", "enabled") == "1" then
entry({"wizard", "welcome"}, template("ffhl-wizard/welcome"), "Willkommen", 10).dependent=false entry({"wizard", "welcome"}, template("ffhl-wizard/welcome"), "Willkommen", 10).dependent=false
entry({"wizard", "password"}, form("ffhl-wizard/password"), "Passwort", 20).dependent=false entry({"wizard", "password"}, form("ffhl-wizard/password"), "Passwort", 20).dependent=false
entry({"wizard", "hostname"}, form("ffhl-wizard/hostname"), "Hostname", 30).dependent=false entry({"wizard", "hostname"}, form("ffhl-wizard/hostname"), "Hostname", 30).dependent=false
entry({"wizard", "meshvpn"}, form("ffhl-wizard/meshvpn"), "Mesh-VPN", 40).dependent=false entry({"wizard", "meshvpn"}, form("ffhl-wizard/meshvpn"), "Mesh-VPN", 40).dependent=false
entry({"wizard", "meshvpn", "pubkey"}, template("ffhl-wizard/meshvpn-key"), "Mesh-VPN Key", 1).dependent=false entry({"wizard", "meshvpn", "pubkey"}, template("ffhl-wizard/meshvpn-key"), "Mesh-VPN Key", 1).dependent=false
entry({"wizard", "completed"}, template("ffhl-wizard/completed"), "Fertig", 50).dependent=false entry({"wizard", "completed"}, template("ffhl-wizard/completed"), "Fertig", 50).dependent=false
entry({"wizard", "completed", "reboot"}, call("reboot"), "reboot", 1).dependent=false entry({"wizard", "completed", "reboot"}, call("reboot"), "reboot", 1).dependent=false
end end
end end
function reboot() function reboot()
local uci = luci.model.uci.cursor() local uci = luci.model.uci.cursor()
uci:foreach("ffhl", "wizard", function(s) uci:foreach("ffhl", "wizard", function(s)
uci:set("ffhl", s[".name"], "enabled", "0") uci:set("ffhl", s[".name"], "enabled", "0")
end end
) )
uci:save("ffhl") uci:save("ffhl")
uci:commit("ffhl") uci:commit("ffhl")
luci.sys.reboot() luci.sys.reboot()
end end

View File

@ -10,29 +10,29 @@ hostname.value = uci:get_first("system", "system", "hostname")
hostname.rmempty = false hostname.rmempty = false
function hostname.validate(self, value, section) function hostname.validate(self, value, section)
return value return value
end end
function f.handle(self, state, data) function f.handle(self, state, data)
if state == FORM_VALID then if state == FORM_VALID then
local stat = true local stat = true
uci:foreach("system", "system", function(s) uci:foreach("system", "system", function(s)
stat = stat and uci:set("system", s[".name"], "hostname", data.hostname) stat = stat and uci:set("system", s[".name"], "hostname", data.hostname)
end end
) )
stat = stat and uci:save("system") stat = stat and uci:save("system")
stat = stat and uci:commit("system") stat = stat and uci:commit("system")
if stat then if stat then
nav.maybe_redirect_to_successor() nav.maybe_redirect_to_successor()
f.message = "Hostname geändert!" f.message = "Hostname geändert!"
else else
f.errmessage = "Fehler!" f.errmessage = "Fehler!"
end end
end end
return true return true
end end
return f return f

View File

@ -15,42 +15,42 @@ downstream = f:field(Value, "downstream", "Downstream bandwidth (kbit/s)")
downstream.value = uci:get_first("ffhl", "bandwidth", "downstream") downstream.value = uci:get_first("ffhl", "bandwidth", "downstream")
function f.handle(self, state, data) function f.handle(self, state, data)
if state == FORM_VALID then if state == FORM_VALID then
local stat = false local stat = false
uci:set("fastd", "ffhl_mesh_vpn", "enabled", data.meshvpn) uci:set("fastd", "ffhl_mesh_vpn", "enabled", data.meshvpn)
uci:save("fastd") uci:save("fastd")
uci:commit("fastd") uci:commit("fastd")
uci:foreach("ffhl", "bandwidth", function(s)
uci:set("ffhl", s[".name"], "upstream", data.upstream)
uci:set("ffhl", s[".name"], "downstream", data.downstream)
end
)
uci:save("ffhl") uci:foreach("ffhl", "bandwidth", function(s)
uci:commit("ffhl") uci:set("ffhl", s[".name"], "upstream", data.upstream)
uci:set("ffhl", s[".name"], "downstream", data.downstream)
end
)
if data.meshvpn == "1" then uci:save("ffhl")
uci:commit("ffhl")
if data.meshvpn == "1" then
local secret = uci:get("fastd", "ffhl_mesh_vpn", "secret") local secret = uci:get("fastd", "ffhl_mesh_vpn", "secret")
if not secret or not secret:match("%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x") then if not secret or not secret:match("%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x") then
luci.sys.call("/etc/init.d/haveged start") luci.sys.call("/etc/init.d/haveged start")
local f = io.popen("fastd --generate-key --machine-readable", "r") local f = io.popen("fastd --generate-key --machine-readable", "r")
local secret = f:read("*a") local secret = f:read("*a")
f:close() f:close()
luci.sys.call("/etc/init.d/haveged stop") luci.sys.call("/etc/init.d/haveged stop")
uci:set("fastd", "ffhl_mesh_vpn", "secret", secret)
uci:save("fastd")
uci:commit("fastd")
uci:set("fastd", "ffhl_mesh_vpn", "secret", secret)
uci:save("fastd")
uci:commit("fastd")
end end
luci.http.redirect(luci.dispatcher.build_url("wizard", "meshvpn", "pubkey")) luci.http.redirect(luci.dispatcher.build_url("wizard", "meshvpn", "pubkey"))
else else
nav.maybe_redirect_to_successor() nav.maybe_redirect_to_successor()
end end
end end
return true return true
end end
return f return f

View File

@ -12,25 +12,25 @@ pw2.password = true
pw2.rmempty = false pw2.rmempty = false
function pw2.validate(self, value, section) function pw2.validate(self, value, section)
return pw1:formvalue(section) == value and value return pw1:formvalue(section) == value and value
end end
function f.handle(self, state, data) function f.handle(self, state, data)
if state == FORM_VALID then if state == FORM_VALID then
local stat = luci.sys.user.setpasswd("root", data.pw1) == 0 local stat = luci.sys.user.setpasswd("root", data.pw1) == 0
if stat then if stat then
nav.maybe_redirect_to_successor() nav.maybe_redirect_to_successor()
f.message = "Passwort geändert!" f.message = "Passwort geändert!"
else else
f.errmessage = "Fehler!" f.errmessage = "Fehler!"
end end
data.pw1 = nil data.pw1 = nil
data.pw2 = nil data.pw2 = nil
end end
return true return true
end end
return f return f

View File

@ -1,43 +1,43 @@
module("luci.tools.ffhl-wizard.nav", package.seeall) module("luci.tools.ffhl-wizard.nav", package.seeall)
function maybe_redirect_to_successor() function maybe_redirect_to_successor()
local pre, suc = get() local pre, suc = get()
if suc then if suc then
luci.http.redirect(luci.dispatcher.build_url("wizard", suc.href)) luci.http.redirect(luci.dispatcher.build_url("wizard", suc.href))
end end
end end
function get() function get()
local disp = require "luci.dispatcher" local disp = require "luci.dispatcher"
local request = disp.context.path local request = disp.context.path
local category = request[1] local category = request[1]
local cattree = category and disp.node(category) local cattree = category and disp.node(category)
local childs = disp.node_childs(cattree) local childs = disp.node_childs(cattree)
local predecessor = nil local predecessor = nil
local successor = nil local successor = nil
if #childs > 0 then if #childs > 0 then
local found_pre = false local found_pre = false
for i, r in ipairs(childs) do for i, r in ipairs(childs) do
local nnode = cattree.nodes[r] local nnode = cattree.nodes[r]
nnode.href = r nnode.href = r
if r == request[2] then if r == request[2] then
found_pre = true found_pre = true
elseif found_pre and successor == nil then elseif found_pre and successor == nil then
successor = nnode successor = nnode
end end
if not found_pre then if not found_pre then
predecessor = nnode predecessor = nnode
end end
end end
end end
return predecessor, successor return predecessor, successor
end end

View File

@ -1,14 +1,14 @@
<% <%
local disp = require "luci.dispatcher" local disp = require "luci.dispatcher"
%> %>
<%+header%> <%+header%>
<h2>Konfiguration abgeschlossen</h2> <h2>Konfiguration abgeschlossen</h2>
<p>Die Konfiguration deines Freifunkknotens ist nun abgeschlossen.<p>
<p>Damit sie aktiv wird, muss der Knoten neugestartet werden.</p> <p>Die Konfiguration deines Freifunkknotens ist nun abgeschlossen.<p>
<p> <p>Damit sie aktiv wird, muss der Knoten neugestartet werden.</p>
<a class="btn primary" href="<%=disp.build_url("wizard", "completed", "reboot")%>">Jetzt neustarten!</a>
</p> <p>
<a class="btn primary" href="<%=disp.build_url("wizard", "completed", "reboot")%>">Jetzt neustarten!</a>
</p>
<%+footer%> <%+footer%>

View File

@ -1,6 +1,6 @@
<% local xtime <% local xtime
if exectime then if exectime then
xtime = (string.format("%.2fs", os.clock() - exectime)) xtime = (string.format("%.2fs", os.clock() - exectime))
end %> end %>
<footer class="footer"> <footer class="footer">

View File

@ -3,7 +3,7 @@
local sys = require "luci.sys" local sys = require "luci.sys"
local http = require "luci.http" local http = require "luci.http"
local disp = require "luci.dispatcher" local disp = require "luci.dispatcher"
local hostname = sys.hostname() local hostname = sys.hostname()
%> %>
<html> <html>
@ -20,5 +20,5 @@
<div class="container"> <div class="container">
<div class="page-header"> <div class="page-header">
<h1>Freifunk Wizard</h1> <h1>Freifunk Wizard</h1>
</div> </div>

View File

@ -1,15 +1,15 @@
<% <%
local disp = require "luci.dispatcher" local disp = require "luci.dispatcher"
local f = io.popen("/etc/init.d/fastd show_key ffhl_mesh_vpn", "r") local f = io.popen("/etc/init.d/fastd show_key ffhl_mesh_vpn", "r")
local key = f:read("*a") local key = f:read("*a")
f:close() f:close()
%> %>
<%+header%> <%+header%>
<h2>Schlüsselaustausch</h2> <h2>Schlüsselaustausch</h2>
<p>Dies ist der öffentliche Schlüssel deines Freifunkknotens. Bitte schicke ihn an freifunk.luebeck@asta.uni-luebeck.de um ihn auf den Freifunkservern eintragen zu lassen. Sobald der Schlüssel eingetragen wurde, kann dein Knoten das Mesh-VPN nutzen.</p> <p>Dies ist der öffentliche Schlüssel deines Freifunkknotens. Bitte schicke ihn an freifunk.luebeck@asta.uni-luebeck.de um ihn auf den Freifunkservern eintragen zu lassen. Sobald der Schlüssel eingetragen wurde, kann dein Knoten das Mesh-VPN nutzen.</p>
<div style="text-align: center;font-size: 2em;line-height: 1em; background: #f5f5f5; border: 1px solid #ececec; margin-bottom: 0.5em; padding: 0.5em"> <div style="text-align: center;font-size: 2em;line-height: 1em; background: #f5f5f5; border: 1px solid #ececec; margin-bottom: 0.5em; padding: 0.5em">
<%=key%> <%=key%>
</div> </div>
<%+ffhl-wizard/nav%> <%+ffhl-wizard/nav%>
<%+footer%> <%+footer%>

View File

@ -4,16 +4,16 @@
%> %>
<div class="actions"> <div class="actions">
<% if successor then %> <% if successor then %>
<a class="btn primary" href="<%=luci.dispatcher.build_url("wizard", successor.href)%>"> <a class="btn primary" href="<%=luci.dispatcher.build_url("wizard", successor.href)%>">
Weiter Weiter
</a> </a>
<% end %> <% end %>
<% if predecessor then %> <% if predecessor then %>
<a class="btn" href="<%=luci.dispatcher.build_url("wizard", predecessor.href)%>"> <a class="btn" href="<%=luci.dispatcher.build_url("wizard", predecessor.href)%>">
Zurück Zurück
</a> </a>
<% end %> <% end %>
</div> </div>

View File

@ -1,14 +1,14 @@
<% <%
local disp = require "luci.dispatcher" local disp = require "luci.dispatcher"
%> %>
<%+ffhl-wizard/header%> <%+ffhl-wizard/header%>
<section> <section>
<h1>Passwort setzen</h1> <h1>Passwort setzen</h1>
<p>Hier steht noch kein Text, der den Benutzer auffordert ein Passwort zu setzen.<p> <p>Hier steht noch kein Text, der den Benutzer auffordert ein Passwort zu setzen.<p>
<div class="form-actions"> <div class="form-actions">
<a class="btn btn-primary" href="#">Weiter</a> <a class="btn btn-primary" href="#">Weiter</a>
<a class="btn" href="<%=disp.build_url("wizard")%>">Zurück</a> <a class="btn" href="<%=disp.build_url("wizard")%>">Zurück</a>
</div> </div>
</section> </section>
<%+ffhl-wizard/footer%> <%+ffhl-wizard/footer%>

View File

@ -1,22 +1,22 @@
<% <%
local disp = require "luci.dispatcher" local disp = require "luci.dispatcher"
local nav = require "luci.tools.ffhl-wizard.nav" local nav = require "luci.tools.ffhl-wizard.nav"
local predecessor, successor = nav.get() local predecessor, successor = nav.get()
%> %>
<%+header%> <%+header%>
<h2>Willkommen auf deinem Freifunkknoten!</h2> <h2>Willkommen auf deinem Freifunkknoten!</h2>
<p>Dieser Wizard hilft dir deinen Freifunkknoten einzurichten.</p> <p>Dieser Wizard hilft dir deinen Freifunkknoten einzurichten.</p>
<div class="actions"> <div class="actions">
<% if successor then %> <% if successor then %>
<a class="btn primary" href="<%=luci.dispatcher.build_url("wizard", successor.href)%>"> <a class="btn primary" href="<%=luci.dispatcher.build_url("wizard", successor.href)%>">
Knoten neu einrichten Knoten neu einrichten
</a> </a>
<% end %> <% end %>
<a class="btn" href="<%=luci.dispatcher.build_url("admin", "system", "flashops")%>"> <a class="btn" href="<%=luci.dispatcher.build_url("admin", "system", "flashops")%>">
Firmware upgrade einspielen Firmware upgrade einspielen
</a> </a>
</div> </div>
<%+footer%> <%+footer%>

View File

@ -1,67 +1,67 @@
<% if not self.embedded then %> <% if not self.embedded then %>
<form method="post" enctype="multipart/form-data" action="<%=REQUEST_URI%>"> <form method="post" enctype="multipart/form-data" action="<%=REQUEST_URI%>">
<div> <div>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script> <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<input type="hidden" name="cbi.submit" value="1" /> <input type="hidden" name="cbi.submit" value="1" />
</div> </div>
<% end %> <% end %>
<div class="cbi-map" id="cbi-<%=self.config%>"> <div class="cbi-map" id="cbi-<%=self.config%>">
<% if self.title and #self.title > 0 then %><h2><a id="content" name="content"><%=self.title%></a></h2><% end %> <% if self.title and #self.title > 0 then %><h2><a id="content" name="content"><%=self.title%></a></h2><% end %>
<% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %> <% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
<% self:render_children() %> <% self:render_children() %>
<br /> <br />
</div> </div>
<%- if self.message then %> <%- if self.message then %>
<div><%=self.message%></div> <div><%=self.message%></div>
<%- end %> <%- end %>
<%- if self.errmessage then %> <%- if self.errmessage then %>
<div class="error"><%=self.errmessage%></div> <div class="error"><%=self.errmessage%></div>
<%- end %> <%- end %>
<% if not self.embedded then %> <% if not self.embedded then %>
<div> <div>
<%- <%-
if type(self.hidden) == "table" then if type(self.hidden) == "table" then
for k, v in pairs(self.hidden) do for k, v in pairs(self.hidden) do
-%> -%>
<input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" /> <input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
<%- <%-
end end
end end
%> %>
<div class="actions"> <div class="actions">
<% if redirect then %> <% if redirect then %>
<div style="float:left"> <div style="float:left">
<input class="cbi-button cbi-button-link" type="button" value="<%:Back to Overview%>" onclick="location.href='<%=pcdata(redirect)%>'" /> <input class="cbi-button cbi-button-link" type="button" value="<%:Back to Overview%>" onclick="location.href='<%=pcdata(redirect)%>'" />
</div> </div>
<% end %> <% end %>
<%- if self.flow and self.flow.skip then %> <%- if self.flow and self.flow.skip then %>
<input class="cbi-button cbi-button-skip" type="submit" name="cbi.skip" value="<%:Skip%>" /> <input class="cbi-button cbi-button-skip" type="submit" name="cbi.skip" value="<%:Skip%>" />
<% end %> <% end %>
<%- if self.submit ~= false then %> <%- if self.submit ~= false then %>
<input class="cbi-button cbi-button-save btn primary" type="submit" value=" <input class="cbi-button cbi-button-save btn primary" type="submit" value="
<%- if not self.submit then -%>Weiter<%-else-%><%=self.submit%><%end-%> <%- if not self.submit then -%>Weiter<%-else-%><%=self.submit%><%end-%>
" /> " />
<% end %> <% end %>
<%- if self.reset ~= false then %> <%- if self.reset ~= false then %>
<input class="cbi-button cbi-button-reset" type="reset" value=" <input class="cbi-button cbi-button-reset" type="reset" value="
<%- if not self.reset then -%><%-:Reset-%><%-else-%><%=self.reset%><%end-%> <%- if not self.reset then -%><%-:Reset-%><%-else-%><%=self.reset%><%end-%>
" /> " />
<% end %> <% end %>
<%- if self.cancel ~= false and self.on_cancel then %> <%- if self.cancel ~= false and self.on_cancel then %>
<input class="cbi-button cbi-button-reset" type="submit" name="cbi.cancel" value=" <input class="cbi-button cbi-button-reset" type="submit" name="cbi.cancel" value="
<%- if not self.cancel then -%><%-:Cancel-%><%-else-%><%=self.cancel%><%end-%> <%- if not self.cancel then -%><%-:Cancel-%><%-else-%><%=self.cancel%><%end-%>
" /> " />
<% end %> <% end %>
<% <%
local nav = require "luci.tools.ffhl-wizard.nav" local nav = require "luci.tools.ffhl-wizard.nav"
local predecessor, successor = nav.get() local predecessor, successor = nav.get()
%> %>
<% if predecessor then %> <% if predecessor then %>
<a class="btn" href="<%=luci.dispatcher.build_url("wizard", predecessor.href)%>"> <a class="btn" href="<%=luci.dispatcher.build_url("wizard", predecessor.href)%>">
Zurück Zurück
</a> </a>
<% end %> <% end %>
<script type="text/javascript">cbi_d_update();</script> <script type="text/javascript">cbi_d_update();</script>
</div> </div>
</form> </form>
<% end %> <% end %>