%#
Argonne is a clean HTML5 theme for LuCI. It is based on luci-theme-bootstrap and MUI and Argonne Template
luci-theme-argonne
Copyright 2021 Jerryk
Have a bug? Please create an issue here on GitHub!
https://github.com/kenzok78/luci-theme-argonne/issues
luci-theme-bootstrap:
Copyright 2008 Steven Barth
Copyright 2008-2016 Jo-Philipp Wich
Copyright 2012 David Menting
MUI:
https://github.com/muicss/mui
Agron Theme
https://demos.creative-tim.com/argon-dashboard/index.html
Licensed to the public under the Apache License 2.0
-%>
<%+header_login%>
<%
local util = require "luci.util"
local fs = require "nixio.fs"
local nutil = require "nixio.util"
local sys = require "luci.sys"
local json = require "luci.jsonc"
local uci = require 'luci.model.uci'.cursor()
-- Fetch Local Background Media
function glob(...)
local iter, code, msg = fs.glob(...)
if iter then
return nutil.consume(iter)
else
return nil, code, msg
end
end
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
local bg = {}
bg.type = ext
bg.url = themeDir .. fs.basename(f)
table.insert(backgroundTable,bg)
backgroundCount = backgroundCount + 1
end
end
end
return backgroundTable,backgroundCount
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/argonne') and uci:get_first('argonne', 'global', 'bing_background') or "0"
local backgroundTable, backgroundCount = fetchMedia("/www" .. themeDir .. "*",themeDir)
local backgroundType = "Image"
function getBing()
local bing = sys.exec("wget --timeout=0.5 -qO- '%s'" %bingApiUrl)
if (bing and bing ~= '') then
bgUrl = bingUrl .. json.parse(bing).images[1].url
end
end
if ( useBing == "0" ) then
if ( backgroundCount > 0 ) then
local currentBg = backgroundTable[math.random(1,backgroundCount)]
bgUrl = currentBg.url
if (currentBg.type == "mp4" ) then
backgroundType = "Video"
end
end
else
pcall(getBing)
end
%>
<% if ( backgroundType == "Video" ) then %>
<% else %>
<% end %>
<%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %>
<%
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+)$")
%>
<% end %>
<%+footer%>