From 62a18e4d0e05f5d8ef18a7c25456213060e39521 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 18 Feb 2011 10:12:12 -0600 Subject: make sure we're showing the historical view of the right page --- lib/Narwhal/Component/Wiki.pm | 2 +- lib/Narwhal/Page.pm | 16 +++++++--------- lib/Narwhal/Page/Revision.pm | 7 +++++++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/Narwhal/Component/Wiki.pm b/lib/Narwhal/Component/Wiki.pm index e3eb254..ce1fbbf 100644 --- a/lib/Narwhal/Component/Wiki.pm +++ b/lib/Narwhal/Component/Wiki.pm @@ -37,7 +37,7 @@ sub old_page { my $page_rev = $self->lookup($rev); return $req->new_response(404) - unless $page_rev; + unless $page_rev && $page_rev->page_id eq $page_name; $self->render( $req, diff --git a/lib/Narwhal/Page.pm b/lib/Narwhal/Page.pm index 70f2f87..829ce2e 100644 --- a/lib/Narwhal/Page.pm +++ b/lib/Narwhal/Page.pm @@ -5,17 +5,16 @@ use Narwhal::Page::Revision; with 'KiokuDB::Role::ID'; -has id => ( - is => 'ro', - isa => 'Str', - required => 1, -); - has current_revision => ( is => 'rw', isa => 'Narwhal::Page::Revision', required => 1, - handles => ['text', 'author', 'modification_date'], + handles => { + id => 'page_id', + text => 'text', + author => 'author', + modification_date => 'modification_date', + }, ); sub kiokudb_object_id { 'page:' . shift->id } @@ -31,9 +30,8 @@ sub new_page { my $class = shift; my %opts = @_; my $id = delete $opts{id}; - my $rev = Narwhal::Page::Revision->new(%opts); + my $rev = Narwhal::Page::Revision->new(page_id => $id, %opts); return $class->new( - id => $id, current_revision => $rev, ); } diff --git a/lib/Narwhal/Page/Revision.pm b/lib/Narwhal/Page/Revision.pm index 08a21c9..9e2770a 100644 --- a/lib/Narwhal/Page/Revision.pm +++ b/lib/Narwhal/Page/Revision.pm @@ -5,6 +5,12 @@ use DateTime; with 'KiokuDB::Role::ID::Digest', 'MooseX::Clone'; +has page_id => ( + is => 'ro', + isa => 'Str', + required => 1, +); + has text => ( is => 'ro', isa => 'Str', @@ -41,6 +47,7 @@ sub new_revision { sub digest_parts { my $self = shift; return ( + $self->page_id, $self->text, $self->modification_date->iso8601, $self->author->id, -- cgit v1.2.3-54-g00ecf