mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Modules can now embed web stuff directly to other web pages which support this feature.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2128 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -387,6 +387,7 @@ CString CModule::GetModNick() const { return ((m_pUser) ? m_pUser->GetStatusPref
|
||||
// Webmods
|
||||
bool CModule::OnWebPreRequest(CWebSock& WebSock, const CString& sPageName) { return false; }
|
||||
bool CModule::OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) { return false; }
|
||||
bool CModule::OnEmbeddedWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) { return false; }
|
||||
// !Webmods
|
||||
|
||||
bool CModule::OnLoad(const CString& sArgs, CString& sMessage) { sMessage = ""; return true; }
|
||||
|
||||
10
Modules.h
10
Modules.h
@@ -313,6 +313,16 @@ public:
|
||||
* @return The List.
|
||||
*/
|
||||
virtual VWebSubPages& GetSubPages() { return m_vSubPages; }
|
||||
/** Using this hook, module can embed web stuff directly to different places.
|
||||
* This method is called whenever embededded modules I/O happens.
|
||||
* Name of used .tmpl file (if any) is up to caller.
|
||||
* @param WebSock Socket for web connection, don't do bad things with it.
|
||||
* @param sPageName Describes the place where web stuff is embedded to.
|
||||
* @param Tmpl Template. Depending on context, you can do various stuff with it.
|
||||
* @return If you don't need to embed web stuff to the specified place, just return false.
|
||||
* Exact meaning of return value is up to caller, and depends on context.
|
||||
*/
|
||||
virtual bool OnEmbeddedWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl);
|
||||
|
||||
|
||||
/** Called just before znc.conf is rehashed */
|
||||
|
||||
@@ -243,11 +243,10 @@ size_t CWebSock::GetAvailSkins(vector<CFile>& vRet) {
|
||||
return vRet.size();
|
||||
}
|
||||
|
||||
void CWebSock::SetPaths(CModule* pModule, bool bIsTemplate) {
|
||||
m_Template.ClearPaths();
|
||||
|
||||
VCString CWebSock::GetDirs(CModule* pModule, bool bIsTemplate) {
|
||||
CString sHomeSkinsDir(CZNC::Get().GetZNCPath() + "/webskins/");
|
||||
CString sSkinName(GetSkinName());
|
||||
VCString vsResult;
|
||||
|
||||
// Module specific paths
|
||||
|
||||
@@ -257,37 +256,58 @@ void CWebSock::SetPaths(CModule* pModule, bool bIsTemplate) {
|
||||
// 1. ~/.znc/webskins/<user_skin_setting>/mods/<mod_name>/
|
||||
//
|
||||
if (!sSkinName.empty()) {
|
||||
m_Template.AppendPath(GetSkinPath(sSkinName) + "/mods/" + sModName + "/");
|
||||
vsResult.push_back(GetSkinPath(sSkinName) + "/mods/" + sModName + "/");
|
||||
}
|
||||
|
||||
// 2. ~/.znc/webskins/_default_/mods/<mod_name>/
|
||||
//
|
||||
m_Template.AppendPath(GetSkinPath("_default_") + "/mods/" + sModName + "/");
|
||||
vsResult.push_back(GetSkinPath("_default_") + "/mods/" + sModName + "/");
|
||||
|
||||
// 3. ./modules/<mod_name>/tmpl/
|
||||
//
|
||||
m_Template.AppendPath(pModule->GetModDataDir() + "/tmpl/");
|
||||
vsResult.push_back(pModule->GetModDataDir() + "/tmpl/");
|
||||
|
||||
// 4. ~/.znc/webskins/<user_skin_setting>/mods/<mod_name>/
|
||||
//
|
||||
if (!sSkinName.empty()) {
|
||||
m_Template.AppendPath(GetSkinPath(sSkinName) + "/mods/" + sModName + "/");
|
||||
vsResult.push_back(GetSkinPath(sSkinName) + "/mods/" + sModName + "/");
|
||||
}
|
||||
|
||||
// 5. ~/.znc/webskins/_default_/mods/<mod_name>/
|
||||
//
|
||||
m_Template.AppendPath(GetSkinPath("_default_") + "/mods/" + sModName + "/");
|
||||
vsResult.push_back(GetSkinPath("_default_") + "/mods/" + sModName + "/");
|
||||
}
|
||||
|
||||
// 6. ~/.znc/webskins/<user_skin_setting>/
|
||||
//
|
||||
if (!sSkinName.empty()) {
|
||||
m_Template.AppendPath(GetSkinPath(sSkinName) + CString(bIsTemplate ? "/tmpl/" : "/"), (0 && pModule != NULL));
|
||||
vsResult.push_back(GetSkinPath(sSkinName) + CString(bIsTemplate ? "/tmpl/" : "/"));
|
||||
}
|
||||
|
||||
// 7. ~/.znc/webskins/_default_/
|
||||
//
|
||||
m_Template.AppendPath(GetSkinPath("_default_") + CString(bIsTemplate ? "/tmpl/" : "/"), (0 && pModule != NULL));
|
||||
vsResult.push_back(GetSkinPath("_default_") + CString(bIsTemplate ? "/tmpl/" : "/"));
|
||||
|
||||
return vsResult;
|
||||
}
|
||||
|
||||
CString CWebSock::FindTmpl(CModule* pModule, const CString& sName) {
|
||||
VCString vsDirs = GetDirs(pModule, true);
|
||||
for (size_t i = 0; i < vsDirs.size(); ++i) {
|
||||
if (CFile::Exists(vsDirs[i] + sName)) {
|
||||
return vsDirs[i] + sName;
|
||||
}
|
||||
}
|
||||
return sName;
|
||||
}
|
||||
|
||||
void CWebSock::SetPaths(CModule* pModule, bool bIsTemplate) {
|
||||
m_Template.ClearPaths();
|
||||
|
||||
VCString vsDirs = GetDirs(pModule, bIsTemplate);
|
||||
for (size_t i = 0; i < vsDirs.size(); ++i) {
|
||||
m_Template.AppendPath(vsDirs[i]);
|
||||
}
|
||||
|
||||
m_bPathsSet = true;
|
||||
}
|
||||
|
||||
@@ -132,6 +132,8 @@ public:
|
||||
EPageReqResult PrintStaticFile(const CString& sPath, CString& sPageRet, CModule* pModule = NULL);
|
||||
|
||||
bool AddModLoop(const CString& sLoopName, CModule& Module);
|
||||
VCString GetDirs(CModule* pModule, bool bIsTemplate);
|
||||
CString FindTmpl(CModule* pModule, const CString& sName);
|
||||
void SetPaths(CModule* pModule, bool bIsTemplate = false);
|
||||
void SetVars();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user