r12833 - in /branches/upstream/libhtml-tagcloud-perl/current: CHANGES META.yml README lib/HTML/TagCloud.pm
emhn-guest at users.alioth.debian.org
emhn-guest at users.alioth.debian.org
Wed Jan 16 13:53:48 UTC 2008
Author: emhn-guest
Date: Wed Jan 16 13:53:47 2008
New Revision: 12833
URL: http://svn.debian.org/wsvn/?sc=1&rev=12833
Log:
[svn-upgrade] Integrating new upstream version, libhtml-tagcloud-perl (0.34)
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
Modified: branches/upstream/libhtml-tagcloud-perl/current/CHANGES
URL: http://svn.debian.org/wsvn/branches/upstream/libhtml-tagcloud-perl/current/CHANGES?rev=12833&op=diff
==============================================================================
--- branches/upstream/libhtml-tagcloud-perl/current/CHANGES (original)
+++ branches/upstream/libhtml-tagcloud-perl/current/CHANGES Wed Jan 16 13:53:47 2008
@@ -1,4 +1,14 @@
CHANGES file for HTML::TagCloud:
+
+0.34 Tue Nov 7 21:00:33 GMT 2006
+ - Internet Explorer fix, which addresses issues with Japanese text
+ (thanks to Tatsuhiko Miyagawa)
+
+0.33 Mon Mar 13 20:26:36 GMT 2006
+ - add a 'tags' method that extracts most of the logic from the html
+ method. It also adds support for setting levels as a parameter to the
+ constructor. It defaults to the before-hardcoded 24.
+ (thanks to Marcus Ramberg)
0.32 Mon Aug 22 16:32:29 BST 2005
- make html_and_css have type="text/css" in the script tag
Modified: branches/upstream/libhtml-tagcloud-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libhtml-tagcloud-perl/current/META.yml?rev=12833&op=diff
==============================================================================
--- branches/upstream/libhtml-tagcloud-perl/current/META.yml (original)
+++ branches/upstream/libhtml-tagcloud-perl/current/META.yml Wed Jan 16 13:53:47 2008
@@ -1,14 +1,8 @@
----
+--- #YAML:1.0
name: HTML-TagCloud
-version: 0.32
+version: 0.34
author:
- - 'Leon Brocard, C<< <acme at astray.com> >>.'
+ - Leon Brocard, C<< <acme at astray.com> >>.
abstract: Generate An HTML Tag Cloud
license: perl
-requires:
- Test::More: 0
-provides:
- HTML::TagCloud:
- file: lib/HTML/TagCloud.pm
- version: 0.32
-generated_by: Module::Build version 0.2611
+generated_by: Module::Build version 0.2612, without YAML.pm
Modified: branches/upstream/libhtml-tagcloud-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libhtml-tagcloud-perl/current/README?rev=12833&op=diff
==============================================================================
--- branches/upstream/libhtml-tagcloud-perl/current/README (original)
+++ branches/upstream/libhtml-tagcloud-perl/current/README Wed Jan 16 13:53:47 2008
@@ -25,9 +25,11 @@
CONSTRUCTOR
new
- The constructor takes no arguments:
+ The constructor takes one optional argument:
- my $cloud = HTML::TagCloud->new;
+ my $cloud = HTML::TagCloud->new(levels=>10);
+
+ if not provided, leves defaults to 24
METHODS
add
@@ -37,6 +39,10 @@
$cloud->add($tag1, $url1, $count1);
$cloud->add($tag2, $url2, $count2);
$cloud->add($tag3, $url3, $count3);
+
+ 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.
css
This returns the CSS that will format the HTML returned by the html()
Modified: branches/upstream/libhtml-tagcloud-perl/current/lib/HTML/TagCloud.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libhtml-tagcloud-perl/current/lib/HTML/TagCloud.pm?rev=12833&op=diff
==============================================================================
--- branches/upstream/libhtml-tagcloud-perl/current/lib/HTML/TagCloud.pm (original)
+++ branches/upstream/libhtml-tagcloud-perl/current/lib/HTML/TagCloud.pm Wed Jan 16 13:53:47 2008
@@ -1,12 +1,15 @@
package HTML::TagCloud;
use strict;
-our $VERSION = '0.32';
+use warnings;
+our $VERSION = '0.34';
sub new {
my $class = shift;
my $self = {
counts => {},
urls => {},
+ levels => 24,
+ @_
};
bless $self, $class;
return $self;
@@ -19,14 +22,14 @@
}
sub css {
- my $self = @_;
+ my ($self) = @_;
my $css = q(
#htmltagcloud {
text-align: center;
- line-height: 16px;
+ line-height: 1;
}
);
- foreach my $level (0..24) {
+ foreach my $level (0 .. $self->{levels}) {
my $font = 12 + $level;
$css .= "span.tagcloud$level { font-size: ${font}px;}\n";
$css .= "span.tagcloud$level a {text-decoration: none;}\n";
@@ -34,22 +37,14 @@
return $css;
}
-sub html {
+sub tags {
my($self, $limit) = @_;
my $counts = $self->{counts};
my $urls = $self->{urls};
my @tags = sort { $counts->{$b} <=> $counts->{$a} } keys %$counts;
-
@tags = splice(@tags, 0, $limit) if defined $limit;
- my $ntags = scalar(@tags);
-
- if ($ntags == 0) {
- return "";
- } elsif ($ntags == 1) {
- my $tag = $tags[0];
- my $url = $urls->{$tag};
- return qq{<div id="htmltagcloud"><span class="tagcloud1"><a href="$url">$tag</a></span></div>\n};
- }
+
+ return unless scalar @tags;
my $min = log($counts->{$tags[-1]});
my $max = log($counts->{$tags[0]});
@@ -57,14 +52,38 @@
# special case all tags having the same count
if ($max - $min == 0) {
- $min = $min - 24;
+ $min = $min - $self->{levels};
$factor = 1;
} else {
- $factor = 24 / ($max - $min);
+ $factor = $self->{levels} / ($max - $min);
}
- if ($ntags < 24) {
- $factor *= ($ntags/24);
+ if (scalar @tags < $self->{levels} ) {
+ $factor *= (scalar @tags/$self->{levels});
+ }
+ my @tag_items;
+ foreach my $tag (sort @tags) {
+ my $tag_item;
+ $tag_item->{name} = $tag;
+ $tag_item->{count} = $counts->{$tag};
+ $tag_item->{url} = $urls->{$tag};
+ $tag_item->{level} = int((log($tag_item->{count}) - $min) * $factor);
+ push @tag_items,$tag_item;
+ }
+ return @tag_items;
+}
+
+sub html {
+ my($self, $limit) = @_;
+ my @tags=$self->tags($limit);
+
+ my $ntags = scalar(@tags);
+ if ($ntags == 0) {
+ 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};
}
# warn "min $min - max $max ($factor)";
@@ -72,11 +91,9 @@
# warn(($max - $min) * $factor);
my $html = "";
- foreach my $tag (sort @tags) {
- my $count = $counts->{$tag};
- my $url = $urls->{$tag};
- my $level = int((log($count) - $min) * $factor);
- $html .= qq{<span class="tagcloud$level"><a href="$url">$tag</a></span>\n};
+ foreach my $tag (@tags) {
+ $html .= qq{<span class="tagcloud}.$tag->{level}.qq{"><a href="}.$tag->{url}.
+ qq{">}.$tag->{name}.qq{</a></span>\n};
}
$html = qq{<div id="htmltagcloud">
$html</div>};
@@ -126,9 +143,11 @@
=head2 new
-The constructor takes no arguments:
-
- my $cloud = HTML::TagCloud->new;
+The constructor takes one optional argument:
+
+ my $cloud = HTML::TagCloud->new(levels=>10);
+
+if not provided, levels defaults to 24
=head1 METHODS
@@ -140,6 +159,12 @@
$cloud->add($tag1, $url1, $count1);
$cloud->add($tag2, $url2, $count2);
$cloud->add($tag3, $url3, $count3);
+
+
+=head2 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.
=head2 css
@@ -171,7 +196,7 @@
=head1 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.
More information about the Pkg-perl-cvs-commits
mailing list