r69885 - in /branches/upstream/libhtml-tagcloud-perl/current: CHANGES META.yml README lib/HTML/TagCloud.pm t/simple.t
chrisb at users.alioth.debian.org
chrisb at users.alioth.debian.org
Sun Feb 27 15:47:07 UTC 2011
Author: chrisb
Date: Sun Feb 27 15:46:53 2011
New Revision: 69885
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=69885
Log:
[svn-upgrade] new version libhtml-tagcloud-perl (0.36)
Modified:
branches/upstream/libhtml-tagcloud-perl/current/CHANGES
branches/upstream/libhtml-tagcloud-perl/current/META.yml
branches/upstream/libhtml-tagcloud-perl/current/README
branches/upstream/libhtml-tagcloud-perl/current/lib/HTML/TagCloud.pm
branches/upstream/libhtml-tagcloud-perl/current/t/simple.t
Modified: branches/upstream/libhtml-tagcloud-perl/current/CHANGES
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-tagcloud-perl/current/CHANGES?rev=69885&op=diff
==============================================================================
--- branches/upstream/libhtml-tagcloud-perl/current/CHANGES (original)
+++ branches/upstream/libhtml-tagcloud-perl/current/CHANGES Sun Feb 27 15:46:53 2011
@@ -1,4 +1,10 @@
CHANGES file for HTML::TagCloud:
+
+0.36 Wed Feb 16 15:10:49 MST 2011
+ - use different styles to distinguish adjacent tags.
+
+0.35 Wed Feb 16 10:27:55 MST 2011
+ - make tag URLs optional.
0.34 Tue Nov 7 21:00:33 GMT 2006
- Internet Explorer fix, which addresses issues with Japanese text
Modified: branches/upstream/libhtml-tagcloud-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-tagcloud-perl/current/META.yml?rev=69885&op=diff
==============================================================================
--- branches/upstream/libhtml-tagcloud-perl/current/META.yml (original)
+++ branches/upstream/libhtml-tagcloud-perl/current/META.yml Sun Feb 27 15:46:53 2011
@@ -1,8 +1,19 @@
--- #YAML:1.0
-name: HTML-TagCloud
-version: 0.34
-author:
- - Leon Brocard, C<< <acme at astray.com> >>.
-abstract: Generate An HTML Tag Cloud
-license: perl
-generated_by: Module::Build version 0.2612, without YAML.pm
+name: HTML-TagCloud
+version: 0.36
+abstract: ~
+author: []
+license: unknown
+distribution_type: module
+configure_requires:
+ ExtUtils::MakeMaker: 0
+requires:
+ Test::More: 0
+no_index:
+ directory:
+ - t
+ - inc
+generated_by: ExtUtils::MakeMaker version 6.48
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
Modified: branches/upstream/libhtml-tagcloud-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-tagcloud-perl/current/README?rev=69885&op=diff
==============================================================================
--- branches/upstream/libhtml-tagcloud-perl/current/README (original)
+++ branches/upstream/libhtml-tagcloud-perl/current/README Sun Feb 27 15:46:53 2011
@@ -2,11 +2,18 @@
HTML::TagCloud - Generate An HTML Tag Cloud
SYNOPSIS
+ # A cloud with tags that link to other web pages.
my $cloud = HTML::TagCloud->new;
$cloud->add($tag1, $url1, $count1);
$cloud->add($tag2, $url2, $count2);
$cloud->add($tag3, $url3, $count3);
my $html = $cloud->html_and_css(50);
+
+ # A cloud with tags that do not link to other web pages.
+ my $cloud = HTML::TagCloud->new;
+ $cloud->add_static($tag1, $count1);
+ $cloud->add_static($tag2, $count2);
+ $cloud->add_static($tag3, $count3);
DESCRIPTION
The HTML::TagCloud module enables you to generate "tag clouds" in HTML.
@@ -25,11 +32,18 @@
CONSTRUCTOR
new
- The constructor takes one optional argument:
+ The constructor takes two optional arguments:
my $cloud = HTML::TagCloud->new(levels=>10);
- if not provided, leves defaults to 24
+ if not provided, levels defaults to 24
+
+ my $cloud = HTML::TagCloud->new(distinguish_adjacent_tags=>1);
+
+ If distinguish_adjacent_tags is true HTML::TagCloud will use different
+ CSS classes for adjacent tags in order to be able to make it easier to
+ distinguish adjacent multi-word tags. If not specified, this parameter
+ defaults to a false value.
METHODS
add
@@ -40,9 +54,16 @@
$cloud->add($tag2, $url2, $count2);
$cloud->add($tag3, $url3, $count3);
+ add_static
+ This module adds a tag that does not link to another web page into the
+ cloud. You pass in the tag name and its count:
+
+ $cloud->add_static($tag1, $count1);
+ $cloud->add_static($tag2, $count2);
+
tags($limit)
Returns a list of hashrefs representing each tag in the cloud, sorted by
- alphabet. each tag has the following keys; name, count, url and level.
+ alphabet. Each tag has the following keys: name, count, url and level.
css
This returns the CSS that will format the HTML returned by the html()
@@ -69,7 +90,7 @@
Leon Brocard, "<acme at astray.com>".
COPYRIGHT
- Copyright (C) 2005, Leon Brocard
+ Copyright (C) 2005-6, Leon Brocard
This module is free software; you can redistribute it or modify it under
the same terms as Perl itself.
Modified: branches/upstream/libhtml-tagcloud-perl/current/lib/HTML/TagCloud.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-tagcloud-perl/current/lib/HTML/TagCloud.pm?rev=69885&op=diff
==============================================================================
--- branches/upstream/libhtml-tagcloud-perl/current/lib/HTML/TagCloud.pm (original)
+++ branches/upstream/libhtml-tagcloud-perl/current/lib/HTML/TagCloud.pm Sun Feb 27 15:46:53 2011
@@ -1,14 +1,15 @@
package HTML::TagCloud;
use strict;
use warnings;
-our $VERSION = '0.34';
+our $VERSION = '0.36';
sub new {
my $class = shift;
my $self = {
- counts => {},
- urls => {},
- levels => 24,
+ counts => {},
+ urls => {},
+ levels => 24,
+ distinguish_adjacent_tags => 0,
@_
};
bless $self, $class;
@@ -19,6 +20,11 @@
my($self, $tag, $url, $count) = @_;
$self->{counts}->{$tag} = $count;
$self->{urls}->{$tag} = $url;
+}
+
+sub add_static {
+ my ($self, $tag, $count) = @_;
+ $self->{counts}->{$tag} = $count;
}
sub css {
@@ -30,11 +36,23 @@
}
);
foreach my $level (0 .. $self->{levels}) {
+ if ( $self->{distinguish_adjacent_tags} ) {
+ $css .= $self->_css_for_tag($level, 'even');
+ $css .= $self->_css_for_tag($level, 'odd');
+ } else {
+ $css .= $self->_css_for_tag($level, q{});
+ }
+ }
+ return $css;
+}
+
+sub _css_for_tag {
+ my ($self, $level, $subclass) = @_;
my $font = 12 + $level;
- $css .= "span.tagcloud$level { font-size: ${font}px;}\n";
- $css .= "span.tagcloud$level a {text-decoration: none;}\n";
- }
- return $css;
+ return <<"END_OF_TAG";
+span.tagcloud${level}${subclass} {font-size: ${font}px;}
+span.tagcloud${level}${subclass} a {text-decoration: none;}
+END_OF_TAG
}
sub tags {
@@ -82,8 +100,8 @@
return "";
} elsif ($ntags == 1) {
my $tag = $tags[0];
- return qq{<div id="htmltagcloud"><span class="tagcloud1"><a href="}.
- $tag->{url}.qq{">}.$tag->{name}.qq{</a></span></div>\n};
+ my $span = $self->_format_span(@{$tag}{qw(name url)}, 1, 1);
+ return qq{<div id="htmltagcloud">$span</div>\n};
}
# warn "min $min - max $max ($factor)";
@@ -91,9 +109,11 @@
# warn(($max - $min) * $factor);
my $html = "";
+ my $is_even = 1;
foreach my $tag (@tags) {
- $html .= qq{<span class="tagcloud}.$tag->{level}.qq{"><a href="}.$tag->{url}.
- qq{">}.$tag->{name}.qq{</a></span>\n};
+ my $span = $self->_format_span(@{$tag}{qw(name url level)}, $is_even);
+ $html .= "$span\n";
+ $is_even = !$is_even;
}
$html = qq{<div id="htmltagcloud">
$html</div>};
@@ -107,6 +127,24 @@
return $html;
}
+sub _format_span {
+ my ($self, $name, $url, $level, $is_even) = @_;
+ my $subclass = q{};
+ if ( $self->{distinguish_adjacent_tags} ) {
+ $subclass = $is_even ? 'even' : 'odd';
+ }
+ my $span_class = qq{tagcloud$level$subclass};
+ my $span = qq{<span class="$span_class">};
+ if (defined $url) {
+ $span .= qq{<a href="$url">};
+ }
+ $span .= $name;
+ if (defined $url) {
+ $span .= qq{</a>};
+ }
+ $span .= qq{</span>};
+}
+
1;
__END__
@@ -117,11 +155,18 @@
=head1 SYNOPSIS
+ # A cloud with tags that link to other web pages.
my $cloud = HTML::TagCloud->new;
$cloud->add($tag1, $url1, $count1);
$cloud->add($tag2, $url2, $count2);
$cloud->add($tag3, $url3, $count3);
my $html = $cloud->html_and_css(50);
+
+ # A cloud with tags that do not link to other web pages.
+ my $cloud = HTML::TagCloud->new;
+ $cloud->add_static($tag1, $count1);
+ $cloud->add_static($tag2, $count2);
+ $cloud->add_static($tag3, $count3);
=head1 DESCRIPTION
@@ -143,11 +188,18 @@
=head2 new
-The constructor takes one optional argument:
+The constructor takes two optional arguments:
my $cloud = HTML::TagCloud->new(levels=>10);
if not provided, levels defaults to 24
+
+ my $cloud = HTML::TagCloud->new(distinguish_adjacent_tags=>1);
+
+If distinguish_adjacent_tags is true HTML::TagCloud will use different CSS
+classes for adjacent tags in order to be able to make it easier to
+distinguish adjacent multi-word tags. If not specified, this parameter
+defaults to a false value.
=head1 METHODS
@@ -160,6 +212,13 @@
$cloud->add($tag2, $url2, $count2);
$cloud->add($tag3, $url3, $count3);
+=head2 add_static
+
+This module adds a tag that does not link to another web page into the
+cloud. You pass in the tag name and its count:
+
+ $cloud->add_static($tag1, $count1);
+ $cloud->add_static($tag2, $count2);
=head2 tags($limit)
Modified: branches/upstream/libhtml-tagcloud-perl/current/t/simple.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-tagcloud-perl/current/t/simple.t?rev=69885&op=diff
==============================================================================
--- branches/upstream/libhtml-tagcloud-perl/current/t/simple.t (original)
+++ branches/upstream/libhtml-tagcloud-perl/current/t/simple.t Sun Feb 27 15:46:53 2011
@@ -1,6 +1,6 @@
#!perl
use strict;
-use Test::More tests => 12;
+use Test::More tests => 20;
use_ok('HTML::TagCloud');
my $cloud = HTML::TagCloud->new;
@@ -58,6 +58,83 @@
<span class="tagcloud3"><a href="a.html">a</a></span>
<span class="tagcloud3"><a href="b.html">b</a></span>
<span class="tagcloud3"><a href="c.html">c</a></span>
+</div>});
+
+$cloud = HTML::TagCloud->new( distinguish_adjacent_tags => 1 );
+$cloud->add("a", "a.html", 10);
+$cloud->add("b", "b.html", 10);
+$cloud->add("c", "c.html", 10);
+
+$css = $cloud->css;
+is(lines($css), 105);
+
+$html = $cloud->html();
+is($html, q{<div id="htmltagcloud">
+<span class="tagcloud3even"><a href="a.html">a</a></span>
+<span class="tagcloud3odd"><a href="b.html">b</a></span>
+<span class="tagcloud3even"><a href="c.html">c</a></span>
+</div>});
+
+$cloud = HTML::TagCloud->new;
+$cloud->add_static("a", 10);
+
+$html = $cloud->html();
+is ($html, q{<div id="htmltagcloud"><span class="tagcloud1">a</span></div>
+});
+
+$cloud = HTML::TagCloud->new( distinguish_adjacent_tags => 1 );
+$cloud->add_static("a", 10);
+
+$html = $cloud->html();
+is ($html, q{<div id="htmltagcloud"><span class="tagcloud1even">a</span></div>
+});
+
+$cloud = HTML::TagCloud->new;
+$cloud->add_static("a", 10);
+$cloud->add_static("b", 10);
+$cloud->add_static("c", 10);
+
+$html = $cloud->html();
+is($html, q{<div id="htmltagcloud">
+<span class="tagcloud3">a</span>
+<span class="tagcloud3">b</span>
+<span class="tagcloud3">c</span>
+</div>});
+
+$cloud = HTML::TagCloud->new( distinguish_adjacent_tags => 1 );
+$cloud->add_static("a", 10);
+$cloud->add_static("b", 10);
+$cloud->add_static("c", 10);
+
+$html = $cloud->html();
+is($html, q{<div id="htmltagcloud">
+<span class="tagcloud3even">a</span>
+<span class="tagcloud3odd">b</span>
+<span class="tagcloud3even">c</span>
+</div>});
+
+$cloud = HTML::TagCloud->new;
+$cloud->add("a", "a.html", 10);
+$cloud->add_static("b", 10);
+$cloud->add("c", "c.html", 10);
+
+$html = $cloud->html();
+is($html, q{<div id="htmltagcloud">
+<span class="tagcloud3"><a href="a.html">a</a></span>
+<span class="tagcloud3">b</span>
+<span class="tagcloud3"><a href="c.html">c</a></span>
+</div>});
+
+$cloud = HTML::TagCloud->new( distinguish_adjacent_tags => 1 );
+$cloud->add("a", "a.html", 10);
+$cloud->add_static("b", 10);
+$cloud->add("c", "c.html", 10);
+
+$html = $cloud->html();
+is($html, q{<div id="htmltagcloud">
+<span class="tagcloud3even"><a href="a.html">a</a></span>
+<span class="tagcloud3odd">b</span>
+<span class="tagcloud3even"><a href="c.html">c</a></span>
</div>});
sub tags {
More information about the Pkg-perl-cvs-commits
mailing list