自用修改:
--[[
luci 封装好的html控件类可以在以下文件查看:./host/usr/lib/lua/luci/cbi.lua
Diagnostics 页面相关文件: controller/admin/network.lua, view/admin_network/diagnostics.htm
HTM 页面的变量和lua交互, html中: name="ping", this.form.ping, lua中: diag_ping
<input style="width: 50%" type="text" value="openwrt.org" name="ping" />
<input type="button" value="<%:Ping%>" class="cbi-button cbi-button-apply" οnclick="update_status(this.form.ping,this.form.proto)" />
page = entry({"admin", "network", "diag_ping"}, call("diag_ping"), nil)
#只修改 name="pingxu", this.form.pingxu, 页面也执行, 出现如下错误:
No page is registered at '/admin/network/diag_pingxu/openwrt.org'.
If this url belongs to an extension, make sure it is properly installed.
If the extension was recently installed, try removing the /tmp/luci-indexcache file.
--- 再修改 diag_pingxu 则OK, page = entry({"admin", "network", "diag_pingxu"}, call("diag_ping"), nil)
在已有的lua文件中修改, 网页上可以直接看到界面; 增加或删除lua文件, 则必须重启路由器才可以看到界面
#lua中增加页面: view/xutest/web-cgi.htm, 后缀名必须为htm, 不能为html.
page.target = template("xutest/web-cgi")
/usr/lib/lua/luci/template.lua:81: Failed to load template 'xutest/web-cgi'.
Error while parsing template '/usr/lib/lua/luci/view/xutest/web-cgi.htm'.
#htm 中直接跳转
<a href="http://www.w3school.com.cn/index.html">W3School web
#/www/xutest/web-cgi.html, uhttp默认的跟目录和luci中的目录不同. 192.168.1.1 换成localhost 则错误
<a href="http://192.168.1.1/xutest/web-cgi.html">web-cgi
#index.html中 直接执行luci命令
<a style="color: white; text-decoration: none" href="/cgi-bin/luci">LuCI - Lua Configuration Interface
]]--
page = node("admin", "network", "diagnostics")
-- 直接链接到 view 相应目录下面的 htm 页面
page.target = template("admin_network/diagnostics")
page.title = _("Diagnostics")
page.order = 60
参考:
1. luci在线API: http://luci.subsignal.org/api/luci/
2. luci实现框架: http://www.cnblogs.com/zmkeil/archive/2013/05/14/3078774.html
BusyBox v1.19.4 (2013-09-27 00:16:27 EDT) built-in shell (ash)
Enter 'help' for a list of built-in commands.
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
BARRIER BREAKER (Attitude Adjustment 12.09.1-qiushui007 test)
-----------------------------------------------------
* 1/2 oz Galliano Pour all ingredients into
* 4 oz cold Coffee an irish coffee mug filled
* 1 1/2 oz Dark Rum with crushed ice. Stir.
* 2 tsp. Creme de Cacao
-----------------------------------------------------
root@OpenWrt:~# df -h
Filesystem Size Used Available Use% Mounted on
rootfs 5.3M 272.0K 5.0M 5% /
/dev/root 1.8M 1.8M 0 100% /rom
tmpfs 30.2M 88.0K 30.1M 0% /tmp
tmpfs 512.0K 0 512.0K 0% /dev
root 30.2M 48.0K 30.1M 0% /tmp/root
overlayfs:/tmp/root 30.2M 48.0K 30.1M 0% /tmp/root
/dev/mtdblock3 5.3M 272.0K 5.0M 5% /overlay
overlayfs:/overlay 5.3M 272.0K 5.0M 5% /
root@OpenWrt:/xutest# opkg update
Downloading http://192.168.2.224/packages-ar71xx-AA/Packages.gz.
Updated list of available packages in /var/opkg-lists/snapshots.
root@OpenWrt:/xutest# opkg install luci
Installing luci (0.11.1-1) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/luci_0.11.1-1_ar71xx.ipk.
Installing uhttpd (2012-10-30-e57bf6d8bfa465a50eea2c30269acdfe751a46fd) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/uhttpd_2012-10-30-e57bf6d8bfa465a50eea2c30269acdfe751a46fd_ar71xx.ipk.
Installing luci-mod-admin-full (0.11.1-1) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/luci-mod-admin-full_0.11.1-1_ar71xx.ipk.
Installing luci-mod-admin-core (0.11.1-1) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/luci-mod-admin-core_0.11.1-1_ar71xx.ipk.
Installing luci-lib-web (0.11.1-1) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/luci-lib-web_0.11.1-1_ar71xx.ipk.
Installing luci-lib-core (0.11.1-1) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/luci-lib-core_0.11.1-1_ar71xx.ipk.
Installing lua (5.1.4-8) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/lua_5.1.4-8_ar71xx.ipk.
Installing liblua (5.1.4-8) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/liblua_5.1.4-8_ar71xx.ipk.
Installing libuci-lua (2013-01-04.1-1) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/libuci-lua_2013-01-04.1-1_ar71xx.ipk.
Installing libubus-lua (2013-01-13-bf566871bd6a633e4504c60c6fc55b2a97305a50) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/libubus-lua_2013-01-13-bf566871bd6a633e4504c60c6fc55b2a97305a50_ar71xx.ipk.
Installing luci-lib-sys (0.11.1-1) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/luci-lib-sys_0.11.1-1_ar71xx.ipk.
Installing luci-lib-nixio (0.11.1-1) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/luci-lib-nixio_0.11.1-1_ar71xx.ipk.
Installing luci-sgi-cgi (0.11.1-1) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/luci-sgi-cgi_0.11.1-1_ar71xx.ipk.
Installing luci-proto-core (0.11.1-1) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/luci-proto-core_0.11.1-1_ar71xx.ipk.
Installing luci-i18n-english (0.11.1-1) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/luci-i18n-english_0.11.1-1_ar71xx.ipk.
Installing luci-lib-ipkg (0.11.1-1) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/luci-lib-ipkg_0.11.1-1_ar71xx.ipk.
Installing luci-theme-openwrt (0.11.1-1) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/luci-theme-openwrt_0.11.1-1_ar71xx.ipk.
Installing luci-theme-base (0.11.1-1) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/luci-theme-base_0.11.1-1_ar71xx.ipk.
Installing luci-app-firewall (0.11.1-1) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/luci-app-firewall_0.11.1-1_ar71xx.ipk.
Installing luci-proto-ppp (0.11.1-1) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/luci-proto-ppp_0.11.1-1_ar71xx.ipk.
Installing libiwinfo-lua (36) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/libiwinfo-lua_36_ar71xx.ipk.
Installing libiwinfo (36) to root...
Downloading http://192.168.2.224/packages-ar71xx-AA/libiwinfo_36_ar71xx.ipk.
Configuring luci-lib-sys.
Configuring liblua.
Configuring libuci-lua.
Configuring lua.
Configuring libubus-lua.
Configuring luci-lib-core.
Configuring luci-lib-nixio.
Configuring luci-sgi-cgi.
Configuring luci-lib-web.
Configuring luci-proto-core.
Configuring luci-i18n-english.
Configuring luci-mod-admin-core.
Configuring libiwinfo.
Configuring libiwinfo-lua.
Configuring luci-theme-base.
Configuring luci-theme-openwrt.
Configuring luci-app-firewall.
Configuring luci-lib-ipkg.
Configuring luci-proto-ppp.
Configuring luci-mod-admin-full.
Configuring uhttpd.
Configuring luci.
Collected errors:
* resolve_conffiles: Existing conffile /etc/config/luci is different from the conffile in the new package. The new conffile will be placed at /etc/config/luci-opkg.
root@OpenWrt:/xutest# df -h
Filesystem Size Used Available Use% Mounted on
rootfs 5.3M 944.0K 4.4M 17% /
/dev/root 1.8M 1.8M 0 100% /rom
tmpfs 30.2M 388.0K 29.8M 1% /tmp
tmpfs 512.0K 0 512.0K 0% /dev
root 30.2M 48.0K 30.1M 0% /tmp/root
overlayfs:/tmp/root 30.2M 48.0K 30.1M 0% /tmp/root
/dev/mtdblock3 5.3M 944.0K 4.4M 17% /overlay
overlayfs:/overlay 5.3M 944.0K 4.4M 17% /