Recently I plan to do some UI customization for openwrt. I have studied the Luci custom topics and recorded them here.
I operate on the vro directly, so here I just explain how to modify the Luci topic directly on the vro running openwrt.
There are three main topics to be modified for custom Luci.
1. Static resources (style sheets, images, and JS files)
Luci stores all the static resources on the web page under/www/Luci-static. By default, there may be two directories, which are related to the number of topics you have installed. Take my example as an example, I only install the openwrt template, so I can see two directories: openwrt.org and resources.
The openwrt.org directory stores the CSS files and images used in the topic. Therefore, we can place CSS and images for custom themes here.
Resources Directory stores the common JS files used by the topic.
In this way, the custom topic can also store our resource files according to the directory structure. I created a yuchen directory to store my resource files. Of course, the JS files are stored in resources or directories named after custom themes.
2. Page Template
The lucion page template is composed of two htms with Lua scripts, specifically header.htmand footer.htm. The combination of the HTML code generated by these two files is the framework of all pages in Luci. These two files are located in/usr/lib/Lua/Luci/View/themes. I have created a yuchen in this directory and put the modified header.htmand footer.htm here. Here I just want to explain the Luci directory structure. The specific file content involves Lua scripts, so I will not elaborate on how to modify these two files, I believe that any front-end development experience can be handled.
3. Configuration File
After completing the preceding two steps, you need to configure your own theme to the Luci configuration file, which is located in/etc/config/Luci. The file structure is as follows:
VI/etc/config/Luci
1 config ‘core‘ ‘main‘ 2 option ‘lang‘ ‘zh_cn‘ 3 option ‘resourcebase‘ ‘/luci-static/resources‘ 4 option ‘mediaurlbase‘ ‘/luci-static/openwrt.org‘ 5 6 config ‘extern‘ ‘flash_keep‘ 7 option ‘uci‘ ‘/etc/config/‘ 8 option ‘dropbear‘ ‘/etc/dropbear/‘ 9 option ‘openvpn‘ ‘/etc/openvpn/‘10 option ‘passwd‘ ‘/etc/passwd‘11 option ‘opkg‘ ‘/etc/opkg.conf‘12 option ‘firewall‘ ‘/etc/firewall.user‘13 option ‘uploads‘ ‘/lib/uci/upload/‘14 15 config ‘internal‘ ‘languages‘16 option ‘zh_cn‘ ‘Chinese‘17 option ‘en‘ ‘English‘18 19 config ‘internal‘ ‘sauth‘20 option ‘sessionpath‘ ‘/tmp/luci-sessions‘21 option ‘sessiontime‘ ‘3600‘22 23 config ‘internal‘ ‘ccache‘24 option ‘enable‘ ‘1‘25 26 config ‘internal‘ ‘template‘27 option ‘compiler_mode‘ ‘memory‘28 option ‘compiledir‘ ‘/tmp/luci-templatecache‘29 30 config ‘internal‘ ‘themes‘31 option ‘OpenWrt‘ ‘/luci-static/openwrt.org‘
We only need to add a line of our own theme in the section 'internal' 'themes', and add it later:
option ‘yuchen‘ ‘/luci-static/yuchen‘
Save and exit, open Luci in the browser, select yuchen as the topic, and refresh the page to view the custom topic.
I am a lazy person, no. I just want to record it so that I don't forget it in the future. Let's take a look.