wiki:TagsPlugin

Version 25 (modified by athomas, 7 years ago) (diff)

Consolidated docs into one page.

Note: Version 0.6 is a complete rewrite. This page documents that version. Refer to this page for documentation on older versions of the plugin.

A Tagging System for Trac

The TagsPlugin implements both a generic tagging engine, and frontends for the Wiki and ticket systems. An extra text entry box is added to the Wiki edit page for tagging Wiki pages, and ticket fields (you can configure which ones) are treated as tags for the ticket system.

The TagsPlugin was originally created by Muness Alrubaie but has since been completely rewritten by Alec Thomas.

Bugs/Feature Requests

Existing bugs and feature requests for TagsPlugin are here.

If you have any issues, create a new ticket.

Installing TagsPlugin

Note: setuptools must be installed on your system for this to work.

  1. Install Trac 0.11 and set up a trac project.
  2. Download tags: download(/tagsplugin/tags/0.6, tags-0.6.zip)? or grab the source from SVN.
  3. Build and install an egg from this source.
  4. Configure appropriately for your version of Trac.

Update your trac.ini with this:

[components]
tractags.* = enabled

Be sure to remove any previous TagsPlugin configuration changes. In particular trac.wiki.web_ui.wikimodule = disabled and default_handler = TagsWikiModule must be removed.

  1. Run trac-admin <env> upgrade on your Trac environment.
  2. Restart your web server.

At this stage the plugin should be working and you should see a text control for tags in your Wiki edit page. You should also see an entry in the main navigation bar labeled Tags.

Configuring TagsPlugin

Tags 0.6 has vastly simplified the configuration to the point where there are only two options, both of which are under the [tags] section:

ignore_closed_tickets = <bool>

Whether to gather tags from closed tickets.

ticket_fields = <field>[, <field> ...]

eg. ticket_fields = component, keywords.

Ticket fields from which to gather tags. Defaults to keywords. Custom fields are currently not supported.

What are tags?

Tags are like hierarchically organized wiki entries, however with them you can categorize a wiki entry under multiple tags and not just under one hierarchy. You can then search for wiki entries categorized under a tag or a collection of tags. In other words, tags provide a faceted classification system for the Trac wiki.

As an added bonus, tags are linked to the wiki entry of the same name, allowing you to describe them explicitly under the wiki entry of the same name. This allows for a flexible means for establishing the context of wiki entries. Besides this, tags also make it incredibly easy to create todo? lists or indexes?.

Tags don't have to be predefined. As long as there are wiki entries categorized under a tag, it'll be automatically created.

Tags are similar to labels in gmail, tags in the social bookmark manager del.icio.us and Flickr. They are substantially different from Wikipedia categories, because tags are associated with wiki entries of the same name, whereas WikiMedia Categories are just indexes.

This implementation of wiki tagging is specific to Trac. To stay consistent with the way Trac names wiki entries, tags are case sensitive. Trac Hacks itself makes extensive use of tagging and is a good example of their use. Also, see http://lists.edgewall.com/archive/trac/2006-April/007646.html for an example of how Alec uses ListTagged to query tickets.

How do I apply tags?

To create a tag, follow these steps:

  1. Go to the wiki entry you want to tag.
  2. Click on Edit This Page
  3. Under Change information, Tag under:, enter the tags you want to categorize the entry under. Separate tags with spaces.
  4. Click Save changes.

The wiki entry you edit is now categorized under the tags you specified.

How do I remove a tag from a wiki entry?

To remove a tag from a wiki entry

  1. Go to the wiki entry you want to untag.
  2. Click on Edit This Page
  3. Under Change information, Tag under:, remove the tag from the list.
  4. Click Save changes.

Using the tags

Querying is implemented through the /tags uri handler, the tag:<tag> syntax or Trac Macros as follows

/tags handler

Going to /tags under your project will show a list of all tags in the wiki. /tags/?q=<expression> will show all the objects matching <expression>. e.g. http://trac-hacks.org/tags/?q=plugin. This accepts all the parameters that the ListTagged macro does. e.g. http://trac-hacks.org/tags?q=plugin%20or%20macro.

tag:<tag> or tagged:<expr> Usage

Both forms are identical and link to the tag search results for the expression.

e.g. tagged:todo or tagged:"plugin macro".

Tag expressions

Both the ListTagged macro and the /tags handler use a basic expression language for filtering tagged objects.

Space-separating terms logically ANDs them together.

Operators supported by the language are:

OperatorFunction
orLogical or
notLogical not
realm:<realm>Restrict to tags in <realm> where realm is wiki, ticket, etc.

Sub-expressions can be grouped inside parentheses (, ).

Expressions and individual tags can be quoted with single ' or double " quotes.

Examples

Intersection of macro and plugin tags:

tagged:"macro plugin"

Union of macro and plugin tags:

tagged:"macro or plugin"

Objects tagged macro or plugin, and example

tagged:"(macro or plugin) example"

Macro Usage

ListTagged

[[ListTagged(<expr>)]]

This will display a list of resources whose tags match <expr>.

Change Log

[14146] by hasienda on 2014-09-01 21:44:01
TagsPlugin: Update unit tests, refs #11695, #11888 and #11954.

Added test for anonymous ticket creation and change request as follow-up to
[14144]. Thanks to Jun Omae for contributing to this part.
Removed test for permisson error on illegitimate request obsoleted by [14041].

[14144] by hasienda on 2014-08-31 23:48:05
TagsPlugin: Improve request object mockup, refs #11695 and #11954.

Thanks to bobhy for reporting the error on anonymous ticket creation.
The issue has been caused by using get_reporter_id() from trac.util for
better author detection since [13862] without paying attention to the
additional attributes it actually tries to get on anonymous changes.

[14136] by hasienda on 2014-08-26 22:48:28
TagsPlugin: Do not rely on TracXMLRPC sources availability for tests.
[14135] by hasienda on 2014-08-26 22:46:40
TagsPlugin: Update wiki macro and configuration option doc-strings, refs #9064.
[14132] by hasienda on 2014-08-25 22:46:07
TagsPlugin: Add 'compact' format for ListTagged inline result presentation, refs #9064.

Attachments (1)

Download all attachments as: .zip