Skip to content

Commit

Permalink
Item1918: adding the concept of public tags
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/TagsPlugin@5063 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
OliverKrueger authored and OliverKrueger committed Sep 20, 2009
1 parent d7eb5dc commit 19b5719
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 13 deletions.
4 changes: 2 additions & 2 deletions data/System/TagsPluginTagList.txt
@@ -1,9 +1,9 @@
%META:TOPICINFO{author="BaseUserMapping_333" date="1252679284" format="1.1" version="1.13"}%
%META:TOPICINFO{author="BaseUserMapping_333" date="1253480019" format="1.1" reprev="1.14" version="1.14"}%
%META:TOPICPARENT{name="TagsPlugin"}%
%TAGSEARCH{
query="tag"
web="%URLPARAM{"tagweb" default="%TAGWEB%"}%"
topic="%URLPARAM{"tagtopic" default="%TAGTOPIC%" }%"
format=" <li class='tagsplugin_tag'><a class='tagsplugin_tag_link' href='%SCRIPTURL{view}%/%SYSTEMWEB%/TagsPluginTagDetails?tag=$tag' tag='$tag' web='$web' topic='$topic'>$percntICON{tag}$percnt $tag</a></li>"
format=" <li class='tagsplugin_tag $public'><a class='tagsplugin_tag_link' href='%SCRIPTURL{view}%/%SYSTEMWEB%/TagsPluginTagDetails?tag=$tag' tag='$tag' web='$web' topic='$topic'>$percntICON{tag}$percnt $tag</a></li>"
sep="$n"
}%
20 changes: 15 additions & 5 deletions lib/Foswiki/Plugins/TagsPlugin.pm
Expand Up @@ -45,15 +45,12 @@ sub initPlugin {
return 0;
}

Foswiki::Func::addToHEAD('TAGSPLUGIN','<link rel="stylesheet" type="text/css" href="%PUBURL%/System/TagsPlugin/tagsplugin.css" media="all" />');

# $debug = $Foswiki::cfg{Plugins}{TagsPlugin}{Debug} || 0;

Foswiki::Func::registerTagHandler( 'TAGLIST', \&_TAGLIST );
Foswiki::Func::registerTagHandler( 'TAGENTRY', \&_TAGENTRY );
Foswiki::Func::registerTagHandler( 'TAGCLOUD', \&_TAGCLOUD ) if ( defined($Foswiki::cfg{TagsPlugin}{EnableTagCloud}) && $Foswiki::cfg{TagsPlugin}{EnableTagCloud} );
Foswiki::Func::registerTagHandler( 'TAGSEARCH', \&_TAGSEARCH );
Foswiki::Func::registerTagHandler( 'TAGGROUPS', \&_TAGGROUPS );
Foswiki::Func::registerTagHandler( 'TAGPUBLIC', \&_TAGPUBLIC );
Foswiki::Func::registerTagHandler( 'ISTAGADMIN', \&_ISTAGADMIN );

Foswiki::Func::registerRESTHandler( 'tag', \&tagCall );
Expand All @@ -65,9 +62,17 @@ sub initPlugin {
# Foswiki::Func::registerRESTHandler('updateGeoTags', \&updateGeoTags);

#TODO: augment the IfParser and the QuerySearch Parsers to add Tags?

#TODO: add a SEARCH{type="tags"} search type

# load some js and css in the header
# plus add some data through meta tags
my $header= <<'HERE';
<meta name="foswiki.tagsplugin.public" content="%TAGPUBLIC%" />
<meta name="foswiki.tagsplugin.defaultuser" content="%TAGSPLUGIN_TAGUSER%" />
<link rel="stylesheet" type="text/css" href="%PUBURL%/System/TagsPlugin/tagsplugin.css" media="all" />
HERE
Foswiki::Func::addToHEAD('TAGSPLUGIN', "\n".$header );

return 1;
}

Expand Down Expand Up @@ -310,6 +315,11 @@ sub _ISTAGADMIN {
}
}

sub _TAGPUBLIC {
my $guest = $Foswiki::cfg{DefaultUserWikiName} || "!DefaultUserWikiName NOT DEFINED!";
return $guest;
}

=pod
---++ tagCall($session) -> $text
Expand Down
10 changes: 9 additions & 1 deletion lib/Foswiki/Plugins/TagsPlugin/TAGSEARCH.pm
Expand Up @@ -184,6 +184,7 @@ $order";
my $item = $row->[1];
my $cuid = $row->[2];
my $tag_count = $row->[3];
my $user = Foswiki::Func::getWikiName($cuid);

# replace all variable occurrences
if ( $entry =~ m/\$(item|topic|web)/ ) {
Expand All @@ -195,7 +196,7 @@ $order";

if ( $entry =~ m/\$(cuid|user)/ ) {
$entry =~ s/\$cuid/$cuid/g;
$entry =~ s/\$user/Foswiki::Func::getWikiName($cuid)/ge;
$entry =~ s/\$user/$user/ge;
}

$entry =~ s/\$tag/$tag/g;
Expand All @@ -214,6 +215,13 @@ $order";
} else {
$entry =~ s/\$untaggable//g;
}

# flag this entry as public
if ( $user eq $Foswiki::cfg{DefaultUserWikiName} ) {
$entry =~ s/\$public/tagsplugin_public/g;
} else {
$entry =~ s/\$public//g;
}

# insert seperator only if needed
if ( $output ne '' ) {
Expand Down
7 changes: 4 additions & 3 deletions pub/System/TagsPlugin/tagsplugin.css
Expand Up @@ -40,7 +40,6 @@
float: left;
margin-left: 5px;
padding: 0px;
width: 64%;
}
li.tagsplugin_tag {
float: left;
Expand All @@ -60,8 +59,10 @@
a.tagsplugin_tag_remove {
display: none;
}
a.tagsplugin_untaggable {
display: none;
.tagsplugin_untaggable {
}
li.tagsplugin_public {
background-color: #B9DAFF;
}
a.tagsplugin_untag_link {
color: #FF0000;
Expand Down
19 changes: 18 additions & 1 deletion pub/System/TagsPlugin/tagsplugin.js
Expand Up @@ -7,11 +7,28 @@
event.preventDefault();
$("#tagsplugin_processing img").show();
var tag = $("#tagsplugin_taginput_input").val();
tagsplugin_be_tag(tag, foswiki.web+'.'+foswiki.topic, foswiki.wikiName );
var user = $("div#tagsplugin_taginput form input[name=user]").attr("value");
tagsplugin_be_tag(tag, foswiki.web+'.'+foswiki.topic, user );
$("#tagsplugin_taginput_input").trigger("blur").val("").focus();
}
);

// public checkbox
$("div#tagsplugin_taginput form input[name=user]")
.attr("checked", "checked")
.val(foswiki.tagsplugin.public)
.removeAttr("disabled")
.bind(
'click',
function(event) {
if ( $(this).is(":checked") ) {
$(this).val(foswiki.tagsplugin.public);
} else {
$(this).val("");
}
}
);

$("#tagsplugin_taginput_input").autocomplete(
foswiki.scriptUrl+"/view/"+foswiki.systemWebName+"/TagsPluginAutoCompleteBackend", {
extraParams: { skin:"text", cover:"text" },
Expand Down
2 changes: 1 addition & 1 deletion templates/view.tagspluginjquery.tmpl
Expand Up @@ -8,7 +8,7 @@
<input type='button' id='tagsplugin_tagcloud_toggle' value='Tags' />
<input type='text' id="tagsplugin_taginput_input" name='tag' value='enter new tag' onclick="if(this.value=='enter new tag'){this.value='';}"/>
<input type='hidden' name='item' value='%BASEWEB%.%BASETOPIC%' />
<input type='hidden' name='user' value='%TAGSPLUGIN_TAGUSER%' />
<input type='checkbox' name='user' value='%TAGPUBLIC%' disabled='disabled' checked='checked' /> public
<input type='hidden' name='type' value='topic' />
<input type='hidden' name='redirectto' value='%SCRIPTURL{view}%/%BASEWEB%.%BASETOPIC%' />
</form>
Expand Down

0 comments on commit 19b5719

Please sign in to comment.