-- 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
function GetDefaultPage()
local PM = cRoot:Get():GetPluginManager()
local SubTitle = "Current Game"
local Content = ""
Content = Content .. "
Server Name:
"
Content = Content .. "
" .. cRoot:Get():GetServer():GetServerID() .. "
"
Content = Content .. "
Plugins:
"
local AllPlugins = PM:GetAllPlugins()
for key,value in pairs(AllPlugins) do
if( value ~= nil and value ~= false ) then
Content = Content .. "
" .. key .. " V." .. value:GetVersion() .. "
"
end
end
Content = Content .. "
"
Content = Content .. "
Players:
"
local AddPlayerToTable = function( Player )
Content = Content .. "
" .. Player:GetName() .. "
"
end
cRoot:Get():ForEachPlayer( AddPlayerToTable )
Content = Content .. "
";
return Content, SubTitle
end
function ShowPage(WebAdmin, TemplateRequest)
SiteContent = {}
local BaseURL = WebAdmin:GetBaseURL(TemplateRequest.Request.Path)
local Title = "MCServer"
local MemoryUsageKiB = cRoot:GetPhysicalRAMUsage()
local NumChunks = cRoot:Get():GetTotalChunkCount()
local PluginPage = WebAdmin:GetPage(TemplateRequest.Request)
local PageContent = PluginPage.Content
local SubTitle = PluginPage.PluginName
if (PluginPage.TabName ~= "") then
SubTitle = PluginPage.PluginName .. " - " .. PluginPage.TabName
end
if (PageContent == "") then
PageContent, SubTitle = GetDefaultPage()
end
Output([[
]] .. Title .. [[
]])
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.."
");
for webname,prettyname in pairs(TabNames) do
Output("