From 1b0836da7305ac26b38ed941a957f4310ec96965 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Mon, 7 Dec 2020 23:08:54 +0100 Subject: Added walks --- base.template.html | 2 +- generate | 31 +++ rundev | 1 + walks/gpx/2020-09-25_14-24_Fri.gpx | 41 ++++ walks/gpx/2020-10-20_13-30_Tue.gpx | 14 ++ walks/gpx/2020-10-23_15-25_Fri.gpx | 15 ++ walks/gpx/bigger-loop.gpx | 86 ++++++++ walks/gpx/central-ottignies.gpx | 124 +++++++++++ walks/gpx/herman-blanmont.gpx | 113 ++++++++++ walks/gpx/herman-blanmont_2.gpx | 113 ++++++++++ walks/gpx/herman_leuven.gpx | 79 +++++++ walks/gpx/hmmm.gpx | 21 ++ walks/gpx/little-loop.gpx | 77 +++++++ walks/gpx/promenade-verte.gpx | 424 +++++++++++++++++++++++++++++++++++++ walks/index.template.html | 35 +++ walks/map.template.html | 11 + walks/script.js | 30 +++ walks/style.css | 9 + 18 files changed, 1225 insertions(+), 1 deletion(-) create mode 100644 walks/gpx/2020-09-25_14-24_Fri.gpx create mode 100644 walks/gpx/2020-10-20_13-30_Tue.gpx create mode 100644 walks/gpx/2020-10-23_15-25_Fri.gpx create mode 100644 walks/gpx/bigger-loop.gpx create mode 100644 walks/gpx/central-ottignies.gpx create mode 100644 walks/gpx/herman-blanmont.gpx create mode 100644 walks/gpx/herman-blanmont_2.gpx create mode 100644 walks/gpx/herman_leuven.gpx create mode 100644 walks/gpx/hmmm.gpx create mode 100644 walks/gpx/little-loop.gpx create mode 100644 walks/gpx/promenade-verte.gpx create mode 100644 walks/index.template.html create mode 100644 walks/map.template.html create mode 100644 walks/script.js create mode 100644 walks/style.css diff --git a/base.template.html b/base.template.html index 6f76652..e433dba 100644 --- a/base.template.html +++ b/base.template.html @@ -20,7 +20,7 @@ about blog utilities - walks + walks diff --git a/generate b/generate index d27992f..9ce0ded 100755 --- a/generate +++ b/generate @@ -74,6 +74,7 @@ do echo "Generated post at $post_dst_path" done + # Generate utilities for util_path in utils/* do @@ -88,3 +89,33 @@ do echo "Generated utility at $util_path/index.html" done + + +base_template < walks/index.template.html | + base_template_link 'static/img/favicon.png' | + base_template_link '../static/css/style.css' | + base_template_link 'https://unpkg.com/leaflet@1.7.1/dist/leaflet.css' | + base_template_link 'style.css' > walks/index.html + +[ ! -d walks/maps ] && mkdir walks/maps + +for gpx_path in walks/gpx/* +do + [ ! -f "$gpx_path" ] && continue + map_dst=$(basename "$gpx_path" | cut -d . -f 1 | tr ' ' '-') + map_dst_path="walks/maps/$map_dst.html" + + base_template < walks/map.template.html | + base_template_link '/static/img/favicon.png' | + base_template_link '/static/css/style.css' | + base_template_link '/walks/style.css' | + base_template_link 'https://unpkg.com/leaflet@1.7.1/dist/leaflet.css' | + sed "// a $(basename "$gpx_path")" > $map_dst_path + + sed -i'' "// a\ +
  • \ + view on map \ + $(basename "$gpx_path") \ +
  • " walks/index.html + echo "Generated walk at $gpx_path" +done diff --git a/rundev b/rundev index c50e7d6..83e2d54 100755 --- a/rundev +++ b/rundev @@ -3,6 +3,7 @@ which inotifywait 2> /dev/null 1> /dev/null || { echo 'Could not found inotifywait'; exit 1; } files=$(find . -name '*.template.*') +files="$files generate" ./generate diff --git a/walks/gpx/2020-09-25_14-24_Fri.gpx b/walks/gpx/2020-09-25_14-24_Fri.gpx new file mode 100644 index 0000000..b48cee9 --- /dev/null +++ b/walks/gpx/2020-09-25_14-24_Fri.gpx @@ -0,0 +1,41 @@ + + + + 2020-09-25_14-24_Fri + + + 2020-09-25_14-24_Fri + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/walks/gpx/2020-10-20_13-30_Tue.gpx b/walks/gpx/2020-10-20_13-30_Tue.gpx new file mode 100644 index 0000000..f341c53 --- /dev/null +++ b/walks/gpx/2020-10-20_13-30_Tue.gpx @@ -0,0 +1,14 @@ + + + + 2020-10-20_13-30_Tue + + + 2020-10-20_13-30_Tue + + + + + + + \ No newline at end of file diff --git a/walks/gpx/2020-10-23_15-25_Fri.gpx b/walks/gpx/2020-10-23_15-25_Fri.gpx new file mode 100644 index 0000000..ee9da8b --- /dev/null +++ b/walks/gpx/2020-10-23_15-25_Fri.gpx @@ -0,0 +1,15 @@ + + + + 2020-10-23_15-25_Fri + + + 2020-10-23_15-25_Fri + + + + + + + + \ No newline at end of file diff --git a/walks/gpx/bigger-loop.gpx b/walks/gpx/bigger-loop.gpx new file mode 100644 index 0000000..8ef4b29 --- /dev/null +++ b/walks/gpx/bigger-loop.gpx @@ -0,0 +1,86 @@ + + + + bigger loop + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/walks/gpx/central-ottignies.gpx b/walks/gpx/central-ottignies.gpx new file mode 100644 index 0000000..cb7424c --- /dev/null +++ b/walks/gpx/central-ottignies.gpx @@ -0,0 +1,124 @@ + + + + central-ottignies + + + central-ottignies + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/walks/gpx/herman-blanmont.gpx b/walks/gpx/herman-blanmont.gpx new file mode 100644 index 0000000..d1bec45 --- /dev/null +++ b/walks/gpx/herman-blanmont.gpx @@ -0,0 +1,113 @@ + + + + herman-blanmont + + + herman-blanmont + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/walks/gpx/herman-blanmont_2.gpx b/walks/gpx/herman-blanmont_2.gpx new file mode 100644 index 0000000..ef4af4c --- /dev/null +++ b/walks/gpx/herman-blanmont_2.gpx @@ -0,0 +1,113 @@ + + + + herman-blanmont_2 + + + herman-blanmont_2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/walks/gpx/herman_leuven.gpx b/walks/gpx/herman_leuven.gpx new file mode 100644 index 0000000..f175682 --- /dev/null +++ b/walks/gpx/herman_leuven.gpx @@ -0,0 +1,79 @@ + + + + herman_leuven + + + herman_leuven + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/walks/gpx/hmmm.gpx b/walks/gpx/hmmm.gpx new file mode 100644 index 0000000..b514358 --- /dev/null +++ b/walks/gpx/hmmm.gpx @@ -0,0 +1,21 @@ + + + + hmmm + + + hmmm + + + + + + + + + + + + + + \ No newline at end of file diff --git a/walks/gpx/little-loop.gpx b/walks/gpx/little-loop.gpx new file mode 100644 index 0000000..4106693 --- /dev/null +++ b/walks/gpx/little-loop.gpx @@ -0,0 +1,77 @@ + + + + little_loop + + + little_loop + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/walks/gpx/promenade-verte.gpx b/walks/gpx/promenade-verte.gpx new file mode 100644 index 0000000..92b4e55 --- /dev/null +++ b/walks/gpx/promenade-verte.gpx @@ -0,0 +1,424 @@ + + + + promenade_verte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/walks/index.template.html b/walks/index.template.html new file mode 100644 index 0000000..672262a --- /dev/null +++ b/walks/index.template.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/walks/map.template.html b/walks/map.template.html new file mode 100644 index 0000000..f36418e --- /dev/null +++ b/walks/map.template.html @@ -0,0 +1,11 @@ +
    +
    + +
    + + + + diff --git a/walks/script.js b/walks/script.js new file mode 100644 index 0000000..2df91b0 --- /dev/null +++ b/walks/script.js @@ -0,0 +1,30 @@ +const parser = new DOMParser() +const mapNode = document.getElementById('map') + +const link = mapNode.querySelector('a') +fetch(link.href) + .then(res => res.text()) + .then(content => { + xml = parser.parseFromString(content, 'text/xml') + const points = xml.getElementsByTagName('rte')[0] || xml.getElementsByTagName('trkseg')[0] + const positions = Array.prototype.map.call( + points.children, p => [p.getAttribute('lat'), p.getAttribute('lon')]) + + const anchor = mapNode.getElementsByClassName('map-anchor')[0] + + const map = L.map(anchor).setView([0, 0], 13) + L.tileLayer( + 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + { + attribution: 'Map data © OpenStreetMap', + // maxZoom: 18, + subdomains: ['a', 'b', 'c'], + id: 'test/' + link.href, + // tileSize: 512, + // zoomOffset: -1, + // accessToken: 'your.mapbox.access.token' + }).addTo(map); + + const polyline = L.polyline(positions, {color: 'red'}).addTo(map); + map.fitBounds(polyline.getBounds()); + }) diff --git a/walks/style.css b/walks/style.css new file mode 100644 index 0000000..d3e0572 --- /dev/null +++ b/walks/style.css @@ -0,0 +1,9 @@ +.map-anchor { + margin-top: 20px; + height: 80vh; +} + +.view-on-map { + margin-right: 20px; + text-transform: capitalize; +} -- cgit