Skip to content

Commit

Permalink
SAK-21865 direct/short urls to tools
Browse files Browse the repository at this point in the history
git-svn-id: https://source.sakaiproject.org/svn/portal/trunk@105456 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
steveswinsburg committed Mar 4, 2012
1 parent f79c729 commit 57e857d
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ public interface Portal
public static final String SAKAI_PORTAL_BREADCRUMBS = "sakai-portal:breadcrumbs";
public static final String SAKAI_PORTAL_SUPPRESSTITLE = "sakai-portal:suppresstitle";


/**
* Tool property to allow the enabling/disabling of the direct url linking UI
*/
public static final String TOOL_DIRECTURL_ENABLED_PROP = "sakai:tool-directurl-enabled";

/**
* prepare the response and send it to the render engine
*
Expand Down
32 changes: 31 additions & 1 deletion portal/portal-charon/charon/src/webapp/scripts/neoscripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,20 @@ jQuery(document).ready(function(){
$('.trayPopupClose').click(function(e){
e.preventDefault();
$(this).closest('.trayPopup').hide();
})
});

//bind directurl checkboxes
jQuery('a.tool-directurl').cluetip({
local: true,
arrows: true,
cluetipClass: 'jtip',
sticky: true,
cursor: 'pointer',
activation: 'click',
closePosition: 'title',
closeText: '<img src="/library/image/silk/cross.png" alt="close" />'
});

});

var setupSiteNav = function(){
Expand Down Expand Up @@ -521,3 +534,20 @@ var setupSkipNav = function(){
$(target).attr('tabindex','-1').focus();
});
};

//handles showing either the short url or the full url, depending on the state of the checkbox
//(if configured, otherwise returns url as-is as according to the url shortening entity provder)
function toggleShortUrlOutput(defaultUrl, checkbox, textbox) {

if($(checkbox).is(':checked')) {

$.ajax({
url:'/direct/url/shorten?path='+encodeURI(defaultUrl),
success: function(shortUrl) {
$('.'+textbox).val(shortUrl);
}
});
} else {
$('.'+textbox).val(defaultUrl);
}
}
28 changes: 28 additions & 0 deletions portal/portal-charon/charon/src/webapp/scripts/portalscripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ jQuery(document).ready(function(){
if (portal.loggedIn && portal.timeoutDialog ) {
setTimeout('setup_timeout_config();', 60000);
}

//bind directurl checkboxes
jQuery('a.tool-directurl').cluetip({
local: true,
arrows: true,
cluetipClass: 'jtip',
sticky: true,
cursor: 'pointer',
activation: 'click',
closePosition: 'title',
closeText: '<img src="/library/image/silk/cross.png" alt="close" />'
});
});

var setup_timeout_config = function() {
Expand Down Expand Up @@ -459,3 +471,19 @@ var setupSkipNav = function(){
});
};

//handles showing either the short url or the full url, depending on the state of the checkbox
//(if configured, otherwise returns url as-is as according to the url shortening entity provder)
function toggleShortUrlOutput(defaultUrl, checkbox, textbox) {

if($(checkbox).is(':checked')) {

$.ajax({
url:'/direct/url/shorten?path='+encodeURI(defaultUrl),
success: function(shortUrl) {
$('.'+textbox).val(shortUrl);
}
});
} else {
$('.'+textbox).val(defaultUrl);
}
}
3 changes: 3 additions & 0 deletions portal/portal-impl/impl/src/bundle/sitenav.properties
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,6 @@ pc_site_users_label = In this site
pc_ping = Ping
pc_ping_connection = to come and chat
pc_pinged_popup = Pinged !

tool_direct_link=Direct link to this tool
short_url=Short URL
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,15 @@ public Map includeTool(HttpServletResponse res, HttpServletRequest req,
toolMap.put("toolShowHelpButton", Boolean.valueOf(showHelpButton));
toolMap.put("toolHelpActionUrl", helpActionUrl);
toolMap.put("toolId", toolId);

String directToolUrl = ServerConfigurationService.getPortalUrl() + "/" + DirectToolHandler.URL_FRAGMENT +"/" + Web.escapeUrl(placement.getId()) + "/";
toolMap.put("directToolUrl", directToolUrl);

//props to enable/disable the display on a per tool/placement basis
//will be displayed if not explicitly disabled in the tool/placement properties
boolean showDirectToolUrl = !"false".equals(placement.getConfig().getProperty(Portal.TOOL_DIRECTURL_ENABLED_PROP));
toolMap.put("showDirectToolUrl", showDirectToolUrl);

return toolMap;
}

Expand Down Expand Up @@ -1180,6 +1189,10 @@ public PortalRenderContext startPageContext(String siteType, String title,
}
boolean isWirelessDevice = s.getAttribute("is_wireless_device") != null ? ((Boolean) s.getAttribute("is_wireless_device")).booleanValue():false;
rcontext.put("portal_add_mobile_link",Boolean.valueOf( "true".equals(addMLnk) && isWirelessDevice ) ) ;

rcontext.put("toolDirectUrlEnabled", ServerConfigurationService.getBoolean("portal.tool.direct.url.enabled", false));
rcontext.put("toolShortUrlEnabled", ServerConfigurationService.getBoolean("shortenedurl.portal.tool.enabled", true));

return rcontext;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,19 @@
<a accesskey="e" id="jsr-edit" href="${tool.toolJSR168Edit}"
title="${rloader.sit_edit}"><img src="/library/image/transparent.gif"
alt="${rloader.sit_edit}" border="0"></a>
#end
#end
#if ($toolDirectUrlEnabled && ${tool.showDirectToolUrl})
<a class="tool-directurl" href="#${tool.toolPlacementIDJS}_directurl" rel="#${tool.toolPlacementIDJS}_directurl" title="${rloader.tool_direct_link}">
<img src="/library/image/transparent.gif" alt="${rloader.tool_direct_link}" border="0"/>
</a>
<div id="${tool.toolPlacementIDJS}_directurl" class="direct-url-wrap">
#if($toolShortUrlEnabled)
<input type="checkbox" onclick="toggleShortUrlOutput('${tool.directToolUrl}', this, '${tool.toolPlacementIDJS}_urlholder');" />
<span>${rloader.short_url}</span>
#end
<textarea class="${tool.toolPlacementIDJS}_urlholder" rows="3" cols="50">${tool.directToolUrl}</textarea>
</div>
#end
#if (${tool.toolShowHelpButton})
#if (${tool.toolJSR168Help} )
<a accesskey="h" href="${tool.toolJSR168Help}" title="${rloader.sit_help}">
Expand Down Expand Up @@ -116,6 +128,18 @@
title="${rloader.sit_edit}"><img src="/library/image/transparent.gif"
alt="${rloader.sit_edit}" border="0"></a>
#end
#if ($toolDirectUrlEnabled && ${tool.showDirectToolUrl})
<a class="tool-directurl" href="#${tool.toolPlacementIDJS}_directurl" rel="#${tool.toolPlacementIDJS}_directurl" title="${rloader.tool_direct_link}">
<img src="/library/image/transparent.gif" alt="${rloader.tool_direct_link}" border="0"/>
</a>
<div id="${tool.toolPlacementIDJS}_directurl" class="direct-url-wrap">
#if($toolShortUrlEnabled)
<input type="checkbox" onclick="toggleShortUrlOutput('${tool.directToolUrl}', this, '${tool.toolPlacementIDJS}_urlholder');" />
<span>${rloader.short_url}</span>
#end
<textarea class="${tool.toolPlacementIDJS}_urlholder" rows="3" cols="50">${tool.directToolUrl}</textarea>
</div>
#end
#if (${tool.toolShowHelpButton})
#if (${tool.toolJSR168Help} )
<a accesskey="h" href="${tool.toolJSR168Help}" title="${rloader.sit_help}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ ${tool.toolRenderResult.getTitle()}
<title>${pageTitle}</title>
${sakai_html_head_css}
<script type="text/javascript" language="JavaScript" src="${pageScriptPath}headscripts.js"></script>
<script type="text/javascript" language="JavaScript" src="${pageScriptPath}jquery.js"></script>
##<script type="text/javascript" language="JavaScript" src="${pageScriptPath}jquery.js"></script>
<script type="text/javascript" language="JavaScript" src="${pageScriptPath}/jquery/1.4.2/jquery-1.4.2.min.js"></script>

#end

<script type="text/javascript" language="JavaScript" src="/portal/scripts/portalscripts.js"></script>
Expand Down Expand Up @@ -78,5 +80,10 @@ ${sakai_html_head_css}
</script>
#end
#end
<script type="text/javascript" language="JavaScript" src="${pageScriptPath}jquery/cluetip/1.2.5/jquery.cluetip.min.js"></script>

## required CSS for cluetip, bundled with the release
<link href="${pageScriptPath}jquery/cluetip/1.2.5/css/jquery.cluetip.css" type="text/css" rel="stylesheet" media="all" />

</head>
<!-- END from includeStandardHead.vm -->
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
title="${rloader.sit_edit}"><img src="/library/image/transparent.gif"
alt="${rloader.sit_edit}" border="0"></a>
#end
#if ($toolDirectUrlEnabled && ${tool.showDirectToolUrl})
<a class="tool-directurl" href="#${tool.toolPlacementIDJS}_directurl" rel="#${tool.toolPlacementIDJS}_directurl" title="${rloader.tool_direct_link}">
<img src="/library/image/transparent.gif" alt="${rloader.tool_direct_link}" border="0"/>
</a>
<div id="${tool.toolPlacementIDJS}_directurl" class="direct-url-wrap">
#if($toolShortUrlEnabled)
<input type="checkbox" onclick="toggleShortUrlOutput('${tool.directToolUrl}', this, '${tool.toolPlacementIDJS}_urlholder');" />
<span>${rloader.short_url}</span>
#end
<textarea class="${tool.toolPlacementIDJS}_urlholder" rows="3" cols="50">${tool.directToolUrl}</textarea>
</div>
#end
#if (${tool.toolShowHelpButton})
#if (${tool.toolJSR168Help} )
<a accesskey="h" href="${tool.toolJSR168Help}" title="${rloader.sit_help}">
Expand Down Expand Up @@ -119,6 +131,18 @@
title="${rloader.sit_edit}"><img src="/library/image/transparent.gif"
alt="${rloader.sit_edit}" border="0"></a>
#end
#if ($toolDirectUrlEnabled && ${tool.showDirectToolUrl})
<a class="tool-directurl" href="#${tool.toolPlacementIDJS}_directurl" rel="#${tool.toolPlacementIDJS}_directurl" title="${rloader.tool_direct_link}">
<img src="/library/image/transparent.gif" alt="${rloader.tool_direct_link}" border="0"/>
</a>
<div id="${tool.toolPlacementIDJS}_directurl" class="direct-url-wrap">
#if($toolShortUrlEnabled)
<input type="checkbox" onclick="toggleShortUrlOutput('${tool.directToolUrl}', this, '${tool.toolPlacementIDJS}_urlholder');" />
<span>${rloader.short_url}</span>
#end
<textarea class="${tool.toolPlacementIDJS}_urlholder" rows="3" cols="50">${tool.directToolUrl}</textarea>
</div>
#end
#if (${tool.toolShowHelpButton})
#if (${tool.toolJSR168Help} )
<a accesskey="h" href="${tool.toolJSR168Help}" title="${rloader.sit_help}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ ${sakai_html_head_css}
</script>
#end
#end
<script type="text/javascript" language="JavaScript" src="${pageScriptPath}jquery/cluetip/1.2.5/jquery.cluetip.min.js"></script>

## required CSS for cluetip, bundled with the release
<link href="${pageScriptPath}jquery/cluetip/1.2.5/css/jquery.cluetip.css" type="text/css" rel="stylesheet" media="all" />


</head>

<!-- END from includeStandardHead.vm -->

0 comments on commit 57e857d

Please sign in to comment.