2022-01-11 22:43:10 +08:00
< %#
Argonne is a clean HTML5 theme for LuCI. It is based on luci-theme-bootstrap and MUI and Argonne Template
luci-theme-argonne
Have a bug? Please create an issue here on GitHub!
2023-04-30 12:50:32 +08:00
https://github.com/jerrykuku/luci-theme-argonne/issues
2022-01-11 22:43:10 +08:00
luci-theme-bootstrap:
Copyright 2008 Steven Barth < steven @ midlink . org >
Copyright 2008-2016 Jo-Philipp Wich < jow @ openwrt . org >
Copyright 2012 David Menting < david @ nut-bolt . nl >
MUI:
https://github.com/muicss/mui
2023-04-30 12:50:32 +08:00
Argonne Theme
2022-04-23 14:35:31 +08:00
https://demos.creative-tim.com/argon-dashboard/index.html
2022-01-11 22:43:10 +08:00
Licensed to the public under the Apache License 2.0
-%>
< %+header_login%>
< %
2023-04-30 12:50:32 +08:00
local util = require "luci.util"
local fs = require "nixio.fs"
local nutil = require "nixio.util"
local json = require "luci.jsonc"
local sys = require "luci.sys"
local uci = require 'luci.model.uci'.cursor()
2022-04-21 22:15:25 +08:00
-- Fetch Local Background Media
2023-04-30 12:50:32 +08:00
local function glob(...)
2022-01-11 22:43:10 +08:00
local iter, code, msg = fs.glob(...)
if iter then
return nutil.consume(iter)
else
return nil, code, msg
end
end
2023-04-30 12:50:32 +08:00
local imageTypes = " jpg png gif webp "
local videoTypes = " mp4 webm "
local allTypes = imageTypes .. videoTypes
local function fetchMedia(path, themeDir)
local backgroundTable = {}
local backgroundCount = 0
2022-01-11 22:43:10 +08:00
for i, f in ipairs(glob(path)) do
attr = fs.stat(f)
if attr then
2022-04-21 22:15:25 +08:00
local ext = fs.basename(f):match(".+%.(%w+)$")
2023-04-30 12:50:32 +08:00
if ext ~= nil then
ext = ext:lower()
end
if ext ~= nil and string.match(allTypes, " "..ext.." ") ~= nil then
2022-01-11 22:43:10 +08:00
local bg = {}
bg.type = ext
2022-04-21 22:15:25 +08:00
bg.url = themeDir .. fs.basename(f)
2023-04-30 12:50:32 +08:00
table.insert(backgroundTable, bg)
2022-04-21 22:15:25 +08:00
backgroundCount = backgroundCount + 1
2022-01-11 22:43:10 +08:00
end
end
end
2023-04-30 12:50:32 +08:00
return backgroundTable, backgroundCount
2022-04-21 22:15:25 +08:00
end
2023-04-30 12:50:32 +08:00
local function selectBackground(themeDir)
local bgUrl = media .. "/img/bg1.jpg"
local backgroundType = "Image"
local mimeType = ""
2022-04-21 22:15:25 +08:00
2023-04-30 12:50:32 +08:00
if fs.access("/etc/config/argonne") then
local online_wallpaper = uci:get_first('argonne', 'global', 'online_wallpaper') or (uci:get_first('argonne', 'global', 'bing_background') == '1' and 'bing')
if (online_wallpaper and online_wallpaper ~= "none") then
local picurl = sys.exec("/usr/libexec/argonne/online_wallpaper")
if (picurl and picurl ~= '') then
return picurl, "Image", ""
end
end
2022-04-21 22:15:25 +08:00
end
2022-01-11 22:43:10 +08:00
2023-04-30 12:50:32 +08:00
local backgroundTable, backgroundCount = fetchMedia("/www" .. themeDir .. "*", themeDir)
2022-04-21 22:15:25 +08:00
if ( backgroundCount > 0 ) then
2023-04-30 12:50:32 +08:00
local currentBg = backgroundTable[math.random(1, backgroundCount)]
bgUrl = currentBg.url
if (string.match(videoTypes, " "..currentBg.type.." ") ~= nil) then
backgroundType = "Video"
mimeType = "video/" .. currentBg.type
2022-04-21 22:15:25 +08:00
end
end
2023-04-30 12:50:32 +08:00
return bgUrl, backgroundType, mimeType
2022-04-21 22:15:25 +08:00
end
2023-04-30 12:50:32 +08:00
local boardinfo = util.ubus("system", "board")
local themeDir = media .. "/background/"
local bgUrl, backgroundType, mimeType = selectBackground(themeDir)
2022-01-11 22:43:10 +08:00
%>
2022-04-21 22:15:25 +08:00
<!-- Login Page Start -->
2022-01-11 22:43:10 +08:00
< div class = "login-page" >
2022-04-21 22:15:25 +08:00
< % if ( backgroundType == "Video" ) then %>
<!-- Video Player Start -->
2023-04-30 12:50:32 +08:00
< div class = "video" >
2022-01-11 22:43:10 +08:00
< video autoplay loop muted id = "video" >
2023-04-30 12:50:32 +08:00
< source src = "<%=bgUrl%>" type = "<%=mimeType%>" >
2022-01-11 22:43:10 +08:00
< / video >
< / div >
< div class = "volume-control mute" > < / div >
2023-04-30 12:50:32 +08:00
< script >
$(".volume-control").click(function(){
if($(this).hasClass("mute")){
$(this).removeClass("mute")
$("#video").prop('muted', false);
}else{
$(this).addClass("mute")
$("#video").prop('muted', true);
}
})
< / script >
2022-04-21 22:15:25 +08:00
<!-- Video Player End -->
< % else %>
<!-- Image Background Start -->
< div class = "main-bg" id = "main-bg" style = "background-image:url(<%=bgUrl%>)" > < / div >
<!-- Image Background End -->
2022-01-11 22:43:10 +08:00
< % end %>
2022-04-21 22:15:25 +08:00
<!-- Login Container Start -->
2022-01-11 22:43:10 +08:00
< div class = "login-container" >
< div class = "login-form" >
2023-04-30 12:50:32 +08:00
<!-- Logo Start -->
< a class = "brand" href = "/" > < img src = "<%=media%>/img/argonne.svg" class = "icon" >
< span class = "brand-text" > < %=striptags( (boardinfo.hostname or "?") ) %>< / span >
< / a >
<!-- Logo End -->
<!-- Login Form Start -->
2022-01-11 22:43:10 +08:00
< form class = "form-login" method = "post" action = "<%=pcdata(luci.http.getenv(" REQUEST_URI " ) ) % > ">
< %- if fuser then %>
< div class = "errorbox" > < %:Invalid username and/or password! Please try again.%>< / div >
< % end -%>
< div class = "input-container" >
< div class = "input-group user-icon" >
< input class = "cbi-input-user" id = "cbi-input-user" type = "text" name = "luci_username" value = "<%=duser%>" / >
< label class = "border" for = "cbi-input-user" > < / label >
< / div >
< div class = "input-group pass-icon" >
< input class = "cbi-input-password" id = "cbi-input-password" type = "password" name = "luci_password" / >
< label class = "border" for = "cbi-input-password" > < / label >
< / div >
< / div >
< div >
< input type = "submit" value = "<%:Login%>" class = "cbi-button cbi-button-apply" / >
< / div >
< / form >
2023-04-30 12:50:32 +08:00
<!-- Login Form End -->
2022-01-11 22:43:10 +08:00
< script type = "text/javascript" > / / < ! [ C D A T A [
var input = document.getElementsByName('luci_password')[0];
if (input)
input.focus();
//]]>< / script >
< %
local uci = require "luci.model.uci".cursor()
local fs = require "nixio.fs"
local https_key = uci:get("uhttpd", "main", "key")
local https_port = uci:get("uhttpd", "main", "listen_https")
if type(https_port) == "table" then
https_port = https_port[1]
end
if https_port and fs.access(https_key) then
https_port = https_port:match("(%d+)$")
%>
< script type = "text/javascript" > / / < ! [ C D A T A [
if (document.location.protocol != 'https:') {
var url = 'https://' + window.location.hostname + ':' + '< %=https_port%>' + window.location.pathname;
var img = new Image;
img.onload = function () { window.location = url };
img.src = 'https://' + window.location.hostname + ':' + '< %=https_port%>' + '< %=resource%>/cbi/up.gif?' + Math.random();;
setTimeout(function () {
img.src = ''
}, 5000);
}
//]]>< / script >
< % end %>
< %+footer%>