]> xenbits.xensource.com Git - people/aperard/emesinae.git/commitdiff
first cut cgi bug list.
authorIan Campbell <ijc@hellion.org.uk>
Tue, 30 Oct 2012 16:21:46 +0000 (17:21 +0100)
committerIan Campbell <ijc@hellion.org.uk>
Wed, 31 Oct 2012 09:20:30 +0000 (10:20 +0100)
Bugs/Bug.pm
Bugs/Common.pm
CGI/bugs.pl [new file with mode: 0755]
CGI/common.pl [new file with mode: 0644]
config.pl

index f5f395c7607cf201c21289d80302e558dd875629..659444da332737e5970afd8e6107c82c447bf610 100644 (file)
@@ -6,11 +6,11 @@ use strict;
 sub new {
     my $class = shift;
     my $dbh = shift;
-    my $bugid = shift;
+    my %args = @_;
 
     my $self = { dbh => $dbh,
-                id => $bugid,
-                #msgid => ... ,
+                id => $args{ID},
+                title => $args{Title}
     };
 
     bless $self, $class;
@@ -22,7 +22,6 @@ sub create {
     my $dbh = shift;
     my $msgid = shift;
     my $subj = shift;
-    #my %args = @_;
 
     my $sth = $dbh->prepare(q{
         INSERT INTO bugs (title) VALUES (?)
@@ -32,13 +31,7 @@ sub create {
 
     my $bugid = $dbh->sqlite_last_insert_rowid();
 
-    my $self = { dbh => $dbh,
-                id => $bugid,
-                msgid => $msgid,
-    };
-
-    bless $self, $class;
-    return $self;
+    return $class->new($dbh, ID => $bugid, Title=>$subj);
 }
 
 sub messages {
@@ -58,5 +51,20 @@ sub messages {
     }
 }
 
+sub listall ($$) {
+    my $class = shift;
+    my $dbh = shift;
+
+    my $sth = $dbh->prepare(q{
+       SELECT id,title FROM bugs ORDER BY id
+    });
+    $sth->execute;
+    my @r;
+    while (my @row = $sth->fetchrow_array) {
+       push @r, $class->new($dbh, ID => $row[0], Title => $row[1]);
+    }
+    return @r;
+}
+
 1;
 
index 4b30bfb3eaeedb79cec2565d48042e0c441af06d..68a978fa0d49a98925786729121a5c8869da2c94 100644 (file)
@@ -11,6 +11,7 @@ BEGIN {
     @EXPORT      = qw(
                       %c readconfig
                       opendb
+                      listbugs
                     );
     %EXPORT_TAGS = ( );
 
diff --git a/CGI/bugs.pl b/CGI/bugs.pl
new file mode 100755 (executable)
index 0000000..5db1b25
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/perl -I/home/ijc/devel/bugs
+
+use strict;
+use warnings;
+
+use CGI qw/:standard/;
+use CGI::Carp qw(fatalsToBrowser);
+
+use Bugs::Bug;
+use Bugs::Common;
+
+require 'common.pl';
+
+readconfig;
+my $dbh = opendb;
+
+print header,
+    start_html($c{TrackerName}.": All Bugs");
+
+my @bugs = Bugs::Bug->listall($dbh);
+
+print table(Tr([
+               th(['Bug #', 'Title']),
+               map { td([$_->{id}, buglink($_)]) } @bugs,
+              ],
+           )
+    );
+print end_html;
+
+
diff --git a/CGI/common.pl b/CGI/common.pl
new file mode 100644 (file)
index 0000000..8feebce
--- /dev/null
@@ -0,0 +1,7 @@
+sub buglink {
+    my $b = shift;
+    my $url = "/cgi-bin/bug.pl?id=" . $b->{id};
+    return a({href=>$url}, $b->{title});
+}
+
+1;
index 6e89a27cf0b328f110d8a0a5df5c46002cbb6755..959563f7515f59b29a04841004683c230c1ef211 100644 (file)
--- a/config.pl
+++ b/config.pl
@@ -1,2 +1,4 @@
 $c{DB} = "/tmp/bugs.sqlite";
 $c{RawMailBase} = "/tmp/bugs.raw";
+
+$c{TrackerName} = "Bug Tracker";