Skip to content

Commit

Permalink
Merge pull request #18 from rl-institut/release/v1.7.0
Browse files Browse the repository at this point in the history
Release v1.7.0
  • Loading branch information
henhuy authored May 13, 2024
2 parents 6152f0e + 696b5ef commit d8238ac
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.bumpversion]
current_version = "1.6.1"
current_version = "1.7.0"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
serialize = ["{major}.{minor}.{patch}"]
search = "{current_version}"
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and the versioning aim to respect [Semantic Versioning](http://semver.org/spec/v

Here is a template for new release sections

## [1.7.0] - 2024-05-13
### Added
- Middleware to prevent 404 errors for missing MVTs

## [1.6.1] - 2024-05-02
### Fixed
- region lines and labels at startup
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,17 @@ Maplibre must be installed (i.e. via npm) and provided as JS framework
MAP_ENGINE_POPUPS = ["results"]
```

5. Add maplibre-gl, pubsub-js and mapengine JS, CSS and JSONs in template by:
5. Add middleware to your middleware setup before Whitenoise middleware (or other static server middleware):
```python
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django_mapengine.django_mapengine.middleware.MapEngineMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
...
]
```

6. Add maplibre-gl, pubsub-js and mapengine JS, CSS and JSONs in template by:
```html
{% block javascript %}
{{ block.super }}
Expand All @@ -98,7 +108,7 @@ Maplibre must be installed (i.e. via npm) and provided as JS framework
{% endblock css %}
```

6. If you want to integrate basemaps to your map add the following to the corresponding places:
7. If you want to integrate basemaps to your map add the following to the corresponding places:
```html
<script src="{% static 'django_mapengine/js/basemaps.js' %}" type="text/javascript"></script>
{% include 'django_mapengine/map_basemaps.html'}
Expand Down
2 changes: 1 addition & 1 deletion django_mapengine/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Map Engine init, holds version"""

__version__ = "1.6.1"
__version__ = "1.7.0"
20 changes: 20 additions & 0 deletions django_mapengine/middleware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Mapengine middleware"""

from django.http import HttpResponse


class MapEngineMiddleware: # pylint: disable=R0903
"""Catches non-existing MVTs and returns empty HTTPResponses instead"""

def __init__(self, get_response):
self.get_response = get_response

def __call__(self, request):
"""
Checks if request is for a distilled MVT and if response is okay.
Otherwise, it returns empty 204 response.
"""
response = self.get_response(request)
if request.path.startswith("/static/mvts") and response.status_code == 404:
return HttpResponse(status=204)
return response
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "django-mapengine"
version = "1.6.1"
version = "1.7.0"
description = "Map engine for maplibre in django"
authors = ["Hendrik Huyskens <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit d8238ac

Please sign in to comment.