Skip to content

Commit

Permalink
add canonical url link to pages - points the timestamp url for when t…
Browse files Browse the repository at this point in the history
…he page was published
  • Loading branch information
jgsmith committed Aug 31, 2012
1 parent 5293490 commit 9763b49
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 29 deletions.
1 change: 0 additions & 1 deletion lib/OokOok.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use Catalyst::Runtime 5.80;

#-Debug
use Catalyst qw/
-Debug
ConfigLoader
Static::Simple
Expand Down
7 changes: 0 additions & 7 deletions lib/OokOok/Base/Resource.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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;
}

Expand Down
2 changes: 0 additions & 2 deletions lib/OokOok/Base/ResultVersion.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 0 additions & 2 deletions lib/OokOok/Collection/Edition.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 0 additions & 2 deletions lib/OokOok/Controller/Admin/Project.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ controller OokOok::Controller::Admin::Project
);
}

print STDERR "Getting page for $uuid: ", $page -> id, "\n";
$ctx -> stash -> {page} = $page;
}

Expand Down Expand Up @@ -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));
Expand Down
14 changes: 14 additions & 0 deletions lib/OokOok/Controller/View.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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') );
}
Expand Down
2 changes: 1 addition & 1 deletion lib/OokOok/Plugin/Authentication.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 0 additions & 1 deletion lib/OokOok/Resource/Page.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions lib/OokOok/Schema/Result/PagePart.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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}) {
Expand All @@ -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 {
Expand Down
7 changes: 0 additions & 7 deletions lib/OokOok/Schema/Result/Project.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 0 additions & 2 deletions lib/OokOok/Schema/Result/Theme.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions lib/OokOok/Template/TagLibrary/Core.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions root/src/view/play.tt2
Original file line number Diff line number Diff line change
@@ -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">
Expand Down

0 comments on commit 9763b49

Please sign in to comment.