From c6b5a4d4db93e58357aa0c2aa7c3626f6504c2bf Mon Sep 17 00:00:00 2001 From: psychon Date: Mon, 17 May 2010 13:25:17 +0000 Subject: [PATCH] Move module's templates to their data dir Instead of having the template files and images in /usr/share/znc/www//, modules now get to use /usr/share/znc//tmpl/ and files/ for this purpose. This puts those directories for static data to good use again and might even fix some bugs (after all, the code for that dir is older and more tested than the new code for www/). git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1997 726aef4b-f618-498e-8847-2d620e286838 --- WebModules.cpp | 25 +++--------------- WebModules.h | 1 - .../lastseen => lastseen/tmpl}/index.tmpl | 0 modules/{www => }/notes/files/trash.gif | Bin modules/{www/notes => notes/tmpl}/index.tmpl | 0 .../stickychan => stickychan/tmpl}/index.tmpl | 0 .../tmpl}/add_edit_chan.tmpl | 0 .../tmpl}/add_edit_user.tmpl | 0 .../webadmin => webadmin/tmpl}/del_user.tmpl | 0 .../webadmin => webadmin/tmpl}/index.tmpl | 0 .../webadmin => webadmin/tmpl}/listusers.tmpl | 0 .../webadmin => webadmin/tmpl}/settings.tmpl | 0 .../webadmin => webadmin/tmpl}/traffic.tmpl | 0 13 files changed, 3 insertions(+), 23 deletions(-) rename modules/{www/lastseen => lastseen/tmpl}/index.tmpl (100%) rename modules/{www => }/notes/files/trash.gif (100%) rename modules/{www/notes => notes/tmpl}/index.tmpl (100%) rename modules/{www/stickychan => stickychan/tmpl}/index.tmpl (100%) rename modules/{www/webadmin => webadmin/tmpl}/add_edit_chan.tmpl (100%) rename modules/{www/webadmin => webadmin/tmpl}/add_edit_user.tmpl (100%) rename modules/{www/webadmin => webadmin/tmpl}/del_user.tmpl (100%) rename modules/{www/webadmin => webadmin/tmpl}/index.tmpl (100%) rename modules/{www/webadmin => webadmin/tmpl}/listusers.tmpl (100%) rename modules/{www/webadmin => webadmin/tmpl}/settings.tmpl (100%) rename modules/{www/webadmin => webadmin/tmpl}/traffic.tmpl (100%) diff --git a/WebModules.cpp b/WebModules.cpp index 6c320efc..075d4eef 100644 --- a/WebModules.cpp +++ b/WebModules.cpp @@ -277,9 +277,9 @@ void CWebSock::SetPaths(CModule* pModule, bool bIsTemplate) { // m_Template.AppendPath(GetSkinPath("_default_") + "/mods/" + sModName + "/"); - // 3. ./modules// + // 3. ./modules//tmpl/ // - m_Template.AppendPath(GetModWebPath(pModule)); + m_Template.AppendPath(pModule->GetModDataDir() + "/tmpl/"); // 4. ~/.znc/webskins//mods// // @@ -447,25 +447,6 @@ CWebSock::EPageReqResult CWebSock::PrintTemplate(const CString& sPageName, CStri } } -CString CWebSock::GetModWebPath(const CModule* pModule) const { - // This is: /path/to/module.so - const CString& sModPath = pModule->GetModPath(); - - // Find the last '/' in sModPath... - CString::size_type pos = sModPath.find_last_of('/'); - - // ...and set sModDir to the dir in which sModPath resides - CString sModDir = sModPath.substr(0, pos); - - // Check if module is loaded from ~/.znc/modules or from source or from installed prefix - if (sModDir.Equals(_MODDIR_)) { - // Loaded from installed prefix - return CString(_DATADIR_) + "/www/" + pModule->GetModName(); - } - - return sModDir + "/www/" + pModule->GetModName(); -} - CString CWebSock::GetSkinPath(const CString& sSkinName) const { CString sRet = CZNC::Get().GetZNCPath() + "/webskins/" + sSkinName; @@ -654,7 +635,7 @@ CWebSock::EPageReqResult CWebSock::OnPageRequestInternal(const CString& sURI, CS if (sURI.Left(10) == "/modfiles/") { m_Template.AppendPath(GetSkinPath(GetSkinName()) + "/mods/" + m_sModName + "/files/"); - m_Template.AppendPath(GetModWebPath(pModule) + "/files/"); + m_Template.AppendPath(pModule->GetModDataDir() + "/files/"); if (PrintFile(m_Template.ExpandFile(m_sPage.TrimLeft_n("/")))) { return PAGE_PRINT; diff --git a/WebModules.h b/WebModules.h index a1dd43d4..95eba663 100644 --- a/WebModules.h +++ b/WebModules.h @@ -150,7 +150,6 @@ public: CString GetCSRFCheck(); virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort); - CString GetModWebPath(const CModule* pModule) const; CString GetSkinPath(const CString& sSkinName) const; CModule* GetModule() const { return (CModule*) m_pModule; } size_t GetAvailSkins(vector& vRet); diff --git a/modules/www/lastseen/index.tmpl b/modules/lastseen/tmpl/index.tmpl similarity index 100% rename from modules/www/lastseen/index.tmpl rename to modules/lastseen/tmpl/index.tmpl diff --git a/modules/www/notes/files/trash.gif b/modules/notes/files/trash.gif similarity index 100% rename from modules/www/notes/files/trash.gif rename to modules/notes/files/trash.gif diff --git a/modules/www/notes/index.tmpl b/modules/notes/tmpl/index.tmpl similarity index 100% rename from modules/www/notes/index.tmpl rename to modules/notes/tmpl/index.tmpl diff --git a/modules/www/stickychan/index.tmpl b/modules/stickychan/tmpl/index.tmpl similarity index 100% rename from modules/www/stickychan/index.tmpl rename to modules/stickychan/tmpl/index.tmpl diff --git a/modules/www/webadmin/add_edit_chan.tmpl b/modules/webadmin/tmpl/add_edit_chan.tmpl similarity index 100% rename from modules/www/webadmin/add_edit_chan.tmpl rename to modules/webadmin/tmpl/add_edit_chan.tmpl diff --git a/modules/www/webadmin/add_edit_user.tmpl b/modules/webadmin/tmpl/add_edit_user.tmpl similarity index 100% rename from modules/www/webadmin/add_edit_user.tmpl rename to modules/webadmin/tmpl/add_edit_user.tmpl diff --git a/modules/www/webadmin/del_user.tmpl b/modules/webadmin/tmpl/del_user.tmpl similarity index 100% rename from modules/www/webadmin/del_user.tmpl rename to modules/webadmin/tmpl/del_user.tmpl diff --git a/modules/www/webadmin/index.tmpl b/modules/webadmin/tmpl/index.tmpl similarity index 100% rename from modules/www/webadmin/index.tmpl rename to modules/webadmin/tmpl/index.tmpl diff --git a/modules/www/webadmin/listusers.tmpl b/modules/webadmin/tmpl/listusers.tmpl similarity index 100% rename from modules/www/webadmin/listusers.tmpl rename to modules/webadmin/tmpl/listusers.tmpl diff --git a/modules/www/webadmin/settings.tmpl b/modules/webadmin/tmpl/settings.tmpl similarity index 100% rename from modules/www/webadmin/settings.tmpl rename to modules/webadmin/tmpl/settings.tmpl diff --git a/modules/www/webadmin/traffic.tmpl b/modules/webadmin/tmpl/traffic.tmpl similarity index 100% rename from modules/www/webadmin/traffic.tmpl rename to modules/webadmin/tmpl/traffic.tmpl