aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/Page.pm26
-rwxr-xr-xweb/alert.cgi35
-rw-r--r--web/css.css2
-rwxr-xr-xweb/index.cgi15
4 files changed, 35 insertions, 43 deletions
diff --git a/perllib/Page.pm b/perllib/Page.pm
index b605992b7..b003a171c 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.66 2007-09-18 08:27:05 matthew Exp $
+# $Id: Page.pm,v 1.67 2007-09-25 11:53:03 matthew Exp $
#
package Page;
@@ -576,4 +576,28 @@ sub short_name {
return $name;
}
+sub recent_photos {
+ my ($num, $e, $n, $dist) = @_;
+ my $probs;
+ if ($e) {
+ $probs = select_all("select id, title
+ from problem_find_nearby(?, ?, ?) as nearby, problem
+ where nearby.problem_id = problem.id
+ and state in ('confirmed', 'fixed') and photo is not null
+ order by confirmed desc limit $num", $e, $n, $dist);
+ } else {
+ $probs = select_all("select id, title from problem
+ where state in ('confirmed', 'fixed') and photo is not null
+ order by confirmed desc limit $num");
+ }
+ my $out = '';
+ foreach (@$probs) {
+ my $title = ent($_->{title});
+ $out .= '<a href="/?id=' . $_->{id} .
+ '"><img border="0" src="/photo?tn=1;id=' . $_->{id} .
+ '" alt="' . $title . '" title="' . $title . '"></a>';
+ }
+ return $out;
+}
+
1;
diff --git a/web/alert.cgi b/web/alert.cgi
index 36c921457..39754826f 100755
--- a/web/alert.cgi
+++ b/web/alert.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: alert.cgi,v 1.18 2007-09-25 11:19:29 matthew Exp $
+# $Id: alert.cgi,v 1.19 2007-09-25 11:53:04 matthew Exp $
use strict;
use Standard;
@@ -153,7 +153,8 @@ but will only appear in the "Within the boundary" alert for the county council.'
my $checked = '';
$checked = ' checked' if $q->param('feed') && $q->param('feed') eq "local:$x:$y";
- my $pics = alert_recent_photos($e, $n, $dist);
+ my $pics = Page::recent_photos(5, $e, $n, $dist);
+ $out .= '<div id="alert_photos"><h2>Photos of recent nearby reports</h2>' . $pics . '</div>' if $pics;
<<EOF;
<h1>Local RSS feeds and email alerts for &lsquo;$input_h{pc}&rsquo;</h1>
@@ -242,16 +243,8 @@ EOF
return $out if $q->referer() =~ /fixmystreet\.com/;
- my $probs = select_all("select id, title from problem
- where state in ('confirmed', 'fixed') and photo is not null
- order by confirmed desc limit 8");
- $out .= '<h2>Some photos of recent reports</h2>' if @$probs;
- foreach (@$probs) {
- my $title = ent($_->{title});
- $out .= '<img border="0" src="/photo?tn=1;id=' . $_->{id} .
- '" alt="' . $title . '" title="' . $title . '"> ';
- }
-
+ my $recent_photos = Page::recent_photos(10);
+ $out .= "<div id='alert_recent'><h2>Some photos of recent reports</h2>$recent_photos</div>" if $recent_photos;
return $out;
}
@@ -377,21 +370,3 @@ sub alert_do_subscribe {
return Page::send_email($email, undef, 'alert', %h);
}
-sub alert_recent_photos {
- my ($e, $n, $dist) = @_;
- my $probs = select_all("select id, title
- from problem_find_nearby(?, ?, ?) as nearby, problem
- where nearby.problem_id = problem.id
- and state in ('confirmed', 'fixed') and photo is not null
- order by confirmed desc limit 5", $e, $n, $dist);
- my $out = '';
- $out .= '<div id="alert_photos"><h2>Photos of recent nearby reports</h2>' if @$probs;
- foreach (@$probs) {
- my $title = ent($_->{title});
- $out .= '<img border="0" src="/photo?tn=1;id=' . $_->{id} .
- '" alt="' . $title . '" title="' . $title . '"> ';
- }
- $out .= '</div>' if @$probs;
- return $out;
-}
-
diff --git a/web/css.css b/web/css.css
index 965449fb6..de97f9999 100644
--- a/web/css.css
+++ b/web/css.css
@@ -235,7 +235,7 @@ ul#error {
width: 48%;
margin-bottom: 1em;
}
-#front_recent img {
+#front_recent img, #alert_recent img {
margin-right: 0.25em;
margin-bottom: 0.25em;
}
diff --git a/web/index.cgi b/web/index.cgi
index 7680d8685..c2134b511 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.165 2007-09-25 11:19:29 matthew Exp $
+# $Id: index.cgi,v 1.166 2007-09-25 11:53:04 matthew Exp $
use strict;
use Standard;
@@ -136,16 +136,9 @@ EOF
<div id="front_recent">
EOF
- my $probs = select_all("select id, title from problem
- where state in ('confirmed', 'fixed') and photo is not null
- order by confirmed desc limit 3");
- $out .= '<h2>Photos of recent reports</h2>' if @$probs;
- foreach (@$probs) {
- my $title = ent($_->{title});
- $out .= '<a href="/?id=' . $_->{id} .
- '"><img border="0" src="/photo?tn=1;id=' . $_->{id} .
- '" alt="' . $title . '" title="' . $title . '"></a>';
- }
+ my $recent_photos = Page::recent_photos(3);
+ $out .= "<h2>Photos of recent reports</h2>$recent_photos" if $recent_photos;
+
$probs = select_all("select id,title from problem
where state in ('confirmed', 'fixed')
order by confirmed desc limit 5");