From 4d2a17e0dce1085115e638e2719a00dcdf09daf8 Mon Sep 17 00:00:00 2001 From: Jan-Tarek Butt Date: Wed, 18 Jul 2018 06:38:25 +0200 Subject: [PATCH] gluon-config-mode-geo-location-with-map: integrate a location picker map into the config-mode. Signed-off-by: Jan-Tarek Butt --- .../gluon-config-mode-geo-location/Makefile | 56 ++++++- .../check_site.lua | 1 - .../gluon-config-mode-geo-location/i18n/de.po | 30 ---- .../gluon-config-mode-geo-location/i18n/fr.po | 30 ---- .../i18n/gluon-config-mode-geo-location.pot | 19 --- .../config-mode/wizard/0400-geo-location.lua | 63 -------- .../src/0400-geo-location.lua.in | 145 ++++++++++++++++++ .../src/check_site.lua.in | 6 + .../src/de.po.in | 54 +++++++ .../src/fr.po.in | 51 ++++++ .../src/gluon-config-mode-geo-location.pot.in | 32 ++++ 11 files changed, 343 insertions(+), 144 deletions(-) delete mode 100644 package/gluon-config-mode-geo-location/check_site.lua delete mode 100644 package/gluon-config-mode-geo-location/i18n/de.po delete mode 100644 package/gluon-config-mode-geo-location/i18n/fr.po delete mode 100644 package/gluon-config-mode-geo-location/i18n/gluon-config-mode-geo-location.pot delete mode 100644 package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua create mode 100644 package/gluon-config-mode-geo-location/src/0400-geo-location.lua.in create mode 100644 package/gluon-config-mode-geo-location/src/check_site.lua.in create mode 100644 package/gluon-config-mode-geo-location/src/de.po.in create mode 100644 package/gluon-config-mode-geo-location/src/fr.po.in create mode 100644 package/gluon-config-mode-geo-location/src/gluon-config-mode-geo-location.pot.in diff --git a/package/gluon-config-mode-geo-location/Makefile b/package/gluon-config-mode-geo-location/Makefile index a020feb9..81137815 100644 --- a/package/gluon-config-mode-geo-location/Makefile +++ b/package/gluon-config-mode-geo-location/Makefile @@ -6,8 +6,62 @@ PKG_VERSION:=1 include ../gluon.mk define Package/gluon-config-mode-geo-location - TITLE:=Set geographic location of a node + TITLE:=Set geographic location of a node manualy and share it. + CONFLICTS:=+gluon-config-mode-geo-location-with-map DEPENDS:=+gluon-config-mode-core +gluon-node-info endef +define Package/gluon-config-mode-geo-location-with-map + TITLE:=Set geographic location of a node manualy and share it, optionally show a map if internet available. + CONFLICTS:=+gluon-config-mode-geo-location + DEPENDS:=+gluon-config-mode-core +gluon-node-info +gluon-web-osm +endef + +define Build/Configure + $(CP) ./src/* $(PKG_BUILD_DIR)/ + + $(INSTALL_DIR) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location{,-with-map}/{luasrc/lib/gluon/config-mode/wizard/,i18n/} +endef + +define Build/Compile + $(CC) -E -x c -P $(PKG_BUILD_DIR)/0400-geo-location.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua + $(CC) -E -x c -P $(PKG_BUILD_DIR)/gluon-config-mode-geo-location.pot.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/i18n/gluon-config-mode-geo-location.pot + $(CC) -E -x c -P $(PKG_BUILD_DIR)/check_site.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/check_site.lua + $(CC) -E -x c -P $(PKG_BUILD_DIR)/de.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/i18n/de.po + $(CC) -E -x c -P $(PKG_BUILD_DIR)/fr.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/i18n/fr.po + $(call GluonBuildI18N,gluon-config-mode-geo-location,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location/i18n) + $(call GluonSrcDiet,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location/luasrc,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location/luadest/) + + $(CC) -DWITHMAP -E -x c -P $(PKG_BUILD_DIR)/0400-geo-location.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua + $(CC) -DWITHMAP -E -x c -P $(PKG_BUILD_DIR)/gluon-config-mode-geo-location.pot.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/i18n/gluon-config-mode-geo-location-with-map.pot + $(CC) -DWITHMAP -E -x c -P $(PKG_BUILD_DIR)/check_site.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/check_site.lua + $(CC) -DWITHMAP -E -x c -P $(PKG_BUILD_DIR)/de.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/i18n/de.po + $(CC) -DWITHMAP -E -x c -P $(PKG_BUILD_DIR)/fr.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/i18n/fr.po + $(call GluonBuildI18N,gluon-config-mode-geo-location-with-map,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/i18n) + $(call GluonSrcDiet,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/luasrc,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/luadest/) +endef + +define Package/gluon-config-mode-geo-location/install + $(CP) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/luadest/* $(1)/ + $(call GluonInstallI18N,gluon-config-mode-geo-location,$(1)) +endef + +define Package/gluon-config-mode-geo-location-with-map/install + $(CP) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/luadest/* $(1)/ + $(INSTALL_DIR) $(1)/lib/gluon/config-mode/www/static/ + $(LN) /lib/gluon/web/www/static/osm.js $(1)/lib/gluon/config-mode/www/static/osm.js + $(call GluonInstallI18N,gluon-config-mode-geo-location-with-map,$(1)) +endef + +define Package/gluon-config-mode-geo-location/postinst +#!/bin/sh +$(call GluonCheckSite,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location/check_site.lua) +endef + +define Package/gluon-config-mode-geo-location-with-map/postinst +#!/bin/sh +$(call GluonCheckSite,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/check_site.lua) +endef + $(eval $(call BuildPackageGluon,gluon-config-mode-geo-location)) +$(eval $(call BuildPackageGluon,gluon-config-mode-geo-location-with-map)) diff --git a/package/gluon-config-mode-geo-location/check_site.lua b/package/gluon-config-mode-geo-location/check_site.lua deleted file mode 100644 index 9d7c26cb..00000000 --- a/package/gluon-config-mode-geo-location/check_site.lua +++ /dev/null @@ -1 +0,0 @@ -need_boolean(in_site({'config_mode', 'geo_location', 'show_altitude'}), false) diff --git a/package/gluon-config-mode-geo-location/i18n/de.po b/package/gluon-config-mode-geo-location/i18n/de.po deleted file mode 100644 index c8bc906a..00000000 --- a/package/gluon-config-mode-geo-location/i18n/de.po +++ /dev/null @@ -1,30 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: gluon-config-mode-geo-location\n" -"PO-Revision-Date: 2015-03-23 02:18+0100\n" -"Last-Translator: Martin Weinelt \n" -"Language-Team: German\n" -"Language: de\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -msgid "" -"If you want the location of your node to be displayed on the map, you can " -"enter its coordinates here." -msgstr "" -"Um deinen Knoten auf der Karte anzeigen zu können, benötigen wir seine " -"Koordinaten. Hier hast du die Möglichkeit, diese zu hinterlegen." - -msgid "Latitude" -msgstr "Breitengrad" - -msgid "Longitude" -msgstr "Längengrad" - -msgid "Show node on the map" -msgstr "Knoten auf der Karte anzeigen" - -msgid "e.g. %s" -msgstr "z.B. %s" diff --git a/package/gluon-config-mode-geo-location/i18n/fr.po b/package/gluon-config-mode-geo-location/i18n/fr.po deleted file mode 100644 index d3d7c6e8..00000000 --- a/package/gluon-config-mode-geo-location/i18n/fr.po +++ /dev/null @@ -1,30 +0,0 @@ -msgid "" -msgstr "" -"Content-Type: text/plain; charset=UTF-8\n" -"Project-Id-Version: PACKAGE VERSION\n" -"PO-Revision-Date: 2015-08-12 23:30+0100\n" -"Last-Translator:Tobias Bernot \n" -"Language-Team: French\n" -"Language: fr\n" -"MIME-Version: 1.0\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -msgid "" -"If you want the location of your node to be displayed on the map, you can " -"enter its coordinates here." -msgstr "" -"Pour Afficher votre nœud sur la Carte nous avons besoin de ses coordonnées. " -"Ici vous pouvez entrer sa position." - -msgid "Latitude" -msgstr "Latitude" - -msgid "Longitude" -msgstr "Longitude" - -msgid "Show node on the map" -msgstr "Afficher le nœud sur la carte" - -msgid "e.g. %s" -msgstr "Ex: %s" diff --git a/package/gluon-config-mode-geo-location/i18n/gluon-config-mode-geo-location.pot b/package/gluon-config-mode-geo-location/i18n/gluon-config-mode-geo-location.pot deleted file mode 100644 index 7acf7f28..00000000 --- a/package/gluon-config-mode-geo-location/i18n/gluon-config-mode-geo-location.pot +++ /dev/null @@ -1,19 +0,0 @@ -msgid "" -msgstr "Content-Type: text/plain; charset=UTF-8" - -msgid "" -"If you want the location of your node to be displayed on the map, you can " -"enter its coordinates here." -msgstr "" - -msgid "Latitude" -msgstr "" - -msgid "Longitude" -msgstr "" - -msgid "Show node on the map" -msgstr "" - -msgid "e.g. %s" -msgstr "" diff --git a/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua b/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua deleted file mode 100644 index 718e59ee..00000000 --- a/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua +++ /dev/null @@ -1,63 +0,0 @@ -return function(form, uci) - local pkg_i18n = i18n 'gluon-config-mode-geo-location' - local site_i18n = i18n 'gluon-site' - - local site = require 'gluon.site' - - local location = uci:get_first("gluon-node-info", "location") - - local function show_altitude() - if site.config_mode.geo_location.show_altitude(true) then - return true - end - - return uci:get_bool("gluon-node-info", location, "altitude") - end - - local text = site_i18n._translate("gluon-config-mode:geo-location-help") or pkg_i18n.translate( - 'If you want the location of your node to ' .. - 'be displayed on the map, you can enter its coordinates here.' - ) - if show_altitude() then - text = text .. ' ' .. site_i18n.translate("gluon-config-mode:altitude-help") - end - - local s = form:section(Section, nil, text) - - local o - - local share_location = s:option(Flag, "location", pkg_i18n.translate("Show node on the map")) - share_location.default = uci:get_bool("gluon-node-info", location, "share_location") - function share_location:write(data) - uci:set("gluon-node-info", location, "share_location", data) - end - - o = s:option(Value, "latitude", pkg_i18n.translate("Latitude"), pkg_i18n.translatef("e.g. %s", "53.873621")) - o.default = uci:get("gluon-node-info", location, "latitude") - o:depends(share_location, true) - o.datatype = "float" - function o:write(data) - uci:set("gluon-node-info", location, "latitude", data) - end - - o = s:option(Value, "longitude", pkg_i18n.translate("Longitude"), pkg_i18n.translatef("e.g. %s", "10.689901")) - o.default = uci:get("gluon-node-info", location, "longitude") - o:depends(share_location, true) - o.datatype = "float" - function o:write(data) - uci:set("gluon-node-info", location, "longitude", data) - end - - if show_altitude() then - o = s:option(Value, "altitude", site_i18n.translate("gluon-config-mode:altitude-label"), pkg_i18n.translatef("e.g. %s", "11.51")) - o.default = uci:get("gluon-node-info", location, "altitude") - o:depends(share_location, true) - o.datatype = "float" - o.optional = true - function o:write(data) - uci:set("gluon-node-info", location, "altitude", data) - end - end - - return {'gluon-node-info'} -end diff --git a/package/gluon-config-mode-geo-location/src/0400-geo-location.lua.in b/package/gluon-config-mode-geo-location/src/0400-geo-location.lua.in new file mode 100644 index 00000000..1e3eae24 --- /dev/null +++ b/package/gluon-config-mode-geo-location/src/0400-geo-location.lua.in @@ -0,0 +1,145 @@ +return function(form, uci) + local pkg_i18n = i18n 'gluon-config-mode-geo-location' + local site_i18n = i18n 'gluon-site' + + local site = require 'gluon.site' + + local location = uci:get_first("gluon-node-info", "location") + local uci_latitude = uci:get("gluon-node-info", location, "latitude") + local uci_longitude = uci:get("gluon-node-info", location, "longitude") + +#ifdef WITHMAP + + local function show_lon() + if uci_longitude ~= nil then + return uci_longitude + end + if site.config_mode.geo_location.map_lon(false) then + return site.config_mode.geo_location.map_lon() + end + return 0.0 + end + + local function show_lat() + if uci_latitude ~= nil then + return uci_latitude + end + if site.config_mode.geo_location.map_lat(false) then + return site.config_mode.geo_location.map_lat() + end + return 0.0 + end + + local function show_olurl() + if site.config_mode.geo_location.olurl(false) then + return site.config_mode.geo_location.olurl() + end + return 'http://dev.openlayers.org/OpenLayers.js' + end + +#endif + + local function show_altitude() + if site.config_mode.geo_location.show_altitude(true) then + return true + end + return uci:get_bool("gluon-node-info", location, "altitude") + end + + local text = site_i18n._translate("gluon-config-mode:geo-location-help") or pkg_i18n.translate( + 'If you want the location of your node to be displayed on the map, you can ' .. + 'enter its coordinates here. ' .. + +#ifdef WITHMAP + + 'If your PC is connected to the internet you can also click on the map displayed below. ' .. + +#endif + + 'Please keep in mind setting a location can also enhance the network quality.' + ) + + if show_altitude() then + text = text .. ' ' .. site_i18n.translate("gluon-config-mode:altitude-help") + end + +#ifdef WITHMAP + + text = text .. [[ + + + + + ]] + +#endif + + local s = form:section(Section, nil, text) + + + local uci_share_location = uci:get_bool("gluon-node-info", location, "share_location") + + local geolocation = s:option(ListValue, "geolocation", pkg_i18n.translate("Geo-Location")) + geolocation:value("static", pkg_i18n.translate("Static location")) + geolocation:value("none", pkg_i18n.translate("Disabled")) + if uci_latitude == nil and uci_longitude == nil and uci_share_location == false then + geolocation.default = "none" + else + geolocation.default = "static" + end + + local share_location = s:option(Flag, "sharelocation", pkg_i18n.translate("Share your location to see your router on the map")) + share_location.default = uci_share_location + share_location:depends(geolocation, "static") + + local latitude = s:option(Value, "latitude", pkg_i18n.translate("Latitude"), pkg_i18n.translatef("e.g. %s", "50.364931")) + latitude.default = uci_latitude + latitude:depends(geolocation, "static") + latitude.datatype = "float" + + local longitude = s:option(Value, "longitude", pkg_i18n.translate("Longitude"), pkg_i18n.translatef("e.g. %s", "7.606417")) + longitude.default = uci_longitude + longitude:depends(geolocation, "static") + longitude.datatype = "float" + + local altitude; + if show_altitude() then + altitude = s:option(Value, "altitude", site_i18n.translate("gluon-config-mode:altitude-label"), pkg_i18n.translatef("e.g. %s", "11.51")) + altitude.default = uci:get("gluon-node-info", location, "altitude") + altitude:depends(geolocation, "static") + altitude.datatype = "float" + altitude.optional = true + end + function geolocation:write(data) + if data == "static" then + uci:set("gluon-node-info", location, "latitude", latitude.data) + uci:set("gluon-node-info", location, "longitude", longitude.data) + if show_altitude() then + if altitude.data then + uci:set("gluon-node-info", location, "altitude", altitude.data) + else + uci:delete("gluon-node-info", location, "altitude") + end + end + end + if data == "none" then + uci:delete("gluon-node-info", location, "altitude") + uci:delete("gluon-node-info", location, "latitude") + uci:delete("gluon-node-info", location, "longitude") + uci:set("gluon-node-info", location, "share_location", 0) + else + uci:set("gluon-node-info", location, "share_location", share_location.data) + end + end + return {'gluon-node-info'} +end diff --git a/package/gluon-config-mode-geo-location/src/check_site.lua.in b/package/gluon-config-mode-geo-location/src/check_site.lua.in new file mode 100644 index 00000000..fdab8963 --- /dev/null +++ b/package/gluon-config-mode-geo-location/src/check_site.lua.in @@ -0,0 +1,6 @@ +need_boolean(in_site({'config_mode', 'geo_location', 'show_altitude'}), false) +#ifdef WITHMAP +need_string(in_site({'config_mode', 'geo_location', 'olurl'}), false) +need_number(in_site({'config_mode', 'geo_location', 'map_lon'}), false) +need_number(in_site({'config_mode', 'geo_location', 'map_lat'}), false) +#endif diff --git a/package/gluon-config-mode-geo-location/src/de.po.in b/package/gluon-config-mode-geo-location/src/de.po.in new file mode 100644 index 00000000..09c8613d --- /dev/null +++ b/package/gluon-config-mode-geo-location/src/de.po.in @@ -0,0 +1,54 @@ +msgid "" +msgstr "" +#ifdef WITHMAP +"Project-Id-Version: gluon-config-mode-geo-location-with-map\n" +#else +"Project-Id-Version: gluon-config-mode-geo-location\n" +#endif +"PO-Revision-Date: 2017-08-22 12:14+0100\n" +"Last-Translator: Jan-Tarek Butt \n" +"Language-Team: German\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgid "" +"If you want the location of your node to be displayed on the map, you can " +"enter its coordinates here. " +#ifdef WITHMAP +"If your PC is connected to the internet you can also click on the map displayed below. " +#endif +"Please keep in mind setting a location can also enhance the network quality." +msgstr "" +"Um Deinen Router auf der Karte anzeigen zu können, benötigen wir seine " +"Koordinaten. Hier hast Du die Möglichkeit, " +"die Koordinaten händisch zu hinterlegen." +#ifdef WITHMAP +"Wenn dein Computer mit dem du den Router einrichtes am Internet angeschlossen ist, " +"hast du die Möglichkeit auf der unten angezeigten Karte an die stelle zu klicken wo " +"der Router Stehen wird." +#endif +"Bitte berücksichtige das, das setzen einer Position die Netzwerk Qualität verbessern kann." + +msgid "Geo-Location" +msgstr "Geo-Position" + +msgid "Static location" +msgstr "Manuelle Position" + +msgid "Disabled" +msgstr "Deaktiviert" + +msgid "Share your location to see your router on the map" +msgstr "Position für die Karte freigeben" + +msgid "Latitude" +msgstr "Breitengrad" + +msgid "Longitude" +msgstr "Längengrad" + +msgid "e.g. %s" +msgstr "z.B. %s" diff --git a/package/gluon-config-mode-geo-location/src/fr.po.in b/package/gluon-config-mode-geo-location/src/fr.po.in new file mode 100644 index 00000000..dfe3af83 --- /dev/null +++ b/package/gluon-config-mode-geo-location/src/fr.po.in @@ -0,0 +1,51 @@ +msgid "" +msgstr "" +#ifdef WITHMAP +"Project-Id-Version: gluon-config-mode-geo-location-with-map\n" +#else +"Project-Id-Version: gluon-config-mode-geo-location\n" +#endif +"PO-Revision-Date: 2017-08-22 12:14+0100\n" +"Last-Translator: Jan-Tarek Butt \n" +"Language-Team: French\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgid "" +"If you want the location of your node to be displayed on the map, you can " +"enter its coordinates here. " +#ifdef WITHMAP +"If your PC is connected to the internet you can also click on the map displayed below. " +#endif +"Please keep in mind setting a location can also enhance the network quality." +msgstr "" +"Si vous souhaitez que l'emplacement de votre nœud soit affiché sur la carte, vous pouvez " +"entrer ses coordonnées ici." +#ifdef WITHMAP +"Si votre PC est connecté à Internet, vous pouvez également cliquer sur la carte ci-dessous." +#endif +"Gardez à l'esprit que la définition d'un emplacement peut également améliorer la qualité du réseau." + +msgid "Geo-Location" +msgstr "Géolocalisation" + +msgid "Static location" +msgstr "position manuelle" + +msgid "Disabled" +msgstr "Désactivé" + +msgid "Share your location to see your router on the map" +msgstr "Partagez votre emplacement pour voir votre routeur sur la carte" + +msgid "Latitude" +msgstr "Latitude" + +msgid "Longitude" +msgstr "Longitude" + +msgid "e.g. %s" +msgstr "Ex: %s" diff --git a/package/gluon-config-mode-geo-location/src/gluon-config-mode-geo-location.pot.in b/package/gluon-config-mode-geo-location/src/gluon-config-mode-geo-location.pot.in new file mode 100644 index 00000000..c7854807 --- /dev/null +++ b/package/gluon-config-mode-geo-location/src/gluon-config-mode-geo-location.pot.in @@ -0,0 +1,32 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8" + +msgid "" +"If you want the location of your node to be displayed on the map, you can " +"enter its coordinates here. " +#ifdef WITHMAP +"If your PC is connected to the internet you can also click on the map displayed below. " +#endif +"Please keep in mind setting a location can also enhance the network quality." +msgstr "" + +msgid "Geo-Location" +msgstr "" + +msgid "Static location" +msgstr "" + +msgid "Disabled" +msgstr "" + +msgid "Share your location to see your router on the map" +msgstr "" + +msgid "Latitude" +msgstr "" + +msgid "Longitude" +msgstr "" + +msgid "e.g. %s" +msgstr ""