Merge branch 'upstream_master'
Foxtons Web Design [Mon, 12 Apr 2010 08:29:44 +0000 (09:29 +0100)]
13 files changed:
Changes
Makefile.PL
lib/Gitalist.pm
lib/Gitalist/Controller/Fragment/Ref.pm
lib/Gitalist/Controller/Ref.pm
lib/Gitalist/Git/Object/Commit.pm
root/_diff.tt2
root/fragment/ref/blob.tt2
root/fragment/ref/commit.tt2
root/ref/blob.tt2
root/ref/tree.tt2
root/static/css/core.css
root/wrapper.tt2

diff --git a/Changes b/Changes
index e9c27bd..7e5894a 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,11 +1,18 @@
 This file documents the revision history for Perl extension Gitalist.
 
+0.000006 2010-04-10
+
+    - Major frontend redesign, thanks to ranguard and the web designers at
+      Foxtons for making this happen.
+    - Major URI overhaul, Gitalist has gone from old gitweb style CGI
+      parameters to proper URIs, however the old URIs are still supported
+      and will redirect appropriately (Tomas Doran).
+    - With the URI overhaul also came breaking up actions into fragments
+      for use with Catalyst::View::Component::SubInclude.
     - BIG BREAKING CHANGE - Gitalist::Model::GitRepos has been renamed
       Gitalist::Model::CollectionOfRepos. You need to fix your config and
       if you have actually installed Gitalist - remove the old model file.
-
     - Bump required version of Git::PurePerl for Encoding fixes.
-
     - Fix Makefile.PL to not need release deps when checking out of Git.
 
 0.000005 2010-01-09
index d733e1c..6abc413 100644 (file)
@@ -83,6 +83,8 @@ requires 'CGI';
 requires 'DateTime';
 requires 'DateTime::Format::Mail';
 requires 'File::Copy::Recursive';
+requires 'File::Type';
+requires 'File::Type::WebImages';
 requires 'File::Which';
 requires 'HTML::Entities';
 requires 'IPC::Run';
index 1be66c8..f213df2 100644 (file)
@@ -14,7 +14,7 @@ use Catalyst qw/
                 SubRequest
 /;
 
-our $VERSION = '0.000006_01';
+our $VERSION = '0.000006';
 $VERSION = eval $VERSION;
 
 __PACKAGE__->config(
index b4a2181..2917616 100644 (file)
@@ -8,6 +8,8 @@ with qw/
     Gitalist::URIStructure::Fragment::WithLog
 /;
 
+use File::Type::WebImages ();
+
 sub base : Chained('/fragment/repository/find') PathPart('') CaptureArgs(0) {}
 
 sub _diff {
@@ -52,7 +54,6 @@ after tree => sub {
     $c->stash(
         tree      => $tree,
         tree_list => [$repository->list_tree($tree->sha1)],
-        path      => $c->stash->{filename}, # FIXME?
     );
 };
 
@@ -83,7 +84,9 @@ after blob => sub {
     my ( $self, $c ) = @_;
     $c->stash(
         # XXX Hack hack hack, see View::SyntaxHighlight
-        language => ($c->stash->{filename} =~ /\.p[lm]$/i ? 'Perl' : ''),
+        language  => ($c->stash->{filename} =~ /\.p[lm]$/i ? 'Perl' : ''),
+        is_image  => File::Type::WebImages::mime_type($c->stash->{blob}),
+        is_binary => -B $c->stash->{blob},
     );
 
     $c->forward('View::SyntaxHighlight')
index e43bd98..b988d4d 100644 (file)
@@ -6,6 +6,9 @@ use namespace::autoclean;
 BEGIN { extends 'Gitalist::Controller' }
 with 'Gitalist::URIStructure::Ref';
 
+use File::Type;
+use File::Type::WebImages ();
+
 sub base : Chained('/repository/find') PathPart('') CaptureArgs(0) {}
 
 after commit => sub {
@@ -20,7 +23,16 @@ sub raw : Chained('find') Does('FilenameArgs') Args() {
     my ($self, $c) = @_;
     $c->forward('find_blob');
 
-    $c->response->content_type('text/plain; charset=utf-8');
+    if(-T $c->stash->{blob}) {
+        $c->response->content_type('text/plain; charset=utf-8');
+    } else {
+        my $ft = File::Type->new();
+        $c->response->content_type(
+            File::Type::WebImages::mime_type($c->stash->{blob})
+         || File::Type->new->mime_type($c->stash->{blob})
+        );
+    }
+
     $c->response->body(delete $c->stash->{blob});
 }
 
index 7ac568b..0445999 100644 (file)
@@ -128,7 +128,7 @@ class Gitalist::Git::Object::Commit
                     next;
                 }
 
-                if (/^index (\w+)\.\.(\w+) (\d+)$/) {
+                if (/^index (\w+)\.\.(\w+)(?: (\d+))?$/) {
                     @{$ret[-1]}{qw(index src dst mode)} = ($_, $1, $2, $3);
                     next
                 }
index 4b217d2..11b4199 100755 (executable)
@@ -7,13 +7,19 @@
 [% FOREACH item IN diff %]
 
 <h4 id="diff[% loop.count %]" class='diff-head'>diff --git [%# FIXME %]
- <a href='[% c.uri_for_action("/ref/blob", [Repository.name, Commit.sha1], item.file) %]' title="Blob">[% item.a %]</a>
- <a href='[% c.uri_for_action("/ref/blob", [Repository.name, Commit.sha1], item.file) %]' title="Blob">[% item.b %]</a>
+ [% IF !item.src.match('^0+$') %]
+   <a href='[% c.uri_for_action("/ref/blob", [Repository.name, item.src]) %]' title="Blob">[% item.a %]</a>
+ [% ELSE %]
+   [% item.a %]
+ [% END %]
+ [% IF !item.dst.match('^0+$') %]
+ <a href='[% c.uri_for_action("/ref/blob", [Repository.name, item.dst]) %]' title="Blob">[% item.b %]</a>
+ [% ELSE %]
+   [% item.b %]
+ [% END %]
 </h4>
 
 
-
-
 <div class='diff-patch'>
        <pre>[% blobs.${loop.index} %]</pre>
 </div>
index 592f8c5..aaaa65d 100644 (file)
@@ -1 +1,7 @@
-[% blob %]
+[%- IF is_image -%]
+<div class='blob'><img src="[% c.uri_for_action('/ref/raw', c.req.captures, filename) %]" title="[% filename %]"></div>
+[%- ELSIF is_binary -%]
+<div class='blob'>This is a binary file which won't render natively on the web, but you can get it here all the same: <a href="[% c.uri_for_action('/ref/raw', c.req.captures, filename) %]" title="[% filename %]">[% filename %]</a></div>
+[%- ELSE -%]
+<pre class='blob'>[% blob | html %]</pre>
+[%- END -%]
index 551d103..8560e1f 100755 (executable)
@@ -38,7 +38,7 @@
        <tr>
                <td class='sha1'>[% INCLUDE 'inc/chroma_hash.tt2' sha1 = Commit.sha1.substr(0, 7), hide_sha1_output = 1 %] <div class="sha1_label">Commit</div></td>
                <td>[% Commit.sha1 %]</td>
-               <td class='action-list'></td>
+               <td class='action-list'><a href="[% c.uri_for_action('/ref/diff_fancy', [Repository.name, Commit.sha1]) %]" title="Difference" class="button diff">diff</a></td>
        </tr>
        <tr>
                <td class='sha1'>[% INCLUDE 'inc/chroma_hash.tt2' sha1 = Commit.tree_sha1.substr(0, 7), hide_sha1_output = 1 %] <div class="sha1_label">Tree</div></td>
index ad81803..fb4497d 100755 (executable)
@@ -7,8 +7,8 @@
     [% short_cmt(head.comment) %]
    </div>
   [% END %]
-       <pre class='blob'>[% subinclude('/fragment/ref/blob', c.req.captures, c.req.args.to_path) | html %]</pre>
+
+[% subinclude('/fragment/ref/blob', c.req.captures, c.req.args.to_path) %]
 
 
  
\ No newline at end of file
index b477e0c..6d76c32 100755 (executable)
@@ -1,8 +1 @@
-  [%
-    IF path;
-      INCLUDE 'nav/path.tt2' filename = path;
-    END;
-
-    subinclude('/fragment/ref/tree', c.req.captures, c.req.args.to_path);
-  %]
-
+[% subinclude('/fragment/ref/tree', c.req.captures, c.req.args.to_path) %]
index 001b995..d4220de 100755 (executable)
@@ -467,6 +467,10 @@ pre.blob {
   overflow:auto;
   font-size:12px;
 }
+div.blob {
+    text-align: center;
+    margin: 30px;
+}
 
 /* /blobdiff etc */
 
index f252e13..545e7b3 100755 (executable)
@@ -74,7 +74,7 @@
                        [% IF c.req.captures.size == 1; SET path = 'repository'; ELSE; SET path = 'ref'; END %]
                        
                        <ul>
-                               <li[% ' class="selected"' IF c.action.name.match('tree') %]><a href="[% c.uri_for_action('/ref/tree', c.req.captures) %]" id="tree">Tree</a></li>
+                               <li[% ' class="selected"' IF c.action.name.match('tree') %]><a href="[% c.uri_for_action('/ref/tree', c.req.captures) || c.uri_for_action('/repository/tree', c.req.captures) %]" id="tree">Tree</a></li>
 
                                <li[% ' class="selected"' IF c.action.name.match('longlog') %]><a href="[% c.uri_for_action('/' _ path _ '/longlog', c.req.captures) %]" id="log_full">Long log</a></li>