source: freethepostcode.org/html/ruby/currentlistlinked.rb @ 726

Last change on this file since 726 was 726, checked in by Dominic Hargreaves, 10 years ago

initial import

  • Property svn:executable set to *
File size: 967 bytes
Line 
1#!/usr/bin/ruby
2
3
4#
5#
6#
7#  This is meant to be run by cron daily and piped to current_list_links in the
8#  html root like
9#
10#  2 0 * * * /home/steve/bin/currentlistlinked.rb > /var/www/freethepostcode.org/currentlistlinked
11#
12
13
14require 'singleton'
15require 'cgi'
16load 'dao.rb'
17
18print '<html><body>'
19puts '# Generated daily. Click a postcode to see its location and leave a <br>
20        comment, or click OSM Map to see the location in OpenStreetMap'
21
22dao = OSM::Dao.instance
23
24res = dao.call_sql { 'select format(avg(lat),6) as lat, format(avg(lon),6) as lon, part1, part2 from codes where confirmed = 1 group by part1, part2;' }
25
26
27res.each_hash do |row|
28  puts "<p>  <a href=\"http://www.kirit.com/Postcode/UK:/#{row['part1']}%20#{row['part2']}\">"
29  puts "#{row['lat']} #{row['lon']} #{row['part1']} #{row['part2']}</a>"
30
31  puts "<a href=\"http://www.openstreetmap.org/index.html?lat=#{row['lat']}&lon=#{row['lon']}&zoom=11\">OSM Map</a>"
32end
33
34puts '</body></html>' 
Note: See TracBrowser for help on using the repository browser.