Skip to content

Commit

Permalink
Don't try to make dynamic pages canonical.
Browse files Browse the repository at this point in the history
  • Loading branch information
benmwebb committed Sep 11, 2015
1 parent 037e609 commit b80189f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
26 changes: 12 additions & 14 deletions perl/saliweb/frontend.pm
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ sub new {
$self->{http_status} = undef;
$self->{'htmlroot'} = $urltop . "/html/";
$self->{'cgiroot'} = $urltop;
$self->{canonical_url} = $self->index_url;
$self->{canonical_url} = undef;
my ($dbh, $dbh_main) = connect_to_database($config);
$self->{'dbh'} = $dbh;
$self->{'dbh_main'} = $dbh_main;
Expand Down Expand Up @@ -742,16 +742,18 @@ sub get_start_html_parameters {
ga('create', '$google_ua', 'ucsf.edu');
ga('send', 'pageview'); ";

my %param = (-title => $self->{page_title},
-style => {-src=>[$style]},
-script=>[{-language => 'JavaScript',
-src => "/saliweb/js/salilab.js"},
{-language => 'JavaScript',
-code => $JS_Google_Analytics}]);
my $canon = $self->{canonical_url};
$canon =~ s/^https:/http:/;
return (-title => $self->{page_title},
-style => {-src=>[$style]},
-head => $q->Link({-rel=>'canonical', -href=>$canon}),
-script=>[{-language => 'JavaScript',
-src => "/saliweb/js/salilab.js"},
{-language => 'JavaScript',
-code => $JS_Google_Analytics}]);

if (defined $canon) {
$canon =~ s/^https:/http:/;
$param{-head} = $q->Link({-rel=>'canonical', -href=>$canon});
}
return %param;
}

sub end_html {
Expand Down Expand Up @@ -1320,7 +1322,6 @@ sub display_submit_page {
try {
my $content;
$self->set_page_title("Submission");
$self->{canonical_url} = $self->submit_url;
try {
$self->check_page_access('submit');
$self->{submitted_jobs} = [];
Expand Down Expand Up @@ -1364,7 +1365,6 @@ sub display_download_page {
my $self = shift;
try {
$self->set_page_title("Download");
$self->{canonical_url} = $self->download_url;
$self->check_page_access('download');
$self->_display_web_page($self->get_download_page());
} catch saliweb::frontend::UserError with {
Expand All @@ -1382,7 +1382,6 @@ sub display_help_page {
my $display_type = $q->param('type') || 'help';
my $style = $q->param('style') || '';
$self->set_page_title("Help");
$self->{canonical_url} = $self->cgiroot . "/help.cgi";
$self->check_page_access('help');
my $content = $self->get_help_page($display_type);
if ($style eq "helplink") {
Expand All @@ -1404,7 +1403,6 @@ sub display_results_page {
my $self = shift;
try {
$self->set_page_title("Results");
$self->{canonical_url} = $self->results_url;
$self->check_page_access('results');
$self->_internal_display_results_page();
} catch saliweb::frontend::UserError with {
Expand Down
4 changes: 1 addition & 3 deletions test/frontend/download_page.pl
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ BEGIN
my $out = stdout_from { $cls->display_download_page() };
like($out,
"/^Content\-Type:.*<!DOCTYPE html.*<html.*<head>.*" .
"<title>dummy server Download</title>.*" .
"<link rel=\"canonical\" href=\"\/foo\/download\.cgi\".*" .
"</head>.*" .
"<title>dummy server Download</title>.*</head>.*" .
'<body>.*' .
"<div id=\"fullpart\">test_download_page</div>.*" .
"</body>.*</html>/s", 'check download page');
Expand Down

0 comments on commit b80189f

Please sign in to comment.