<%# Spectra - A Modern Responsive LuCI Theme A clean, responsive web interface for OpenWRT LuCI luci-theme-spectra Copyright 2024 Thaolga Features: - Modern responsive design - Mobile-first approach - Enhanced user experience - Customizable appearance Based on: - luci-theme-bootstrap (Apache License 2.0) - luci-theme-argon (Apache License 2.0) - Bootstrap & MUI design principles For bug reports, feature requests and contributions: https://github.com/Thaolga/openwrt-nekobox Licensed under the Apache License, Version 2.0 -%> <%+themes/spectra/out_header_login%> <% local util = require "luci.util" local fs = require "nixio.fs" local nutil = require "nixio.util" local sys = require "luci.sys" -- Fetch Local Background Media local function glob(...) local iter, code, msg = fs.glob(...) if iter then return nutil.consume(iter) else return nil, code, msg end end local imageTypes = " jpg jpeg png gif webp " local videoTypes = " mp4 webm mkv " local audioTypes = " mp3 wav ogg flac m4a " local allTypes = imageTypes .. videoTypes .. audioTypes local 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 ~= nil then ext = ext:lower() end if ext ~= nil and string.match(allTypes, " "..ext.." ") ~= nil 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 function selectBackground(themeDir) local bgUrl = media .. "/img/bg1.jpg" local backgroundType = "Image" local mimeType = "" local audioUrl = "" local audioMimeType = "" local mediaTable, mediaCount = fetchMedia("/www" .. themeDir .. "*", themeDir) if mediaCount > 0 then local videoFiles = {} local audioFiles = {} local imageFiles = {} for _, mediaFile in ipairs(mediaTable) do if string.match(videoTypes, " "..mediaFile.type.." ") ~= nil then table.insert(videoFiles, mediaFile) elseif string.match(audioTypes, " "..mediaFile.type.." ") ~= nil then table.insert(audioFiles, mediaFile) elseif string.match(imageTypes, " "..mediaFile.type.." ") ~= nil then table.insert(imageFiles, mediaFile) end end if #videoFiles > 0 then local selectedVideo = videoFiles[math.random(1, #videoFiles)] bgUrl = selectedVideo.url backgroundType = "Video" mimeType = "video/" .. selectedVideo.type if #audioFiles > 0 then local selectedAudio = audioFiles[math.random(1, #audioFiles)] audioUrl = selectedAudio.url audioMimeType = "audio/" .. selectedAudio.type end elseif #imageFiles > 0 then local selectedImage = imageFiles[math.random(1, #imageFiles)] bgUrl = selectedImage.url backgroundType = "Image" if #audioFiles > 0 then local selectedAudio = audioFiles[math.random(1, #audioFiles)] audioUrl = selectedAudio.url audioMimeType = "audio/" .. selectedAudio.type end end end return bgUrl, backgroundType, mimeType, audioUrl, audioMimeType end local boardinfo = util.ubus("system", "board") local themeDir = "/spectra/stream/" local bgUrl, backgroundType, mimeType, audioUrl, audioMimeType = selectBackground(themeDir) %>
<% if ( backgroundType == "Video" ) then %> <% else %>
<% if ( audioUrl ~= "" ) then %> <% else %> <% end %> <% end %>
<% if fuser then %> <% end %>
">
<%+themes/spectra/footer_login%>