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)
function index()
local uci = luci.model.uci.cursor()
if uci:get_first("ffhl", "wizard", "enabled") == "1" then
entry({"wizard", "welcome"}, template("ffhl-wizard/welcome"), "Willkommen", 10).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", "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", "completed"}, template("ffhl-wizard/completed"), "Fertig", 50).dependent=false
entry({"wizard", "completed", "reboot"}, call("reboot"), "reboot", 1).dependent=false
end
local uci = luci.model.uci.cursor()
if uci:get_first("ffhl", "wizard", "enabled") == "1" then
entry({"wizard", "welcome"}, template("ffhl-wizard/welcome"), "Willkommen", 10).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", "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", "completed"}, template("ffhl-wizard/completed"), "Fertig", 50).dependent=false
entry({"wizard", "completed", "reboot"}, call("reboot"), "reboot", 1).dependent=false
end
end
function reboot()
local uci = luci.model.uci.cursor()
uci:foreach("ffhl", "wizard", function(s)
uci:set("ffhl", s[".name"], "enabled", "0")
end
)
uci:save("ffhl")
uci:commit("ffhl")
luci.sys.reboot()
local uci = luci.model.uci.cursor()
uci:foreach("ffhl", "wizard", function(s)
uci:set("ffhl", s[".name"], "enabled", "0")
end
)
uci:save("ffhl")
uci:commit("ffhl")
luci.sys.reboot()
end

View File

@ -10,29 +10,29 @@ hostname.value = uci:get_first("system", "system", "hostname")
hostname.rmempty = false
function hostname.validate(self, value, section)
return value
return value
end
function f.handle(self, state, data)
if state == FORM_VALID then
local stat = true
uci:foreach("system", "system", function(s)
stat = stat and uci:set("system", s[".name"], "hostname", data.hostname)
end
)
stat = stat and uci:save("system")
stat = stat and uci:commit("system")
if stat then
nav.maybe_redirect_to_successor()
f.message = "Hostname geändert!"
else
f.errmessage = "Fehler!"
end
end
return true
if state == FORM_VALID then
local stat = true
uci:foreach("system", "system", function(s)
stat = stat and uci:set("system", s[".name"], "hostname", data.hostname)
end
)
stat = stat and uci:save("system")
stat = stat and uci:commit("system")
if stat then
nav.maybe_redirect_to_successor()
f.message = "Hostname geändert!"
else
f.errmessage = "Fehler!"
end
end
return true
end
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")
function f.handle(self, state, data)
if state == FORM_VALID then
local stat = false
uci:set("fastd", "ffhl_mesh_vpn", "enabled", data.meshvpn)
uci:save("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
)
if state == FORM_VALID then
local stat = false
uci:set("fastd", "ffhl_mesh_vpn", "enabled", data.meshvpn)
uci:save("fastd")
uci:commit("fastd")
uci:save("ffhl")
uci:commit("ffhl")
uci:foreach("ffhl", "bandwidth", function(s)
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")
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")
local f = io.popen("fastd --generate-key --machine-readable", "r")
local secret = f:read("*a")
f:close()
luci.sys.call("/etc/init.d/haveged stop")
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")
local f = io.popen("fastd --generate-key --machine-readable", "r")
local secret = f:read("*a")
f:close()
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
luci.http.redirect(luci.dispatcher.build_url("wizard", "meshvpn", "pubkey"))
else
nav.maybe_redirect_to_successor()
end
end
return true
luci.http.redirect(luci.dispatcher.build_url("wizard", "meshvpn", "pubkey"))
else
nav.maybe_redirect_to_successor()
end
end
return true
end
return f

View File

@ -12,25 +12,25 @@ pw2.password = true
pw2.rmempty = false
function pw2.validate(self, value, section)
return pw1:formvalue(section) == value and value
return pw1:formvalue(section) == value and value
end
function f.handle(self, state, data)
if state == FORM_VALID then
local stat = luci.sys.user.setpasswd("root", data.pw1) == 0
if stat then
nav.maybe_redirect_to_successor()
f.message = "Passwort geändert!"
else
f.errmessage = "Fehler!"
end
data.pw1 = nil
data.pw2 = nil
end
return true
if state == FORM_VALID then
local stat = luci.sys.user.setpasswd("root", data.pw1) == 0
if stat then
nav.maybe_redirect_to_successor()
f.message = "Passwort geändert!"
else
f.errmessage = "Fehler!"
end
data.pw1 = nil
data.pw2 = nil
end
return true
end
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()
local pre, suc = get()
if suc then
luci.http.redirect(luci.dispatcher.build_url("wizard", suc.href))
local pre, suc = get()
if suc then
luci.http.redirect(luci.dispatcher.build_url("wizard", suc.href))
end
end
function get()
function get()
local disp = require "luci.dispatcher"
local request = disp.context.path
local category = request[1]
local cattree = category and disp.node(category)
local childs = disp.node_childs(cattree)
local predecessor = nil
local successor = nil
if #childs > 0 then
local found_pre = false
for i, r in ipairs(childs) do
local nnode = cattree.nodes[r]
nnode.href = r
local childs = disp.node_childs(cattree)
local predecessor = nil
local successor = nil
if #childs > 0 then
local found_pre = false
for i, r in ipairs(childs) do
local nnode = cattree.nodes[r]
nnode.href = r
if r == request[2] then
found_pre = true
found_pre = true
elseif found_pre and successor == nil then
successor = nnode
successor = nnode
end
if not found_pre then
predecessor = nnode
predecessor = nnode
end
end
end
end
end
return predecessor, successor
end

View File

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

View File

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

View File

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

View File

@ -1,15 +1,15 @@
<%
local disp = require "luci.dispatcher"
local f = io.popen("/etc/init.d/fastd show_key ffhl_mesh_vpn", "r")
local key = f:read("*a")
f:close()
local disp = require "luci.dispatcher"
local f = io.popen("/etc/init.d/fastd show_key ffhl_mesh_vpn", "r")
local key = f:read("*a")
f:close()
%>
<%+header%>
<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>
<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%>
</div>
<%+ffhl-wizard/nav%>
<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>
<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%>
</div>
<%+ffhl-wizard/nav%>
<%+footer%>

View File

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

View File

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

View File

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

View File

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