aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatthew <matthew>2007-05-14 21:21:44 +0000
committermatthew <matthew>2007-05-14 21:21:44 +0000
commit3716d7fc96e829322009abcfb5ea34f7cf326374 (patch)
tree964c3a2876b9d94034aeca6fd4c351fcc22ef7c6
parent4e050c1bca29c39f402ab7056f342e9ccb8f97f5 (diff)
RSS in header.
-rw-r--r--perllib/Page.pm18
-rwxr-xr-xweb/index.cgi22
-rwxr-xr-xweb/report.cgi5
3 files changed, 32 insertions, 13 deletions
diff --git a/perllib/Page.pm b/perllib/Page.pm
index 0986328a9..2e92e99f0 100644
--- a/perllib/Page.pm
+++ b/perllib/Page.pm
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Page.pm,v 1.45 2007-05-09 20:07:00 matthew Exp $
+# $Id: Page.pm,v 1.46 2007-05-14 21:21:44 matthew Exp $
#
package Page;
@@ -64,7 +64,7 @@ sub header ($$%) {
$title = '' unless $title;
$title .= ' - ' if $title;
- my %permitted_params = map { $_ => 1 } qw();
+ my %permitted_params = map { $_ => 1 } qw(rss);
foreach (keys %params) {
croak "bad parameter '$_'" if (!exists($permitted_params{$_}));
}
@@ -84,6 +84,14 @@ EOF
<script type="text/javascript" src="/js.js"></script>
<title>${title}Neighbourhood Fix-It</title>
<style type="text/css">\@import url("/css.css");</style>
+EOF
+ if ($params{rss}) {
+ foreach (keys %{$params{rss}}) {
+ print '<link rel="alternate" type="application/rss+xml" title="'
+ . $_ . '" href="' . $params{rss}{$_} . '">';
+ }
+ }
+ $html .= <<EOF;
</head>
<body>
EOF
@@ -339,7 +347,7 @@ sub prettify_duration {
$s = int(($s+60*30)/60/60)*60*60;
} elsif ($nearest eq 'minute') {
$s = int(($s+30)/60)*60;
- return 'less than a minute' if $s == 0;
+ return 'less than a minute' if $s == 0;
}
my @out = ();
_part(\$s, 60*60*24*7, 'week', \@out);
@@ -352,8 +360,8 @@ sub _part {
my ($s, $m, $w, $o) = @_;
if ($$s >= $m) {
my $i = int($$s / $m);
- push @$o, "$i $w" . ($i != 1 ? 's' : '');
- $$s -= $i * $m;
+ push @$o, "$i $w" . ($i != 1 ? 's' : '');
+ $$s -= $i * $m;
}
}
diff --git a/web/index.cgi b/web/index.cgi
index 80cfb72c7..fde9b671c 100755
--- a/web/index.cgi
+++ b/web/index.cgi
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: index.cgi,v 1.129 2007-05-14 10:35:10 matthew Exp $
+# $Id: index.cgi,v 1.130 2007-05-14 21:21:44 matthew Exp $
use strict;
require 5.8.0;
@@ -57,6 +57,7 @@ sub main {
my $out = '';
my $title = '';
+ my %params;
if ($q->param('submit_problem')) {
$title = 'Submitting your problem';
$out = submit_problem($q);
@@ -68,14 +69,14 @@ sub main {
$out = display_form($q);
} elsif ($q->param('id')) {
$title = 'Viewing a problem';
- $out = display_problem($q);
+ ($out, %params) = display_problem($q);
} elsif ($q->param('pc') || ($q->param('x') && $q->param('y'))) {
$title = 'Viewing a location';
- $out = display_location($q);
+ ($out, %params) = display_location($q);
} else {
$out = front_page($q);
}
- print Page::header($q, $title);
+ print Page::header($q, $title, %params);
print $out;
print Page::footer();
dbh()->rollback();
@@ -531,7 +532,12 @@ EOF
}
$out .= '</div>';
$out .= Page::display_map_end(1);
- return $out;
+
+ my %params = (
+ 'Recent local problems, Neighbourhood Fix-It' => "/rss/$x,$y"
+ );
+
+ return ($out, %params);
}
sub display_problem {
@@ -632,7 +638,11 @@ $fixedline
</form>
EOF
$out .= Page::display_map_end(0);
- return $out;
+
+ my %params = (
+ 'Updates to this problem, Neighbourhood Fix-It' => "/rss/$input_h{id}"
+ );
+ return ($out, %params);
}
sub map_pins {
diff --git a/web/report.cgi b/web/report.cgi
index 882de57fb..0a4a1025a 100755
--- a/web/report.cgi
+++ b/web/report.cgi
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: report.cgi,v 1.26 2007-05-14 18:28:24 matthew Exp $
+# $Id: report.cgi,v 1.27 2007-05-14 21:21:44 matthew Exp $
use strict;
require 5.8.0;
@@ -74,8 +74,8 @@ sub main {
}
}
my $areas_info = mySociety::MaPit::get_voting_areas_info([keys %councils]);
- print Page::header($q, 'Summary reports');
if (!$one_council) {
+ print Page::header($q, 'Summary reports');
print $q->p('This is a summary of all reports on this site that have been sent to a council; select \'show only\' to see the reports for just one council.');
print '<table>';
print '<tr><th>Name</th><th>New problems</th><th>Ongoing problems</th>
@@ -92,6 +92,7 @@ sub main {
}
print '</table>';
} else {
+ print Page::header($q, 'Summary reports', rss => ('Problems in this council, Neighbourhood Fix-It' => "/rss/council/$one_council"));
print $q->p(
$q->a({href => "/rss/council/$one_council"}, '<img align="right" src="/i/feed.png" width="16" height="16" title="RSS feed" alt="RSS feed of problems in this council" border="0" hspace="4">'),
'This is a summary of all reports for one council. You can ' .