From e3d34d9917bb2c341de3c7206e3021e916d3f706 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 21 Mar 2016 09:58:15 +0100 Subject: Revert "Lua callback" --- Server/webadmin/template.lua | 62 +++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 41 deletions(-) (limited to 'Server/webadmin/template.lua') diff --git a/Server/webadmin/template.lua b/Server/webadmin/template.lua index 168f87993..d80ca5f74 100644 --- a/Server/webadmin/template.lua +++ b/Server/webadmin/template.lua @@ -20,7 +20,7 @@ end -local function GetDefaultPage() +function GetDefaultPage() local PM = cRoot:Get():GetPluginManager() local SubTitle = "Current Game" @@ -55,31 +55,30 @@ end function ShowPage(WebAdmin, TemplateRequest) SiteContent = {} - local BaseURL = cWebAdmin:GetBaseURL(TemplateRequest.Request.Path) + local BaseURL = WebAdmin:GetBaseURL(TemplateRequest.Request.Path) local Title = "Cuberite WebAdmin" local NumPlayers = cRoot:Get():GetServer():GetNumPlayers() local MemoryUsageKiB = cRoot:GetPhysicalRAMUsage() local NumChunks = cRoot:Get():GetTotalChunkCount() - local PluginPage = cWebAdmin:GetPage(TemplateRequest.Request) + local PluginPage = WebAdmin:GetPage(TemplateRequest.Request) local PageContent = PluginPage.Content - local SubTitle = PluginPage.PluginFolder - if (PluginPage.UrlPath ~= "") then - SubTitle = PluginPage.PluginFolder .. " - " .. PluginPage.TabTitle + local SubTitle = PluginPage.PluginName + if (PluginPage.TabName ~= "") then + SubTitle = PluginPage.PluginName .. " - " .. PluginPage.TabName end if (PageContent == "") then PageContent, SubTitle = GetDefaultPage() end - --[[ - -- 2016-01-15 Mattes: This wasn't used anywhere in the code, no idea what it was supposed to do local reqParamsClass = "" - for key, value in pairs(TemplateRequest.Request.Params) do + + for key,value in pairs(TemplateRequest.Request.Params) do reqParamsClass = reqParamsClass .. " param-" .. string.lower(string.gsub(key, "[^a-zA-Z0-9]+", "-") .. "-" .. string.gsub(value, "[^a-zA-Z0-9]+", "-")) end + if (string.gsub(reqParamsClass, "%s", "") == "") then reqParamsClass = " no-param" end - --]] Output([[ @@ -134,39 +133,20 @@ function ShowPage(WebAdmin, TemplateRequest) ]]) - -- Get all tabs: - local perPluginTabs = {} - for _, tab in ipairs(cWebAdmin:GetAllWebTabs()) do - local pluginTabs = perPluginTabs[tab.PluginName] or {}; - perPluginTabs[tab.PluginName] = pluginTabs - table.insert(pluginTabs, tab) - end - - -- Sort by plugin: - local pluginNames = {} - for pluginName, pluginTabs in pairs(perPluginTabs) do - table.insert(pluginNames, pluginName) - end - table.sort(pluginNames) - - -- Output by plugin, then alphabetically: - for _, pluginName in ipairs(pluginNames) do - local pluginTabs = perPluginTabs[pluginName] - table.sort(pluginTabs, - function(a_Tab1, a_Tab2) - return ((a_Tab1.Title or "") < (a_Tab2.Title or "")) + + local AllPlugins = WebAdmin:GetPlugins() + for key,value in pairs(AllPlugins) do + local PluginWebTitle = value:GetWebTitle() + local TabNames = value:GetTabNames() + if (GetTableSize(TabNames) > 0) then + Output("
"..PluginWebTitle.."
\n"); + + for webname,prettyname in pairs(TabNames) do + Output("
" .. prettyname .. "
\n") end - ) - - -- Translate the plugin name into the folder name (-> title) - local pluginWebTitle = cPluginManager:Get():GetPluginFolderName(pluginName) or pluginName - Output("
" .. pluginWebTitle .. "
\n"); - - -- Output each tab: - for _, tab in pairs(pluginTabs) do - Output("
" .. tab.Title .. "
\n") + + Output("
\n"); end - Output("
\n"); end -- cgit v1.2.3