summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-02-18 10:12:12 -0600
committerJesse Luehrs <doy@tozt.net>2011-02-18 11:52:22 -0600
commit62a18e4d0e05f5d8ef18a7c25456213060e39521 (patch)
tree3496d4e995888784f13eba628b9d17a11bdfd061
parent1ffb8c7688a3ecc947c81bccbd406f277c9d853a (diff)
downloadnarwhal-62a18e4d0e05f5d8ef18a7c25456213060e39521.tar.gz
narwhal-62a18e4d0e05f5d8ef18a7c25456213060e39521.zip
make sure we're showing the historical view of the right page
-rw-r--r--lib/Narwhal/Component/Wiki.pm2
-rw-r--r--lib/Narwhal/Page.pm16
-rw-r--r--lib/Narwhal/Page/Revision.pm7
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,