-- Use a table for fast concatenation of strings local SiteContent = {} function Output(String) table.insert(SiteContent, String) end function GetTableSize(Table) local Size = 0 for key,value in pairs(Table) do Size = Size + 1 end return Size end local function GetDefaultPage() local PM = cRoot:Get():GetPluginManager() local SubTitle = "Current Game" local Content = "" Content = Content .. "

Plugins:

" Content = Content .. "

Players:


"; return Content, SubTitle end function ShowPage(WebAdmin, TemplateRequest) SiteContent = {} local BaseURL = cWebAdmin: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 PageContent = PluginPage.Content local SubTitle = PluginPage.PluginFolder if (PluginPage.UrlPath ~= "") then SubTitle = PluginPage.PluginFolder .. " - " .. PluginPage.TabTitle 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 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([[ ]] .. Title .. [[
Menu
Home
Server Management
]]) -- 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 "")) end ) -- Translate the plugin name into the folder name (-> title) local pluginWebTitle = cPluginManager:Get():GetPluginFolderName(pluginName) or pluginName Output("\n"); -- Output each tab: for _, tab in pairs(pluginTabs) do Output("\n") end Output("
\n"); end Output([[
]] .. SubTitle .. [[
]] .. PageContent .. [[
]]) return table.concat(SiteContent) end