Skip to content

Commit

Permalink
Merge pull request #310 from jjm2473/luci-21
Browse files Browse the repository at this point in the history
Luci 21相关的各种优化
  • Loading branch information
jerrykuku authored Apr 24, 2022
2 parents 7dacb6e + ed74e9c commit 385cd0e
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 66 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
include $(TOPDIR)/rules.mk

LUCI_TITLE:=Argon Theme
LUCI_DEPENDS:=
PKG_VERSION:=2.2.9
PKG_RELEASE:=20211016-1
LUCI_DEPENDS:=+curl +jsonfilter
PKG_VERSION:=2.2.9.4
PKG_RELEASE:=20220421

include $(TOPDIR)/feeds/luci/luci.mk

# call BuildPackage - OpenWrt buildroot signature
# call BuildPackage - OpenWrt buildroot signature
2 changes: 1 addition & 1 deletion htdocs/luci-static/argon/background/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Drop background here!
accept jpg png gif and mp4
accept jpg png gif mp4 webm
2 changes: 1 addition & 1 deletion htdocs/luci-static/argon/css/cascade.css

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion htdocs/luci-static/argon/less/cascade.less
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,10 @@ fieldset>fieldset,
padding: 1rem;
}

.cbi-tblsection {
overflow-x: scroll;
}

table {
border-spacing: 0;
border-collapse: collapse;
Expand Down Expand Up @@ -1521,6 +1525,11 @@ tr>th,
width: 100%;
}

.cbi-section-table-row>.cbi-value-field .cbi-input-text,
.cbi-section-table-row>.cbi-value-field .cbi-input-password {
min-width: 80px;
}

.cbi-section-table-row>.cbi-value-field [data-dynlist]>input,
.cbi-section-table-row>.cbi-value-field input.cbi-input-password {
width: calc(100% - 1.5rem);
Expand All @@ -1530,6 +1539,11 @@ tr>th,
text-align: center !important;
}

.cbi-section-table-row>.cbi-value-field .control-group {
display: inline-flex;
width: 100%;
}

div>table>tbody>tr:nth-of-type(2n),
div>.table>.tr:nth-of-type(2n) {
background-color: #f9f9f9;
Expand Down Expand Up @@ -2901,7 +2915,7 @@ td>.ifacebadge,
}

.cbi-section-table-row>.cbi-value-field .cbi-dropdown {
min-width: 7rem;
min-width: 3rem;
}

.cbi-section-create {
Expand Down
24 changes: 14 additions & 10 deletions htdocs/luci-static/resources/menu-argon.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ return baseclass.extend({

handleMenuExpand: function (ev) {
var a = ev.target, slide = a.parentNode, slide_menu = a.nextElementSibling;
var collapse = false;

document.querySelectorAll('.main .main-left .nav > li >ul.active').forEach(function (ul) {
if (ul !== slide_menu) {
$(ul).stop(true).slideUp("fast", function () {
ul.classList.remove('active');
ul.previousElementSibling.classList.remove('active');
});
$(ul).stop(true).slideUp("fast", function () {
ul.classList.remove('active');
ul.previousElementSibling.classList.remove('active');
});
if (!collapse && ul === slide_menu) {
collapse = true;
}

});
Expand All @@ -52,11 +54,13 @@ return baseclass.extend({
return;


$(slide).find(".slide-menu").slideDown("fast",function(){
slide_menu.classList.add('active');
a.classList.add('active');
});
a.blur();
if (!collapse) {
$(slide).find(".slide-menu").slideDown("fast",function(){
slide_menu.classList.add('active');
a.classList.add('active');
});
a.blur();
}
ev.preventDefault();
ev.stopPropagation();
},
Expand Down
2 changes: 0 additions & 2 deletions luasrc/view/themes/argon/footer_login.htm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<a class="luci-link" href="https://github.com/openwrt/luci">Powered by <%= ver.luciname %> (<%= ver.luciversion %>)</a> /
<a href="https://github.com/jerrykuku/luci-theme-argon">ArgonTheme <%# vPKG_VERSION %></a> /
<%= ver.distversion %>
<ul class="breadcrumb pull-right" id="modemenu" style="display:none"></ul>
</div>
</footer>
</div>
Expand All @@ -41,6 +40,5 @@
}
})
</script>
<script type="text/javascript">L.require('menu-argon')</script>
</body>
</html>
11 changes: 6 additions & 5 deletions luasrc/view/themes/argon/header.htm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
local util = require "luci.util"
local http = require "luci.http"
local disp = require "luci.dispatcher"
local ver = require "luci.version"

local boardinfo = util.ubus("system", "board")

Expand Down Expand Up @@ -85,7 +86,7 @@
<meta name="msapplication-TileColor" content="<%=bar_color%>">
<meta name="msapplication-TileImage" content="<%=media%>/icon/ms-icon-144x144.png">
<meta name="theme-color" content="<%=bar_color%>">
<link rel="stylesheet" href="<%=media%>/css/cascade.css?v=<%=math.random(1,100000)%>">
<link rel="stylesheet" href="<%=media%>/css/cascade.css<%# ?v=PKG_VERSION %>">
<style title="text/css">
<% if mode == 'normal' then %>
@media (prefers-color-scheme: dark) {
Expand Down Expand Up @@ -115,10 +116,10 @@
</style>
<% end -%>
<script src="<%=media%>/js/polyfill.min.js"></script>
<script src="<%=url('admin/translations', luci.i18n.context.lang)%>?v=2.2.4"></script>
<script src="<%=resource%>/cbi.js?v=2.2.4"></script>
<script src="<%=resource%>/luci.js?v=2.2.4"></script>
<script src="<%=media%>/js/jquery.min.js?v=2.2.4"></script>
<script src="<%=url('admin/translations', luci.i18n.context.lang)%>?v=<%=ver.luciversion%>"></script>
<script src="<%=resource%>/cbi.js?v=<%=ver.luciversion%>"></script>
<script src="<%=resource%>/luci.js?v=<%=ver.luciversion%>"></script>
<script src="<%=media%>/js/jquery.min.js?v=3.5.1"></script>
</head>

<body
Expand Down
12 changes: 4 additions & 8 deletions luasrc/view/themes/argon/header_login.htm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
local util = require "luci.util"
local http = require "luci.http"
local disp = require "luci.dispatcher"
local ver = require "luci.version"

local boardinfo = util.ubus("system", "board")

Expand Down Expand Up @@ -82,7 +83,7 @@
<meta name="msapplication-TileColor" content="<%=bar_color%>">
<meta name="msapplication-TileImage" content="<%=media%>/icon/ms-icon-144x144.png">
<meta name="theme-color" content="<%=bar_color%>">
<link rel="stylesheet" href="<%=media%>/css/cascade.css?v=<%=math.random(1,100000)%>">
<link rel="stylesheet" href="<%=media%>/css/cascade.css<%# ?v=PKG_VERSION %>">
<style title="text/css">
<% if mode == 'normal' then %>
@media (prefers-color-scheme: dark) {
Expand Down Expand Up @@ -111,13 +112,8 @@
<%=css %>
</style>
<% end -%>
<script src="<%=url('admin/translations', luci.i18n.context.lang)%><%# ?v=PKG_VERSION %>"></script>
<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=PKG_VERSION %>"></script>
<script src="<%=media%>/js/jquery.min.js?v=3.5.1"></script>

</head>

<body
class="lang_<%=luci.i18n.context.lang%> <% if node then %><%= striptags( node.title ) %><% end %> <% if luci.dispatcher.context.authsession then %>logged-in<% end %>"
data-page="<%= table.concat(disp.context.requestpath, "-") %>">
<body>
28 changes: 2 additions & 26 deletions luasrc/view/themes/argon/out_header_login.htm
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,10 @@
-%>

<%
local ver = require "luci.version"

if not luci.dispatcher.context.template_header_sent then
include("themes/" .. theme .. "/header_login")
luci.dispatcher.context.template_header_sent = true
end

local applyconf = luci.config and luci.config.apply
%>

<script type="text/javascript" src="<%=resource%>/promis.min.js"></script>
<script type="text/javascript" src="<%=resource%>/luci.js"></script>
<script type="text/javascript">
L = new LuCI(<%= luci.http.write_json({
token = token,
media = media,
resource = resource,
scriptname = luci.http.getenv("SCRIPT_NAME"),
pathinfo = luci.http.getenv("PATH_INFO"),
documentroot = luci.http.getenv("DOCUMENT_ROOT"),
requestpath = luci.dispatcher.context.requestpath,
dispatchpath = luci.dispatcher.context.path,
pollinterval = luci.config.main.pollinterval or 5,
ubuspath = luci.config.main.ubuspath or '/ubus/',
sessionid = luci.dispatcher.context.authsession,
nodespec = luci.dispatcher.context.dispatched,
apply_rollback = math.max(applyconf and applyconf.rollback or 90, 90),
apply_holdoff = math.max(applyconf and applyconf.holdoff or 4, 1),
apply_timeout = math.max(applyconf and applyconf.timeout or 5, 1),
apply_display = math.max(applyconf and applyconf.display or 1.5, 1),
rollback_token = rollback_token
}) %>);
</script>
18 changes: 10 additions & 8 deletions luasrc/view/themes/argon/sysauth.htm
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@
end


local imageTypes = " jpg png gif "
local videoTypes = " mp4 webm "
local allTypes = imageTypes .. videoTypes
function fetchMedia(path,themeDir)
local backgroundTable = {}
local backgroundCount = 0
for i, f in ipairs(glob(path)) do
attr = fs.stat(f)
if attr then
local ext = fs.basename(f):match(".+%.(%w+)$")
if ext == "jpg" or ext == "png" or ext == "gif" or ext == "mp4" then
if ext ~= nil and string.match(allTypes, " "..ext.." ") ~= nil then
local bg = {}
bg.type = ext
bg.url = themeDir .. fs.basename(f)
Expand All @@ -62,24 +65,23 @@
end

local boardinfo = util.ubus("system", "board")
local bingUrl = "http://www.bing.com/"
local bingApiUrl = bingUrl .. "HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US"
local themeDir = media .. "/background/"
local bgUrl = media .. "/img/bg1.jpg"
local useBing = fs.access('/etc/config/argon') and "1" or "0"
local backgroundTable, backgroundCount = fetchMedia("/www" .. themeDir .. "*",themeDir)
local backgroundType = "Image"
local mimeType = ""

if ( backgroundCount > 0 ) then
local currentBg = backgroundTable[math.random(1,backgroundCount)]
bgUrl = currentBg.url
if (currentBg.type == "mp4" ) then
if (string.match(videoTypes, " "..currentBg.type.." ") ~= nil) then
backgroundType = "Video"
mimeType = "video/" .. currentBg.type
end
else
local bing = sys.exec("wget --timeout=0.5 -qO- '%s'" %bingApiUrl)
local bing = sys.exec("/usr/libexec/argon/bing_wallpaper")
if (bing and bing ~= '') then
bgUrl = bingUrl .. json.parse(bing).images[1].url
bgUrl = bing
end
end
%>
Expand All @@ -89,7 +91,7 @@
<!-- Video Player Start -->
<div class="video">
<video autoplay loop muted id="video">
<source src="<%=bgUrl%>" type="video/mp4">
<source src="<%=bgUrl%>" type="<%=mimeType%>">
</video>
</div>
<div class="volume-control mute"></div>
Expand Down
52 changes: 52 additions & 0 deletions root/usr/libexec/argon/bing_wallpaper
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/sh
# author jjm2473

BING_BASE=http://www.bing.com
CACHE=/var/run/argon_bing.url
WRLOCK=/var/lock/argon_bing.lock

fetch_url_path() {
curl --fail --show-error --max-time 1 \
"$BING_BASE/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US" 2>/dev/null \
| jsonfilter -q -e '@.images[0].url'
}

try_update() {
local lock="$WRLOCK"
exec 200>$lock

if flock -n 200 >/dev/null 2>&1; then
local path=`fetch_url_path`
if [ -n "$path" ]; then
echo "${BING_BASE}${path}" | tee "$CACHE"
else
if [ -s "$CACHE" ]; then
cat "$CACHE"
else
touch "$CACHE"
fi
fi
flock -u 200 >/dev/null 2>&1
elif [ -s "$CACHE" ]; then
cat "$CACHE"
fi
}

get_url() {
if [ -f "$CACHE" ]; then
local idle_t=$((`date '+%s'` - `date -r "$CACHE" '+%s' 2>/dev/null || echo '0'`))
if [ -s "$CACHE" ]; then
if [ $idle_t -le 43200 ]; then
cat "$CACHE"
return
fi
else
if [ $idle_t -le 120 ]; then
return
fi
fi
fi
try_update
}

get_url

0 comments on commit 385cd0e

Please sign in to comment.