replaced old tag cloud and adopted design a bit

pull/1/head
Michael Peter Christen 11 years ago
parent dc38d35986
commit 16e3b357b3

@ -9,7 +9,7 @@
<script type="text/javascript">hs.outlineType = 'rounded-white';</script>
<script src="/yacy/ui/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="/yacy/ui/js/jquery-ui-1.7.2.min.js" type="text/javascript"></script>
<script src="/yacy/ui/js/jquery.tagcloud.min.js" type="text/javascript"></script>
<script src="/yacy/ui/js/jquery.tagcloud.js" type="text/javascript"></script>
<script src="/yacy/ui/js/jquery.tinysort.min.js" type="text/javascript"></script>
<link media="screen" type="text/css" href="/yacy/ui/css/themes/start/ui.base.css" rel="stylesheet" />
<link media="screen" type="text/css" href="/yacy/ui/css/themes/start/ui.theme.css" rel="stylesheet" />
@ -87,69 +87,77 @@ $(function() {
</fieldset>
</div>
<!-- the sidebar navigation -->
<div style="float: right; width: 27%;">
<div style="float: right; width: 280px;">
<fieldset>
<table>
<tr>
<td><input type="checkbox" name="search.navigation.topics" value="true" #(search.navigation.topics)#::checked="checked" #(/search.navigation.topics)# /></td>
<td>
<div style="float: right; margin-top: 0px; width: 100%; height: 80px">
<div>
<ul id="sidebarTopics" style="padding-left: 0px;">
<li value="3"><a href="yacysearch.html" target="LayouTest">Tag</a></li>
<li value="4"><a href="yacysearch.html" target="LayouTest">Topics</a></li>
<li value="3"><a href="yacysearch.html" target="LayouTest">Cloud</a></li>
<li value="2"><a href="yacysearch.html" target="LayouTest">Topics</a></li>
<li value="1"><a href="yacysearch.html" target="LayouTest">Cloud</a></li>
<li value="1"><a href="yacysearch.html" target="LayouTest">Tag</a></li>
<li value="1"><a href="yacysearch.html" target="LayouTest">Cloud</a></li>
<li value="1"><a href="yacysearch.html" target="LayouTest">Topic</a></li>
<li value="1"><a href="yacysearch.html" target="LayouTest">Tag</a></li>
<li value="1"><a href="yacysearch.html" target="LayouTest">Cloud</a></li>
</ul>
<div id="tagcloud" style="text-align:justify">
<a href="yacysearch.html" target="LayouTest" rel="1" style="text-decoration: none;">Tag</a>
<a href="yacysearch.html" target="LayouTest" rel="2" style="text-decoration: none;">Topics</a>
<a href="yacysearch.html" target="LayouTest" rel="3" style="text-decoration: none;">Cloud</a>
<a href="yacysearch.html" target="LayouTest" rel="4" style="text-decoration: none;">Topics</a>
<a href="yacysearch.html" target="LayouTest" rel="6" style="text-decoration: none;">Cloud</a>
<a href="yacysearch.html" target="LayouTest" rel="5" style="text-decoration: none;">Tag</a>
<a href="yacysearch.html" target="LayouTest" rel="4" style="text-decoration: none;">Cloud</a>
<a href="yacysearch.html" target="LayouTest" rel="3" style="text-decoration: none;">Topic</a>
<a href="yacysearch.html" target="LayouTest" rel="2" style="text-decoration: none;">Tag</a>
<a href="yacysearch.html" target="LayouTest" rel="1" style="text-decoration: none;">Cloud</a>
</div>
<script type="text/javascript" charset="utf-8">
$.fn.tagcloud.defaults = {
size: {start: 8, end: 16, unit: 'pt'},
color: {start: '#c08080', end: '#2200CC'}
};
$(document).ready(function(){
$("#tagcloud a").tagcloud();
return false;
})
</script>
</div>
</td>
</tr>
<tr>
<td><input type="checkbox" name="search.navigation.protocol" value="true" #(search.navigation.protocol)#::checked="checked" #(/search.navigation.protocol)# /></td>
<td><div id="sidebarProtocols" style="float: right; margin-top: 0px; width: 210px;">
<td><div id="sidebarProtocols" style="float: right; margin-top: 0px; width: 230px;">
<h3 style="padding-left: 25px;">Protocol Navigator</h3>
</div></td>
</tr>
<tr>
<td><input type="checkbox" name="search.navigation.filetype" value="true" #(search.navigation.filetype)#::checked="checked" #(/search.navigation.filetype)# /></td>
<td><div id="sidebarFiletypes" style="float: right; margin-top: 0px; width: 210px;">
<td><div id="sidebarFiletypes" style="float: right; margin-top: 0px; width: 230px;">
<h3 style="padding-left: 25px;">Filetype Navigator</h3>
</div></td>
</tr>
<tr>
<td><input type="checkbox" name="search.navigation.hosts" value="true" #(search.navigation.hosts)#::checked="checked" #(/search.navigation.hosts)# /></td>
<td><div id="sidebarDomains" style="float: right; margin-top: 0px; width: 210px;">
<td><div id="sidebarDomains" style="float: right; margin-top: 0px; width: 230px;">
<h3 style="padding-left: 25px;">Domain Navigator</h3>
</div></td>
</tr>
<tr>
<td><input type="checkbox" name="search.navigation.namespace" value="true" #(search.navigation.namespace)#::checked="checked" #(/search.navigation.namespace)# /></td>
<td><div id="sidebarNameSpace" style="float: right; margin-top: 0px; width: 210px;">
<td><div id="sidebarNameSpace" style="float: right; margin-top: 0px; width: 230px;">
<h3 style="padding-left: 25px;">Wiki Name Space Navigator</h3>
</div></td>
</tr>
<tr>
<td><input type="checkbox" name="search.navigation.authors" value="true" #(search.navigation.authors)#::checked="checked" #(/search.navigation.authors)# /></td>
<td><div id="sidebarAuthors" style="float: right; margin-top: 0px; width: 210px;">
<td><div id="sidebarAuthors" style="float: right; margin-top: 0px; width: 230px;">
<h3 style="padding-left: 25px;">Author Navigator</h3>
</div></td>
</tr>
<tr>
<td></td>
<td><div id="vocabulary" style="float: right; margin-top: 0px; width: 210px;">
<td><div id="vocabulary" style="float: right; margin-top: 0px; width: 230px;">
<h3 style="padding-left: 25px;">Vocabulary Navigator</h3>
</div></td>
</tr>
<tr>
<td></td>
<td><div id="sidebarAbout" style="float: right; margin-top: 5px; width: 210px;">
<td><div id="sidebarAbout" style="float: right; margin-top: 5px; width: 230px;">
<h3 style="padding-left: 25px;">about#[about.headline]#</h3>
<div>#[about.body]#</div>
</div></td>

@ -672,7 +672,7 @@ dl.bplike
{
float: left;
margin: 0 0;
width: 184px;
width: 194px;
padding: 0;
}

@ -0,0 +1,92 @@
/*!
* jquery.tagcloud.js
* A Simple Tag Cloud Plugin for JQuery
*
* https://github.com/addywaddy/jquery.tagcloud.js
* created by Adam Groves
*/
(function($) {
/*global jQuery*/
"use strict";
var compareWeights = function(a, b)
{
return a - b;
};
// Converts hex to an RGB array
var toRGB = function(code) {
if (code.length === 4) {
code = code.replace(/(\w)(\w)(\w)/gi, "\$1\$1\$2\$2\$3\$3");
}
var hex = /(\w{2})(\w{2})(\w{2})/.exec(code);
return [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
};
// Converts an RGB array to hex
var toHex = function(ary) {
return "#" + jQuery.map(ary, function(i) {
var hex = i.toString(16);
hex = (hex.length === 1) ? "0" + hex : hex;
return hex;
}).join("");
};
var colorIncrement = function(color, range) {
return jQuery.map(toRGB(color.end), function(n, i) {
return (n - toRGB(color.start)[i])/range;
});
};
var tagColor = function(color, increment, weighting) {
var rgb = jQuery.map(toRGB(color.start), function(n, i) {
var ref = Math.round(n + (increment[i] * weighting));
if (ref > 255) {
ref = 255;
} else {
if (ref < 0) {
ref = 0;
}
}
return ref;
});
return toHex(rgb);
};
$.fn.tagcloud = function(options) {
var opts = $.extend({}, $.fn.tagcloud.defaults, options);
var tagWeights = this.map(function(){
return $(this).attr("rel");
});
tagWeights = jQuery.makeArray(tagWeights).sort(compareWeights);
var lowest = tagWeights[0];
var highest = tagWeights.pop();
var range = highest - lowest;
if(range === 0) {range = 1;}
// Sizes
var fontIncr, colorIncr;
if (opts.size) {
fontIncr = (opts.size.end - opts.size.start)/range;
}
// Colors
if (opts.color) {
colorIncr = colorIncrement (opts.color, range);
}
return this.each(function() {
var weighting = $(this).attr("rel") - lowest;
if (opts.size) {
$(this).css({"font-size": opts.size.start + (weighting * fontIncr) + opts.size.unit});
}
if (opts.color) {
$(this).css({"color": tagColor(opts.color, colorIncr, weighting)});
}
});
};
$.fn.tagcloud.defaults = {
size: {start: 14, end: 18, unit: "pt"}
};
})(jQuery);

@ -1,8 +0,0 @@
/*
* jQuery TagCloud 0.5.0
* Copyright (c) 2008 Ron Valstar
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
(function(F){var C;var A={};var G={};var L=2.399963;F.tagcloud={id:"TagCloud",version:"0.5.0",defaults:{height:null,type:"cloud",sizemax:20,sizemin:10,colormax:"00F",colormin:"B4D2FF",seed:null,power:0.5}};F.fn.extend({tagcloud:function(M){C=F.extend({},F.tagcloud.defaults,M);if(C.seed===null){C.seed=Math.ceil(Math.random()*45309714203)}switch(C.type){case"sphere":case"cloud":A={position:"relative"};G={position:"absolute",display:"block"};break;case"list":A={height:"auto"};G={position:"static",display:"inline"};break}B.setSeed(C.seed+123456);return this.each(function(f,a){var q=F(a);var R=q.find(">li");var S=R.length;var Z=q.width();var l=C.height===null?(0.004*Z*S):C.height;q.css({width:Z,height:l,listStyle:"none",margin:0,padding:0});q.css(A);var e=-2147483647;var r=2147483648;var T=-1;for(var d=0;d<S;d++){var p=F(R[d]);var n=p.attr("value")==-1?T++:p.attr("value");if(n>e){e=n}if(n<r){r=n}T=n}var b=e-r;var X=new Array();for(var d=0;d<S;d++){X[d]=d}for(var d,V,c=X.length;c;d=parseInt(B.rand(0,1000)/1000*c),V=X[--c],X[c]=X[d],X[d]=V){}T=-1;for(var d=0;d<S;d++){var p=F(R[d]);var n=p.attr("value")==-1?T++:p.attr("value");T=n;var g=((S-d-1)/(S-1));var g=(n-r)/b;var m=C.sizemin+g*(C.sizemax-C.sizemin);var N=D(C.colormin,C.colormax,g);p.css({fontSize:m,position:"absolute",color:"#"+N,margin:0,padding:0}).children().css({color:"#"+N});var Y=p.width();var h=p.height();var Q={};if(C.type!="list"){if(C.type=="cloud"){var s=B.rand(0,Z-Y);var W=X[d]*(l/S)-h/2}else{var P=Math.pow(d/S,C.power);var U=(d+Math.PI/2)*L;var s=Z/2-Y/2+0.5*Z*P*Math.sin(U);var W=l/2-h/2+0.5*l*P*Math.cos(U)}Q.left=s;Q.top=W}for(var O in G){Q[O]=G[O]}p.css(Q)}})}});var B=new function(){this.seed=23145678901;this.A=48271;this.M=2147483647;this.Q=this.M/this.A;this.R=this.M%this.A;this.oneOverM=1/this.M};B.setSeed=function(M){this.seed=M};B.next=function(){var M=this.seed/this.Q;var N=this.seed%this.Q;var O=this.A*N-this.R*M;this.seed=O+(O>0?0:this.M);return(this.seed*this.oneOverM)};B.rand=function(N,M){return Math.floor((M-N+1)*this.next()+N)};function I(M){return M.toString(16)}function K(M){return parseInt(M,16)}function H(Q){var M=Q.length==3;var O=[];for(var N=0;N<3;N++){var P=Q.substring(N*(M?1:2),(N+1)*(M?1:2));O.push(K(M?P+P:P))}return O}function J(M){var O="";for(var N=0;N<3;N++){var P=I(M[N]);if(P.length==1){P="0"+P}O+=P}return O}function D(R,S,P){var Q=H(R);var M=H(S);var O=[];for(var N=0;N<3;N++){O.push(Q[N]+Math.floor(P*(M[N]-Q[N])))}return J(O)}function E(M){if(window.console&&window.console.log){if(typeof (M)=="string"){window.console.log(M)}else{for(var N in M){window.console.log(N+": "+M[N])}}}}F.fn.TagCloud=F.fn.Tagcloud=F.fn.tagcloud})(jQuery);

@ -14,7 +14,7 @@
<script type="text/javascript">hs.outlineType = 'rounded-white';</script>
<script src="/yacy/ui/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="/yacy/ui/js/jquery-ui-1.7.2.min.js" type="text/javascript"></script>
<script src="/yacy/ui/js/jquery.tagcloud.min.js" type="text/javascript"></script>
<script src="/yacy/ui/js/jquery.tagcloud.js" type="text/javascript"></script>
<script src="/yacy/ui/js/jquery.tinysort.min.js" type="text/javascript"></script>
<link media="screen" type="text/css" href="/yacy/ui/css/themes/start/ui.base.css" rel="stylesheet" />
<link media="screen" type="text/css" href="/yacy/ui/css/themes/start/ui.theme.css" rel="stylesheet" />

@ -1,7 +1,7 @@
<div style="float:right;width:25%;">
#(cat-location)#::
<div style="float:right; margin-top:5px; width:220px;">
<div style="float:right; margin-top:5px; width:230px;">
<a href="yacysearch_location.html?query=#[queryenc]#">
<img src="/env/grafics/earthsearch.png" width="215" height="159" alt="earthsearchlogo" /></a>
<a href="yacysearch_location.html?query=#[queryenc]#">Show search results for "#[query]#" on map</a>
@ -9,15 +9,25 @@
#(/cat-location)#
#(nav-topics)#::
<div style="float: right; margin-top:5px; width: 220px; height: 80px">
<div><ul id="sidebarTopics" style="padding-left: 0px;">#{element}#
<li value="#[count]#"><a href="#[url]#">#[name]#</a></li>
#{/element}#</ul></div>
<div style="float: right; margin-top:5px; width: 230px; height: 72px">
<div id="tagcloud" style="text-align:justify">#{element}#
<a rel="#[count]#" href="#[url]#" style="text-decoration: none;">#[name]#</a>
#{/element}#</div>
</div>
<script type="text/javascript" charset="utf-8">
$.fn.tagcloud.defaults = {
size: {start: 8, end: 16, unit: 'pt'},
color: {start: '#c08080', end: '#2200CC'}
};
$(document).ready(function(){
$("#tagcloud a").tagcloud();
return false;
})
</script>
#(/nav-topics)#
#(nav-protocols)#::
<div id="sidebarProtocols" style="float:right; margin-top:5px; width:220px;">
<div id="sidebarProtocols" style="float:right; margin-top:5px; width:230px;">
<h3 style="padding-left:25px;">Protocol Navigator</h3>
<dl class="bplike" style="padding-left:5px;">#{element}#
<dt><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/></dt>
@ -34,7 +44,7 @@ $(function() { $("#sidebarProtocols").accordion('activate', false); });
#(/nav-protocols)#
#(nav-filetypes)#::
<div id="sidebarFiletypes" style="float:right; margin-top:5px; width:220px;">
<div id="sidebarFiletypes" style="float:right; margin-top:5px; width:230px;">
<h3 style="padding-left:25px;">Filetype Navigator</h3>
<dl class="bplike" style="padding-left:5px;">#{element}#
<dt><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/></dt>
@ -51,7 +61,7 @@ $(function() { $("#sidebarFiletypes").accordion('activate', false); });
#(/nav-filetypes)#
#(nav-domains)#::
<div id="sidebarDomains" style="float:right; margin-top:5px; width:220px;">
<div id="sidebarDomains" style="float:right; margin-top:5px; width:230px;">
<h3 style="padding-left:25px;">Domain Navigator</h3>
<dl class="bplike" style="padding-left:5px;">#{element}#
<dt><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/></dt>
@ -68,7 +78,7 @@ $(function() { $("#sidebarDomains").accordion('activate', false); });
#(/nav-domains)#
#(nav-namespace)#::
<div id="sidebarNameSpace" style="float:right; margin-top:5px; width:220px;">
<div id="sidebarNameSpace" style="float:right; margin-top:5px; width:230px;">
<h3 style="padding-left:25px;">Name Space Navigator</h3>
<dl class="bplike" style="padding-left:5px;">#{element}#
<dt><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/></dt>
@ -85,7 +95,7 @@ $(function() { $("#sidebarNameSpace").accordion('activate', false); });
#(/nav-namespace)#
#(nav-authors)#::
<div id="sidebarAuthors" style="float:right; margin-top:5px; width:220px;">
<div id="sidebarAuthors" style="float:right; margin-top:5px; width:230px;">
<h3 style="padding-left:25px;">Author Navigator</h3>
<dl class="bplike" style="padding-left:5px;">#{element}#
<dt><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/></dt>
@ -102,7 +112,7 @@ $(function() { $("#sidebarAuthors").accordion('activate', false); });
#(/nav-authors)#
#{nav-vocabulary}#
<div id="sidebar#[navname]#" style="float:right; margin-top:5px; width:220px;">
<div id="sidebar#[navname]#" style="float:right; margin-top:5px; width:230px;">
<h3 style="padding-left:25px;">#[navname]# Navigator</h3>
<dl class="bplike" style="padding-left:5px;">#{element}#
<dt><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/></dt>
@ -112,7 +122,7 @@ $(function() { $("#sidebarAuthors").accordion('activate', false); });
#{/nav-vocabulary}#
#(nav-about)#::
<div id="sidebarAbout" style="float: right; margin-top:5px; width: 220px;">
<div id="sidebarAbout" style="float: right; margin-top:5px; width: 230px;">
<h3 style="padding-left:25px;">#[headline]#</h3>
<div style="margin:0px; padding:0px;">
#[body]#

@ -24,7 +24,9 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import java.util.AbstractMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import net.yacy.cora.document.analysis.Classification;
@ -46,7 +48,7 @@ import net.yacy.server.serverSwitch;
public class yacysearchtrailer {
private static final int MAX_TOPWORDS = 12;
private static final int MAX_TOPWORDS = 16;
private static final int MAXLIMIT_NAV_LOW = 5;
private static final int MAXLIMIT_NAV_HIGH = 20;
@ -209,26 +211,29 @@ public class yacysearchtrailer {
prop.put("nav-topics", "1");
navigatorIterator = topicNavigator.keys(false);
int i = 0;
String queryStringForUrl;
String queryStringForUrl = theSearch.query.getQueryGoal().getOriginalQueryString(true);
// first sort the list to a form where the greatest element is in the middle
LinkedList<Map.Entry<String, Integer>> cloud = new LinkedList<Map.Entry<String, Integer>>();
while (i < MAX_TOPWORDS && navigatorIterator.hasNext()) {
name = navigatorIterator.next();
count = topicNavigator.get(name);
if (count == 0) {
break;
}
queryStringForUrl = theSearch.query.getQueryGoal().getOriginalQueryString(true);
if (queryStringForUrl == null) {
break;
}
if (name != null) {
prop.put("nav-topics_element_" + i + "_on", 1);
prop.put(fileType, "nav-topics_element_" + i + "_modifier", name);
prop.put(fileType, "nav-topics_element_" + i + "_name", name);
prop.put(fileType, "nav-topics_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, queryStringForUrl + "+" + name).toString());
prop.put("nav-topics_element_" + i + "_count", count);
prop.put("nav-topics_element_" + i + "_nl", 1);
i++;
}
if (count == 0) break;
if (name == null) continue;
Map.Entry<String, Integer> entry = new AbstractMap.SimpleEntry<String, Integer>(name, (count + MAX_TOPWORDS - i) / 2);
if (cloud.size() % 2 == 0) cloud.addFirst(entry); else cloud.addLast(entry); // alternating add entry to first or last position.
i++;
}
i= 0;
for (Map.Entry<String, Integer> entry: cloud) {
name = entry.getKey();
count = entry.getValue();
prop.put("nav-topics_element_" + i + "_on", 1);
prop.put(fileType, "nav-topics_element_" + i + "_modifier", name);
prop.put(fileType, "nav-topics_element_" + i + "_name", name);
prop.put(fileType, "nav-topics_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, queryStringForUrl + "+" + name).toString());
prop.put("nav-topics_element_" + i + "_count", count);
prop.put("nav-topics_element_" + i + "_nl", 1);
i++;
}
prop.put("nav-topics_element", i);
i--;

Loading…
Cancel
Save