]> xenbits.xensource.com Git - people/aperard/emesinae.git/commitdiff
CGI: Move common.pl to a proper module Emesinae::CGI
authorIan Campbell <ian.campbell@citrix.com>
Mon, 1 Jul 2013 12:17:24 +0000 (13:17 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 1 Jul 2013 12:17:24 +0000 (13:17 +0100)
CGI/bug.pl
CGI/bugs.pl
CGI/common.pl [deleted file]
CGI/message.pl
Emesinae/CGI.pm [new file with mode: 0644]
Makefile

index af31aba00341ac2ae80819c7216eaafc3ef70261..5720456d987d0da0417da9f34c8b28c15357547d 100755 (executable)
@@ -20,7 +20,7 @@ use Encode qw/encode decode/;
 use Emesinae::Bug;
 use Emesinae::Common;
 
-require 'common.cgi';
+use Emesinae::CGI;
 
 readconfig;
 my $dbh = opendb;
index aa642465c07e3beb67d1fb048523ea78191982cf..03994e4a8e7b92862df1dbd7086dd821edba9639 100755 (executable)
@@ -11,7 +11,7 @@ $CGI::DISABLE_UPLOADS = 1;             # no uploads
 use Emesinae::Bug;
 use Emesinae::Common;
 
-require 'common.cgi';
+use Emesinae::CGI;
 
 readconfig;
 
diff --git a/CGI/common.pl b/CGI/common.pl
deleted file mode 100644 (file)
index 94b92fd..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-sub cgipath {
-    my $p = shift;
-    return $c{CGIPath} . $p;
-}
-
-sub buglink {
-    my $b = shift;
-    my $t = shift or $b->{title};
-    my $p = shift or "";            # Optional subpath
-
-    my $url = cgipath( "bug/" . $b->{id} . $p );
-    return a( { href => $url }, $t );
-}
-
-sub msglink {
-    my $m = shift;
-    my $t = shift;
-    my $p = shift or "";            # Optional subpath
-
-    my $url = cgipath( "message/" . $m->{id} . $p );
-    return a( { href => $url }, $t );
-}
-
-sub htmlsanit {
-    my %saniarray = ( '<', 'lt', '>', 'gt', '&', 'amp', '"', 'quot' );
-    my $in = shift || "";
-    $in =~ s/([<>&"])/\&$saniarray{$1};/g;
-    return $in;
-}
-
-1;
index 0877ceb49f1bbc6d45bed91c71fcb7148c6b7d5b..c8072ea55d88f7e9dcc7a824c94755b717461786 100755 (executable)
@@ -11,7 +11,7 @@ $CGI::DISABLE_UPLOADS = 1;             # no uploads
 use Emesinae::Bug;
 use Emesinae::Common;
 
-require 'common.cgi';
+use Emesinae::CGI;
 
 readconfig;
 my $dbh = opendb;
diff --git a/Emesinae/CGI.pm b/Emesinae/CGI.pm
new file mode 100644 (file)
index 0000000..60cac70
--- /dev/null
@@ -0,0 +1,59 @@
+package Emesinae::CGI;
+
+use warnings;
+use strict;
+
+use CGI qw/:standard/;
+use CGI::Carp qw(fatalsToBrowser);
+
+use Emesinae::Bug;
+use Emesinae::Message;
+use Emesinae::Common;
+
+BEGIN {
+    use Exporter ();
+    our ( $VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS );
+    $VERSION = 1.00;
+    @ISA     = qw(Exporter);
+    @EXPORT  = qw(
+      cgipath
+      buglink
+      msglink
+      htmlsanit
+    );
+    %EXPORT_TAGS = ();
+
+    @EXPORT_OK = qw();
+}
+
+sub cgipath {
+    my $p = shift;
+    return $c{CGIPath} . $p;
+}
+
+sub buglink($;$$) {
+    my $b = shift;
+    my $t = shift || $b->{title};
+    my $p = shift || "";            # Optional subpath
+
+    my $url = cgipath( "bug/" . $b->{id} . $p );
+    return a( { href => $url }, $t );
+}
+
+sub msglink {
+    my $m = shift;
+    my $t = shift;
+    my $p = shift || "";            # Optional subpath
+
+    my $url = cgipath( "message/" . $m->{id} . $p );
+    return a( { href => $url }, $t );
+}
+
+sub htmlsanit {
+    my %saniarray = ( '<', 'lt', '>', 'gt', '&', 'amp', '"', 'quot' );
+    my $in = shift || "";
+    $in =~ s/([<>&"])/\&$saniarray{$1};/g;
+    return $in;
+}
+
+1;
index f4788f84dec9a946dca5066035bcdf6e7b8ed434..ff3e96d6cbb69b466255c8c65205cc8a435b3f93 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -23,12 +23,12 @@ SCRIPTS     := scripts/receive.pl     \
 
 MODULES     := Emesinae/Bug.pm          \
                Emesinae/Common.pm       \
-               Emesinae/Message.pm
+               Emesinae/Message.pm      \
+               Emesinae/CGI.pm
 
 CGIS        := CGI/bug.pl               \
                CGI/bugs.pl              \
-               CGI/message.pl           \
-               CGI/common.pl
+               CGI/message.pl
 
 CSSS        := css/style.css