Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Item1918: introducing clickable tagsclouds
git-svn-id: http://svn.foswiki.org/trunk/TagsPlugin@5065 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
- Loading branch information
OliverKrueger
authored and
OliverKrueger
committed
Sep 21, 2009
1 parent
3871986
commit d049c6d
Showing
9 changed files
with
269 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
%META:TOPICINFO{author="BaseUserMapping_333" date="1253507705" format="1.1" reprev="1.1" version="1.1"}% | ||
%TAGSEARCH{ | ||
query="tag" | ||
web="%URLPARAM{"tagweb" default="%TAGWEB%"}%" | ||
topic="%URLPARAM{"tagtopic" default="%TAGTOPIC%"}%" | ||
user="%URLPARAM{"taguser" default="%TAGUSER%"}%" | ||
header="[ " | ||
format="'$tag'" | ||
footer=" ]" | ||
sep=", " | ||
}% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
%META:TOPICINFO{author="BaseUserMapping_333" date="1252340265" format="1.1" version="1.2"}% | ||
%META:TOPICPARENT{name="TagsPlugin"}% | ||
#VarTAGCLOUDCLICK | ||
|
||
---+++ TAGCLOUDCLICK -- render a clickable tagcloud | ||
* Inline tag search, shows a tag search result embedded in a topic | ||
* Syntax: =%<nop>TAGCLOUDCLICK{...}%= | ||
* %X% Limitation: This macro can only be used once per page. | ||
* Supported parameters: | ||
| *Parameter:* | *Description:* | *Default:* | | ||
| =sourceuser="wikiname"= <br /> =sourceuser="all"= | When rendering the tagcloud, this filter is used for the user-dimension. Leave out the =%MAINWEB%= part here. | ="all"= | | ||
| =sourceweb="Name"= <br /> =sourceweb="%USERSWEB%, Know"= <br /> =sourceweb="all"= | Comma-separated list of webs to render the tagcloud. The special word =all= means all webs (inlcuding those which have the =NOSEARCHALL= preference set to =on=). Use =%= as a wildcard. | ="all"= | | ||
| =targetweb="Name"= | Webname of the target topic. This is where the tags are posted to. | =current web= | | ||
| =targettopic="Name"= | Topicname of the target topic. This is where the tags are posted to. | =current topic= | | ||
| =targetuser="wikiname"= | New tags are created with this ownership. | =%TAGPUBLIC%= | | ||
| =cloudtopic="Web.Topic"= | This topic is used (included) to actually render the tagcloud. | =%SYSTEMWEB%.<nop>TagsPluginTagCloud= | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# This script Copyright | ||
# (c) 2009 Oliver Krueger, (wiki-one.net) | ||
# and distributed under the GPL (see below) | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; either version 2 | ||
# of the License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details, published at | ||
# http://www.gnu.org/copyleft/gpl.html | ||
# | ||
# Author(s): Oliver Krueger | ||
|
||
package Foswiki::Plugins::TagsPlugin::TAGCLOUDCLICK; | ||
|
||
use strict; | ||
use warnings; | ||
use Error qw(:try); | ||
|
||
use constant DEBUG => 1; # toggle me | ||
|
||
=begin TML | ||
---++ do( $session, $params, $topic, $web ) | ||
Taghandler for TAGCLOUDCLICK. | ||
Returns an INCLUDE statement based on the input parameters plus add meta data to html header and include a js file. | ||
Return: | ||
Clickable Tag Cloud. | ||
=cut | ||
|
||
sub do { | ||
my ( $session, $params, $topic, $web ) = @_; | ||
|
||
my $theSourceUser = $params->{sourceuser} || "all"; | ||
my $theTargetUser = $params->{targetuser} || Foswiki::Func::getPreferencesValue("TAGSPLUGIN_TAGUSER") || Foswiki::Func::getWikiName(); | ||
my $theSourceWeb = $params->{sourceweb} || $web; | ||
my $theTargetWeb = $params->{targetweb} || $web; | ||
my $theTargetTopic = $params->{targettopic} || $topic; | ||
my $theCloudTopic = $params->{cloudtopic} || "%SYSTEMWEB%.TagsPluginTagCloud"; | ||
|
||
my $header = "<meta name='foswiki.tagsplugin.cloudclick.targetuser' content='$theTargetUser' />\n"; | ||
$header .= "<meta name='foswiki.tagsplugin.cloudclick.targetweb' content='$theTargetWeb' />\n"; | ||
$header .= "<meta name='foswiki.tagsplugin.cloudclick.targettopic' content='$theTargetTopic' />\n"; | ||
$header .= "<meta name='foswiki.tagsplugin.cloudclick.sourceuser' content='$theSourceUser' />\n"; | ||
$header .= "<meta name='foswiki.tagsplugin.cloudclick.sourceweb' content='$theSourceWeb' />\n"; | ||
$header .= "<meta name='foswiki.tagsplugin.cloudclick.cloudtopic' content='$theCloudTopic' />\n"; | ||
$header .= "<script type='text/javascript' src='%PUBURL%/System/TagsPlugin/tagsplugin-cloudclick.js'></script>\n"; | ||
Foswiki::Func::addToHEAD('TAGSPLUGIN::CLOUDCLICK', "\n".$header ); | ||
|
||
my $output = "<div id='tagsplugin_cloudclick'>%INCLUDE{\"$theCloudTopic\" TAGUSER=\"$theSourceUser\" TAGWEB=\"$theSourceWeb\"}%</div>\n"; | ||
$output .= "<div id='tagsplugin_cloudclick_processing'>%ICON{processing-bg}%</div>\n"; | ||
$output .= "<div id='tagsplugin_cloudclick_dialog' />\n"; | ||
return $output; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
(function($){ | ||
$(function(){ | ||
tagsplugin_cloudclick_refresh() | ||
}); // ready handler | ||
|
||
function tagsplugin_cloudclick_mark() { | ||
|
||
$("div#tagsplugin_cloudclick .tagsplugin_tagcloud_tag:not(.tagsplugin_tagcloud_tag_bound)") | ||
.bind( | ||
'click', | ||
function(event) { | ||
event.preventDefault(); | ||
tagsplugin_cloudclick_toggletag(event); | ||
} | ||
) | ||
.addClass("tagsplugin_tagcloud_tag_bound"); | ||
$.getJSON( | ||
foswiki.scriptUrl+"/view/"+foswiki.systemWebName+"/TagsPluginTagListJSON", | ||
{ | ||
skin: "text", | ||
cover: "text", | ||
tagweb: foswiki.tagsplugin.cloudclick.targetweb, | ||
tagtopic: foswiki.tagsplugin.cloudclick.targettopic, | ||
taguser: foswiki.tagsplugin.cloudclick.targetuser | ||
}, | ||
function(data) { | ||
for(var i = 0; i < data.length; i++) | ||
$("div#tagsplugin_cloudclick .tagsplugin_tagcloud_tag[tag='"+data[i]+"']").addClass("tagsplugin_tagged"); | ||
} | ||
) | ||
} | ||
|
||
function tagsplugin_cloudclick_toggletag(event) { | ||
if ( $(event.target).hasClass("tagsplugin_tagged") ) { | ||
$("#tagsplugin_cloudclick_processing img").show(); | ||
var tag = $(event.target).attr("tag"); | ||
var item = foswiki.tagsplugin.cloudclick.targetweb+"."+foswiki.tagsplugin.cloudclick.targettopic; | ||
var user = foswiki.tagsplugin.cloudclick.targetuser; | ||
tagsplugin_be_untag( tag, item, user ); | ||
$(event.target).removeClass("tagsplugin_tagged"); | ||
} else { | ||
$("#tagsplugin_cloudclick_processing img").show(); | ||
var tag = $(event.target).attr("tag"); | ||
var item = foswiki.tagsplugin.cloudclick.targetweb+"."+foswiki.tagsplugin.cloudclick.targettopic; | ||
var user = foswiki.tagsplugin.cloudclick.targetuser; | ||
tagsplugin_be_tag( tag, item, user ); | ||
$(event.target).addClass("tagsplugin_tagged"); | ||
} | ||
} | ||
|
||
function tagsplugin_cloudclick_refresh() { | ||
$("#tagsplugin_cloudclick_processing img").show(); | ||
$.get( | ||
foswiki.scriptUrl+"/view/"+foswiki.tagsplugin.cloudclick.cloudtopic, | ||
{ skin : "text", | ||
cover : "text", | ||
tagweb : foswiki.tagsplugin.cloudclick.sourceweb, | ||
taguser : foswiki.tagsplugin.cloudclick.sourceuser | ||
}, | ||
function(data) { | ||
$("div#tagsplugin_cloudclick").html(data); | ||
tagsplugin_cloudclick_mark(); | ||
$("#tagsplugin_cloudclick_processing img").hide(); | ||
} | ||
); | ||
} | ||
|
||
function tagsplugin_be_tag(tag, item, user) { | ||
$.ajax( | ||
{ url: foswiki.scriptUrl+'/rest/TagsPlugin/tag', | ||
type: "POST", | ||
data: { tag : tag, | ||
item : item, | ||
user : user | ||
}, | ||
complete: function(xhr, statusText) { | ||
switch (xhr.status) { | ||
case 200: | ||
tagsplugin_cloudclick_refresh(); | ||
break; | ||
case 400: | ||
tagsplugin_alert("Assuming you are logged-in and assuming you provided a tag name you probably just revealed a software bug. I'm sorry about that. (400)"); | ||
break; | ||
case 401: | ||
tagsplugin_alert("According to my data, you are not logged in. Please log-in before you retry."); | ||
break; | ||
case 403: | ||
tagsplugin_alert("I'm sorry, but you are not allowed to do that."); | ||
break; | ||
case 500: | ||
tagsplugin_alert("Something beyond your sphere of influence went wrong. Most probably a problem with the database. May I kindly ask you to inform your administrator? Thank you."); | ||
break; | ||
default: | ||
tagsplugin_alert("Unknown error in tagsplugin_be_tag."); | ||
break; | ||
} | ||
$("#tagsplugin_cloudclick_processing img").hide(); | ||
} | ||
} | ||
); | ||
} | ||
|
||
function tagsplugin_be_untag(tag, item, user) { | ||
$.ajax( | ||
{ url: foswiki.scriptUrl+'/rest/TagsPlugin/untag', | ||
type: "POST", | ||
data: { tag : tag, | ||
item : item, | ||
user : user | ||
}, | ||
complete: function(xhr, statusText) { | ||
switch (xhr.status) { | ||
case 200: | ||
tagsplugin_cloudclick_refresh(); | ||
break; | ||
case 400: | ||
tagsplugin_alert("Assuming you are logged in you probably just revealed a software bug. I'm sorry about that. (400)"); | ||
break; | ||
case 401: | ||
tagsplugin_alert("According to my data, you are not logged in. Please log-in before you retry."); | ||
break; | ||
case 403: | ||
tagsplugin_alert("I'm sorry, but you are not allowed to do that."); | ||
break; | ||
case 404: | ||
tagsplugin_alert("I'm sorry, but either the tag or the topic does not exist."); | ||
break; | ||
case 500: | ||
tagsplugin_alert("Something beyond your sphere of influence went wrong. Most probably a problem with the database. May I kindly ask you to inform your administrator? Thank you."); | ||
break; | ||
default: | ||
tagsplugin_alert("Unknown error in tagsplugin_be_untag."); | ||
break; | ||
} | ||
$("#tagsplugin_cloudclick_processing img").hide(); | ||
} | ||
} | ||
); | ||
} | ||
|
||
function tagsplugin_alert(text) { | ||
$("#tagsplugin_cloudclick_dialog") | ||
.html(text) | ||
.dialog() | ||
.dialog('option', 'modal', true) | ||
.dialog('option', 'width', 460) | ||
.dialog('option', 'title', 'May I kindly ask for your attention?') | ||
.dialog('option', 'buttons', { "Ok": function() { $(this).dialog("close"); } }) | ||
.dialog("open"); | ||
} | ||
|
||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters