Virtual directory are handled at website's root directories.

This commit is contained in:
Pierre HUBERT 2018-07-14 14:07:27 +02:00
parent 5cfee77bb2
commit 665cbb8374
6 changed files with 117 additions and 4 deletions

View File

@ -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
},
},
},
};

View File

@ -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
@ -180,7 +183,16 @@ ComunicWeb.common.page = {
//Else we include the 404 not found page
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

View 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);
},
}

View 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);
}
});
},
};

View File

@ -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
*/

View File

@ -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",