r41995 - in /branches/upstream/libhtml-latemp-news-perl: ./ current/ current/lib/ current/lib/HTML/ current/lib/HTML/Latemp/ current/t/
ryan52-guest at users.alioth.debian.org
ryan52-guest at users.alioth.debian.org
Sun Aug 16 20:56:18 UTC 2009
Author: ryan52-guest
Date: Sun Aug 16 20:56:13 2009
New Revision: 41995
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=41995
Log:
[svn-inject] Installing original source of libhtml-latemp-news-perl
Added:
branches/upstream/libhtml-latemp-news-perl/
branches/upstream/libhtml-latemp-news-perl/current/
branches/upstream/libhtml-latemp-news-perl/current/Build.PL
branches/upstream/libhtml-latemp-news-perl/current/Changes
branches/upstream/libhtml-latemp-news-perl/current/MANIFEST
branches/upstream/libhtml-latemp-news-perl/current/META.yml
branches/upstream/libhtml-latemp-news-perl/current/Makefile.PL
branches/upstream/libhtml-latemp-news-perl/current/README
branches/upstream/libhtml-latemp-news-perl/current/lib/
branches/upstream/libhtml-latemp-news-perl/current/lib/HTML/
branches/upstream/libhtml-latemp-news-perl/current/lib/HTML/Latemp/
branches/upstream/libhtml-latemp-news-perl/current/lib/HTML/Latemp/News.pm
branches/upstream/libhtml-latemp-news-perl/current/t/
branches/upstream/libhtml-latemp-news-perl/current/t/00-load.t
branches/upstream/libhtml-latemp-news-perl/current/t/pod.t
Added: branches/upstream/libhtml-latemp-news-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-latemp-news-perl/current/Build.PL?rev=41995&op=file
==============================================================================
--- branches/upstream/libhtml-latemp-news-perl/current/Build.PL (added)
+++ branches/upstream/libhtml-latemp-news-perl/current/Build.PL Sun Aug 16 20:56:13 2009
@@ -1,0 +1,19 @@
+use strict;
+use warnings;
+use Module::Build;
+
+my $builder = Module::Build->new(
+ module_name => 'HTML::Latemp::News',
+ license => 'bsd',
+ dist_author => 'Shlomi Fish <shlomif at iglu.org.il>',
+ dist_version_from => 'lib/HTML/Latemp/News.pm',
+ requires => {
+ 'Test::More' => 0,
+ 'Class::Accessor' => 0,
+ 'CGI' => 0,
+ 'XML::RSS' => 0,
+ },
+ add_to_cleanup => [ 'HTML-Latemp-News-*' ],
+);
+
+$builder->create_build_script();
Added: branches/upstream/libhtml-latemp-news-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-latemp-news-perl/current/Changes?rev=41995&op=file
==============================================================================
--- branches/upstream/libhtml-latemp-news-perl/current/Changes (added)
+++ branches/upstream/libhtml-latemp-news-perl/current/Changes Sun Aug 16 20:56:13 2009
@@ -1,0 +1,18 @@
+Revision history for HTML-Latemp-News
+
+0.1.7 2005-12-07
+ - Added a Makefile.PL wrapper to the Build.PL build process (taken
+ verbatim from http://search.cpan.org/dist/accessors/)
+
+0.1.6 2005-05-07
+ - Added the base_url argument to get_news_page_entries()
+
+0.1.5 2005-05-05
+ - Some documentation updates: made the synopsis better.
+
+0.1.4 2005-04-30
+ - Added the get_news_box_contents function.
+
+0.1.3 2005-04-27
+ - First CPAN Release
+
Added: branches/upstream/libhtml-latemp-news-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-latemp-news-perl/current/MANIFEST?rev=41995&op=file
==============================================================================
--- branches/upstream/libhtml-latemp-news-perl/current/MANIFEST (added)
+++ branches/upstream/libhtml-latemp-news-perl/current/MANIFEST Sun Aug 16 20:56:13 2009
@@ -1,0 +1,9 @@
+Build.PL
+Changes
+Makefile.PL
+MANIFEST
+META.yml # Will be created by "make dist"
+README
+lib/HTML/Latemp/News.pm
+t/00-load.t
+t/pod.t
Added: branches/upstream/libhtml-latemp-news-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-latemp-news-perl/current/META.yml?rev=41995&op=file
==============================================================================
--- branches/upstream/libhtml-latemp-news-perl/current/META.yml (added)
+++ branches/upstream/libhtml-latemp-news-perl/current/META.yml Sun Aug 16 20:56:13 2009
@@ -1,0 +1,25 @@
+---
+name: HTML-Latemp-News
+version: 0.1.7
+author:
+ - Shlomi Fish <shlomif at iglu.org.il>
+abstract: |-
+ News Maintenance Module for Latemp (and possibly other
+ web frameworks)
+license: bsd
+resources:
+ license: http://www.opensource.org/licenses/bsd-license.php
+requires:
+ CGI: 0
+ Class::Accessor: 0
+ Test::More: 0
+ XML::RSS: 0
+provides:
+ HTML::Latemp::News:
+ file: lib/HTML/Latemp/News.pm
+ version: 0.1.7
+ HTML::Latemp::News::Base:
+ file: lib/HTML/Latemp/News.pm
+ HTML::Latemp::News::Item:
+ file: lib/HTML/Latemp/News.pm
+generated_by: Module::Build version 0.2703
Added: branches/upstream/libhtml-latemp-news-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-latemp-news-perl/current/Makefile.PL?rev=41995&op=file
==============================================================================
--- branches/upstream/libhtml-latemp-news-perl/current/Makefile.PL (added)
+++ branches/upstream/libhtml-latemp-news-perl/current/Makefile.PL Sun Aug 16 20:56:13 2009
@@ -1,0 +1,28 @@
+
+ unless (eval "use Module::Build::Compat 0.02; 1" ) {
+ print "This module requires Module::Build to install itself.\n";
+
+ require ExtUtils::MakeMaker;
+ my $yn = ExtUtils::MakeMaker::prompt
+ (' Install Module::Build now from CPAN?', 'y');
+
+ unless ($yn =~ /^y/i) {
+ warn " *** Cannot install without Module::Build. Exiting ...\n";
+ exit 1;
+ }
+
+ require Cwd;
+ require File::Spec;
+ require CPAN;
+
+ # Save this 'cause CPAN will chdir all over the place.
+ my $cwd = Cwd::cwd();
+ my $makefile = File::Spec->rel2abs($0);
+
+ CPAN::Shell->install('Module::Build::Compat');
+
+ chdir $cwd or die "Cannot chdir() back to $cwd: $!";
+ exec $^X, $makefile, @ARGV; # Redo now that we have Module::Build
+ }
+ Module::Build::Compat->run_build_pl(args => \@ARGV);
+ Module::Build::Compat->write_makefile();
Added: branches/upstream/libhtml-latemp-news-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-latemp-news-perl/current/README?rev=41995&op=file
==============================================================================
--- branches/upstream/libhtml-latemp-news-perl/current/README (added)
+++ branches/upstream/libhtml-latemp-news-perl/current/README Sun Aug 16 20:56:13 2009
@@ -1,0 +1,32 @@
+HTML-Latemp-News
+
+The README is used to introduce the module and provide instructions on
+how to install the module, any machine dependencies it may have (for
+example C compilers and installed libraries) and any other information
+that should be provided before the module is installed.
+
+A README file is required for CPAN modules since CPAN extracts the README
+file from a module distribution so that people browsing the archive
+can use it get an idea of the modules uses. It is usually a good idea
+to provide version information here so that people can decide whether
+fixes for the module are worth downloading.
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+ perl Build.PL
+ ./Build
+ ./Build test
+ ./Build install
+
+
+COPYRIGHT AND LICENCE
+
+Put the correct copyright and licence information here.
+
+Copyright (C) 2005 Shlomi Fish
+
+This library is free software; you can redistribute it and/or modify
+it under the terms of the MIT X11 license.
+
Added: branches/upstream/libhtml-latemp-news-perl/current/lib/HTML/Latemp/News.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-latemp-news-perl/current/lib/HTML/Latemp/News.pm?rev=41995&op=file
==============================================================================
--- branches/upstream/libhtml-latemp-news-perl/current/lib/HTML/Latemp/News.pm (added)
+++ branches/upstream/libhtml-latemp-news-perl/current/lib/HTML/Latemp/News.pm Sun Aug 16 20:56:13 2009
@@ -1,0 +1,479 @@
+package HTML::Latemp::News;
+
+use warnings;
+use strict;
+
+=head1 NAME
+
+HTML::Latemp::News - News Maintenance Module for Latemp (and possibly other
+web frameworks)
+
+=cut
+
+our $VERSION = '0.1.7';
+
+=head1 SYNOPSIS
+
+ #!/usr/bin/perl
+
+ use strict;
+ use warnings;
+
+ use MyManageNews;
+
+ my @news_items =
+ (
+ .
+ .
+ .
+ {
+ 'title' => "Changes of 18-April-2005",
+ 'id' => "changes-2005-04-18",
+ 'description' => q{Around 18 April, 2005, Jane's Site has seen a
+ lot of changes. Click the link for details on them.},
+ 'date' => "2005-04-18",
+ 'author' => "Jane Smith",
+ 'category' => "Jane's Site",
+ },
+ .
+ .
+ .
+ );
+
+ my $news_manager =
+ HTML::Latemp::News->new(
+ 'news_items' => \@news_items,
+ 'title' => "Better SCM News",
+ 'link' => "http://janes-site.tld/",
+ 'language' => "en-US",
+ 'copyright' => "Copyright by Jane Smith, (c) 2005",
+ 'webmaster' => "Jane Smith <jane at janes-site.tld>",
+ 'managing_editor' => "Jane Smith <jane at janes-site.tld>",
+ 'description' => "News of Jane's Site - a personal site of " .
+ "Jane Smith",
+ );
+
+ $news_manager->generate_rss_feed(
+ 'output_filename' => "dest/rss.xml"
+ );
+
+ 1;
+=cut
+
+package HTML::Latemp::News::Base;
+
+use base 'Class::Accessor';
+use CGI;
+
+sub new
+{
+ my $class = shift;
+ my $self = {};
+ bless $self, $class;
+ $self->initialize(@_);
+ return $self;
+}
+
+package HTML::Latemp::News::Item;
+
+our @ISA=(qw(HTML::Latemp::News::Base));
+
+__PACKAGE__->mk_accessors(qw(index title id description author date
+ category text));
+
+sub initialize
+{
+ my $self = shift;
+
+ my (%args) = (@_);
+
+ foreach my $k (keys(%args))
+ {
+ if (! $self->can($k))
+ {
+ die "Unknown property for HTML::Latemp::News::Item - \"$k\"!";
+ }
+ $self->set($k, $args{$k});
+ }
+}
+
+package HTML::Latemp::News;
+
+our @ISA=(qw(HTML::Latemp::News::Base));
+
+__PACKAGE__->mk_accessors(qw(copyright description docs generator items
+ language link managing_editor rating title ttl webmaster));
+
+use XML::RSS;
+
+sub input_items
+{
+ my $self = shift;
+
+ my $items = shift;
+
+ return
+ [
+ map
+ { $self->input_single_item($_, $items->[$_]) }
+ (0 .. $#$items)
+ ];
+}
+
+sub input_single_item
+{
+ my $self = shift;
+ my ($index, $inputted_item) = (@_);
+
+ return
+ HTML::Latemp::News::Item->new(
+ %$inputted_item,
+ 'index' => $index,
+ );
+}
+
+sub initialize
+{
+ my $self = shift;
+
+ my %args = (@_);
+
+ my $items = $args{'news_items'};
+
+ $self->items(
+ $self->input_items($items)
+ );
+
+ $self->title($args{'title'});
+ $self->link($args{'link'});
+ $self->language($args{'language'});
+ $self->rating($args{'rating'} || '(PICS-1.1 "http://www.classify.org/safesurf/" 1 r (SS~~000 1))');
+ $self->copyright($args{'copyright'} || "");
+ $self->docs($args{'docs'} || "http://blogs.law.harvard.edu/tech/rss");
+ $self->ttl($args{'ttl'} || "360");
+ $self->generator($args{'generator'} || "Perl and XML::RSS");
+ $self->webmaster($args{'webmaster'});
+ $self->managing_editor($args{'managing_editor'} || $self->webmaster());
+ $self->description($args{'description'});
+
+ return 0;
+}
+
+=head1 DESCRIPTION
+
+This is a module that maintains news item for a web-site. It can generate
+an RSS feed, as well as a news page, and an HTML newsbox, all from the same
+data.
+
+=head1 FUNCTION
+
+=head2 HTML::Latemp::News->new(...)
+
+This is the constructor for the news manager. It accepts the following named
+parameters:
+
+=over 8
+
+=item 'news_items'
+
+This is a reference to a list of news_items. See below.
+
+=item 'title'
+
+The title of the RSS feed.
+
+=item 'link'
+
+The link to the homepage of the site.
+
+=item 'language'
+
+The language of the text.
+
+=item 'copyright'
+
+The copyright notice of the text.
+
+=item 'webmaster'
+
+The Webmaster.
+
+=item 'managing_editor'
+
+The managing editor.
+
+=item 'description'
+
+A description of the news feed as will be put in the RSS feed.
+
+=back
+
+=head3 Format of the news_items
+
+The news_items is a reference to an array, of which each element is a hash
+reference. The hash may contain the following keys:
+
+=over 8
+
+=item 'title'
+
+The title of the item.
+
+=item 'id'
+
+The ID of the item. This will also be used to calculate URLs.
+
+=item 'description'
+
+A text description explaining what the item is all about.
+
+=item 'author'
+
+The author of the item.
+
+=item 'date'
+
+A string representing the daet.
+
+=item 'category'
+
+The cateogry of the item.
+
+=back
+
+=cut
+
+sub add_item_to_rss_feed
+{
+ my $self = shift;
+ my %args = (@_);
+
+ my $item = $args{'item'};
+ my $rss_feed = $args{'feed'};
+
+ my $item_url = $self->get_item_url($item);
+
+ $rss_feed->add_item(
+ 'title' => $item->title(),
+ 'link' => $item_url,
+ 'permaLink' => $item_url,
+ 'enclosure' => { 'url' => $item_url, },
+ 'description' => $item->description(),
+ 'author' => $item->author(),
+ 'pubDate' => $item->date(),
+ 'category' => $item->category(),
+ );
+}
+
+sub get_item_url
+{
+ my $self = shift;
+ my $item = shift;
+ return $self->link() . $self->get_item_rel_url($item);
+}
+
+sub get_item_rel_url
+{
+ my $self = shift;
+ my $item = shift;
+ return "news/" . $item->id() . "/";
+}
+
+sub get_items_to_include
+{
+ my $self = shift;
+ my $args = shift;
+
+ my $num_items_to_include = $args->{'num_items'} || 10;
+
+ my $items = $self->items();
+
+ if (@$items < $num_items_to_include)
+ {
+ $num_items_to_include = scalar(@$items);
+ }
+
+ return [ @$items[(-$num_items_to_include) .. (-1)] ];
+}
+
+sub generate_rss_feed
+{
+ my $self = shift;
+
+ my %args = (@_);
+
+ my $rss_feed = XML::RSS->new('version' => "2.0");
+ $rss_feed->channel(
+ 'title' => $self->title(),
+ 'link' => $self->link(),
+ 'language' => $self->language(),
+ 'description' => $self->description(),
+ 'rating' => $self->rating(),
+ 'copyright' => $self->copyright(),
+ 'pubDate' => (scalar(localtime())),
+ 'lastBuildDate' => (scalar(localtime())),
+ 'docs' => $self->docs(),
+ 'ttl' => $self->ttl(),
+ 'generator' => $self->generator(),
+ 'managingEditor' => $self->managing_editor(),
+ 'webMaster' => $self->webmaster(),
+ );
+
+ foreach my $single_item (@{$self->get_items_to_include(\%args)})
+ {
+ $self->add_item_to_rss_feed(
+ 'item' => $single_item,
+ 'feed' => $rss_feed,
+ );
+ }
+
+ my $filename = $args{'output_filename'} || "rss.xml";
+
+ $rss_feed->save($filename);
+}
+
+=head2 $news_manager->generate_rss_feed('output_filename' => "rss.xml")
+
+This generates an RSS feed. It accepts two named arguments.
+C<'output_filename'> is the name of the RSS file to write to. C<'num_items'>
+is the number of items to include, which defaults to 10.
+
+=cut
+
+sub get_navmenu_items
+{
+ my $self = shift;
+ my %args = (@_);
+
+ my @ret;
+
+ foreach my $single_item (reverse(@{$self->get_items_to_include(\%args)}))
+ {
+ push @ret,
+ {
+ 'text' => $single_item->title(),
+ 'url' => $self->get_item_rel_url($single_item),
+ };
+ }
+ return \@ret;
+}
+
+=head2 $news_manager->get_navmenu_items('num_items' => 5)
+
+This generates navigation menu items for input to the navigation menu of
+L<HTML::Widgets::NavMenu>. It accepts a named argument C<'num_items'> which
+defaults to 10.
+
+=cut
+
+sub format_news_page_item
+{
+ my $self = shift;
+ my (%args) = (@_);
+
+ my $item = $args{'item'};
+ my $base_url = $args{'base_url'};
+
+ return "<h3><a href=\"$base_url" . $item->id() . "/\">" .
+ CGI::escapeHTML($item->title()) . "</a></h3>\n" .
+ "<p>\n" . $item->description() . "\n</p>\n";
+}
+
+sub get_news_page_entries
+{
+ my $self = shift;
+ my %args = (@_);
+
+ my $html = "";
+
+ my $base_url = exists($args{'base_url'}) ? $args{'base_url'} : "";
+
+ foreach my $single_item (reverse(@{$self->get_items_to_include(\%args)}))
+ {
+ $html .=
+ $self->format_news_page_item(
+ 'item' => $single_item,
+ 'base_url' => $base_url,
+ );
+ }
+ return $html;
+}
+
+=head2 $news_manager->get_news_page_entries('num_items' => 5, 'base_url' => "news/")
+
+This generates HTML for the news page. 'base_url' points to a URL to be
+appended to each item's ID.
+
+=cut
+
+sub get_news_box_contents
+{
+ my $self = shift;
+ my (%args) = (@_);
+
+ my $html = "";
+ foreach my $item (reverse(@{$self->get_items_to_include(\%args)}))
+ {
+ $html .= "<li><a href=\"" .
+ $self->get_item_rel_url($item) . "\">" .
+ CGI::escapeHTML($item->title()) . "</a></li>\n";
+ }
+ return $html;
+}
+
+
+sub get_news_box
+{
+ my $self = shift;
+
+ my $html = "";
+
+ $html .= qq{<div class="news">\n};
+ $html .= qq{<h3>News</h3>\n};
+ $html .= qq{<ul>\n};
+ $html .=
+ $self->get_news_box_contents(
+ @_
+ );
+ $html .= qq{<li><a href="./news/">More…</a></li>};
+ $html .= qq{</ul>\n};
+ $html .= qq{</div>\n};
+ return $html;
+}
+
+=head2 $news_manager->get_news_box('num_items' => 5)
+
+This generates an HTML news box with the recent headlines.
+
+=cut
+
+1;
+
+__END__
+
+=head1 AUTHOR
+
+Shlomi Fish, C<< <shlomif at iglu.org.il> >>
+
+=head1 BUGS
+
+Please report any bugs or feature requests to
+C<bug-html-latemp-news at rt.cpan.org>, or through the web interface at
+L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTML-Latemp-News>.
+I will be notified, and then you'll automatically be notified of progress on
+your bug as I make changes.
+
+=head1 SEE ALSO
+
+L<XML::RSS>, L<HTML::Widgets::NavMenu>.
+
+=head1 ACKNOWLEDGEMENTS
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2005 Shlomi Fish, All Rights Reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the MIT X11 license.
+
+=cut
Added: branches/upstream/libhtml-latemp-news-perl/current/t/00-load.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-latemp-news-perl/current/t/00-load.t?rev=41995&op=file
==============================================================================
--- branches/upstream/libhtml-latemp-news-perl/current/t/00-load.t (added)
+++ branches/upstream/libhtml-latemp-news-perl/current/t/00-load.t Sun Aug 16 20:56:13 2009
@@ -1,0 +1,7 @@
+use Test::More tests => 1;
+
+BEGIN {
+use_ok( 'HTML::Latemp::News' );
+}
+
+diag( "Testing HTML::Latemp::News $HTML::Latemp::News::VERSION, Perl 5.008006, /usr/bin/perl5.8.6" );
Added: branches/upstream/libhtml-latemp-news-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-latemp-news-perl/current/t/pod.t?rev=41995&op=file
==============================================================================
--- branches/upstream/libhtml-latemp-news-perl/current/t/pod.t (added)
+++ branches/upstream/libhtml-latemp-news-perl/current/t/pod.t Sun Aug 16 20:56:13 2009
@@ -1,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();
More information about the Pkg-perl-cvs-commits
mailing list