mirror of
https://github.com/pierre42100/ComunicWeb
synced 2025-02-17 03:12:43 +00:00
Virtual directory are handled at website's root directories.
This commit is contained in:
parent
5cfee77bb2
commit
665cbb8374
@ -1015,6 +1015,19 @@ var ComunicWeb = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Virtual directories component
|
||||||
|
*/
|
||||||
|
virtualDirectory: {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API interface
|
||||||
|
*/
|
||||||
|
interface: {
|
||||||
|
//TODO : implement
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1441,5 +1454,18 @@ var ComunicWeb = {
|
|||||||
openLogoutPage: function(additionnalData, targetElement){},
|
openLogoutPage: function(additionnalData, targetElement){},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Virtual directory pages
|
||||||
|
*/
|
||||||
|
virtualDirectory: {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main page
|
||||||
|
*/
|
||||||
|
page: {
|
||||||
|
//TODO : implement
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
@ -157,20 +157,23 @@ ComunicWeb.common.page = {
|
|||||||
firstPartURI = "home";
|
firstPartURI = "home";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Save the first part of the URI as an argument
|
||||||
|
additionnalData.rootDirectory = firstPartURI;
|
||||||
|
|
||||||
//Check if there is also subfolders
|
//Check if there is also subfolders
|
||||||
if(firstPartURI.indexOf("/") != -1){
|
if(firstPartURI.indexOf("/") != -1){
|
||||||
|
|
||||||
//Save the list of subfolders
|
//Save the list of subfolders
|
||||||
var subfoldersURIarray = firstPartURI.split("/");
|
var subfoldersURIarray = firstPartURI.split("/");
|
||||||
subfoldersURIarray.shift();
|
subfoldersURIarray.shift();
|
||||||
subfoldersURI = subfoldersURIarray.join("/");
|
var subfoldersURI = subfoldersURIarray.join("/");
|
||||||
|
|
||||||
//Remove them to find the right page
|
//Remove them to find the right page
|
||||||
firstPartURI = firstPartURI.split("/")[0];
|
firstPartURI = firstPartURI.split("/")[0];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//No subfolder was specified
|
//No subfolder was specified
|
||||||
subfoldersURI = false;
|
var subfoldersURI = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if specied page exists
|
//Check if specied page exists
|
||||||
@ -179,8 +182,17 @@ ComunicWeb.common.page = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Else we include the 404 not found page
|
//Else we include the 404 not found page
|
||||||
else{
|
else {
|
||||||
var pageInfos = ComunicWeb.pagesList.notFound;
|
|
||||||
|
//Check if no subfolder was specified
|
||||||
|
if(subfoldersURI)
|
||||||
|
var pageInfos = ComunicWeb.pagesList.notFound;
|
||||||
|
|
||||||
|
//Find & open dynamically the appropriate page
|
||||||
|
else {
|
||||||
|
var pageInfos = ComunicWeb.pagesList.virtual_directory;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Change page title
|
//Change page title
|
||||||
|
23
assets/js/components/virtualDirectory/interface.js
Normal file
23
assets/js/components/virtualDirectory/interface.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Virtual directories interface
|
||||||
|
*
|
||||||
|
* @author Pierre HUBERT
|
||||||
|
*/
|
||||||
|
|
||||||
|
ComunicWeb.components.virtualDirectory.interface = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the user / group related to a virtual directory
|
||||||
|
*
|
||||||
|
* @param {String} directory The directory to find
|
||||||
|
* @param {Function} callback
|
||||||
|
*/
|
||||||
|
find: function(directory, callback){
|
||||||
|
var apiURI = "virtualDirectory/find";
|
||||||
|
var params = {
|
||||||
|
directory: directory
|
||||||
|
};
|
||||||
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
37
assets/js/pages/virtualDirectory/page.js
Normal file
37
assets/js/pages/virtualDirectory/page.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* Virtual directory main page
|
||||||
|
*
|
||||||
|
* @author Pierre HUBERT
|
||||||
|
*/
|
||||||
|
|
||||||
|
ComunicWeb.pages.virtualDirectory.page = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open virtual directory page
|
||||||
|
*
|
||||||
|
* @param {object} args Optionnal arguments
|
||||||
|
* @param {HTMLElement} target The target for the page
|
||||||
|
*/
|
||||||
|
open: function(args, target){
|
||||||
|
|
||||||
|
//Forward the request on the API
|
||||||
|
ComunicWeb.components.virtualDirectory.interface.find(args.rootDirectory, function(r){
|
||||||
|
|
||||||
|
//Check for errors
|
||||||
|
if(r.error)
|
||||||
|
return ComunicWeb.common.error.pageNotFound(args, target);
|
||||||
|
|
||||||
|
//Check if the page is a user
|
||||||
|
if(r.kind == "user"){
|
||||||
|
ComunicWeb.pages.userPage.main.openUserPage(r.id, args, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check if the page is a group
|
||||||
|
if(r.kind == "group"){
|
||||||
|
ComunicWeb.pages.groups.pages.group.open(r.id, target);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
@ -124,6 +124,15 @@ ComunicWeb.pagesList = {
|
|||||||
disableMenus: false
|
disableMenus: false
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Virtual directory
|
||||||
|
*/
|
||||||
|
virtual_directory: {
|
||||||
|
pageTitle: "Loading",
|
||||||
|
methodHandler: "ComunicWeb.pages.virtualDirectory.page.open",
|
||||||
|
disableMenus: false
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 404 Page not found
|
* 404 Page not found
|
||||||
*/
|
*/
|
||||||
|
@ -392,6 +392,9 @@ class Dev {
|
|||||||
"js/components/groups/interface.js",
|
"js/components/groups/interface.js",
|
||||||
"js/components/groups/utils.js",
|
"js/components/groups/utils.js",
|
||||||
|
|
||||||
|
//Virtual directory component
|
||||||
|
"js/components/virtualDirectory/interface.js",
|
||||||
|
|
||||||
//User scripts
|
//User scripts
|
||||||
"js/user/loginTokens.js",
|
"js/user/loginTokens.js",
|
||||||
"js/user/userLogin.js",
|
"js/user/userLogin.js",
|
||||||
@ -471,6 +474,9 @@ class Dev {
|
|||||||
//Logout page
|
//Logout page
|
||||||
"js/pages/logout.js",
|
"js/pages/logout.js",
|
||||||
|
|
||||||
|
//Virtual directory page
|
||||||
|
"js/pages/virtualDirectory/page.js",
|
||||||
|
|
||||||
//Create shortcuts for common functions
|
//Create shortcuts for common functions
|
||||||
"js/common/shorcuts.js",
|
"js/common/shorcuts.js",
|
||||||
"js/common/helpers.js",
|
"js/common/helpers.js",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user