From 8d8e6a1494f982b79a1c50a6fce49173fff1d2bb Mon Sep 17 00:00:00 2001 From: surrim Date: Fri, 28 May 2021 19:12:35 +0200 Subject: [PATCH] Updated event_osm to v0.3.7 (#124) * default path for *.gpx files * path description fixed for many paths * escape map parameter * set default category id to "without" * removed not needed "global $serendipity;" * added README.md * updated event_osm to v0.3.7 Co-authored-by: surrim --- serendipity_event_osm/ChangeLog | 9 ++ serendipity_event_osm/README.md | 121 ++++++++++++++++++ serendipity_event_osm/UTF-8/lang_de.inc.php | 2 +- serendipity_event_osm/lang_de.inc.php | 2 +- serendipity_event_osm/lang_en.inc.php | 2 +- serendipity_event_osm/plugin_version.inc.php | 2 +- .../serendipity_event_osm.php | 13 +- .../serendipity_event_static_osm.php | 1 - 8 files changed, 144 insertions(+), 8 deletions(-) create mode 100644 serendipity_event_osm/README.md diff --git a/serendipity_event_osm/ChangeLog b/serendipity_event_osm/ChangeLog index 4cb1791d..b8cd6473 100644 --- a/serendipity_event_osm/ChangeLog +++ b/serendipity_event_osm/ChangeLog @@ -1,3 +1,12 @@ +0.3.7: +--- + +* Added README.md +* Set default category id to "without" +* Escape map parameter +* Path description fixed for many paths +* Default path for *.gpx files + 0.3.6: --- diff --git a/serendipity_event_osm/README.md b/serendipity_event_osm/README.md new file mode 100644 index 00000000..03f1fb5d --- /dev/null +++ b/serendipity_event_osm/README.md @@ -0,0 +1,121 @@ +# OpenStreetMap plugin for Serendipity + +With this plugin you can implement one ore more interactive +maps for geo tagged entries and uploaded \*.gpx files. +The map is build by [OpenLayers][ol], a high-performance +JavaScript library. + +## Setup + +Some plugins are needed to make it work. + +### serendipity_event_geo_json or Geo-JSON object + +First you need a JSON object with all the geo information +for your maps. This can be simple done with the plugin +`serendipity_event_geo_json` or by hand as a JavaScript +global constant like below. + +```javascript +const geo = { + "entries": [ + { + "title": "I love Bochum", + "url": "/archives/12-I-love-Bochum.html", + "date": 1536588060, + "size": 211, + "author": "surrim", + "pos": [51.414369, 6.729898], + "categories": [42] + }, + /* (more entries) */ + ], + "uploads": [ + { + "title": "2021-06-30-essen-bochum.gpx", + "url": "/uploads/my-tour/2021-06-30-essen-bochum.gpx", + "date": 1610319360, + "size": 105144 + }, + /* (more uploads) */ + ] +}; +``` + +### serendipity_event_static_osm + +Next you need `serendipity_event_static_osm`. +It's needed to include all OpenLayers scripts and +stylesheets once. It can also remove all unnecessary things +from \*.gpx files like timestamps and metadata. This +behavior is enabled by default. +Enabling this is highly recommented to minimize traffic and +for uploading tracked data, for example from OsmAnd or +Garmin. +Geo data (including altitudes) will be untouched. + +### serendipity_event_osm + +This plugin can be used to include map instances. You can +set a default map position, zoomlevel, one or +more folders for the \*.gpx files and categories. +It inserts a div-element like below. + +```html +
+``` + +All the div-elements will be processed by the mentioned +static scripts later. +You can display the total distance of all \*.gpx files by +using a span-element like this. + +```html +Total distance: (calculating...) kilometers. +``` + +## How to use + +Now you can enable the `serendipity_event_geotag` plugin to +enter coordinates of your entries. When you paste data like +"45.76697, 4.83519" it will be put into the latitude and +longitude fields. After saving the changes the entry will be +shown on the map. +Uploading \*.gpx files is even simpler. After uploading a +file you will find it on the map. + +## Features + +- Minimap + For faster position changes +- Fullscreen mode + To use all of the pixels of your monitor or smartphone + display +- Zoom + You can use the mouse wheel, double click, use the buttons + or two fingers on touchscreens to zoom +- Scale + Shown to make it easier to see distances +- Rainbow colors + The date of the entries and \*.gpx files is used to + calculate its color by the day of the month. For example + dates at the beginning or end of a month are red, dates in + the middle of a months are cyan +- Interaction + When you click on the map it will display a list of + entries to read and tracks to download. Extra information + like track length and date is shown as a tooltip + +## Author + +Martin Sewelies + +[ol]: https://openlayers.org/ diff --git a/serendipity_event_osm/UTF-8/lang_de.inc.php b/serendipity_event_osm/UTF-8/lang_de.inc.php index f5391538..2ec4c9c6 100644 --- a/serendipity_event_osm/UTF-8/lang_de.inc.php +++ b/serendipity_event_osm/UTF-8/lang_de.inc.php @@ -11,7 +11,7 @@ @define('PLUGIN_EVENT_OSM_CATEGORY_WITHOUT', 'Ohne'); @define('PLUGIN_EVENT_OSM_CATEGORY_ANY', 'Beliebig'); @define('PLUGIN_EVENT_OSM_PATH', 'Pfad'); - @define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Pfad für GPX-Dateien'); + @define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Pfad(e) für GPX-Dateien, getrennt durch Zeilenumbruch'); @define('PLUGIN_EVENT_OSM_LAT', 'Breitengrad (Lat.)'); @define('PLUGIN_EVENT_OSM_LAT_DESCRIPTION', 'Breitengrad für die Mitte der Karte'); @define('PLUGIN_EVENT_OSM_LONG', 'Längengrad (Lon.)'); diff --git a/serendipity_event_osm/lang_de.inc.php b/serendipity_event_osm/lang_de.inc.php index 3609206c..c65a7312 100644 --- a/serendipity_event_osm/lang_de.inc.php +++ b/serendipity_event_osm/lang_de.inc.php @@ -11,7 +11,7 @@ @define('PLUGIN_EVENT_OSM_CATEGORY_WITHOUT', 'Ohne'); @define('PLUGIN_EVENT_OSM_CATEGORY_ANY', 'Beliebig'); @define('PLUGIN_EVENT_OSM_PATH', 'Pfad'); - @define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Pfad für GPX-Dateien'); + @define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Pfad(e) für GPX-Dateien, getrennt durch Zeilenumbruch'); @define('PLUGIN_EVENT_OSM_LAT', 'Breitengrad (Lat.)'); @define('PLUGIN_EVENT_OSM_LAT_DESCRIPTION', 'Breitengrad für die Mitte der Karte'); @define('PLUGIN_EVENT_OSM_LONG', 'Längengrad (Lon.)'); diff --git a/serendipity_event_osm/lang_en.inc.php b/serendipity_event_osm/lang_en.inc.php index 6e37588b..47454732 100644 --- a/serendipity_event_osm/lang_en.inc.php +++ b/serendipity_event_osm/lang_en.inc.php @@ -11,7 +11,7 @@ @define('PLUGIN_EVENT_OSM_CATEGORY_WITHOUT', 'Without'); @define('PLUGIN_EVENT_OSM_CATEGORY_ANY', 'Any'); @define('PLUGIN_EVENT_OSM_PATH', 'Path'); - @define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Path for GPX-files'); + @define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Path(s) for GPX-files, separated by linebreak'); @define('PLUGIN_EVENT_OSM_LAT', 'Latitude'); @define('PLUGIN_EVENT_OSM_LAT_DESCRIPTION', 'Latitude of the center of the map'); @define('PLUGIN_EVENT_OSM_LONG', 'Longitude'); diff --git a/serendipity_event_osm/plugin_version.inc.php b/serendipity_event_osm/plugin_version.inc.php index 4c6d101d..511ad870 100644 --- a/serendipity_event_osm/plugin_version.inc.php +++ b/serendipity_event_osm/plugin_version.inc.php @@ -1,4 +1,4 @@ diff --git a/serendipity_event_osm/serendipity_event_osm.php b/serendipity_event_osm/serendipity_event_osm.php index 95f12e3a..ffd3962f 100644 --- a/serendipity_event_osm/serendipity_event_osm.php +++ b/serendipity_event_osm/serendipity_event_osm.php @@ -65,7 +65,13 @@ || in_array($category_id, $page_categories) ) { - echo '
'.PHP_EOL; + echo '
'.PHP_EOL; } } } @@ -85,6 +91,7 @@ function introspect_config_item($name, &$propbag) { + global $serendipity; switch($name) { case 'title': $propbag->add('type', 'string'); @@ -97,13 +104,13 @@ $propbag->add('name', PLUGIN_EVENT_OSM_CATEGORY); $propbag->add('description', PLUGIN_EVENT_OSM_CATEGORY_DESCRIPTION); $propbag->add('select_values', $this->get_selectable_categories()); - $propbag->add('default', 'all'); + $propbag->add('default', 'without'); break; case 'path': $propbag->add('type', 'text'); $propbag->add('name', PLUGIN_EVENT_OSM_PATH); $propbag->add('description', PLUGIN_EVENT_OSM_PATH_DESCRIPTION); - $propbag->add('default', ''); + $propbag->add('default', $serendipity['serendipityHTTPPath'] . $serendipity['uploadPath']); break; case 'height': $propbag->add('type', 'string'); diff --git a/serendipity_event_osm/serendipity_event_static_osm.php b/serendipity_event_osm/serendipity_event_static_osm.php index 92bd00da..7389c65e 100644 --- a/serendipity_event_osm/serendipity_event_static_osm.php +++ b/serendipity_event_osm/serendipity_event_static_osm.php @@ -37,7 +37,6 @@ function event_hook($event, &$bag, &$eventData, $addData = null) { - global $serendipity; if ($event === 'frontend_header') { echo ' '.PHP_EOL; echo ' '.PHP_EOL;