from pelican import signals import geohash_tools as gh hashes = [] def generate_geohash(generator): for article in generator.articles: if "location" in article.metadata: lat, lon = [float(i) for i in article.metadata['location'].replace(' ', '').split(',')] article.metadata['lat'] = lat article.metadata['lon'] = lon article.metadata['geohash'] = gh.encode(lat, lon, 11) if article.metadata['geohash'] not in hashes: article.slug = gh.encode(lat, lon, 11) hashes.append(article.metadata['geohash']) def register(): signals.article_generator_finalized.connect(generate_geohash)