diff --git a/README.md b/README.md index b8e2a8a..4351b66 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,8 @@ This will create a virtual environment, install the necessary dependencies and w If you are using a database other then sqlite you will first need to configure the correct uri to the database in the generated 'config.py' file. Afterwards upgrade the database to the latest version using - python app/haldis.py db upgrade + cd app + python haldis.py db upgrade You can now still seed the database by running diff --git a/app/static/css/main.css b/app/static/css/main.css index 802364e..3c654f3 100644 --- a/app/static/css/main.css +++ b/app/static/css/main.css @@ -3,6 +3,10 @@ body { padding-top: 70px; } +.padding-top { + padding-top: 10px; +} + .darker { background-color: #fafafa; margin-top: 10px; @@ -23,6 +27,21 @@ body { padding-left: 20px; } + +@media(min-width: 768px) and (max-width: 991px){ + /* Make sure the small map in the location page has the same with as the block above */ + .sm-no-side-padding { + padding-left: 0px; + padding-right: 0px; + } +} + +@media(min-width: 992px){ + .md-no-right-padding { + padding-right: 0px; + } +} + .showcase .product { font-size: 16px; } diff --git a/app/static/css/map.css b/app/static/css/map.css index eb42ff5..46adeb4 100644 --- a/app/static/css/map.css +++ b/app/static/css/map.css @@ -1,4 +1,9 @@ -#mapid { +.large-map { min-height: 400px; height: 600px; -} \ No newline at end of file +} + +.small-map { + min-height: 150px; + height: 250px; +} diff --git a/app/static/js/map.js b/app/static/js/map.js index 20f68f4..18344df 100644 --- a/app/static/js/map.js +++ b/app/static/js/map.js @@ -1,11 +1,11 @@ -var map = L.map('mapid').setView([ - 51.0231119, 3.7102741 -], 14); +var map = L.map('mapid'); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map); +let base_request_uri = "https://photon.komoot.de/api/?limit=1&q="; + function performRequest(url, location, success_callback) { var request = new XMLHttpRequest(); request.open('GET', url, true); @@ -52,6 +52,10 @@ let callback = function OSMCallBack(location, data) { marker.on('mouseout', function(env) { marker.closePopup(); }); + + if (location.center) { + map.setView([lat, lon], 14); + } } else { console.log(`Location ${JSON.stringify(location, null, 2)} returned no features, are you sure this is a valid address?`); } @@ -59,7 +63,7 @@ let callback = function OSMCallBack(location, data) { function loadmap(locations) { for (let loc of locations) { - let request_uri = "https://photon.komoot.de/api/?limit=1&q=" + loc.address; + let request_uri = base_request_uri + loc.address; performRequest(request_uri, loc, callback); } } diff --git a/app/templates/location.html b/app/templates/location.html index 3448e98..24f8604 100644 --- a/app/templates/location.html +++ b/app/templates/location.html @@ -5,15 +5,20 @@ {% block container %}
-
-

Location: {{ location.name }}

- : {{ location.address }}
- : {{ location.telephone }}
- : {{ location.website }}
+
+

{{ location.name }}

+ {{ location.address }}
+ {{ location.telephone }}
+ {{ location.website }} {% if not current_user.is_anonymous() %} Create order {% endif %}
+
+ {% if location.address %} +
+ {% endif %} +
@@ -34,3 +39,31 @@
{% endblock %} + +{% block styles %} +{{ super() }} + + +{% endblock %} + +{% block scripts %} +{{super()}} + +{% if location.address %} + + + +{% endif %} +{% endblock %} diff --git a/app/templates/maps.html b/app/templates/maps.html index 1310d12..0c43dd5 100644 --- a/app/templates/maps.html +++ b/app/templates/maps.html @@ -4,7 +4,7 @@ {% import "utils.html" as util %} {% block container %} -
+
{% endblock %} {% block styles %} @@ -28,13 +28,15 @@ loc = { "address": "{{loc.address}}", "name": "{{loc.name}}", - "url": "{{ url_for('location', id=loc.id) }}" + "url": "{{ url_for('location', id=loc.id) }}" }; locations.push(loc); {% endif %} {%- endfor %} +map.setView([51.0231119, 3.7102741], 14); + loadmap(locations); {% endblock %}