Get the controller ready for changing model - you can override which model we try...
[catagits/Gitalist.git] / lib / Gitalist.pm
index 16e0990..8b0cee5 100644 (file)
@@ -6,23 +6,36 @@ use Catalyst::Runtime 5.80;
 
 extends 'Catalyst';
 
-use Catalyst qw/-Debug
+use Catalyst qw/
                 ConfigLoader
                 Static::Simple
-                               StackTrace/;
+                StackTrace/;
+
 our $VERSION = '0.01';
 
 # Bring in the libified gitweb.cgi.
 use gitweb;
 
 __PACKAGE__->config(
-       name => 'Gitalist',
-       default_view => 'Default',
+    name => 'Gitalist',
+    default_view => 'Default',
+    default_model => 'Git', # Yes, we are going to be changing this.
 );
 
 # Start the application
 __PACKAGE__->setup();
 
+around uri_for => sub {
+  my ($orig, $c) = (shift, shift);
+  my $params = Catalyst::Utils::merge_hashes(
+    { p => $c->model('Git')->project },
+    ref($_[-1]) eq 'HASH' ? pop @_ : {}
+  );
+  (my $uri = $c->$orig(@_, $params))
+    =~ tr[&][;];
+  return $uri;
+};
+
 =head1 NAME
 
 Gitalist - Catalyst based application