Another Tag Cloud Plugin

  • Tags: tag cloud tagcloud
  • Latest: 0.2
  • Last Updated: 08 September 2010
  • Grails version: 1.0.5 > *
  • Authors: OSOCO
0 vote
Dependency:
compile ":atac:0.2"

 Documentation

Summary

Installation

To install the plugin in your application just run the 'install-plugin' Grails script, e.g.

grails install-plugin atac

Description

This plugin is a complete and easy tag cloud generator. As simple as you need only one tag to generate a tag cloud. The ATAC Plugin provides a simple interface to handle a tag cloud.

Installation

To install the plugin in your application just run the 'install-plugin' Grails script, e.g.

grails install-plugin atac

Once the plugin is installed and your application running, you can view the ATAC Plugin Guide at: <your_app_path>/atac/guide.

Usage

The plugin provides a taglib to generate the tag cloud. It's simple to use, just use the taglib and create the tag cloud.

There are two ways to build the tag cloud:

  1. With the tag tagCloud you can build a tag cloud with the default body offered by the plugin.
  2. With the tag bodyTagCloud you can build a custom tag cloud with your own custom body.
The two tags are under the atac namespace. So you can use the two of them as show here:

<atac:tagCloud .../>
<atac:bodyTagCloud ...> … custom body … </atac:bodyTagCloud>

Taglib attributes (attributes with [ ] are optional):

  • values: should be a map with the tags and its ocurrences. The key is the tag and the value is its ocurrences. Example: ['Java':100,'C':80].
  • [type]: indicates the type of the taglib. Can be cloud or list. The default value is cloud. This attribute is useful in cloud mode.
  • [sort]: indicates the sort field to order the map. Can be tag or ocurrence. If it's not set, the map won't be sorted.
  • [order]: indicates the sort direction to order the map. Can be asc or desc. If sort attribute is not set, this attribute has no effect.
  • [action]: indicates the action to execute when the tag is clicked. The default value is action, so it's advisible to change.
  • [controller]: indicates the controller which handles the petition when the tag is clicked. The default value is controller, so it's advisible to change.
  • [link]: indicates if tag link is required. If link is not desired should be no. By default link is stablished.
  • [divClass]: indicates the CSS class style which is applied to the cloud or the list. The default value is cloud, if you don't change it, you should need a class style named cloud. This attribute is useful in cloud mode.
  • [tagClass]: indicates the CSS class style which is applied to the tag in the cloud. The default value is tag, if you don't change it, you should need a class style named tag.
  • [intervals]: indicates the number of intervals to calculate the ranges for set the size of the tags in the cloud. The default value is 5.
  • [calc]: indicates the calculation type to set the size of the tags in the cloud. Can be linear or logarithmic. The default value is logarithmic.
  • [maxTags]: indicates the maximun number of tags desired. By default all tags are shown.

Examples with tagCloud tag

TagCloud with default configuration

<atac:tagCloud values="[Java:1000,C:500,Grails:2000]"/>

TagCloud sort by tag in order ascendant

<atac:tagCloud values="[Java:1000,C:500,Grails:2000]" sort="tag" order="asc"/>

TagCloud sort by ocurrences in order descendant

<atac:tagCloud values="[Java:1000,C:500,Grails:2000]" sort="ocurrence" order="desc"/>

TagCloud with linear calculation

<atac:tagCloud values="[Java:1000,C:500,Grails:2000]" calc="linear"/>

TagCloud in list form

<atac:tagCloud values="[Java:1000,C:500,Grails:2000]" type="list"/>

Examples with bodyTagCloud tag

BodyTagCloud with default configuration

<div class="cloud">
    <atac:bodyTagCloud values="[Java:1000,C:500,Grails:2000]">
        <div class="${it.value.class}${it.value.range}">
            <a href="${it.value.controller}/${it.value.action}/${it.key}">${it.key}</a>
        </div>
    </atac:bodyTagCloud>
</div>

BodyTagCloud sort by tag in order ascendant

<div class="cloud">
    <atac:bodyTagCloud values="[Java:1000,C:500,Grails:2000]" sort="tag" order="asc">
        <div class="${it.value.class}${it.value.range}">
            <a href="${it.value.controller}/${it.value.action}/${it.key}">${it.key}</a>
        </div>
    </atac:bodyTagCloud>
</div>

BodyTagCloud sort by ocurrences in order descendant

<div class="cloud">
    <atac:bodyTagCloud values="[Java:1000,C:500,Grails:2000]" sort="ocurrence" order="desc">
        <div class="${it.value.class}${it.value.range}">
            <a href="${it.value.controller}/${it.value.action}/${it.key}">${it.key}</a>
        </div>
    </atac:bodyTagCloud>
</div>

BodyTagCloud with linear calculation

<div class="cloud">
    <atac:bodyTagCloud values="[Java:1000,C:500,Grails:2000]" calc="linear">
        <div class="${it.value.class}${it.value.range}">
            <a href="${it.value.controller}/${it.value.action}/${it.key}">${it.key}</a>
        </div>
    </atac:bodyTagCloud>
</div>

BodyTagCloud in list form

<div class="cloud">
    <atac:bodyTagCloud values="[Java:1000,C:500,Grails:2000]">
        <ul>
            <li>
                <a href="${it.value.controller}/${it.value.action}/${it.key}">${it.key}
                </a>(${it.value.ocurrences})
            </li>
        </ul>
    </atac:bodyTagCloud>
</div>

Author

OSOCO Software Company

Please report any issues to the Grails User mailing list.

History

  • July 28, 2010
    • Released initial version 0.1.
  • September 9, 2010
    • Released version 0.2.
    • Fixed tag links bug, now generates a correct link with the controller and action attributes.
    • Added a new attribute to generate a tag cloud with a maximun number of tags.
    • Added a new attribute to disable the generation of the links.