Skip to content

Instantly share code, notes, and snippets.

@sergebug
Last active December 19, 2015 14:59
Show Gist options
  • Save sergebug/5973247 to your computer and use it in GitHub Desktop.
Save sergebug/5973247 to your computer and use it in GitHub Desktop.
FitNesse WIKI page for creating tag cloud based on the WIKI page Tags.

FitNesse WIKI page for rendering tag clouds.

How to use:

  1. Download jQuery.tagcloud.js from https://github.com/addywaddy/jquery.tagcloud.js/

  2. Place downloaded js file into FitNesseRoot/files/javascript

  3. Create .TagCloud page and paste WIKI page content (below)

  4. Go and Assign tags to the pages in the WIKI

  5. In the page where you want to see tag clouds for all the pages down below paste following:

!include -seamless .TagCloud 
!*< Hidden Table of Content 
!contents -R -f 
*! 

Note: Click on the TAG - enjoy

#!-<script src="/files/javascript/jquery-1.3.2.min.js"></script>-!
!-<script src="/files/javascript/jquery.tagcloud.js"></script>-!
!-<style type="text/css">
#tagcloud {width: 700px;margin:0 auto;}
#tagcloud a {text-decoration: none;}
#tagcloud a:hover {text-decoration: underline;}
#tagcloud >a {display:inline-block; margin: 5px 10px;font: 75% Arial, "MS Trebuchet", sans-serif;}
</style>-!
!-
<div id="tagcloud"></div>
<script>
$(document).ready(function () {
var tagMap = [];
var tagRef = [];
//$("div#tagcloud").append("<p>Tag Cloud</p>");
$("div.contents").find("li a").each(function () {
var tags = $(this).text();
var startindex = tags.indexOf(' (');
var endindex = tags.indexOf(')', startindex);
if (startindex !=-1 && endindex !=-1 && endindex > startindex ){
tags = tags.substring(startindex+2 , endindex );
var aTags = tags.split(",");
for(var i=0; i < aTags.length; i++) {
tag = $.trim(aTags[i]);
ref = $(this).next("div:eq(0)").find("div.nested-contents li a").length+1;
tagIndex = $.inArray(tag,tagMap);
if(tagIndex < 0){
tagMap.push(tag);
tagRef.push(ref);
}
else{
tagRef[tagIndex] = tagRef[tagIndex] + ref
};
//console.log( tagMap );
//console.log( tagRef );
};
};
});
for(var i=0; i<tagMap.length; i++){
$("div#tagcloud").append("<a>"+tagMap[i]+"</a>");
$("div#tagcloud a:eq("+i+")").attr("rel",tagRef[i]);
$("div#tagcloud a:eq("+i+")").attr("href",window.location+"?executeSearchProperties&Suites="+tagMap[i]);
};
});
$.fn.tagcloud.defaults = {
size: {start: 14, end: 18, unit: 'pt'},
color: {start: '#cde', end: '#f52'}
};
//console.log($.fn.tagcloud.defaults);
$(function () {
$('div#tagcloud a').tagcloud();
});
</script>
-!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment