Move module's templates to their data dir

Instead of having the template files and images in /usr/share/znc/www/<mod>/,
modules now get to use /usr/share/znc/<mod>/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
This commit is contained in:
psychon
2010-05-17 13:25:17 +00:00
parent 38d6129964
commit c6b5a4d4db
13 changed files with 3 additions and 23 deletions

View File

@@ -277,9 +277,9 @@ void CWebSock::SetPaths(CModule* pModule, bool bIsTemplate) {
//
m_Template.AppendPath(GetSkinPath("_default_") + "/mods/" + sModName + "/");
// 3. ./modules/<mod_name>/
// 3. ./modules/<mod_name>/tmpl/
//
m_Template.AppendPath(GetModWebPath(pModule));
m_Template.AppendPath(pModule->GetModDataDir() + "/tmpl/");
// 4. ~/.znc/webskins/<user_skin_setting>/mods/<mod_name>/
//
@@ -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;