Permalink
Browse files

add canonical url link to pages - points the timestamp url for when t…

…he page was published
  • Loading branch information...
jgsmith committed Aug 31, 2012
1 parent 5293490 commit 9763b49d8638267c09ec7b70a8aec4c0c135b68a
View
@@ -19,7 +19,6 @@ use Catalyst::Runtime 5.80;
#-Debug
use Catalyst qw/
- -Debug
ConfigLoader
Static::Simple
@@ -221,19 +221,14 @@ sub GET_oai_pmh {
sub _DELETE {
my($self) = @_;
- print STDERR "In _DELETE\n";
OokOok::Exception -> forbidden(
message => "Unable to DELETE unless authenticated"
) unless $self -> c -> user;
- print STDERR " user is authenticated\n";
-
OokOok::Exception -> forbidden(
message => "Unable to DELETE"
) unless $self -> can_DELETE;
- print STDERR " user can delete\n";
-
$self -> DELETE
}
@@ -244,8 +239,6 @@ sub DELETE {
message => 'Unable to DELETE without source'
) unless $self -> has_source;
- print STDERR " passing delete request on to resource source\n";
-
$self -> source -> delete;
}
@@ -40,8 +40,6 @@ override update => sub {
sub duplicate_to_current_edition {
my($self, $current_edition) = @_;
- print STDERR "Calling duplicate_to_current_edition from ", join(", ", caller), "\n";
-
my $edition_id_key = $self -> edition -> result_source -> from . "_id";
my $owner_id_key = $self -> owner -> result_source -> from . "_id";
@@ -39,8 +39,6 @@ sub POST {
$edition = $edition -> get_from_storage;
- print STDERR "Closing date: ", $edition -> closed_on, "\n";
-
my @changes;
my $new_edition = OokOok::Resource::Edition -> new(
@@ -36,7 +36,6 @@ controller OokOok::Controller::Admin::Project
);
}
- print STDERR "Getting page for $uuid: ", $page -> id, "\n";
$ctx -> stash -> {page} = $page;
}
@@ -69,7 +68,6 @@ controller OokOok::Controller::Admin::Project
my $collection = OokOok::Collection::Project -> new(c => $ctx);
my $params = $ctx -> request -> params;
$params->{theme_date} = DateTime->now -> iso8601;
-print STDERR "POSTing a project:", Data::Dumper -> Dump([$params]), "\n";
my $project = $self -> POST( $ctx, $collection, $params );
if($project) {
$ctx -> response -> redirect($ctx->uri_for("/admin/project/" . $project -> id));
@@ -66,6 +66,20 @@ controller OokOok::Controller::View
$ctx -> uri_for( "/s/$project_uuid/style/$_" )
} $page -> stylesheets ];
+ if($page -> date) {
+ my $date = $page -> source_version -> edition -> closed_on;
+ my $root = "/";
+ if($ctx -> stash -> {date}) {
+ #$root .= "../";
+ }
+ local $URI::ABS_REMOTE_LEADING_DOTS = 1;
+ my $url = URI->new($root
+ . $date -> ymd('') . $date -> hms('')
+ . "/v/$project_uuid/" . ($page -> slug_path || ''))
+ -> abs($ctx -> uri_for("/"));
+ $ctx -> stash -> {canonical_url} = $url -> as_string;
+ }
+
$ctx -> stash -> {template} = 'view/play.tt2';
$ctx -> forward( $ctx -> view('HTML') );
}
@@ -116,7 +116,7 @@ sub authenticate {
if($response -> is_success) {
my $json = JSON::decode_json($response -> decoded_content);
use Data::Dumper ();
- print STDERR "Returned from twitter:", Data::Dumper -> Dump([$json]);
+ #print STDERR "Returned from twitter:", Data::Dumper -> Dump([$json]);
$info->{user_id} = $access_token -> {user_id};
$info->{name} = $json->{name};
$info->{url} = $json->{url};
@@ -180,7 +180,6 @@ sub get_layout {
if($layout_uuid) {
$layout = $theme -> layout($layout_uuid);
if($layout) {
- print "Layout: ", $layout -> id, "\n";
return $layout;
}
if($self -> parent_page) {
@@ -45,7 +45,6 @@ override update => sub {
if($self -> page_version -> edition -> is_closed) {
# the following will die if we can't duplicate
$self -> discard_changes();
- print STDERR "Duplicating page to current edition\n";
my $page_version = $self -> page_version -> duplicate_to_current_edition;
my $new;
if($changes{name}) {
@@ -59,7 +58,6 @@ override update => sub {
{ name => $self -> name }
) -> first;
}
- print STDERR "Updating new page copy page part (", $self -> name, ")\n";
return $new -> update(\%changes);
}
else {
@@ -31,17 +31,10 @@ after insert => sub {
});
$ce -> update_or_insert;
- print STDERR "CE page id: ", $ce -> page_id, "\n";
- print STDERR "Home page id: ", $home_page -> id, "\n";
while($ce -> is_changed) {
- print STDERR "CE marked as changed: ", $ce -> is_changed, "\n";
$ce -> update_or_insert;
}
- print STDERR "CE page id: ", $ce -> page_id, "\n";
- print STDERR "CE marked as changed: ", $ce -> is_changed, "\n";
-
-
# now add libraries that should be included automatically
my @libs = $self -> result_source->schema-> resultset('Library') -> search({
new_project_prefix => { '!=' => undef }
@@ -37,10 +37,8 @@ after insert => sub {
my $ce = $self -> current_edition;
my @libs = $self -> result_source -> schema -> resultset('Library') -> all;
- print STDERR "We have ", scalar(@libs), " libs\n";
for my $lib (@libs) {
next unless $lib -> new_theme_prefix && $lib -> has_public_edition;
- print STDERR "Adding ", $lib -> new_theme_prefix, " to theme\n";
my $tl = $self -> create_related('library_themes', {
library_id => $lib -> id
@@ -89,8 +89,6 @@ sub element_content {
$name = 'body';
}
- print STDERR "content: [$name]\n";
-
my $inherit = $attr -> {'inherit'};
# we want to render the page part with the current context
View
@@ -1,5 +1,8 @@
<html>
<head>
+ [%- IF canonical_url -%]
+ <link rel="canonical" href="[% canonical_url %]" />
+ [%- END -%]
<title>[% project.name %] - [% page.title %]</title>
[%- FOR stylesheet IN stylesheets.unique -%]
<link href="[% stylesheet %]" rel="stylesheet/less" type="text/css">

0 comments on commit 9763b49

Please sign in to comment.