Improve the SEO for the catalog - support hashbang tag https://developers.google.com/webmasters/ajax-crawling/docs/getting-started
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/26e63add Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/26e63add Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/26e63add Branch: refs/heads/master Commit: 26e63add205ce15ea86b42e5c632522609ec6afa Parents: ab6abfa Author: Valentin Aitken <[email protected]> Authored: Mon Feb 23 19:37:27 2015 +0200 Committer: Valentin Aitken <[email protected]> Committed: Mon Feb 23 19:37:27 2015 +0200 ---------------------------------------------------------------------- .../website/learnmore/catalog/catalog-item.html | 65 ++++++++++++++++---- 1 file changed, 52 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/26e63add/docs/website/learnmore/catalog/catalog-item.html ---------------------------------------------------------------------- diff --git a/docs/website/learnmore/catalog/catalog-item.html b/docs/website/learnmore/catalog/catalog-item.html index 82512a9..2eaf96b 100644 --- a/docs/website/learnmore/catalog/catalog-item.html +++ b/docs/website/learnmore/catalog/catalog-item.html @@ -22,6 +22,8 @@ under the License. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Brooklyn Entity - Brooklyn Node</title> + <meta name="fragment" content="!"> + {% include base-head.html %} <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> @@ -58,18 +60,13 @@ under the License. <script src="{{site.path.style}}/js/catalog/items.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { - updateItems(); + updateItem(); - $(window).on('hashchange', updateItems); + $(window).on('hashchange', updateItem); - function updateItems() { - var args; - var hash = window.location.hash; - if(!hash || hash.length <= 2) { - alert('No such catalog item'); - return; - } - args = hash.substring(2).split('/'); + function updateItem() { + var args, catalog_type; + args = getArgs(); if(args.length!=2) { alert('bad entity format') return; @@ -77,11 +74,53 @@ under the License. // entities/brooklyn.entity.brooklynnode.BrooklynNode var item = brooklyn.findItemOfType(items[args[0]], args[1]); + $("#summary").html(brooklyn.typeSummary(item)); + if(args[0] == 'entities') { + catalog_type = 'Entity'; + } else if(args[0] == 'policies') { + catalog_type = 'Policy'; + } else if(args[0] == 'enrichers') { + catalog_type = 'Enricher' + } + + document.title = 'Brooklyn ' + catalog_type + ' - ' + item.name; + item.config.forEach(function (element) { $("#configKeys").append(brooklyn.configKeyCard(element)); }); - item.sensors.forEach(function (element) { $("#sensors").append(brooklyn.sensorCard(element)); }); - if (item.effectors != undefined) { - item.effectors.forEach(function (element) { $("#effectors").append(brooklyn.effectorCard(element)); }); + + if(args[0] == 'entities') { + item.sensors.forEach(function (element) { $("#sensors").append(brooklyn.sensorCard(element)); }); + if (item.effectors != undefined) { + item.effectors.forEach(function (element) { $("#effectors").append(brooklyn.effectorCard(element)); }); + } + } + } + + function getArgs() { + var args; + var params = window.location.hash; + if(params) { + if(params.length <= 2) { + alert('No such catalog item'); + } + args = params.substring(2).split('/'); + } else { + params = getParameterByName('_escaped_fragment_'); + args = params.split('/'); + } + + return args; + + function getParameterByName(name) { + var search = window.location.search || document.location.search; + if(search === undefined) { + alert('No get parameter specified for a catalog item') + } + + name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); + var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), + results = regex.exec(search); + return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } } });
