Skip to content

Commit

Permalink
gluon-config-mode-geo-location: rebase on master
Browse files Browse the repository at this point in the history
  • Loading branch information
2tata committed Jul 18, 2018
1 parent 3569f12 commit 908efde
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 165 deletions.
108 changes: 107 additions & 1 deletion package/gluon-config-mode-geo-location/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))
1 change: 0 additions & 1 deletion package/gluon-config-mode-geo-location/check_site.lua

This file was deleted.

6 changes: 0 additions & 6 deletions package/gluon-config-mode-geo-location/jssrc/build.js

This file was deleted.

70 changes: 0 additions & 70 deletions package/gluon-config-mode-geo-location/jssrc/src/osm.js

This file was deleted.

This file was deleted.

39 changes: 21 additions & 18 deletions package/gluon-config-mode-geo-location/src/0400-geo-location.lua.in
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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 ' ..
Expand All @@ -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 .. [[
<div id="locationPickerMap" style="width:100%; height:300px; display: none;"></div>
<script src="]] .. show_olurl() .. [["></script>
<script src="/static/gluon/osm.js"></script>
<script>
<script type="text/javascript" src="]] .. show_olurl() .. [["></script>
<script type="text/javascript" src="/static/osm.js"></script>
<script type="text/javascript">
var latitude=]] .. show_lon() .. ",longitude=" .. show_lat() .. [[;
document.addEventListener("DOMContentLoaded", showMap, false);
setInterval(function() {
Expand All @@ -89,13 +92,13 @@ return function(form, uci)

local uci_share_location = uci:get_bool("gluon-node-info", location, "share_location")

local geolocation = s:option(ListValue, "geolocation", translate("Geo-Location"))
local geolocation = s:option(ListValue, "geolocation", pkg_i18n.translate("Geo-Location"))
#ifdef WITHGELOC
geolocation:value("automatic", translate("Automatic (geolocator)"))
geolocation:value("auto_static", translate("Automatic & Static"))
geolocation:value("automatic", pkg_i18n.translate("Automatic (geolocator)"))
geolocation:value("auto_static", pkg_i18n.translate("Automatic & Static"))
#endif
geolocation:value("static", translate("Static location"))
geolocation:value("none", translate("Disabled"))
geolocation:value("static", pkg_i18n.translate("Static location"))
geolocation:value("none", pkg_i18n.translate("Disabled"))
#ifdef WITHGELOC
local auto_location = uci:get_bool("geolocator", "settings", "auto_location")
local static_location = uci:get_bool("geolocator", "settings", "static_location")
Expand All @@ -118,7 +121,7 @@ return function(form, uci)
end
#endif

local share_location = s:option(Flag, "sharelocation", translate("Share your location to see your router on the map"))
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
#ifdef WITHGELOC
share_location:depends(geolocation, "automatic")
Expand All @@ -128,27 +131,27 @@ return function(form, uci)

#ifdef WITHGELOC
--[[ -- Currently not available
o = s:option(DummyValue, "automatic_disc", " ", translatef("Automaticaly location service over wifi."))
o = s:option(DummyValue, "automatic_disc", " ", pkg_i18n.translatef("Automaticaly location service over wifi."))
o:depends(geolocation, "automatic")
o.description = translatef("Automaticaly location service over wifi.")
o.description = pkg_i18n.translatef("Automaticaly location service over wifi.")
--]]

local interval = s:option(Value, "interval", translate("Interval in minutes"), translatef("Set refresh interval"))
local interval = s:option(Value, "interval", pkg_i18n.translate("Interval in minutes"), pkg_i18n.translatef("Set refresh interval"))
interval.default = uci:get_first("geolocator", "settings", "refresh_interval")
interval:depends(geolocation, "automatic")
interval:depends(geolocation, "auto_static")
interval.datatype = "uinteger"
#endif

local latitude = s:option(Value, "latitude", translate("Latitude"), translatef("e.g. %s", "50.364931"))
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")
#ifdef WITHGELOC
latitude:depends(geolocation, "auto_static")
#endif
latitude.datatype = "float"

local longitude = s:option(Value, "longitude", translate("Longitude"), translatef("e.g. %s", "7.606417"))
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")
#ifdef WITHGELOC
Expand All @@ -158,7 +161,7 @@ return function(form, uci)

local altitude;
if show_altitude() then
altitude = s:option(Value, "altitude", translate("gluon-config-mode:altitude-label"), translatef("e.g. %s", "11.51"))
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")
#ifdef WITHGELOC
Expand Down
Loading

0 comments on commit 908efde

Please sign in to comment.