* luci/themes: fix log pages
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 16 Nov 2008 22:45:10 +0000 (22:45 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 16 Nov 2008 22:45:10 +0000 (22:45 +0000)
* 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()

19 files changed:
i18n/english/luasrc/i18n/default.en.lua
i18n/english/luasrc/i18n/default.en.xml
i18n/french/luasrc/i18n/default.fr.lua
i18n/french/luasrc/i18n/default.fr.xml
i18n/german/luasrc/i18n/default.de.lua
i18n/german/luasrc/i18n/default.de.xml
i18n/portuguese_brazilian/luasrc/i18n/default.pt-br.lua
i18n/portuguese_brazilian/luasrc/i18n/default.pt-br.xml
i18n/russian/luasrc/i18n/default.ru.lua
i18n/russian/luasrc/i18n/default.ru.xml
libs/core/luasrc/util.lua
libs/sys/luasrc/sys.lua
modules/admin-full/luasrc/controller/admin/status.lua
modules/admin-full/luasrc/view/admin_status/dmesg.htm [new file with mode: 0644]
modules/admin-full/luasrc/view/admin_status/syslog.htm
themes/fledermaus/htdocs/luci-static/fledermaus/cascade.css
themes/openwrt-light/htdocs/luci-static/openwrt-light/cascade.css
themes/openwrt.org/htdocs/luci-static/openwrt.org/cascade.css
themes/oxygen/htdocs/luci-static/oxygen/cascade.css

index 666b7a3..d923a88 100644 (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'
index 3c0f270..e499dbb 100644 (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>
index 60cba34..808abea 100644 (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'
index d91f5e2..f17ef92 100644 (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>
index 24c37ea..238cba5 100644 (file)
@@ -27,6 +27,7 @@ device = 'Gerät'
 devices = 'Geräte'
 disable = 'deaktivieren'
 distance = 'Distanz'
+dmesg = 'Kernelprotokoll'
 dnsserver = 'DNS-Server'
 edit = 'Bearbeiten'
 enable = 'aktivieren'
index e9c4ca2..fb1348d 100644 (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>
index 3e17c47..26672bd 100644 (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'
index fbce7fb..ac90be3 100644 (file)
 <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>
index efdac7b..fe59e45 100644 (file)
@@ -22,6 +22,7 @@ device = 'Устройство'
 devices = 'Устройства'
 disable = 'выключено'
 distance = 'Расстояние'
+dmesg = 'Kernel log'
 dnsserver = '<abbr title="Служба Доменных Имён">DNS</abbr>-Сервер'
 edit = 'Редактировать'
 enable = 'включено'
index f3be7c7..69f092a 100644 (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>
index 109ccab..ea1fccb 100644 (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
index 413aa4c..52ed0c3 100644 (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
index addc3ca..09e7766 100644 (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
\ No newline at end of file
+end
+
+function action_dmesg()
+       local dmesg = luci.sys.dmesg()
+       luci.template.render("admin_status/dmesg", {dmesg=dmesg})
+end
diff --git a/modules/admin-full/luasrc/view/admin_status/dmesg.htm b/modules/admin-full/luasrc/view/admin_status/dmesg.htm
new file mode 100644 (file)
index 0000000..4fa8673
--- /dev/null
@@ -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%>
index d5bf5d6..2e172cf 100644 (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%>
index 590e062..f9adade 100644 (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;
index 6c0e282..a26e662 100644 (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;
index 2c0004c..8aea909 100644 (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 {
index 5bf14d2..585c970 100644 (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;