gluon-config-mode-*, gluon-luci-*: add escaping for many user- or site-defined strings
Allows weird release numbers, models and site names, and prepares support for pretty hostnames.
This commit is contained in:
parent
79a49a1515
commit
819c7d59f1
@ -22,11 +22,11 @@ msgstr ""
|
||||
"er auf den Servern des Entenhausener Freifunk-Projektes eingetragen wurde, "
|
||||
"kann sich dein Knoten mit dem Entenhausener Mesh-VPN verbinden. Bitte "
|
||||
"schicke dazu diesen Schlüssel und den Namen deines Knotens "
|
||||
"(<em><%=hostname%></em>) an "
|
||||
"(<em><%=escape(hostname)%></em>) an "
|
||||
"<a href=\"mailto:keys@entenhausen.freifunk.net\">keys@entenhausen.freifunk.net</a>."
|
||||
"</p>"
|
||||
"<div class=\"the-key\">"
|
||||
" # <%= hostname %>"
|
||||
" # <%= escape(hostname) %>"
|
||||
" <br/>"
|
||||
"<%= pubkey %>"
|
||||
"</div>"
|
||||
|
@ -20,11 +20,11 @@ msgstr ""
|
||||
"<p>This is your Freifunk node's public key. The node won't be able to "
|
||||
"connect to the mesh VPN until the key has been registered on the Freifunk "
|
||||
"Duckburg servers. "
|
||||
"To register, send the key together with your node's name (<em><%=hostname%></em>) to "
|
||||
"To register, send the key together with your node's name (<em><%=escape(hostname)%></em>) to "
|
||||
"<a href=\"mailto:keys@entenhausen.freifunk.net\">keys@entenhausen.freifunk.net</a>."
|
||||
"</p>"
|
||||
"<div class=\"the-key\">"
|
||||
" # <%= hostname %>"
|
||||
" # <%= escape(hostname) %>"
|
||||
" <br/>"
|
||||
"<%= pubkey %>"
|
||||
"</div>"
|
||||
|
@ -22,11 +22,11 @@ msgstr ""
|
||||
"entrée sur les serveurs de votre groupe de Freifunk votre nœud pourra se connecter "
|
||||
"sur les serveur Mesh-VPN de votre groupe Freifunk. Veuillez envoyer la clé avec le "
|
||||
"nom de votre nœud "
|
||||
"(<em><%=hostname%></em>) à "
|
||||
"(<em><%=escape(hostname)%></em>) à "
|
||||
"<a href=\"mailto:keys@entenhausen.freifunk.net\">keys@entenhausen.freifunk.net</a>."
|
||||
"</p>"
|
||||
"<div class=\"the-key\">"
|
||||
" # <%= hostname %>"
|
||||
" # <%= escape(hostname) %>"
|
||||
" <br/>"
|
||||
"<%= pubkey %>"
|
||||
"</div>"
|
||||
|
@ -1,4 +1,5 @@
|
||||
<%-
|
||||
local gluon_luci = require 'gluon.luci'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
local i18n = require 'luci.i18n'
|
||||
local template = require 'luci.template'
|
||||
@ -6,7 +7,12 @@
|
||||
|
||||
<h2><%:Welcome!%></h2>
|
||||
<p>
|
||||
<%= template.render_string(i18n.translate('gluon-config-mode:welcome'), {hostname=hostname, sysconfig=sysconfig}) %>
|
||||
<%= template.render_string(i18n.translate('gluon-config-mode:welcome'), {
|
||||
hostname = hostname,
|
||||
sysconfig = sysconfig,
|
||||
escape = gluon_luci.escape,
|
||||
urlescape = gluon_luci.urlescape,
|
||||
}) %>
|
||||
</p>
|
||||
|
||||
<% if not self.embedded then %>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%=luci.i18n.context.lang%>" lang="<%=luci.i18n.context.lang%>">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title><%=hostname%> is rebooting</title>
|
||||
<title><%=escape(hostname)%> is rebooting</title>
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
@ -48,6 +48,7 @@ function action_reboot()
|
||||
uci:save("gluon-setup-mode")
|
||||
uci:commit("gluon-setup-mode")
|
||||
|
||||
local gluon_luci = require "gluon.luci"
|
||||
local fs = require "nixio.fs"
|
||||
local util = require "nixio.util"
|
||||
|
||||
@ -73,6 +74,8 @@ function action_reboot()
|
||||
{
|
||||
parts = parts,
|
||||
hostname = hostname,
|
||||
escape = gluon_luci.escape,
|
||||
urlescape = gluon_luci.urlescape,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -6,6 +6,8 @@ if meshvpn_enabled ~= "1" then
|
||||
else
|
||||
local i18n = require "luci.i18n"
|
||||
local util = require "luci.util"
|
||||
|
||||
local gluon_luci = require 'gluon.luci'
|
||||
local site = require 'gluon.site_config'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
|
||||
@ -16,11 +18,14 @@ else
|
||||
local msg = i18n.translate('gluon-config-mode:pubkey')
|
||||
|
||||
return function ()
|
||||
luci.template.render_string(msg, { pubkey=pubkey
|
||||
, hostname=hostname
|
||||
, site=site
|
||||
, sysconfig=sysconfig
|
||||
, contact=contact
|
||||
})
|
||||
end
|
||||
luci.template.render_string(msg, {
|
||||
pubkey = pubkey,
|
||||
hostname = hostname,
|
||||
site = site,
|
||||
sysconfig = sysconfig,
|
||||
contact = contact,
|
||||
escape = gluon_luci.escape,
|
||||
urlescape = gluon_luci.urlescape,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
@ -1,45 +1,46 @@
|
||||
<%-
|
||||
local fs = require 'nixio.fs'
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
local util = require 'luci.util'
|
||||
local i18n = require 'luci.i18n'
|
||||
local fs = require 'nixio.fs'
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
local util = require 'luci.util'
|
||||
local i18n = require 'luci.i18n'
|
||||
|
||||
local site = require 'gluon.site_config'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
local platform = require 'gluon.platform'
|
||||
local gluon_luci = require "gluon.luci"
|
||||
local site = require 'gluon.site_config'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
local platform = require 'gluon.platform'
|
||||
|
||||
|
||||
local keys = {
|
||||
hostname = i18n.translate('Hostname'),
|
||||
primary_mac = i18n.translate('MAC address'),
|
||||
model = i18n.translate('Hardware model'),
|
||||
version = i18n.translate('Gluon version'),
|
||||
release = i18n.translate('Firmware release'),
|
||||
site = i18n.translate('Site'),
|
||||
pubkey = i18n.translate('Public VPN key'),
|
||||
}
|
||||
local keys = {
|
||||
hostname = i18n.translate('Hostname'),
|
||||
primary_mac = i18n.translate('MAC address'),
|
||||
model = i18n.translate('Hardware model'),
|
||||
version = i18n.translate('Gluon version'),
|
||||
release = i18n.translate('Firmware release'),
|
||||
site = i18n.translate('Site'),
|
||||
pubkey = i18n.translate('Public VPN key'),
|
||||
}
|
||||
|
||||
local values = {
|
||||
hostname = uci:get_first('system', 'system', 'hostname'),
|
||||
primary_mac = sysconfig.primary_mac,
|
||||
model = platform.get_model(),
|
||||
version = util.trim(fs.readfile('/lib/gluon/gluon-version')),
|
||||
release = util.trim(fs.readfile('/lib/gluon/release')),
|
||||
site = site.site_name,
|
||||
pubkey = 'n/a',
|
||||
}
|
||||
local values = {
|
||||
hostname = uci:get_first('system', 'system', 'hostname'),
|
||||
primary_mac = sysconfig.primary_mac,
|
||||
model = platform.get_model(),
|
||||
version = util.trim(fs.readfile('/lib/gluon/gluon-version')),
|
||||
release = util.trim(fs.readfile('/lib/gluon/release')),
|
||||
site = site.site_name,
|
||||
pubkey = 'n/a',
|
||||
}
|
||||
|
||||
local meshvpn_enabled = uci:get("fastd", "mesh_vpn", "enabled", "0")
|
||||
if meshvpn_enabled == "1" then
|
||||
local pubkey = util.trim(util.exec('/etc/init.d/fastd show_key mesh_vpn'))
|
||||
if pubkey ~= '' then
|
||||
values.pubkey = pubkey
|
||||
end
|
||||
end
|
||||
local meshvpn_enabled = uci:get("fastd", "mesh_vpn", "enabled", "0")
|
||||
if meshvpn_enabled == "1" then
|
||||
local pubkey = util.trim(util.exec('/etc/init.d/fastd show_key mesh_vpn'))
|
||||
if pubkey ~= '' then
|
||||
values.pubkey = pubkey
|
||||
end
|
||||
end
|
||||
-%>
|
||||
<h2><%:Information%></h2>
|
||||
<% for _, key in ipairs({'hostname', 'primary_mac', 'model', 'version', 'release', 'site', 'pubkey'}) do %>
|
||||
<div class="cbi-value">
|
||||
<div class="cbi-value-title"><%=keys[key]%></div><div class="cbi-value-field"><%=values[key] or 'n/a'%></div>
|
||||
<div class="cbi-value-title"><%=keys[key]%></div><div class="cbi-value-field"><%=gluon_luci.escape(values[key] or 'n/a')%></div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
Loading…
Reference in New Issue
Block a user