diff --git a/package/gluon-config-mode-geo-location/Makefile b/package/gluon-config-mode-geo-location/Makefile index a020feb917..85cca1d598 100644 --- a/package/gluon-config-mode-geo-location/Makefile +++ b/package/gluon-config-mode-geo-location/Makefile @@ -6,8 +6,114 @@ 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-geloc-map +gluon-config-mode-geo-location-with-geloc +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 +gluon-config-mode-geo-location-with-geloc-map +gluon-config-mode-geo-location-with-geloc + DEPENDS:=+gluon-config-mode-core +gluon-node-info +gluon-web-osm +endef + +define Package/gluon-config-mode-geo-location-with-geloc + TITLE:=Set geographic location of a node manualy or automatically recive geo locations via surrunding wifis and share it. + CONFLICTS:=+gluon-config-mode-geo-location +gluon-config-mode-geo-location-with-geloc-map +gluon-config-mode-geo-location-with-map + DEPENDS:=+gluon-config-mode-core +gluon-node-info +gluon-geolocator +endef + +define Package/gluon-config-mode-geo-location-with-geloc-map + TITLE:=Set geographic location of a node manualy or automatically recive geo locations via surrunding wifis and share it, optionally show a map if internet available. + CONFLICTS:=+gluon-config-mode-geo-location +gluon-config-mode-geo-location-with-geloc +gluon-config-mode-geo-location-with-map + DEPENDS:=+gluon-config-mode-core +gluon-node-info +gluon-geolocator +gluon-web-osm +endef + +define Build/Configure + $(CP) ./src/* $(PKG_BUILD_DIR)/ + + $(INSTALL_DIR) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location{,-with-map,-with-geloc,-with-geloc-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/) + + $(CC) -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/0400-geo-location.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua + $(CC) -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/gluon-config-mode-geo-location.pot.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/i18n/gluon-config-mode-geo-location-with-geloc.pot + $(CC) -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/check_site.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/check_site.lua + $(CC) -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/de.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/i18n/de.po + $(CC) -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/fr.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/i18n/fr.po + $(call GluonBuildI18N,gluon-config-mode-geo-location-with-geloc,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/i18n) + $(call GluonSrcDiet,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/luasrc,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/luadest/) + + $(CC) -DWITHMAP -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/0400-geo-location.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua + $(CC) -DWITHMAP -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/gluon-config-mode-geo-location.pot.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/i18n/gluon-config-mode-geo-location-with-geloc-map.pot + $(CC) -DWITHMAP -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/check_site.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/check_site.lua + $(CC) -DWITHMAP -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/de.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/i18n/de.po + $(CC) -DWITHMAP -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/fr.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/i18n/fr.po + $(call GluonBuildI18N,gluon-config-mode-geo-location-with-geloc-map,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/i18n) + $(call GluonSrcDiet,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/luasrc,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-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-with-geloc/install + $(CP) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/luadest/* $(1)/ + $(call GluonInstallI18N,gluon-config-mode-geo-location-with-geloc,$(1)) +endef + +define Package/gluon-config-mode-geo-location-with-geloc-map/install + $(CP) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-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-geloc-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 + +define Package/gluon-config-mode-geo-location-with-geloc/postinst +#!/bin/sh +$(call GluonCheckSite,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/check_site.lua) +endef + +define Package/gluon-config-mode-geo-location-with-geloc-map/postinst +#!/bin/sh +$(call GluonCheckSite,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/check_site.lua) +endef + $(eval $(call BuildPackageGluon,gluon-config-mode-geo-location)) +$(eval $(call BuildPackageGluon,gluon-config-mode-geo-location-with-map)) +$(eval $(call BuildPackageGluon,gluon-config-mode-geo-location-with-geloc)) +$(eval $(call BuildPackageGluon,gluon-config-mode-geo-location-with-geloc-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 9d7c26cb40..0000000000 --- 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/jssrc/build.js b/package/gluon-config-mode-geo-location/jssrc/build.js deleted file mode 100644 index 146bbd10ee..0000000000 --- a/package/gluon-config-mode-geo-location/jssrc/build.js +++ /dev/null @@ -1,6 +0,0 @@ -({ - baseUrl: "src", - include: "osm.js", - optimize: "uglify2", - out: "osm.js", -}) diff --git a/package/gluon-config-mode-geo-location/jssrc/src/osm.js b/package/gluon-config-mode-geo-location/jssrc/src/osm.js deleted file mode 100644 index 978d859f18..0000000000 --- a/package/gluon-config-mode-geo-location/jssrc/src/osm.js +++ /dev/null @@ -1,70 +0,0 @@ -function findObj(name) { - list = document.getElementsByClassName("gluon-input-text"); - for(i = 0; i < list.length; i++) { - item = list.item(i); - if(item.id.indexOf(name) >= 0) return item; - } - return false; -} - -function showMap() { - if ("object" == typeof OpenLayers && false !== findObj("longitude")) { - document.getElementById("locationPickerMap").style.display = "block"; - var e = new OpenLayers.Projection("EPSG:4326"), - a = new OpenLayers.Projection("EPSG:900913"), - t = 12, - n = new OpenLayers.Layer.Markers("Markers"); - OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { - defaultHandlerOptions: { - single: !0, - "double": !1, - pixelTolerance: 0, - stopSingle: !1, - stopDouble: !1 - }, - initialize: function() { - this.handlerOptions = OpenLayers.Util.extend({}, this.defaultHandlerOptions), OpenLayers.Control.prototype.initialize.apply(this, arguments), this.handler = new OpenLayers.Handler.Click(this, { - click: this.trigger - }, this.handlerOptions) - }, - trigger: function(t) { - var i = osmMap.getLonLatFromPixel(t.xy); - oLon = findObj("longitude"); - oLat = findObj("latitude"); - lonlat1 = new OpenLayers.LonLat(i.lon, i.lat).transform(a, e), - oLon.value = lonlat1.lon, - oLat.value = lonlat1.lat, - n.clearMarkers(), - n.addMarker(new OpenLayers.Marker(i)), - oLon.className = oLon.className.replace(/ gluon-input-invalid/g, ""), - oLat.className = oLat.className.replace(/ gluon-input-invalid/g, ""); - //Anyone knows how to trigger the change event? - //oLon.onChange() - //oLat.onChange() - } - }), osmMap = new OpenLayers.Map("locationPickerMap", { - controls: [new OpenLayers.Control.Navigation, new OpenLayers.Control.PanZoomBar, new OpenLayers.Control.MousePosition], - maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34), - numZoomLevels: 18, - maxResolution: 156543, - units: "m", - projection: a, - displayProjection: e - }); - var i = new OpenLayers.Layer.OSM("OpenStreetMap"); - osmMap.addLayer(i), osmMap.addLayer(n); - var o = longitude, - r = latitude; - oLon = findObj("longitude"); - oLat = findObj("latitude"); - "" != oLon.value && (o = oLon.value), - "" != oLat.value && (r = oLat.value), - n.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(o, r).transform(e, a))); - var l = new OpenLayers.LonLat(o, r), - d = l.transform(e, a); - osmMap.setCenter(d, t); - var s = new OpenLayers.Control.Click; - osmMap.addControl(s), s.activate() - } else setTimeout(showMap, 1e3) -} - 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 718e59eee7..0000000000 --- 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 index 3215aa4ebe..cfbb6b9eca 100644 --- 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 @@ -1,5 +1,8 @@ return function(form, uci) - local site = require 'gluon.site' + 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") @@ -43,7 +46,7 @@ return function(form, uci) return uci:get_bool("gluon-node-info", location, "altitude") end - local text = translate( + 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 ' .. #ifdef WITHGELOC 'set an automatically localization of your router or ' .. @@ -60,16 +63,16 @@ return function(form, uci) ) if show_altitude() then - text = text .. ' ' .. translate("gluon-config-mode:altitude-help") + text = text .. ' ' .. site_i18n.translate("gluon-config-mode:altitude-help") end #ifdef WITHMAP text = text .. [[ - - - + +