[Jifty-commit] r981 - in wifty/trunk: lib/Wifty/Model share/web/static/css share/web/templates share/web/templates/_elements

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Wed May 3 16:36:37 EDT 2006


Author: alexmv
Date: Wed May  3 16:36:36 2006
New Revision: 981

Added:
   wifty/trunk/share/web/templates/_elements/diff
Modified:
   wifty/trunk/   (props changed)
   wifty/trunk/Makefile.PL
   wifty/trunk/lib/Wifty/Model/Revision.pm
   wifty/trunk/share/web/static/css/app-base.css
   wifty/trunk/share/web/templates/view

Log:
 r12809 at zoq-fot-pik:  chmrr | 2006-05-03 16:36:11 -0400
  * Diffs of revisions


Modified: wifty/trunk/Makefile.PL
==============================================================================
--- wifty/trunk/Makefile.PL	(original)
+++ wifty/trunk/Makefile.PL	Wed May  3 16:36:36 2006
@@ -4,4 +4,5 @@
 requires('Jifty');
 requires('Text::Markdown');
 requires('HTML::Scrubber');
+requires('Text::Diff::HTML');
 WriteAll;

Modified: wifty/trunk/lib/Wifty/Model/Revision.pm
==============================================================================
--- wifty/trunk/lib/Wifty/Model/Revision.pm	(original)
+++ wifty/trunk/lib/Wifty/Model/Revision.pm	Wed May  3 16:36:36 2006
@@ -30,6 +30,50 @@
 
 }
 
+sub previous {
+    my $self = shift;
+    return undef unless $self->id;
+
+    my $revisions = Wifty::Model::RevisionCollection->new;
+    $revisions->limit(
+        column         => 'page',
+        value          => $self->page->id,
+        quote_value    => 0,
+        case_sensitive => 1
+    );
+    $revisions->limit(
+        column         => 'id',
+        operator       => '<',
+        value          => $self->id,
+        quote_value    => 0,
+        case_sensitive => 1
+    );
+    $revisions->order_by( { column => 'id' } );
+    return $revisions->last;
+}
+
+sub next {
+    my $self = shift;
+    return undef unless $self->id;
+
+    my $revisions = Wifty::Model::RevisionCollection->new;
+    $revisions->limit(
+        column         => 'page',
+        value          => $self->page->id,
+        quote_value    => 0,
+        case_sensitive => 1
+    );
+    $revisions->limit(
+        column         => 'id',
+        operator       => '>',
+        value          => $self->id,
+        quote_value    => 0,
+        case_sensitive => 1
+    );
+    $revisions->order_by( { column => 'id' } );
+    return $revisions->first;
+}
+
 =head2 current_user_can RIGHT
 
 We're using L<Jifty::RightsFrom> to pass off ACL decisions to this

Modified: wifty/trunk/share/web/static/css/app-base.css
==============================================================================
--- wifty/trunk/share/web/static/css/app-base.css	(original)
+++ wifty/trunk/share/web/static/css/app-base.css	Wed May  3 16:36:36 2006
@@ -61,6 +61,8 @@
     right: 2em;
 }
 
-
-
-
+.file span { display: block; clear: both; }
+.file .fileheader, .file .hunkheader {color: #888; }
+.file .hunk .ctx { background: #eee;}
+.file .hunk ins { background: #dfd; text-decoration: none; display: block; }
+.file .hunk del { background: #fdd; text-decoration: none; display: block; }

Added: wifty/trunk/share/web/templates/_elements/diff
==============================================================================
--- (empty file)
+++ wifty/trunk/share/web/templates/_elements/diff	Wed May  3 16:36:36 2006
@@ -0,0 +1,24 @@
+<%args>
+$page
+$from =>undef
+$to => undef
+</%args>
+<%init>
+
+$to   ||= $page->revisions->last;
+$from ||= $to->previous || Wifty::Model::Revision->new;
+
+my $before = $to->previous;
+my $after  = $to->next;
+
+use Text::Diff ();
+my $diff = Text::Diff::diff(\($from->content), \($to->content), { STYLE => 'Text::Diff::HTML' });
+
+</%init>
+% if ($before) {
+<span style="float: left"><% Jifty->web->link(url => "/view/".$page->name."/".$before->id, label => "Previous revision") %></span>
+% }
+% if ($after) {
+<span style="float: right"><% Jifty->web->link(url => "/view/".$page->name."/".$after->id, label => "Next revision") %></span>
+% }
+<pre><% $diff |n%></pre><hr />

Modified: wifty/trunk/share/web/templates/view
==============================================================================
--- wifty/trunk/share/web/templates/view	(original)
+++ wifty/trunk/share/web/templates/view	Wed May  3 16:36:36 2006
@@ -5,6 +5,8 @@
 <& /_elements/page_nav, page => $page->name, rev => $revision->id &>
 <&|/_elements/wrapper, title => $page->name . ($revision->id ? " as of ".$revision->created : '') &>
 % if ($revision->id) {
+<& _elements/diff, page => $page, to => $revision &>
+
 <% $page->wiki_content($revision->content) |n%>
 % } else {
 <% $page->wiki_content |n %>


More information about the Jifty-commit mailing list