diff --git a/include/znc/Modules.h b/include/znc/Modules.h index b7e3e995..ca075add 100644 --- a/include/znc/Modules.h +++ b/include/znc/Modules.h @@ -376,6 +376,8 @@ public: * @return The Title. */ virtual CString GetWebMenuTitle() { return ""; } + virtual CString GetWebPath(); + virtual CString GetWebFilesPath(); /** For WebMods: Called before the list of registered SubPages will be checked. * Important: If you return true, you need to take care of calling WebSock.Close! * This allows for stuff like returning non-templated data, long-polling and other fun. diff --git a/modules/cert.cpp b/modules/cert.cpp index a756b609..25e20d5b 100644 --- a/modules/cert.cpp +++ b/modules/cert.cpp @@ -73,11 +73,11 @@ public: fPemFile.Close(); } - WebSock.Redirect("/mods/cert/"); + WebSock.Redirect(GetWebPath()); return true; } else if (sPageName == "delete") { CFile::Delete(PemFile()); - WebSock.Redirect("/mods/cert/"); + WebSock.Redirect(GetWebPath()); return true; } diff --git a/modules/certauth.cpp b/modules/certauth.cpp index c5f2ff42..96e6a245 100644 --- a/modules/certauth.cpp +++ b/modules/certauth.cpp @@ -249,7 +249,7 @@ public: return true; } else if (sPageName == "add") { AddKey(pUser, WebSock.GetParam("key")); - WebSock.Redirect("/mods/certauth/"); + WebSock.Redirect(GetWebPath()); return true; } else if (sPageName == "delete") { MSCString::iterator it = m_PubKeys.find(pUser->GetUserName()); @@ -263,7 +263,7 @@ public: } } - WebSock.Redirect("/mods/certauth/"); + WebSock.Redirect(GetWebPath()); return true; } diff --git a/modules/data/cert/tmpl/index.tmpl b/modules/data/cert/tmpl/index.tmpl index 84356b63..5066573f 100644 --- a/modules/data/cert/tmpl/index.tmpl +++ b/modules/data/cert/tmpl/index.tmpl @@ -1,12 +1,12 @@ -

You already have a certificate set, use the form below to overwrite the current certificate. Alternatively click here to delete your certificate.

+

You already have a certificate set, use the form below to overwrite the current certificate. Alternatively click here to delete your certificate.

You do not have a cert.

-
+

Certificate

diff --git a/modules/data/certauth/tmpl/index.tmpl b/modules/data/certauth/tmpl/index.tmpl index 7cb9b136..b43e3975 100644 --- a/modules/data/certauth/tmpl/index.tmpl +++ b/modules/data/certauth/tmpl/index.tmpl @@ -1,6 +1,6 @@ - +

Add A Note

@@ -32,7 +32,7 @@ - [del] + [del] diff --git a/modules/data/lastseen/tmpl/index.tmpl b/modules/data/lastseen/tmpl/index.tmpl index ff24254d..3e8e43d0 100644 --- a/modules/data/lastseen/tmpl/index.tmpl +++ b/modules/data/lastseen/tmpl/index.tmpl @@ -17,8 +17,8 @@ - [Edit] - [Delete] + [Edit] + [Delete] diff --git a/modules/data/notes/tmpl/index.tmpl b/modules/data/notes/tmpl/index.tmpl index fad56494..3f7c62cc 100644 --- a/modules/data/notes/tmpl/index.tmpl +++ b/modules/data/notes/tmpl/index.tmpl @@ -1,6 +1,6 @@ - +

Add A Note

@@ -37,7 +37,7 @@ - [del] + [del] diff --git a/modules/data/perform/tmpl/index.tmpl b/modules/data/perform/tmpl/index.tmpl index d8a1d8cc..89920389 100644 --- a/modules/data/perform/tmpl/index.tmpl +++ b/modules/data/perform/tmpl/index.tmpl @@ -1,6 +1,6 @@ - +

Perform

diff --git a/modules/extra/data/send_raw/tmpl/index.tmpl b/modules/extra/data/send_raw/tmpl/index.tmpl index 088e1aa9..76ea4a91 100644 --- a/modules/extra/data/send_raw/tmpl/index.tmpl +++ b/modules/extra/data/send_raw/tmpl/index.tmpl @@ -1,6 +1,6 @@ - +
diff --git a/modules/notes.cpp b/modules/notes.cpp index 37404c4e..2d4dcf3b 100644 --- a/modules/notes.cpp +++ b/modules/notes.cpp @@ -200,11 +200,11 @@ public: return true; } else if (sPageName == "delnote") { DelNote(WebSock.GetParam("key", false)); - WebSock.Redirect("/mods/notes/"); + WebSock.Redirect(GetWebPath()); return true; } else if (sPageName == "addnote") { AddNote(WebSock.GetParam("key"), WebSock.GetParam("note")); - WebSock.Redirect("/mods/notes/"); + WebSock.Redirect(GetWebPath()); return true; } diff --git a/modules/perform.cpp b/modules/perform.cpp index 7a2016f4..5948526f 100644 --- a/modules/perform.cpp +++ b/modules/perform.cpp @@ -136,7 +136,7 @@ public: virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) { if (sPageName != "index") { - // only accept requests to /mods/perform/ + // only accept requests to index return false; } diff --git a/src/Modules.cpp b/src/Modules.cpp index ebac3e75..dd100338 100644 --- a/src/Modules.cpp +++ b/src/Modules.cpp @@ -156,6 +156,24 @@ const CString& CModule::GetSavePath() const { return m_sSavePath; } +CString CModule::GetWebPath() { + switch (m_eType) { + case CModInfo::GlobalModule: return "/mods/global/" + GetModName() + "/"; + case CModInfo::UserModule: return "/mods/user/" + GetModName() + "/"; + case CModInfo::NetworkModule: return "/mods/network/" + m_pNetwork->GetName() + "/" + GetModName() + "/"; + default: return "/"; + } +} + +CString CModule::GetWebFilesPath() { + switch (m_eType) { + case CModInfo::GlobalModule: return "/modfiles/global/" + GetModName() + "/"; + case CModInfo::UserModule: return "/modfiles/user/" + GetModName() + "/"; + case CModInfo::NetworkModule: return "/modfiles/network/" + m_pNetwork->GetName() + "/" + GetModName() + "/"; + default: return "/"; + } +} + bool CModule::LoadRegistry() { //CString sPrefix = (m_pUser) ? m_pUser->GetUserName() : ".global"; return (m_mssRegistry.ReadFromDisk(GetSavePath() + "/.registry") == MCString::MCS_SUCCESS); diff --git a/src/WebModules.cpp b/src/WebModules.cpp index 63d9e9e2..63c46a81 100644 --- a/src/WebModules.cpp +++ b/src/WebModules.cpp @@ -342,6 +342,7 @@ bool CWebSock::AddModLoop(const CString& sLoopName, CModule& Module) { CTemplate& Row = m_Template.AddRow(sLoopName); Row["ModName"] = Module.GetModName(); + Row["ModPath"] = Module.GetWebPath(); Row["Title"] = sTitle; if (m_sModName == Module.GetModName()) { @@ -367,6 +368,7 @@ bool CWebSock::AddModLoop(const CString& sLoopName, CModule& Module) { CTemplate& SubRow = Row.AddRow("SubPageLoop"); SubRow["ModName"] = Module.GetModName(); + SubRow["ModPath"] = Module.GetWebPath(); SubRow["PageName"] = SubPage->GetName(); SubRow["Title"] = SubPage->GetTitle().empty() ? SubPage->GetName() : SubPage->GetTitle(); @@ -667,6 +669,9 @@ CWebSock::EPageReqResult CWebSock::OnPageRequestInternal(const CString& sURI, CS break; } + m_Template["ModPath"] = pModule->GetWebPath(); + m_Template["ModFilesPath"] = pModule->GetWebFilesPath(); + if (!pModule) { return PAGE_NOTFOUND; } else if (pModule->WebRequiresLogin() && !ForceLogin()) { diff --git a/webskins/_default_/tmpl/Menu.tmpl b/webskins/_default_/tmpl/Menu.tmpl index 5d2856c2..a8849bc6 100644 --- a/webskins/_default_/tmpl/Menu.tmpl +++ b/webskins/_default_/tmpl/Menu.tmpl @@ -6,9 +6,9 @@
  • Global Modules
      -
    • +
    • -
    • +
    @@ -19,9 +19,9 @@
  • User Modules
      -
    • +
    • -
    • +