Skip to content

Commit

Permalink
Add refresh link in make_pretty()
Browse files Browse the repository at this point in the history
When building an HTML result, make the title link back to the page so
that it's easier to refresh on some devices.
  • Loading branch information
grantisu committed Jun 13, 2014
1 parent ac9350f commit b0adeb5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app.psgi
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ sub help_doc {
}

sub make_pretty {
my ($name, $mk_list, $lines) = @_;
my @page = ("<html><head><title>$name</title></head><body style='max-width: 75em;'><h3>$name</h3>\n");
my ($name, $qstr, $mk_list, $lines) = @_;
my @page = ("<html><head><title>$name</title></head><body style='max-width: 75em;'><h3><a href=\"?$qstr\">$name</a></h3>\n");

if ($mk_list) {
push @page, "<ul style=\"list-style-type: none;\">\n", (map { "<li>$_</li>\n" } @$lines), "\n</ul>";
} else {
push @page, (map { s/_([^_]+)_/<em>\1<\/em>/g; /^\s*$/ ? '<br>' : "<p>$_</p>\n" } @$lines);
push @page, (map { s/_([^_]+)_/<em>$1<\/em>/g; /^\s*$/ ? '<br>' : "<p>$_</p>\n" } @$lines);
}

push @page, '</body></html>';
Expand Down Expand Up @@ -122,7 +122,7 @@ my $app = sub {
if (defined $qp->{plain}) {
return [ 200, ['Content-Type','text/plain; charset=utf-8'], \@lines ];
} else {
return make_pretty($path, $info{$path}{as_list}, \@lines);
return make_pretty($path, $env->{QUERY_STRING}, $info{$path}{as_list}, \@lines);
}
};

Expand Down

0 comments on commit b0adeb5

Please sign in to comment.