Commits

Anonymous committed 094a47c

Importing the source for the Subversion Light RA-based Web-viewer

  • Participants

Comments (0)

Files changed (7)

+Revision history for Perl extension SVN::RaWeb::Light.
+
+0.01  Mon Nov  8 19:20:12 2004
+	- original version; created by h2xs 1.23 with options
+		-X -n SVN::RaWeb::Light
+
+Changes
+Makefile.PL
+MANIFEST
+README
+t/SVN-RaWeb-Light.t
+lib/SVN/RaWeb/Light.pm
+META.yml                                 Module meta-data (added by MakeMaker)
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
+name:         SVN-RaWeb-Light
+version:      0.1.1
+version_from: lib/SVN/RaWeb/Light.pm
+installdirs:  site
+requires:
+    CGI:                           0
+    SVN::Ra:                       0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+    NAME              => 'SVN::RaWeb::Light',
+    VERSION_FROM      => 'lib/SVN/RaWeb/Light.pm', # finds $VERSION
+    PREREQ_PM         => 
+        {
+            'SVN::Ra' => 0,
+            'CGI' => 0,
+        }, # e.g., Module::Name => 1.1
+    ABSTRACT_FROM  => 'lib/SVN/RaWeb/Light.pm', # retrieve abstract from module
+    AUTHOR         => 'Shlomi Fish <shlomif@iglu.org.il>',
+);
+
+SVN-RaWeb-Light version 0.01
+============================
+
+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 type the following:
+
+   perl Makefile.PL
+   make
+   make test
+   make install
+
+DEPENDENCIES
+
+This module requires these other modules and libraries:
+
+  blah blah blah
+
+COPYRIGHT AND LICENCE
+
+Put the correct copyright and licence information here.
+
+Copyright (C) 2004 by Shlomi Fish
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.8.5 or,
+at your option, any later version of Perl 5 you may have available.
+
+

lib/SVN/RaWeb/Light.pm

+package SVN::RaWeb::Light;
+
+use strict;
+use warnings;
+
+use vars qw($VERSION);
+
+$VERSION = '0.1.1';
+
+use CGI;
+
+require SVN::Core;
+require SVN::Ra;
+
+# Preloaded methods go here.
+
+sub new
+{
+    my $self = {};
+    my $class = shift;
+    bless $self, $class;
+    $self->initialize(@_);
+    return $self;
+}
+
+sub initialize
+{
+    my $self = shift;
+    
+    my %args = (@_);
+    
+    my $cgi = CGI->new();
+    $self->{'cgi'} = $cgi;
+
+    my $svn_ra =
+        SVN::Ra->new(
+            'url' => $args{'url'},
+        );
+
+    $self->{'svn_ra'} = $svn_ra;
+
+    return $self;
+}
+
+sub run
+{
+    my $self = shift;
+    my $cgi = $self->{'cgi'};
+    my $svn_ra = $self->{'svn_ra'};
+    my $path_info = $cgi->path_info();
+    my $path = $path_info;
+    $path =~ s!^/!!;
+    my $should_be_dir = ($path =~ s{/$}{});
+    if ($path =~ /\/\//)
+    {
+        return $self->multi_slashes();
+    }
+    
+        
+    my $rev_num = $svn_ra->get_latest_revnum();
+
+    my $node_kind = $svn_ra->check_path($path, $rev_num);
+
+    if ($node_kind eq $SVN::Node::dir)
+    {
+        my ($dir_contents, $fetched_rev) = $svn_ra->get_dir($path, $rev_num);
+        print $cgi->header();
+        print "<html><head><title>Revision $rev_num: </title></head>\n";
+        print "<body>\n";
+        print "<h2>Revision $rev_num: </h2>\n";
+        print "<ul>\n";
+        print "<li><a href=\"../\">..</a></li>\n";
+        print map { my $escaped_name = CGI::escapeHTML($_); 
+            if ($dir_contents->{$_}->kind() eq $SVN::Node::dir)
+            {
+                $escaped_name .= "/";
+            }
+            "<li><a href=\"$escaped_name\">$escaped_name</a></li>\n"
+            } sort { $a cmp $b } keys(%$dir_contents);
+        print "</ul>\n";
+        print "</body></html>\n";
+    }
+    elsif ($node_kind eq $SVN::Node::file)
+    {
+        print $cgi->header();
+        print "<h1>A File!</h1>";
+    }
+    else
+    {
+        print $cgi->header();
+        print "<html><head><title>Does not exist!</title></head>";
+        print "<body><h1>Does not exist!</h1></body></html>";
+    }
+}
+
+sub multi_slashes
+{
+    my $self = shift;
+    my $cgi = $self->{'cgi'};
+    print $cgi->header();
+    print "<html><head><title>Wrong URL!</title></head>";
+    print "<body><h1>Wrong URL - Multiple Slashes in the URL." . 
+        "</h1></body></html>";
+}
+
+# Autoload methods go after =cut, and are processed by the autosplit program.
+
+1;
+
+
+__END__
+# Below is stub documentation for your module. You'd better edit it!
+
+=head1 NAME
+
+SVN::RaWeb::Light - Perl extension for blah blah blah
+
+=head1 SYNOPSIS
+
+  use SVN::RaWeb::Light;
+  blah blah blah
+
+=head1 DESCRIPTION
+
+Stub documentation for SVN::RaWeb::Light, created by h2xs. It looks like the
+author of the extension was negligent enough to leave the stub
+unedited.
+
+Blah blah blah.
+
+=head2 EXPORT
+
+None by default.
+
+
+
+=head1 SEE ALSO
+
+Mention other useful documentation such as the documentation of
+related modules or operating system documentation (such as man pages
+in UNIX), or any relevant external documentation such as RFCs or
+standards.
+
+If you have a mailing list set up for your module, mention it here.
+
+If you have a web site set up for your module, mention it here.
+
+=head1 AUTHOR
+
+Shlomi Fish, E<lt>shlomi@mandrakesoft.comE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2004 by Shlomi Fish
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.8.5 or,
+at your option, any later version of Perl 5 you may have available.
+
+
+=cut

t/SVN-RaWeb-Light.t

+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl SVN-RaWeb-Light.t'
+
+#########################
+
+# change 'tests => 1' to 'tests => last_test_to_print';
+
+use Test::More tests => 1;
+BEGIN { use_ok('SVN::RaWeb::Light') };
+
+#########################
+
+# Insert your test code below, the Test::More module is use()ed here so read
+# its man page ( perldoc Test::More ) for help writing this test script.
+