mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 13:59:23 +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){},
|
||||
},
|
||||
|
||||
/**
|
||||
* Virtual directory pages
|
||||
*/
|
||||
virtualDirectory: {
|
||||
|
||||
/**
|
||||
* Main page
|
||||
*/
|
||||
page: {
|
||||
//TODO : implement
|
||||
},
|
||||
|
||||
},
|
||||
},
|
||||
};
|
@ -157,20 +157,23 @@ ComunicWeb.common.page = {
|
||||
firstPartURI = "home";
|
||||
}
|
||||
|
||||
//Save the first part of the URI as an argument
|
||||
additionnalData.rootDirectory = firstPartURI;
|
||||
|
||||
//Check if there is also subfolders
|
||||
if(firstPartURI.indexOf("/") != -1){
|
||||
|
||||
//Save the list of subfolders
|
||||
var subfoldersURIarray = firstPartURI.split("/");
|
||||
subfoldersURIarray.shift();
|
||||
subfoldersURI = subfoldersURIarray.join("/");
|
||||
var subfoldersURI = subfoldersURIarray.join("/");
|
||||
|
||||
//Remove them to find the right page
|
||||
firstPartURI = firstPartURI.split("/")[0];
|
||||
|
||||
} else {
|
||||
//No subfolder was specified
|
||||
subfoldersURI = false;
|
||||
var subfoldersURI = false;
|
||||
}
|
||||
|
||||
//Check if specied page exists
|
||||
@ -179,8 +182,17 @@ ComunicWeb.common.page = {
|
||||
}
|
||||
|
||||
//Else we include the 404 not found page
|
||||
else{
|
||||
var pageInfos = ComunicWeb.pagesList.notFound;
|
||||
else {
|
||||
|
||||
//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
|
||||
|
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
|
||||
},
|
||||
|
||||
/**
|
||||
* Virtual directory
|
||||
*/
|
||||
virtual_directory: {
|
||||
pageTitle: "Loading",
|
||||
methodHandler: "ComunicWeb.pages.virtualDirectory.page.open",
|
||||
disableMenus: false
|
||||
},
|
||||
|
||||
/**
|
||||
* 404 Page not found
|
||||
*/
|
||||
|
@ -392,6 +392,9 @@ class Dev {
|
||||
"js/components/groups/interface.js",
|
||||
"js/components/groups/utils.js",
|
||||
|
||||
//Virtual directory component
|
||||
"js/components/virtualDirectory/interface.js",
|
||||
|
||||
//User scripts
|
||||
"js/user/loginTokens.js",
|
||||
"js/user/userLogin.js",
|
||||
@ -471,6 +474,9 @@ class Dev {
|
||||
//Logout page
|
||||
"js/pages/logout.js",
|
||||
|
||||
//Virtual directory page
|
||||
"js/pages/virtualDirectory/page.js",
|
||||
|
||||
//Create shortcuts for common functions
|
||||
"js/common/shorcuts.js",
|
||||
"js/common/helpers.js",
|
||||
|
Loading…
Reference in New Issue
Block a user