mirror of
https://github.com/sirpdboy/luci-theme-kucat.git
synced 2025-01-07 03:16:57 +08:00
493 lines
16 KiB
HTML
493 lines
16 KiB
HTML
<%#
|
|
Copyright (C) 2019-2024 The Sirpdboy Team <herboy2008@gmail.com>
|
|
luci-theme-material:
|
|
Copyright 2015 Lutty Yang <lutty@wcan.in>
|
|
luci-theme-bootstrap:
|
|
Copyright 2008 Steven Barth <steven@midlink.org>
|
|
Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
|
|
Copyright 2012 David Menting <david@nut-bolt.nl>
|
|
|
|
MUI:
|
|
https://github.com/muicss/mui
|
|
Licensed to the public under the Apache License 2.0
|
|
-%>
|
|
|
|
<%
|
|
local sys = require "luci.sys"
|
|
local util = require "luci.util"
|
|
local http = require "luci.http"
|
|
local disp = require "luci.dispatcher"
|
|
local json = require "luci.jsonc"
|
|
local fs = require "nixio.fs"
|
|
local nutil = require "nixio.util"
|
|
local uci = require 'luci.model.uci'.cursor()
|
|
local boardinfo = util.ubus("system", "board")
|
|
|
|
local request = disp.context.path
|
|
local request2 = disp.context.request
|
|
|
|
local category = request[1]
|
|
local cattree = category and disp.node(category)
|
|
|
|
local leaf = request2[#request2]
|
|
|
|
local tree = disp.node()
|
|
local node = disp.context.dispatched
|
|
|
|
local categories = disp.node_childs(tree)
|
|
local c = tree
|
|
local i, r
|
|
|
|
function glob(...)
|
|
local iter, code, msg = fs.glob(...)
|
|
if iter then
|
|
return nutil.consume(iter)
|
|
else
|
|
return nil, code, msg
|
|
end
|
|
end
|
|
function getExtension(str)
|
|
return str:match(".+%.(%w+)$")
|
|
end
|
|
-- tag all nodes leading to this page
|
|
for i, r in ipairs(request) do
|
|
if c.nodes and c.nodes[r] then
|
|
c = c.nodes[r]
|
|
c._menu_selected = true
|
|
end
|
|
end
|
|
|
|
-- send as HTML5
|
|
http.prepare_content("text/html")
|
|
|
|
local function nodeurl(prefix, name, query)
|
|
local u = url(prefix, name)
|
|
if query then
|
|
u = u .. http.build_querystring(query)
|
|
end
|
|
return pcdata(u)
|
|
end
|
|
|
|
local function render_tabmenu(prefix, node, level)
|
|
if not level then
|
|
level = 1
|
|
end
|
|
|
|
local childs = disp.node_childs(node)
|
|
if #childs > 0 then
|
|
if level > 2 then
|
|
write('<ul class="tabs">')
|
|
end
|
|
|
|
local selected_node
|
|
local selected_name
|
|
local i, v
|
|
|
|
for i, v in ipairs(childs) do
|
|
local nnode = node.nodes[v]
|
|
if nnode._menu_selected then
|
|
selected_node = nnode
|
|
selected_name = v
|
|
end
|
|
|
|
if level > 2 then
|
|
write('<li class="tabmenu-item-%s %s"><a href="%s">%s</a></li>' %{
|
|
v, (nnode._menu_selected or (node.leaf and v == leaf)) and 'active' or '',
|
|
nodeurl(prefix, v, nnode.query),
|
|
striptags(translate(nnode.title))
|
|
})
|
|
end
|
|
end
|
|
|
|
if level > 2 then
|
|
write('</ul>')
|
|
end
|
|
|
|
if selected_node then
|
|
render_tabmenu(prefix .. "/" .. selected_name, selected_node, level + 1)
|
|
end
|
|
end
|
|
end
|
|
|
|
local function render_submenu(prefix, node)
|
|
local childs = disp.node_childs(node)
|
|
if #childs > 0 then
|
|
|
|
write('<ul class="slide-menu">')
|
|
|
|
for i, r in ipairs(childs) do
|
|
local nnode = node.nodes[r]
|
|
local title = pcdata(striptags(translate(nnode.title)))
|
|
|
|
write('<li><a data-title="%s" href="%s">%s</a></li>' %{
|
|
title,
|
|
nodeurl(prefix, r, nnode.query),
|
|
title
|
|
})
|
|
end
|
|
|
|
write('</ul>')
|
|
end
|
|
end
|
|
|
|
local function render_topmenu()
|
|
local childs = disp.node_childs(cattree)
|
|
if #childs > 0 then
|
|
write('<ul class="nav">')
|
|
|
|
for i, r in ipairs(childs) do
|
|
local nnode = cattree.nodes[r]
|
|
local grandchildren = disp.node_childs(nnode)
|
|
|
|
if #grandchildren > 0 then
|
|
local title = pcdata(striptags(translate(nnode.title)))
|
|
local en_title = pcdata(striptags(string.gsub(nnode.title," ","_")))
|
|
write('<li class="slide"><a class="menu" data-title="%s" href="#">%s</a>' %{
|
|
en_title,
|
|
title
|
|
})
|
|
|
|
render_submenu(category .. "/" .. r, nnode)
|
|
write('</li>')
|
|
else
|
|
local title = pcdata(striptags(translate(nnode.title)))
|
|
local en_title = pcdata(striptags(nnode.title))
|
|
write('<li class="slide"><a class="menu exit" data-title="%s" href="%s">%s</a></li>' %{
|
|
en_title,
|
|
nodeurl(category, r, nnode.query),
|
|
title
|
|
})
|
|
end
|
|
end
|
|
|
|
write('</ul>')
|
|
end
|
|
end
|
|
|
|
local function render_changes()
|
|
if tree.nodes[category] and tree.nodes[category].ucidata then
|
|
local ucichanges = 0
|
|
for i, j in pairs(require("luci.model.uci").cursor():changes()) do
|
|
for k, l in pairs(j) do
|
|
for m, n in pairs(l) do
|
|
ucichanges = ucichanges + 1;
|
|
end
|
|
end
|
|
end
|
|
|
|
if ucichanges > 0 then
|
|
write('<a class="uci_change_indicator label notice" href="%s?redir=%s">%s: %d</a>' %{
|
|
url(category, 'uci/changes'),
|
|
http.urlencode(http.formvalue('redir') or table.concat(disp.context.request, "/")),
|
|
translate('Unsaved Changes'),
|
|
ucichanges
|
|
})
|
|
end
|
|
end
|
|
end
|
|
local bar='/cgi-bin/luci/admin/'
|
|
local mode = 'light'
|
|
local home = ''
|
|
local user = ''
|
|
local setbar = "1"
|
|
local bgqs = '1'
|
|
local ssr = ""
|
|
local gohome = bar .. 'status/' ..home
|
|
local gouser = bar .. 'system/' ..user
|
|
local gossr = bar .. 'services/' ..ssr
|
|
local background = '0'
|
|
local fontd = '1.2rem'
|
|
local fontz = '0.92rem'
|
|
local fontx = '0.875rem'
|
|
local primary_rgbbody = '248,248,248'
|
|
local primary_rgbm = '45,102,147'
|
|
local primary_rgbm_ts = '0.8'
|
|
local primary_rgbs = '132,188,218'
|
|
local primary_rgbs_ts = '0.1'
|
|
local primary_opacity = '0'
|
|
local bkuse = '0'
|
|
local bk_use='rgba(var(--primary-rgbbody),1)'
|
|
local loginbk_use = 'background: linear-gradient(0deg, rgba(var(--primary-rgbm), 1) 0%, rgba(var(--primary-rgbbody), 1) 100%)'
|
|
local bklock = '1'
|
|
local dayword = '0'
|
|
local kucat = ''
|
|
if fs.access('/etc/config/advancedplus') then
|
|
kucat = 'advancedplus'
|
|
elseif fs.access('/etc/config/kucat') then
|
|
kucat = 'kucat'
|
|
end
|
|
if (kucat and kucat ~= '') then
|
|
primary_rgbbody = uci:get_first(kucat, 'basic', 'primary_rgbbody')
|
|
primary_rgbm = uci:get_first(kucat, 'basic', 'primary_rgbm')
|
|
primary_rgbm_ts = uci:get_first(kucat, 'basic', 'primary_rgbm_ts')
|
|
primary_opacity = uci:get_first(kucat, 'basic', 'primary_opacity')
|
|
primary_rgbs = uci:get_first(kucat, 'basic', 'primary_rgbs')
|
|
primary_rgbs_ts = uci:get_first(kucat, 'basic', 'primary_rgbs_ts')
|
|
mode = uci:get_first(kucat, 'basic', 'mode')
|
|
setbar = uci:get_first(kucat, 'basic', 'setbar')
|
|
home = uci:get_first(kucat, 'basic', 'gohome')
|
|
user = uci:get_first(kucat, 'basic', 'gouser')
|
|
ssr = uci:get_first(kucat, 'basic', 'gossr')
|
|
gohome = bar .. "status/" .. home
|
|
gouser = bar .. "system/" .. user
|
|
gossr = bar .. "services/" .. ssr
|
|
background = uci:get_first(kucat, 'basic', 'background')
|
|
bkuse = uci:get_first(kucat, 'basic', 'bkuse')
|
|
bklock = uci:get_first(kucat, 'basic', 'bklock')
|
|
fontd = uci:get_first(kucat, 'basic', 'font_d')
|
|
fontz = uci:get_first(kucat, 'basic', 'font_z')
|
|
fontx = uci:get_first(kucat, 'basic', 'font_x')
|
|
bgqs = uci:get_first(kucat, 'basic', 'bgqs')
|
|
dayword = uci:get_first(kucat, 'basic', 'dayword')
|
|
end
|
|
local primary_ufilter = "saturate(150%) contrast(50%) blur(" .. primary_opacity .. "px)"
|
|
if primary_opacity == '0' then
|
|
primary_ufilter = 'none'
|
|
end
|
|
local bgqs_image = '-webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent)'
|
|
if bgqs == '1' then
|
|
bgqs_image = 'rgba(var(--primary-rgbm),var(--primary-rgbm-ts))'
|
|
end
|
|
local bg_url = media..'/img/bg1.jpg'
|
|
if background == '0' then
|
|
math.randomseed(os.time())
|
|
|
|
local theme_dir = resource .. '/background/'
|
|
if not fs.access('/www' .. resource .. '/background/') then
|
|
local theme_dir = media .. '/background/'
|
|
end
|
|
local bgcount = 0
|
|
local currentBg = {}
|
|
local bgs,attr = {}
|
|
for i, f in ipairs(glob("/www" .. theme_dir .. "*")) do
|
|
attr = fs.stat(f)
|
|
if attr then
|
|
local ext = getExtension(fs.basename(f))
|
|
if ext == "jpg" or ext == "png" or ext == "gif" then
|
|
local bg = {}
|
|
bg.type = ext
|
|
bg.url = theme_dir .. fs.basename(f)
|
|
table.insert(bgs,bg)
|
|
bgcount = bgcount + 1
|
|
end
|
|
end
|
|
end
|
|
if bgcount > 0 then
|
|
currentBg = bgs[math.random(1,bgcount)]
|
|
picurl = currentBg.url
|
|
end
|
|
else
|
|
picurl = sys.exec("/usr/libexec/kucat/kucat_wallpaper")
|
|
end
|
|
if (picurl and picurl ~= '') then
|
|
bg_url = picurl
|
|
end
|
|
local bg_lock = bg_url
|
|
if bklock == '0' then
|
|
math.randomseed(os.time())
|
|
local bk_dir = media .. "/bg/"
|
|
local bkcount = 0
|
|
local currentbk = {}
|
|
local bgs,attr = {}
|
|
for i, f in ipairs(glob("/www" .. bk_dir .. "*")) do
|
|
attr = fs.stat(f)
|
|
if attr then
|
|
local ext = getExtension(fs.basename(f))
|
|
if ext == "jpg" or ext == "png" or ext == "gif" then
|
|
local bg = {}
|
|
bg.type = ext
|
|
bg.url = bk_dir .. fs.basename(f)
|
|
table.insert(bgs,bg)
|
|
bkcount = bkcount + 1
|
|
end
|
|
end
|
|
end
|
|
if bkcount > 0 then
|
|
currentbk = bgs[math.random(1,bkcount)]
|
|
bg_lock = currentbk.url
|
|
end
|
|
end
|
|
if dayword == '1' then
|
|
showword = sys.exec("/usr/libexec/kucat/kucat_word")
|
|
end
|
|
if bkuse == '1' then
|
|
bk_use='url('..bg_lock..') no-repeat center center fixed'
|
|
loginbk_use = "background-image:url(" .. bg_url .. ")"
|
|
end
|
|
-%>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="<%=luci.i18n.context.lang%>">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
|
|
<link rel="manifest" href="<%=media%>/manifest.json" crossorigin="use-credentials">
|
|
|
|
<title> <%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
|
|
<meta name="format-detection" content="telephone=no, email=no" />
|
|
|
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
<meta name="mobile-web-app-capable" content="yes">
|
|
<meta name="x5-fullscreen" content="true">
|
|
<meta name="full-screen" content="yes">
|
|
<meta name="x5-page-mode" content="app">
|
|
<meta name="browsermode" content="application">
|
|
<meta name="msapplication-tap-highlight" content="no">
|
|
<meta name="msapplication-TileColor" content="<%=bar_color%>">
|
|
<meta name="theme-color" media="(prefers-color-scheme: light)" content="white">
|
|
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="black">
|
|
<meta name="application-name" content="<%=striptags( (boardinfo.hostname or "?") ) %> - LuCI">
|
|
<meta name="apple-mobile-web-app-title" content="<%=striptags( (boardinfo.hostname or "?") ) %> - LuCI">
|
|
|
|
<link rel="apple-touch-icon" sizes="144x144" href="<%=media%>/img/apple-touch-icon.png">
|
|
<link rel="apple-touch-icon-precomposed" href="<%=media%>/img/apple-touch-icon.png" sizes="144x144">
|
|
|
|
<link rel="icon" type="image/png" sizes="192x192" href="<%=media%>/logo.png">
|
|
<meta name="msapplication-TileColor" content="<%=bar_color%>">
|
|
<meta name="msapplication-TileImage" content="<%=media%>/logo.png"/>
|
|
<meta name="theme-color" content="<%=bar_color%>">
|
|
<link rel="shortcut icon" href="<%=media%>/favicon.ico" type="image/x-icon">
|
|
<link rel="icon" href="<%=media%>/logo.png" type="image/png">
|
|
<link rel="icon" href="<%=media%>/logo.svg" sizes="any">
|
|
<link rel="stylesheet" href="<%=media%>/css/style.css?v=<%=math.random(1,100000)%>">
|
|
<style title="text/css">
|
|
|
|
:root {
|
|
--primary-rgbbody:<%=primary_rgbbody%>;
|
|
--primary-rgbm: <%=primary_rgbm%>;
|
|
--primary-rgbm-ts: <%=primary_rgbm_ts%>;
|
|
--primary-rgbs: <%=primary_rgbs%>;
|
|
--primary-rgbs-ts: <%=primary_rgbs_ts%>;
|
|
--primary-ufilter: <%=primary_ufilter%>;
|
|
--font-d: <%=fontd%>;
|
|
--font-z: <%=fontz%>;
|
|
--font-x: <%=fontx%>;
|
|
--theme-background: <%=bk_use%>;
|
|
--bgqs-image: <%=bgqs_image%>;
|
|
}
|
|
img[src*="/luci-static/resources/cbi/add.gif"] {
|
|
background-image: url(<%=media%>/img/add.png);
|
|
}
|
|
|
|
img[src*="/luci-static/resources/cbi/remove.gif"] {
|
|
background-image: url(<%=media%>/img/del.png);
|
|
}
|
|
|
|
img[src*="/luci-static/resources/cbi/reload.gif"] {
|
|
background-image: url(<%=media%>/img/reload.png);
|
|
}
|
|
<% if setbar == "1" then %>
|
|
header.bar-primary .container-bar-left {
|
|
width: 300px;
|
|
display: block;
|
|
}
|
|
header.bar-primary .container-bar-right {
|
|
width: 0;
|
|
display: none;
|
|
}
|
|
<% else %>
|
|
header.bar-primary .container-bar-left {
|
|
width: 0;
|
|
display: none;
|
|
}
|
|
header.bar-primary .container-bar-right {
|
|
width: 50px;
|
|
display: block;
|
|
}
|
|
<% end -%>
|
|
</style>
|
|
<% if node and node.css then %>
|
|
<link rel="stylesheet" href="<%=resource%>/<%=node.css%>">
|
|
<% end -%>
|
|
<% if css then %>
|
|
<style title="text/css"><%=css %></style>
|
|
<% end -%>
|
|
<script src="<%=resource%>/cbi.js<%# ?v=PKG_VERSION %>"></script>
|
|
<script src="<%=resource%>/xhr.js<%# ?v=PKG_VERSION %>"></script>
|
|
<script src="<%=media%>/js/jquery.min.js?v=3.5.1"></script>
|
|
</head>
|
|
<body
|
|
class="<%- if node then %><%= striptags( node.title ) %><%- end %> <% if luci.dispatcher.context.authsession then %>logged-in<% end %> lang_<%=luci.i18n.context.lang%> "
|
|
<% if mode ~= 'auto' then %>
|
|
data-theme = "<%= mode %>"
|
|
<% end -%>
|
|
>
|
|
<% if mode == 'auto' then %>
|
|
<script>
|
|
function setTheme() {
|
|
let color_scheme = window.matchMedia('(prefers-color-scheme: dark)');
|
|
document.body.setAttribute('data-theme', color_scheme.matches? 'dark': 'light');
|
|
}
|
|
setTheme();
|
|
window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', setTheme);
|
|
</script>
|
|
<% end -%>
|
|
<header class="bar-primary">
|
|
<div id="header-bar-left" class="container-bar-left">
|
|
<a class="labelbar pdboy-closebar" href="javascript:void(0)" onclick="pdclosebar()" title="Close" ></a>
|
|
<a class="labelbar pdboy-gohome" href="<%=gohome%>" title="<%=Status%>"></a>
|
|
<a class="labelbar pdboy-goadvanced" href="<%=gouser%>" title="<%=System%>"></a>
|
|
<a class="labelbar pdboy-gossr" href="<%=gossr%>" title="<%=Services%>"></a>
|
|
<a class="labelbar pdboy-gonet" href="<%=url("admin/network/network")%>" title="<%:Network%>"></a>
|
|
<a class="labelbar pdboy-gopoweroff" href="<%=url("admin/system/reboot")%>" title="<%:Reboot%>"></a>
|
|
</div>
|
|
<div id="header-bar-right" class="container-bar-right">
|
|
<a class="labelbar pdboy-openbar" href="javascript:void(0)" title="Open" onclick="pdopenbar()"></a>
|
|
</div>
|
|
</header>
|
|
<div class="main">
|
|
<div style="" class="loading">
|
|
</div>
|
|
<div class="main-left">
|
|
<div class="sidenav-header d-flex align-items-center">
|
|
<a class="brand" href="#"><%=boardinfo.hostname or "?"%></a>
|
|
</div>
|
|
<% render_topmenu() %>
|
|
</div>
|
|
<div class="main-right">
|
|
<header class="pd-primary">
|
|
<div class="fill">
|
|
<div class="container">
|
|
<div class="flex1">
|
|
<a class="showSide" title="<%:Menu%>" ></a>
|
|
<a class="brand" href="#"><%=striptags(boardinfo.hostname or "OpenWrt")%></a>
|
|
</div>
|
|
<% if dayword == '1' then %>
|
|
<a class="showWord" href="#"><%=showword%></a>
|
|
<% end -%>
|
|
<% render_changes() %>
|
|
<span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
|
|
<a class="pdboy-status_on" id="xhr_poll_status_on" title="Disable Refresh"></a>
|
|
<a class="pdboy-status_off" id="xhr_poll_status_off" style="display:none" title="Enable Refresh"></a>
|
|
</span>
|
|
|
|
<span > <a class="pdboy-qlogout" href="<%=url("admin/logout")%>" title="<%:Logout%>" > </a></span>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
<div class="darkMask"></div>
|
|
<div class="login-bg" style="<%=loginbk_use%>"></div>
|
|
<div id="maincontent">
|
|
<div class="container">
|
|
<%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
|
|
<div class="alert-message warning">
|
|
<h4><%:No password set!%></h4>
|
|
<p><%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%>
|
|
</p>
|
|
<div class="right"><a class="btn"
|
|
href="<%=url("admin/system/admin")%>"><%:Go to password configuration...%></a></div>
|
|
</div>
|
|
<%- end -%>
|
|
|
|
<noscript>
|
|
<div class="alert-message warning">
|
|
<h4><%:JavaScript required!%></h4>
|
|
<p><%:You must enable JavaScript in your browser or LuCI will not work properly.%></p>
|
|
</div>
|
|
</noscript>
|
|
<% if category then render_tabmenu(category, cattree) end %>
|
|
<script>
|
|
var luciLocation = <%= luci.http.write_json(luci.dispatcher.context.path) %>;
|
|
</script>
|
|
<script src="<%=media%>/js/menu-kucat.js<%# ?v=PKG_VERSION %>"></script>
|