email bluesky fediverse feed

Revised Blogofile GeoBlogging used on this site, simplified and with new, cleaner url parsing ;)

Controller file

Firstly create a new Controller file (same as before), say which contains:

from blogofile.cache import bf
def run():
    write_map(bf.posts, bf.util.path_join(bf.config.blog_path), "map.mako")
def write_map(posts, root, template):
    root = root.lstrip("/")
    path = bf.util.path_join(root,"map.html")"Writing map: "+path)
    bf.writer.materialize_template(template, path, {"posts":posts, "root":root})

Map file

and now the new map.mako template file (full screen as before). This uses simple "," to break the url for parsing the latitude, longitude and zoom. Also, there is only the need for a single "psn" line in the article's mako header for the lat/long coordinates (the zoom level is handled by the post.mako file - in the link behind the GeoTagIcon):

<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="keywords" content="some stuff" />
<meta name="copyright" content="Copyright (c) Anon" />
<meta name="generator" content="Blogofile" />
<meta name="viewport" content="width=device-width" />
<link rel="alternate" type="application/rss+xml" title="Your Site" href="" />
<link rel="alternate" type="application/rss+xml" title="Your Site geo" href="" />
<style type="text/css">
html, body, #map_canvas {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: Skia, Helvetica, Tahoma sans-serif;
    font-size: 1em;
    color: #003300;
h2 {
    text-shadow: 1px 2px 5px rgba(0, 0, 0, 0.5);
    text-align: center;
a {
    color: #485c70;
a:hover, a:active {
    <script type="text/javascript" src=""></script>
    <script type="text/JavaScript">
        if ( {
            var qs =;
            var url = qs.split(',',3);
            var lat = parseFloat(url[0]);
            var lng = parseFloat(url[1]);
            var zmn = parseFloat(url[2]);
            var vars = url.vars;
        else {
            var lat = 42.94033923363181;
            var lng = -2.8125;
            var zmn = 3;
            var map;
    function initialize() {
        map = new google.maps.Map(document.getElementById("map_canvas"), {
            center: new google.maps.LatLng(lat,lng),
            zoom: zmn,
            mapTypeId: google.maps.MapTypeId.TERRAIN
    var georssLayer = new google.maps.KmlLayer('', {preserveViewport:true});
    var ctaLayer = new google.maps.KmlLayer('', {preserveViewport:true});
    var ctaLayer = new google.maps.KmlLayer('', {preserveViewport:true});
% for post in posts:
% if hasattr(post, "psn"):
    var marker${} = new google.maps.Marker({
        position: new google.maps.LatLng(${post.psn}),
        map: map,
        title: "${post.title}"
    var infowindow${} = new google.maps.InfoWindow({
        content: ('<h2><a href="${bf.config.blog_url}${post.permapath()}">${post.title}</a></h2><p>${post.excerpt}</p>')
    google.maps.event.addListener(marker${}, 'click', function() {
% endif
% endfor
    var url = getAttribute("url");
    <body onload="initialize()">
        <div id="map_canvas"></div>
           <a href="/" title="home"><img src="" alt="home" style="border:0; position: absolute; bottom: 35px; left: 3px" /></a>
           <a href="" title="GeoRSS"><img src="" alt="georss" style="position:absolute; bottom: 35px; left: 37px" /></a>
        <h2><a href="" title="reset map" style="position: absolute; bottom: 15px; right: 3px">RESET</a></h2>


You may need to alter one or two things:

(There are some things absent from the previous mapping effort, such as crosshairs and centre coordinate readout, these may come later.)

Article link

This needs inserting somewhere in the Article meta - in the post.mako file - it actually only focusses onto the map where the marker has been placed by the map code. Thus, you may manually make links for the body of your posts using any lat, long and zoom values which are parsed by the map code to focus on any bit of the map.

    % if hasattr(post, "psn"):
      <a href="${post.psn},13" title="location on my Map"><img src="" alt="geotag" /></a>
    % endif