From cbed72fb47c8c0eda6322574c678389b795cd23c Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 16 Nov 2008 22:45:10 +0000 Subject: [PATCH] * 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() --- i18n/english/luasrc/i18n/default.en.lua | 1 + i18n/english/luasrc/i18n/default.en.xml | 1 + i18n/french/luasrc/i18n/default.fr.lua | 1 + i18n/french/luasrc/i18n/default.fr.xml | 1 + i18n/german/luasrc/i18n/default.de.lua | 1 + i18n/german/luasrc/i18n/default.de.xml | 1 + .../luasrc/i18n/default.pt-br.lua | 1 + .../luasrc/i18n/default.pt-br.xml | 5 ++-- i18n/russian/luasrc/i18n/default.ru.lua | 1 + i18n/russian/luasrc/i18n/default.ru.xml | 1 + libs/core/luasrc/util.lua | 20 ++++++++++++++ libs/sys/luasrc/sys.lua | 6 +++++ .../luasrc/controller/admin/status.lua | 10 +++++-- .../luasrc/view/admin_status/dmesg.htm | 20 ++++++++++++++ .../luasrc/view/admin_status/syslog.htm | 5 ++-- .../htdocs/luci-static/fledermaus/cascade.css | 8 ++++++ .../luci-static/openwrt-light/cascade.css | 8 ++++++ .../luci-static/openwrt.org/cascade.css | 3 +-- .../htdocs/luci-static/oxygen/cascade.css | 26 ++++++++++++------- 19 files changed, 102 insertions(+), 18 deletions(-) create mode 100644 modules/admin-full/luasrc/view/admin_status/dmesg.htm diff --git a/i18n/english/luasrc/i18n/default.en.lua b/i18n/english/luasrc/i18n/default.en.lua index 666b7a312..d923a88fc 100644 --- a/i18n/english/luasrc/i18n/default.en.lua +++ b/i18n/english/luasrc/i18n/default.en.lua @@ -27,6 +27,7 @@ device = 'Device' devices = 'Devices' disable = 'disable' distance = 'Distance' +dmesg = 'Kernel Log' dnsserver = 'DNS-Server' edit = 'Edit' enable = 'enable' diff --git a/i18n/english/luasrc/i18n/default.en.xml b/i18n/english/luasrc/i18n/default.en.xml index 3c0f270c2..e499dbb39 100644 --- a/i18n/english/luasrc/i18n/default.en.xml +++ b/i18n/english/luasrc/i18n/default.en.xml @@ -32,6 +32,7 @@ Devices disable Distance +Kernel Log DNS-Server Edit enable diff --git a/i18n/french/luasrc/i18n/default.fr.lua b/i18n/french/luasrc/i18n/default.fr.lua index 60cba3438..808abea94 100644 --- a/i18n/french/luasrc/i18n/default.fr.lua +++ b/i18n/french/luasrc/i18n/default.fr.lua @@ -27,6 +27,7 @@ device = 'Equipement' devices = 'Equipements' disable = 'désactiver' distance = 'Distance' +dmesg = 'Journal du noyau' dnsserver = 'Serveur DNS' edit = 'Editer' enable = 'activer' diff --git a/i18n/french/luasrc/i18n/default.fr.xml b/i18n/french/luasrc/i18n/default.fr.xml index d91f5e287..f17ef92c9 100644 --- a/i18n/french/luasrc/i18n/default.fr.xml +++ b/i18n/french/luasrc/i18n/default.fr.xml @@ -32,6 +32,7 @@ Equipements désactiver Distance +Journal du noyau Serveur DNS Editer activer diff --git a/i18n/german/luasrc/i18n/default.de.lua b/i18n/german/luasrc/i18n/default.de.lua index 24c37eaa9..238cba56e 100644 --- a/i18n/german/luasrc/i18n/default.de.lua +++ b/i18n/german/luasrc/i18n/default.de.lua @@ -27,6 +27,7 @@ device = 'Gerät' devices = 'Geräte' disable = 'deaktivieren' distance = 'Distanz' +dmesg = 'Kernelprotokoll' dnsserver = 'DNS-Server' edit = 'Bearbeiten' enable = 'aktivieren' diff --git a/i18n/german/luasrc/i18n/default.de.xml b/i18n/german/luasrc/i18n/default.de.xml index e9c4ca2c0..fb1348d11 100644 --- a/i18n/german/luasrc/i18n/default.de.xml +++ b/i18n/german/luasrc/i18n/default.de.xml @@ -36,6 +36,7 @@ Geräte deaktivieren Distanz +Kernelprotokoll DNS-Server Bearbeiten diff --git a/i18n/portuguese_brazilian/luasrc/i18n/default.pt-br.lua b/i18n/portuguese_brazilian/luasrc/i18n/default.pt-br.lua index 3e17c478b..26672bdf9 100644 --- a/i18n/portuguese_brazilian/luasrc/i18n/default.pt-br.lua +++ b/i18n/portuguese_brazilian/luasrc/i18n/default.pt-br.lua @@ -28,6 +28,7 @@ device = 'Dispositivo' devices = 'Dispositivos' disable = 'desativar' distance = 'Distância' +dmesg = 'Log do Kernel' dnsserver = 'Servidor-DNS' edit = 'Editar' enable = 'ativar' diff --git a/i18n/portuguese_brazilian/luasrc/i18n/default.pt-br.xml b/i18n/portuguese_brazilian/luasrc/i18n/default.pt-br.xml index fbce7fbb6..ac90be3ba 100644 --- a/i18n/portuguese_brazilian/luasrc/i18n/default.pt-br.xml +++ b/i18n/portuguese_brazilian/luasrc/i18n/default.pt-br.xml @@ -28,11 +28,12 @@ Apagar Descrição Tema -Destino +Destino Dispositivo Dispositivos desativar Distância +Log do Kernel Servidor-DNS Editar ativar @@ -87,7 +88,7 @@ Serviços Configurações Tamanho -Origem +Origem Início estático Status diff --git a/i18n/russian/luasrc/i18n/default.ru.lua b/i18n/russian/luasrc/i18n/default.ru.lua index efdac7bc0..fe59e45a1 100644 --- a/i18n/russian/luasrc/i18n/default.ru.lua +++ b/i18n/russian/luasrc/i18n/default.ru.lua @@ -22,6 +22,7 @@ device = 'Устройство' devices = 'Устройства' disable = 'выключено' distance = 'Расстояние' +dmesg = 'Kernel log' dnsserver = 'DNS-Сервер' edit = 'Редактировать' enable = 'включено' diff --git a/i18n/russian/luasrc/i18n/default.ru.xml b/i18n/russian/luasrc/i18n/default.ru.xml index f3be7c7fb..69f092ac3 100644 --- a/i18n/russian/luasrc/i18n/default.ru.xml +++ b/i18n/russian/luasrc/i18n/default.ru.xml @@ -26,6 +26,7 @@ Устройства выключено Расстояние +Kernel log DNS-Сервер Редактировать включено diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua index 109ccab28..ea1fccbc1 100644 --- a/libs/core/luasrc/util.lua +++ b/libs/core/luasrc/util.lua @@ -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 diff --git a/libs/sys/luasrc/sys.lua b/libs/sys/luasrc/sys.lua index 413aa4c11..52ed0c36d 100644 --- a/libs/sys/luasrc/sys.lua +++ b/libs/sys/luasrc/sys.lua @@ -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 diff --git a/modules/admin-full/luasrc/controller/admin/status.lua b/modules/admin-full/luasrc/controller/admin/status.lua index addc3ca74..09e7766c1 100644 --- a/modules/admin-full/luasrc/controller/admin/status.lua +++ b/modules/admin-full/luasrc/controller/admin/status.lua @@ -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 index 000000000..4fa867397 --- /dev/null +++ b/modules/admin-full/luasrc/view/admin_status/dmesg.htm @@ -0,0 +1,20 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008 Steven Barth +Copyright 2008 Jo-Philipp Wich + +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%> +

<%:dmesg%>

+
+ +
+<%+footer%> diff --git a/modules/admin-full/luasrc/view/admin_status/syslog.htm b/modules/admin-full/luasrc/view/admin_status/syslog.htm index d5bf5d65a..2e172cfbf 100644 --- a/modules/admin-full/luasrc/view/admin_status/syslog.htm +++ b/modules/admin-full/luasrc/view/admin_status/syslog.htm @@ -13,9 +13,8 @@ $Id$ -%> <%+header%> -

<%:status%>

-

<%:syslog%>

+

<%:syslog%>

- +
<%+footer%> diff --git a/themes/fledermaus/htdocs/luci-static/fledermaus/cascade.css b/themes/fledermaus/htdocs/luci-static/fledermaus/cascade.css index 590e06298..f9adadee8 100644 --- a/themes/fledermaus/htdocs/luci-static/fledermaus/cascade.css +++ b/themes/fledermaus/htdocs/luci-static/fledermaus/cascade.css @@ -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; diff --git a/themes/openwrt-light/htdocs/luci-static/openwrt-light/cascade.css b/themes/openwrt-light/htdocs/luci-static/openwrt-light/cascade.css index 6c0e282c5..a26e66222 100644 --- a/themes/openwrt-light/htdocs/luci-static/openwrt-light/cascade.css +++ b/themes/openwrt-light/htdocs/luci-static/openwrt-light/cascade.css @@ -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; diff --git a/themes/openwrt.org/htdocs/luci-static/openwrt.org/cascade.css b/themes/openwrt.org/htdocs/luci-static/openwrt.org/cascade.css index 2c0004cbb..8aea90999 100644 --- a/themes/openwrt.org/htdocs/luci-static/openwrt.org/cascade.css +++ b/themes/openwrt.org/htdocs/luci-static/openwrt.org/cascade.css @@ -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 { diff --git a/themes/oxygen/htdocs/luci-static/oxygen/cascade.css b/themes/oxygen/htdocs/luci-static/oxygen/cascade.css index 5bf14d2f9..585c9700a 100644 --- a/themes/oxygen/htdocs/luci-static/oxygen/cascade.css +++ b/themes/oxygen/htdocs/luci-static/oxygen/cascade.css @@ -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; -- 2.25.1