Plugin to tag wiki content collectively or authoritatively in order to make it easier to find content and to get a meaningful page ranking.

Introduction

The larger a TWiki installation gets, the harder it becomes to find content.
Even in a single web, if it has many topics, it may be difficult to keep the webcontent well organized and easy to navigate.

Meanwhile, intranet search does not work well due to inadequate ranking of search engines on intranets. This is because there are typically not many cross-links between pages.

Given the challenge, this plugin provides a tagging capability to TWiki.

There are clear benefits in tagging content in a large TWiki (10K or more topics):

Solve the search ranking issue of wiki content indexed by a search engine

Help solve stale content issue (old topics do not get tagged)

Single v.s. multiple tag namespaces

By default, there is only one tag namespace - all webs share a single tag set.
If $TWiki::cfg{TagMePlugin}{SplitSpace} is set to 1, each top level web has its own tag namespace, which is shared by its subwebs.
This is not the case on this TWiki installation.
Switching between single tag namespace and multiple namespaces takes some effort, you should understand the consequences and set the appropriate value for your installation.

If UserSubwebs are in effect (this is not the case on this installation), each user subweb has its own tag name space, which is shared by its subwebs, provided that multiple tag namespaces are in effect.

User conscious v.s. user agnostic tagging

There are two modes of tagging - user conscious tagging and user agnostic tagging.

Under user conscious tagging:

Let the individuals build their own taxonomy to find content quickly

Let the users do the ranking to get an "human intelligence" ranking of important content

Access my favorite topics quickly (assuming I tag topics of interest)

It is used as follows.

Any topic can be tagged by individuals -> create taxonomy for individuals

Show tag statistics of all users on each topic -> show popularity

Encourage users to reuse the same tag on a topic -> get a "collective ranking", or "vote for a tag", or "tag count"

Make it as easy as possible to increase the tag count

Make it as easy as possible to add a new tag to a topic

Encourage users to create new tags, but try to avoid use of similar tags for the same subject

Search for topic by tag, sorted by tag popularity

Under user agnostic tagging:

A tag is put on a topic or not and there is not voting aspect in tagging. This implies that tags are user agnostic

You can restrict who can tag topics and probably you do

You may not like the "democratic" nature of user conscious tagging.
As the owner of a web, you may want total control over what tags topics in the web have.
That is achieved by user agnostic tagging if you restrict tagging.

By default, the plugin works in the user conscious tagging mode.
If you set $TWiki::cfg{TagMePlugin}{UserAgnostic} 1, user agnostic tagging is used.

If there is only one tag namespace (the default setting), user conscious or user agnostic is a global setting. You cannot set one web user conscious tagging while another web user agnostic.
This is because under single tag namespace, tag search is global - all webs are subject to tag search.
User conscious tagging and user agnostic tagging are semantically different.
Different things should not be mixed together.

If multiple tag namespaces are there, each top level web can choose user conscious or user agnostic tagging by setting TAGMEPLUGIN_USER_AGNOSTIC_TAGGING preferences variable on or off on the WebPreferences topic.
The default tagging mode is specified by $TWiki::cfg{TagMePlugin}{UserAgnostic}.

Please note that setting TAGMEPLUGIN_USER_AGNOSTIC_TAGGING on the TWikiPreferences topic doesn't have the effect.

Permission

Who can add/delete/rename tags in the tag set

The plug-in maintains a set of tags. Only tags in the tag set can be added to a topic.
By default, any authenticated user can add/delete/rename tags in the tag set.
But you may want to restrict who can modify the tag set.

DENY_TAG_CHANGE and ALLOW_TAG_CHANGE, which are supposed to be set and finalized in TWikiPreferences, restrict users who can modify the tag set.
The way they work is similar to other access control variables DENY* and ALLOW*. You can find out the details of TWiki's access control at TWiki.TWikiAccessControl.

Under multiple tag namespaces, DENY_TAG_CHANGE and ALLOW_TAG_CHANGE need to be set at the web level. Those variables set at the TWiki installation level don't take effect.

Just like TWikiAdminGroup members can view/update/delete any topic regardless of access restriction, they can add/delete/rename tags regardless of DENY_TAG_CHANGE and ALLOW_TAG_CHANGE.

Who can tag

You may want to restrict who can put/remove tags to/from topics.
Please note that whether you can add/delete/rename tags in the tag set (tag change permission) and whether you can put/remove tags to/from a topic (tagging permmision) are two different things. Tagging permission is set by the following preference variables.

DENYWEBTAG

ALLOWWEBTAG

DENYWEBTAG

ALLOWWEBTAG

If none of above is set, a user who can change a topic can put/remove tags to/from the topic.

Even if a user is denied tagging by the logic above, if the user has tag change permission, the user is allowed to put/remove tags to/from a topic.
This may sound odd. The reason behind this is as follows.

If you have tag change permission, you can add and delete tags. Only unused tags can be deleted. As such, when you delete a tag, you need to remove the tag from all topics having it.

If you have tag change permission, you can rename an existing tag. A rename operation ends up changing tags on multiple topics.

For these, if you can change the tag set but you cannot put/remove tags, it's strange.

As you can imagine, TWikiAdminGroup members can tag any topic regardless of access restriction.

Behavior on a read-only web

If ReadOnlyAndMirrorWebs is in use, some webs are read-only.
This plug-in supports read-only webs.
On a read-only web, tags are displayed but cannot be manipulated.

User Interface

Tag list on topic

Every topic has a list showing all tags associated with the topic. Additional tags can be added to the topic, and new tags can be created.

Default "twiki" style

Screenshot of tags shown on a topic:

You see:

a list of tags with vote count and add/remove vote buttons,

an add tag selector

a link to create a new tag

a link to the all tags view

"blog" style

But the same control can have a different look and feel if we specify
style="blog". In view mode it has a terse apperance:

But, if you click on Tags, and that you have an account and can edit tags, you
will see:

In this style, you can define tag bundles - bundles are groups of tags that are presented as menus for convenience.
It is a list of space-separated (or comma-separated if your tags may contain spaces) prefixed by bundle labels terminated by colon (":"). e.g:

Set TAGMEPLUGIN_BUNDLES =

#Set TAGMEPLUGIN_BUNDLES = Rating: * * * Todo: to_blog to_read

#Set TAGMEPLUGIN_BUNDLES = Rating:, , *, **, Todo:, to_blog, to_read

Tags in bundes need to be valid - simply putting a tag in a bundle doesn't make it valid. You need to create it on TagMeCreateNewTag before putting a tag in a bundle.

TAGMEPLUGIN_BUNDLES is a preferences variable and you can set its value at the installation level, the web level, or the topic level.

Create, rename, delete, list, search tags

There are topics for various tag operations as shown below.
Links to those topics are provided from various places off the shelf.
Things are supposed to just work without doing anything special.
So this part of this topic is to inform you what topics are there for tag manipulation rather than how to set things up.

The TWiki06x00 web has all of those topics.
And the _default template web has all of those topics now, but not in the past.
Lack of those topics in each web is not an issue under single tag namespace since only those topics in the TWiki06x00 web are referred to.
All tag operations are done on those topics in the TWiki06x00 web.

If you employ multiple tag namespaces, each top level web needs those topics to manipulate tags in the web, hence you may need to copy those topics from the _default web.

Create, rename, delete tags programmatically

You may want to do tag creation, rename, deletion programatically. Maybe needless to say, you can do that by mimicking form submission from those pages.

List tags

TagMeViewAllTags shows all tags either in the TWiki installation (if there is only one tag namespace) or in the current top level web (if each top level web has its tag namespace). The font size indicates the overall tag count of a tag.

Screenshot of tag cloud in the list all tags view:

Tip: In a WebHome of a web you can show a tag cloud of all tagged topics in that web with this variable:

If user conscious tagging is in effect, TagMeViewMyTags shows all tags used by the logged-in user. The font size indicates the overall tag count of a tag.
Under user agnostic tagging, TagMeViewMyTags shows the same result as TagMeViewAllTags.

Tag search

TagMeSearch shows a list of topics that are tagged with all of the selected tags, sorted by relevance. Topics with a high tag count are shown first.

Plugin variables

TAGME

Various tag operations are provided through the %TAGME{}% variable. The tpaction="" parameter is required.

will expand into a "tag edit" frame that allows tag management as commonly found in blogs or tag systems like delicious, but only if tpaction is actually present. If tpaction is omitted, but the style is "blog", will show nothing. Thus a button to make the edit tags frame appear can be put as: <a href="%SCRIPTURL{viewauth}%/%SYSTEMWEB%/%TOPIC%?tpaction=show">Edit tags</a>

"twiki"

label=", "

(for style=blog) link label (text) to open the edit tags form

""

button=", "

(for style=blog) the complete button, link or html construct that will be shown when not in edit tag mode. Should open the Edit tag form when clicked by redirection to this same topic with a tpaction=show added. Overrides label.

""

header="..."

(for style=blog) Printed before the edit tags form if it is not empty, $n can be used for newlines. e.g: header="Manage your tags: <i>"

""

footer="..."

(for style=blog) Printed after the edit tags form if it is not empty, $n can be used for newlines. e.g: footer="</i>"

Limit query to a topic, or a comma-space delimited list of topics with optional asterisk wildcards

all topics

tag="..."

Name of tag

(required)

sort="web"

Sorting of tagged topics: "tagcount" by tag count (relevance), "web" by web then topic name, "topic" by topic name

"tagcount"

norelated="on"

Do not show the list of "related tags"

(show related tags)

nototal="on"

Do not show total number of topics found

(show total)

minsize="90"

Minimum size of topic $size (typically percent font size)

"90"

maxsize="180"

Maximum size of topic $size

"180"

format="..."

Format of a topic, any token of TWiki06x00.FormattedSearch can be used, such as $web, $topic, $summary, $rev, $n. In addition, $votecount expands to the number of tag votes, $size to the suggested font size, and $taglist to the tag list of the topic.

(nice formatting)

separator=", "

Separator between tags, $n or $n() can be used for newlines

"$n"

limit=""

limit number of results if sort="web"

header=""

if sort="web", add this header once per web with results (only $web is interpreted)

---+++ $web

footer=""

if sort="web", add this footer once per web with results (only $web and $count and $showmore are interpreted)

showing $limit out of $count results $showmore

refine

Normally related tags are shown that when clicked on will search for the related tag. If refine is set to 1, then the link instead will add the clicked tag to the set of tags being searched for, allowing you to incrementally refine search results. If not set the value of ALWAYS_REFINE is used.

TAGMEPLUGIN_USER_AGNOSTIC

%TAGMEPLUGIN_USER_AGNOSTIC% (without _TAGGING)is expanded to off if the current web employs user conscious tagging. It's expanded to on if the current web employs user agnostic tagging.

This variable is for reading, not for setting whereas TAGMEPLUGIN_USER_AGNOSTIC_TAGGING (with _TAGGING) is for setting.

TAGMEPLUGIN_USER_AGNOSTIC_TAGGING

%TAGMEPLUGIN_USER_AGNOSTIC_TAGGING% is referred to by the plugin code only if multiple tag namespaces are there.
This is to override the installation-wide default of user conscious tagging or user agnostic tagging.
The installation-wide default is specified by $TWiki::cfg{TagMePlugin}{UserAgnostic}.

How to put tags on every page

To show the tag interface at the top of the page directly below the breadcrumb (like on twiki.org), use the default template view.tagme.tmpl in the templates directory.

The list of skins can be appended, for instance: tagme,corporate,pattern.

For the "blog" style, use for a simple "Tags: list-of-tags (edit)" at the top
of the page:

* Set SKIN = tagme_styleblog,pattern

And for an alternate style, with no tags line shown if no tags exists, and
the button to open the tag edit frame placed at the right of the Edit and
Attach ones, in the same style, on the upper right:

* Set SKIN = tagme_styleblogbutton,pattern

For TWiki 4.1, use:

* Set SKIN = tagme04x01,pattern

Customizing the appearance

If you customize your site you probably want to change overall appearance. You can find instructions how to do that - at least for default pattern skin - in TWiki06x00.PatternSkinCssCookbook.
The short summary is:

Search results CSS Styles

Table header with link to topic, last modified date and author. These have the additional classes td.tagmeTopicTd, td.tagmeDateTd, td.tagmeAuthorTd, tagmeTopicTdWeb

tagmeResultsDetails

Wrapper around tagmeResultsSummary and tagmeResultsDetails

tagmeResultsSummary

The topic summary

tagmeResultsTags

List of tags for the topic

Preventing link wrap

If users are allowed to use spaces in their tag names (when {TagMePlugin}{NormalizeTagInput} is set to 0), tag links may break halfway to the next line. To prevent wrapping, add a wrapper div around the tags:

$TWiki::cfg{TagMePlugin}{NormalizeTagInput} (default 0) When you add a new tag, the tag name is somewhat normalized. If this parameter is 1, then the degree of normalization is higher - a tag consists only of non-accented letters, numbers, or underscores. To achieve that, spaces and hyphens are replaced with underscores, characters other than non-accented letters, numbers, or underscores are eliminated, all uppercase letters are made lowercase. If this parameter is 0, then the following characters are eliminated: ^#,'"|* Other than that, no normalization is conducted.

$TWiki::cfg{TagMePlugin}{LogAction} (default: 0) If 1, then tag actions such as creation of a new tag, adding a tag to a topic are logged in the log file in the same manner as topic view and edit are logged.

$TWiki::cfg{TagMePlugin}{AlwaysRefine} (default: 0) If 1, then the refine parameter is always added to TAGME queries.

$TWiki::cfg{TagMePlugin}{TagLenLimit} (default: 30) Maximum length of a tag name

$TWiki::cfg{TagMePlugin}{Debug} (default: 0) If 1, then debug messages are put into the debug log file

Switching SplitNamespace and/or UserAgnostic

You may change {TagMePlugin}{SplitSpace} or {TagMePlugin}{UserAgnostic} after using TagMePlugin for a while.
This is not recommended, but you may need to do that.
So here's how you can deal with it.

Switching SplitNamespace

If {TagMePlugin}{SplitSpace} is 0, all tag data, namely the tag set and which topic has which tags put by whom, is stored in the following directory:$TWiki::cfg{WorkingDir}/work_areas/TagMePlugin

If the directory there are two kinds of files:

_tags_all.txt - having the tag set

_tags_WEB.TOPIC.txt (e.g. _tags_TWiki.WebPreferences.txt) - having who put which tag to which topic

If {TagMePlugin}{SplitSpace} is 1, tag data is stored in the pub directories of top level webs under the .tags subdirectory. For example, WebA's tag data is stored in pub/WebA/.tags, WebB's tag data is stored in pub/WebB/.tags, etc. Tag data file names and content are the same as they are under single tag namespace configuration.

As you see, under the multiple tag namespace configuration, tag data is not stored under $TWiki::cfg{WorkingDir}. Instead, it's stored under pub/WEB_NAME. This is to mirror a web simply by mirroring data/WEB_NAME and pub/WEB_NAME.

If you change {TagMePlugin}{SplitSpace} from 0 to 1, all webs become unable to see existing tag data since they refer to their own tag data, which is empty immediately after the switch.
There is no ready-made tool, but it's easy to move/copy tag data files from $TWiki::cfg{WorkingDir}/work_areas/TagMePlugin to pub/WEB_NAME/.tags.

The amount of information-wise, single tag namespace and mutliple tag namespaces are not different.
Though cumbersome, you can go back and force without losing information.

Switching UserAgnostic

If {TagMePlugin}{UserAgnostic} is 0, tagging data in _tags_WEB.TOPIC.txt consists of lines for tags put to the topic. For example, if the user john (login name) put the tag foo, the file gets the following line.

001, foo, john

Then if the user jane put the tag foo, the line becomes as follows.

002, foo, john, jane

Even if {TagMePlugin}{UserAgnostic} is 1, the tagging data file format remains the same.
The difference is, when the tagging data file is read, each line is recognized as:

001, TAG, YOUR_LOGIN_ID

This means, if you switch {TagMePlugin}{UserAgnostic} from 0 to 1, all tags put by anybody are recognized as yours. Due to the way showing tags in user agnostic tagging, those tags are displayed as expected.

A tagging data file remains as it is unless a tag is added or removed. Then, the file is filled with lines of the following format.

001, TAG, YOUR_LOGIN_ID

And the information of who put which tag is lost.

Obviously, user conscious tagging houses more information than user agnostic tagging. So switching from user conscious to user agnostic has no problem. But the other way around causes a weird situation - all tags put to the topic A is by the user U while the topic B has tags tags put only by the user V.

Plugin Installation Instructions

This plugin is pre-installed. TWiki administrators can upgrade the plugin as needed on the TWiki server.

Note: If you have upgraded TagMePlugin to TWiki 4.2 or later and appear to have lost all your old tags: Copy all your tag files from pub/TWiki/TagMePlugin/ files to working/work_areas/TagMePlugin/ and they should magically re-appear.

Limitations

TWiki 04-Sep-2005 and older: Tags are lost if a topic is renamed or moved.

Peter Thoeny: Validate tag against known tags when adding a tag; improved docs

30 Aug 2008:

Colas Nahaboo: enhancements to the "blog" style: Bundles, count of known tags, option to delete tags

28 Aug 2008:

Colas Nahaboo: prefix & suffix options renamed as header & footer. New parameter style to TAGME to be able to define different UI style for the default "show" action of TAGME. Implemented a first one, "blog" for the simpler case of authors managing the same tags

Arthur Clemens: Added option NORMALIZE_TAG_INPUT (to be set to 0) to allow any word as tag name (including upper case, punctuation characters and spaces). Moved "Create New Tag" to dedicated page. Created CSS styles in tagme.css. Added mincount parameter to TAGME{tpaction="showalltags"}.