UVic's Deep Linking into Luminis

0
No votes yet

For some time now it has irritated us that we cannot link directly to content in Luminis. Due to business priorities we never put this in... until now.

Here is the strategy we took. Provide a GET variable that allows the user to specify the channel functional name they want. If the user is logged in and they go to the home page they will either go strait into the portal, or into the page that is specified through the get variable. If they are not logged in, the requested variable is put into a cookie and then parsed once they have logged in.

Here is what I did:

In the Index page I removed the code that sets the "query" cookie. If you know what that cookie was for please let me know. I then added the following code to set the cookie and check the login status (we are using jQuery so the ajax call is done with that).


var deeplink = get_params('deeplink');
//set the deeplink target cookie for if the user needs to login.
//Make sure that people are not passing things with querys
if(deeplink.length>0 && deeplink.indexOf("&")<0 && deeplink.indexOf("?")<0 && get_params('deepanchor').indexOf("&")<0 && get_params('deepanchor').indexOf("?")<0 )
setCookie("uSDeepLink", "/cp/tag.idempotent.render.userLayoutRootNode.uP?uP_sfname="+deeplink+"#"+get_params('deepanchor'))

$.ajax({
url: "/cp/wu/as?getAlertMessage=true",
cache: false,
dataType: 'xml',
async: false,
timeout: 3000,
success: function(xml){
var $xml = $(xml).children("alertmodel").children("statuscode");
// alert($xml.text());
if ($xml.text() == '1' || $xml.text() == '50' || $xml.text() == '100') // logging out, stop polling
{
//We need to kill the deeplink cookie if we are deeplinking this way!
if (getCookie("uSDeepLink"))
document.cookie = "uSDeepLink=; path=/; expires=Thu, 01-Jan-70 00:00:01 GMT";

if(get_params('deeplink').length>0)
window.top.location.href = "/cp/tag.idempotent.render.userLayoutRootNode.uP?uP_sfname="+get_params('deeplink')+"#"+get_params('deepanchor');
else
window.top.location.href = "/cp/render.userLayoutRootNode.uP";
}
}
});

I then added the following code to util.js to do some parameter grabbing and to perform the cookie re-direct:


function get_params( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}

if (getCookie("uSDeepLink")) //deep link re-direct. This kills the cookie and redirects the browser.
{ var deeploc=getCookie("uSDeepLink");
document.cookie = "uSDeepLink=; path=/; expires=Thu, 01-Jan-70 00:00:01 GMT";
window.top.location.href=deeploc;
}

Let me know what you think. If there is anything wrong please let me know. I was a bit worried about removing the "query" cookie making code, and I was a bit worried about people specifying get variables along with their functional channel names, but I think I have it covered.

Cheers

Dave W

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

An alternative method

Our strategy for deep-linking is to use URLs of the form:

/cp/redirect/portal?dest=/cp/tag.idempotent.render.userLayoutRootNode.uP%3FuP_sfname%3DLibraryDatabases

And we've added an servlet to Luminis that listens on /redirect and contains the following method:

private void portal(HttpServletRequest request, HttpServletResponse response) throws IOException {
IPerson person = (IPerson) request.getSession().getAttribute("org.jasig.portal.security.IPerson");
String dest = request.getParameter("dest");
String url = person == null ? ("/cp/home/displaylogin?service=" + dest) : URLDecoder.decode(dest);
response.sendRedirect(url);
}

This works regardless of whether the user is logged in or not. It uses Luminis' built in login redirection (/cp/home/displaylogin?service=...).