Browse Source

ffho-site-auto-select: remove community specific stuff

move geo_default_site to site.conf and add some documentation
Karsten Böddeker 8 years ago
parent
commit
d336156855

+ 16 - 0
ffho/ffho-site-auto-select/ReadMe.md

@@ -0,0 +1,16 @@
+ffho-site-auto-select
+=====================
+
+Autoselect correct site-code by geocoordinates during upgrade and by ``gluon-neighbour-info`` hourly.
+One can specify a default site within site.conf, if the coordinates do not match to any site defined within extra/geo.json.
+
+site.conf
+---------
+
+site_select.geo_default_site : optional
+    - ``'ffho_uml'``
+
+extra/geo.json
+--------------
+
+File with geojson format. The corresponding site_code has to be defined within ``properties`` section as ``"site_code": "ffho_abn"``.

+ 6 - 3
ffho/ffho-site-auto-select/files/lib/gluon/upgrade/003-site-auto-select

@@ -4,8 +4,7 @@ local uci = require('luci.model.uci').cursor()
 local json = require 'luci.json'
 local tools = require 'gluon.site_generate'
 local shape = require 'gluon.pointwithinshape'
-
-local geo_default_site = "ffho_yho"
+local site_conf = require 'gluon.site_conf'
 
 function get_config(file)
   local f = io.open(file)
@@ -47,7 +46,11 @@ function get_site_by_geo(latitude, longitude)
     end
   end
 
-  return geo_default_site
+  if (site_conf.site_select or {}).geo_default_site then
+     return site_conf.site_select.geo_default_site
+  end
+
+  return nil
 end
 
 local currentsite = uci:get('currentsite', 'current', 'name')