13 lines
No EOL
557 B
Python
13 lines
No EOL
557 B
Python
from pelican import signals
|
|
import geohash_tools as gh
|
|
|
|
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['latlon'] = article.metadata['location'].replace(' ', '')
|
|
article.metadata['geohash'] = gh.encode(lat, lon, 11)
|
|
article.slug = gh.encode(lat, lon, 11)
|
|
|
|
def register():
|
|
signals.article_generator_finalized.connect(generate_geohash) |