* luci/themes: fix log pages

* luci/modules/admin-full: add dmesg page
* luci/i18n: add "dmesg" translations
* luci/libs/util: add cmatch(), register string functions in string class
* luci/libs/sys: add dmesg()
This commit is contained in:
Jo-Philipp Wich 2008-11-16 22:45:10 +00:00
parent 8b8d903035
commit cbed72fb47
19 changed files with 102 additions and 18 deletions

View file

@ -27,6 +27,7 @@ device = 'Device'
devices = 'Devices'
disable = 'disable'
distance = 'Distance'
dmesg = 'Kernel Log'
dnsserver = '<abbr title="Domain Name System">DNS</abbr>-Server'
edit = 'Edit'
enable = 'enable'

View file

@ -32,6 +32,7 @@
<i18n:msg xml:id="devices">Devices</i18n:msg>
<i18n:msg xml:id="disable">disable</i18n:msg>
<i18n:msg xml:id="distance">Distance</i18n:msg>
<i18n:msg xml:id="dmesg">Kernel Log</i18n:msg>
<i18n:msg xml:id="dnsserver"><abbr title="Domain Name System">DNS</abbr>-Server</i18n:msg>
<i18n:msg xml:id="edit">Edit</i18n:msg>
<i18n:msg xml:id="enable">enable</i18n:msg>

View file

@ -27,6 +27,7 @@ device = 'Equipement'
devices = 'Equipements'
disable = 'désactiver'
distance = 'Distance'
dmesg = 'Journal du noyau'
dnsserver = 'Serveur DNS'
edit = 'Editer'
enable = 'activer'

View file

@ -32,6 +32,7 @@
<i18n:msg xml:id="devices">Equipements</i18n:msg>
<i18n:msg xml:id="disable">désactiver</i18n:msg>
<i18n:msg xml:id="distance">Distance</i18n:msg>
<i18n:msg xml:id="dmesg">Journal du noyau</i18n:msg>
<i18n:msg xml:id="dnsserver">Serveur DNS</i18n:msg>
<i18n:msg xml:id="edit">Editer</i18n:msg>
<i18n:msg xml:id="enable">activer</i18n:msg>

View file

@ -27,6 +27,7 @@ device = 'Gerät'
devices = 'Geräte'
disable = 'deaktivieren'
distance = 'Distanz'
dmesg = 'Kernelprotokoll'
dnsserver = 'DNS-Server'
edit = 'Bearbeiten'
enable = 'aktivieren'

View file

@ -36,6 +36,7 @@
<i18n:msg xml:id="devices">Geräte</i18n:msg>
<i18n:msg xml:id="disable">deaktivieren</i18n:msg>
<i18n:msg xml:id="distance">Distanz</i18n:msg>
<i18n:msg xml:id="dmesg">Kernelprotokoll</i18n:msg>
<i18n:msg xml:id="dnsserver">DNS-Server</i18n:msg>
<i18n:msg xml:id="edit">Bearbeiten</i18n:msg>

View file

@ -28,6 +28,7 @@ device = 'Dispositivo'
devices = 'Dispositivos'
disable = 'desativar'
distance = 'Distância'
dmesg = 'Log do Kernel'
dnsserver = 'Servidor-<abbr title="Sistema de Nomes de Domínios">DNS</abbr>'
edit = 'Editar'
enable = 'ativar'

View file

@ -28,11 +28,12 @@
<i18n:msg xml:id="delete">Apagar</i18n:msg>
<i18n:msg xml:id="descr">Descrição</i18n:msg>
<i18n:msg xml:id="design">Tema</i18n:msg>
<i18n:msg xml:id="destination">Destino</i18n:msg>
<i18n:msg xml:id="destination">Destino</i18n:msg>
<i18n:msg xml:id="device">Dispositivo</i18n:msg>
<i18n:msg xml:id="devices">Dispositivos</i18n:msg>
<i18n:msg xml:id="disable">desativar</i18n:msg>
<i18n:msg xml:id="distance">Distância</i18n:msg>
<i18n:msg xml:id="dmesg">Log do Kernel</i18n:msg>
<i18n:msg xml:id="dnsserver">Servidor-<abbr title="Sistema de Nomes de Domínios">DNS</abbr></i18n:msg>
<i18n:msg xml:id="edit">Editar</i18n:msg>
<i18n:msg xml:id="enable">ativar</i18n:msg>
@ -87,7 +88,7 @@
<i18n:msg xml:id="services">Serviços</i18n:msg>
<i18n:msg xml:id="settings">Configurações</i18n:msg>
<i18n:msg xml:id="size">Tamanho</i18n:msg>
<i18n:msg xml:id="source">Origem</i18n:msg>
<i18n:msg xml:id="source">Origem</i18n:msg>
<i18n:msg xml:id="start">Início</i18n:msg>
<i18n:msg xml:id="static">estático</i18n:msg>
<i18n:msg xml:id="status">Status</i18n:msg>

View file

@ -22,6 +22,7 @@ device = 'Устройство'
devices = 'Устройства'
disable = 'выключено'
distance = 'Расстояние'
dmesg = 'Kernel log'
dnsserver = '<abbr title="Служба Доменных Имён">DNS</abbr>-Сервер'
edit = 'Редактировать'
enable = 'включено'

View file

@ -26,6 +26,7 @@
<i18n:msg xml:id="devices">Устройства</i18n:msg>
<i18n:msg xml:id="disable">выключено</i18n:msg>
<i18n:msg xml:id="distance">Расстояние</i18n:msg>
<i18n:msg xml:id="dmesg">Kernel log</i18n:msg>
<i18n:msg xml:id="dnsserver"><abbr title="Служба Доменных Имён">DNS</abbr>-Сервер</i18n:msg>
<i18n:msg xml:id="edit">Редактировать</i18n:msg>
<i18n:msg xml:id="enable">включено</i18n:msg>

View file

@ -261,6 +261,16 @@ function trim(str)
return (str:gsub("^%s*(.-)%s*$", "%1"))
end
--- Count the occurences of given substring in given string.
-- @param str String to search in
-- @param pattern String containing pattern to find
-- @return Number of found occurences
function cmatch(str, pat)
local count = 0
for _ in str:gmatch(pat) do count = count + 1 end
return count
end
--- Parse certain units from the given string and return the canonical integer
-- value or 0 if the unit is unknown. Upper- or lower case is irrelevant.
-- Recognized units are:
@ -320,6 +330,16 @@ function parse_units(ustr)
return val
end
-- also register functions above in the central string class for convenience
string.escape = escape
string.pcdata = pcdata
string.striptags = striptags
string.split = split
string.trim = trim
string.cmatch = cmatch
string.parse_units = parse_units
--- Appends numerically indexed tables or single objects to a given table.
-- @param src Target table
-- @param ... Objects to insert

View file

@ -204,6 +204,12 @@ function syslog()
return luci.util.exec("logread")
end
--- Retrieves the output of the "dmesg" command.
-- @return String containing the current log buffer
function dmesg()
return luci.util.exec("dmesg")
end
--- Generates a random id with specified length.
-- @param bytes Number of bytes for the unique id
-- @return String containing hex encoded id

View file

@ -18,10 +18,16 @@ function index()
local i18n = luci.i18n.translate
entry({"admin", "status"}, template("admin_status/index"), i18n("status", "Status"), 20).index = true
entry({"admin", "status", "syslog"}, call("action_syslog"), i18n("syslog", "Systemprotokoll"))
entry({"admin", "status", "syslog"}, call("action_syslog"), i18n("syslog", "Systemprotokoll"), 1)
entry({"admin", "status", "dmesg"}, call("action_dmesg"), i18n("dmesg", "Kernelprotokoll"), 2)
end
function action_syslog()
local syslog = luci.sys.syslog()
luci.template.render("admin_status/syslog", {syslog=syslog})
end
end
function action_dmesg()
local dmesg = luci.sys.dmesg()
luci.template.render("admin_status/dmesg", {dmesg=dmesg})
end

View file

@ -0,0 +1,20 @@
<%#
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
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
$Id: syslog.htm 3622 2008-10-23 16:05:55Z jow $
-%>
<%+header%>
<h2><a id="content" name="content"><%:dmesg%></a></h2>
<div id="content_syslog">
<textarea readonly="readonly" wrap="off" rows="<%=dmesg:cmatch("\n")+2%>" id="syslog"><%=dmesg:pcdata()%></textarea>
</div>
<%+footer%>

View file

@ -13,9 +13,8 @@ $Id$
-%>
<%+header%>
<h2><a id="content" name="content"><%:status%></a></h2>
<h3><%:syslog%></h3>
<h2><a id="content" name="content"><%:syslog%></a></h2>
<div id="content_syslog">
<textarea readonly="readonly" wrap="off" id="syslog"><%=luci.util.pcdata(syslog)%></textarea>
<textarea readonly="readonly" wrap="off" rows="<%=syslog:cmatch("\n")+2%>" id="syslog"><%=syslog:pcdata()%></textarea>
</div>
<%+footer%>

View file

@ -191,6 +191,14 @@ div#maincontent ul {
margin-bottom: 1em;
}
textarea#syslog {
width: 98%;
min-height: 500px;
border: 3px solid #cccccc;
padding: 5px;
font-family: monospace;
}
.cbi-section {
margin-bottom: 0.5em;
padding: 0.5em 1em;

View file

@ -356,6 +356,14 @@ html #menubar a:visited.warning {
margin-bottom: 1em;
}
textarea#syslog {
width: 98%;
min-height: 500px;
border: 3px solid #cccccc;
padding: 5px;
font-family: monospace;
}
.cbi-section {
margin-bottom: 0.5em;
padding: 0.5em 1em;

View file

@ -335,11 +335,10 @@ html #menubar a:visited.warning {
textarea#syslog {
width: 98%;
height: 450px;
min-height: 500px;
border: 3px solid #cccccc;
padding: 5px;
font-family: monospace;
overflow: auto;
}
#maincontent {

View file

@ -1,16 +1,16 @@
@charset "utf-8";
@media all {
html, body {
height: 100%;
}
body {
font-family: Verdana, Arial, sans-serif;
font-size: 101%;
line-height: 100%;
background: #557788 url(bg.png) no-repeat;
background: #557788 url(bg.png) no-repeat;
}
div#screen {
@ -110,13 +110,13 @@ code {
color: #ffffff;
width: 80%;
font-size: 0.8em;
margin: 0.5em auto;
padding: 0.25em;
padding-left: 0.5em;
padding-right: 0.5em;
border: 1px solid #000000;
border-radius: 0.8em;
-khtml-border-radius: 0.8em;
@ -136,9 +136,9 @@ html .menubar a:visited {
text-decoration: none;
font-weight: bold;
}
html .menubar a.menulink {
margin-left: 1em;
margin-left: 1em;
}
@ -186,7 +186,7 @@ html .menubar a:visited.warning {
color: #000000;
border-width: 1px solid #444444;
font-size: 80%;
border-radius: 1em;
-khtml-border-radius: 1em;
-moz-border-radius: 1em;
@ -211,6 +211,14 @@ html .menubar a:visited.warning {
margin-bottom: 1em;
}
textarea#syslog {
width: 98%;
min-height: 500px;
border: 3px solid #cccccc;
padding: 5px;
font-family: monospace;
}
.cbi-section {
margin-bottom: 0.5em;
padding: 0.5em 1em;