summaryrefslogtreecommitdiffstats
path: root/Server/webadmin/template.lua
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2016-03-02 10:05:10 +0100
committerMattes D <github@xoft.cz>2016-03-17 19:29:01 +0100
commit62d81eb763e6fb72af5d828c1892156e1f5a3127 (patch)
tree7c04181f9f1f21dbe6a5ef00d5fed53c1baa8a54 /Server/webadmin/template.lua
parentAdded cLuaState::cCallback for representing (resettable) Lua callbacks. (diff)
downloadcuberite-62d81eb763e6fb72af5d828c1892156e1f5a3127.tar
cuberite-62d81eb763e6fb72af5d828c1892156e1f5a3127.tar.gz
cuberite-62d81eb763e6fb72af5d828c1892156e1f5a3127.tar.bz2
cuberite-62d81eb763e6fb72af5d828c1892156e1f5a3127.tar.lz
cuberite-62d81eb763e6fb72af5d828c1892156e1f5a3127.tar.xz
cuberite-62d81eb763e6fb72af5d828c1892156e1f5a3127.tar.zst
cuberite-62d81eb763e6fb72af5d828c1892156e1f5a3127.zip
Diffstat (limited to 'Server/webadmin/template.lua')
-rw-r--r--Server/webadmin/template.lua62
1 files changed, 41 insertions, 21 deletions
diff --git a/Server/webadmin/template.lua b/Server/webadmin/template.lua
index d80ca5f74..168f87993 100644
--- a/Server/webadmin/template.lua
+++ b/Server/webadmin/template.lua
@@ -20,7 +20,7 @@ end
-function GetDefaultPage()
+local function GetDefaultPage()
local PM = cRoot:Get():GetPluginManager()
local SubTitle = "Current Game"
@@ -55,30 +55,31 @@ end
function ShowPage(WebAdmin, TemplateRequest)
SiteContent = {}
- local BaseURL = WebAdmin:GetBaseURL(TemplateRequest.Request.Path)
+ 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 = WebAdmin:GetPage(TemplateRequest.Request)
+ local PluginPage = cWebAdmin:GetPage(TemplateRequest.Request)
local PageContent = PluginPage.Content
- local SubTitle = PluginPage.PluginName
- if (PluginPage.TabName ~= "") then
- SubTitle = PluginPage.PluginName .. " - " .. PluginPage.TabName
+ 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
+ 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([[
<!-- Copyright Justin S and Cuberite Team, licensed under CC-BY-SA 3.0 -->
@@ -133,20 +134,39 @@ function ShowPage(WebAdmin, TemplateRequest)
<td class="trow1 smalltext">
]])
-
- 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("<div><a class='usercp_nav_item usercp_nav_pmfolder' style='text-decoration:none;'><b>"..PluginWebTitle.."</b></a></div>\n");
-
- for webname,prettyname in pairs(TabNames) do
- Output("<div><a href='" .. BaseURL .. PluginWebTitle .. "/" .. webname .. "' class='usercp_nav_item usercp_nav_sub_pmfolder'>" .. prettyname .. "</a></div>\n")
+ -- 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
-
- Output("<br>\n");
+ )
+
+ -- Translate the plugin name into the folder name (-> title)
+ local pluginWebTitle = cPluginManager:Get():GetPluginFolderName(pluginName) or pluginName
+ Output("<div><a class='usercp_nav_item usercp_nav_pmfolder' style='text-decoration:none;'><b>" .. pluginWebTitle .. "</b></a></div>\n");
+
+ -- Output each tab:
+ for _, tab in pairs(pluginTabs) do
+ Output("<div><a href='" .. BaseURL .. pluginName .. "/" .. tab.UrlPath .. "' class='usercp_nav_item usercp_nav_sub_pmfolder'>" .. tab.Title .. "</a></div>\n")
end
+ Output("<br>\n");
end