Started the switch from hand-written URLs to uri_for.
[catagits/Gitalist.git] / lib / Gitalist.pm
index 8d3f4f5..5213ef7 100644 (file)
@@ -9,27 +9,35 @@ extends 'Catalyst';
 use Catalyst qw/-Debug
                 ConfigLoader
                 Static::Simple
-                               StackTrace/;
+                StackTrace/;
+
+use Class::C3::Adopt::NEXT -no_warn;
+
 our $VERSION = '0.01';
 
 # Bring in the libified gitweb.cgi.
 use gitweb;
 
-# Load the testing config if we're invoked under test
-if ($ENV{APP_TEST} ) {
-  __PACKAGE__->config( 'Plugin::ConfigLoader' =>
-                       { file => __PACKAGE__->path_to
-                         ('t/lib/gitalist_testing.conf')}
-                     );
-}
 __PACKAGE__->config(
-       name => 'Gitalist',
-       default_view => 'Default',
+    name => 'Gitalist',
+    default_view => 'Default',
 );
 
 # Start the application
 __PACKAGE__->setup();
 
+sub uri_for {
+    my $p = ref $_[-1] eq 'HASH'
+          ? $_[-1]
+          : push(@_, {}) && $_[-1];
+    $p->{p} = $_[0]->model('Git')->project;
+
+    (my $uri = $_[0]->NEXT::uri_for(@_[1 .. $#_]))
+      # Ampersand! What is this, the 90s?
+      =~ s/&/;/g;
+    return $uri;
+}
+
 =head1 NAME
 
 Gitalist - Catalyst based application