Pelican plugin to embed OpenStreetMap maps in Markdown articles using a {% place %} shortcode.
Project description
pelican-osm
pelican-osm is a Pelican plugin that allows you to embed OpenStreetMap (OSM) maps into your Markdown or reStructuredText articles using a simple {% place %} shortcode. The plugin integrates with Leaflet.js and provides a lightweight, open-source alternative to Google Maps for your Pelican blogs.
Features
- Embed interactive maps from OpenStreetMap.
- Simple shortcode syntax:
{% place <key> %}. - Supports multiple places per article.
- Customizable place data using a YAML file (`places.yaml``).
- Works in Markdown and reStructuredText articles.
- Minimal external dependencies (PyYAML, Pelican).
Installation
Using pip:
pip install pelican-osm
Usage
1. Create a places.yaml file
Place this file in your Pelican content`` folder (PATH) or specify a custom path viapelicanconf.py`.
Example places.yaml:
cafe:
name: "My Cafe"
lat: 25.0503164
lon: 121.5253053
park:
name: "Nice Park"
lat: 24.5
lon: 120.9
2. Add the shortcode to your articles
In Markdown or reStructuredText:
I visited this cafe:
{% place cafe %}
And also went to the park:
{% place park %}
The plugin will replace the shortcode with an interactive map and a caption.
3. Add Leaflet.js and CSS to your templates
pelican-osm does not automatically inject scripts and styles.
Add the following to your `base.html`` (or relevant template):
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css">
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
<script src="/static/pelican_osm/js/map-init.js"></script>
<link rel="stylesheet" href="/static/pelican_osm/css/map.css">
Make sure map-init.js and map.css are available in your `output/static/pelican_osm`` folder.
This happens automatically when you build your site with Pelican if the plugin is installed.
4. Optional configuration
You can customize the shortcode name or the YAML file path in pelicanconf.py:
OSM_PLUGIN_SHORTCODE = "osm" # default is "place"
OSM_PLUGIN_PLACES = "data/places.yaml" # default is "places.yaml"
Example Output
The shortcode:
{% place cafe %}
Produces:
<div class="map-block">
<div class="map" style="height:320px;" data-lat="25.0503164" data-lon="121.5253053" data-name="My Cafe"></div>
<div class="map-caption">My Cafe</div>
</div>
With Leaflet.js loaded, this renders an interactive map.
Requirements
- Python >= 3.11
- Pelican >= 4.5
- PyYAML >= 6.0
License
MIT License © Wei Lee
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pelican_osm-0.2.0.tar.gz.
File metadata
- Download URL: pelican_osm-0.2.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6c9ee8c0bf0d80dd6f3762b55e8e1a84e423b2614b0e5303e5155788ac5f9d3
|
|
| MD5 |
3de36ea6e0e8c70e5acbb4417978f900
|
|
| BLAKE2b-256 |
486745be33709f56c77ffe62546d82b04c44bb1b334c87c19e08d300375e5a1a
|
Provenance
The following attestation bundles were made for pelican_osm-0.2.0.tar.gz:
Publisher:
publish-to-pypi.yaml on Lee-W/pelican-osm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pelican_osm-0.2.0.tar.gz -
Subject digest:
a6c9ee8c0bf0d80dd6f3762b55e8e1a84e423b2614b0e5303e5155788ac5f9d3 - Sigstore transparency entry: 956270787
- Sigstore integration time:
-
Permalink:
Lee-W/pelican-osm@849588cf41d287aa838f49256455b34bb562c116 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/Lee-W
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yaml@849588cf41d287aa838f49256455b34bb562c116 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pelican_osm-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pelican_osm-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c795af8cf36e7c645106c977618c058181e0a1478d62618a92e330c3121bbcf9
|
|
| MD5 |
e85d41a537b4cec5b686ec25405daecc
|
|
| BLAKE2b-256 |
c10e202e1eb59833b505f8140d96c4513fb2b1ec0e433cce23a40156b912c693
|
Provenance
The following attestation bundles were made for pelican_osm-0.2.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yaml on Lee-W/pelican-osm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pelican_osm-0.2.0-py3-none-any.whl -
Subject digest:
c795af8cf36e7c645106c977618c058181e0a1478d62618a92e330c3121bbcf9 - Sigstore transparency entry: 956270791
- Sigstore integration time:
-
Permalink:
Lee-W/pelican-osm@849588cf41d287aa838f49256455b34bb562c116 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/Lee-W
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yaml@849588cf41d287aa838f49256455b34bb562c116 -
Trigger Event:
push
-
Statement type: