luci-0.8: merge r4605 and r4606
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 25 May 2009 14:01:31 +0000 (14:01 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 25 May 2009 14:01:31 +0000 (14:01 +0000)
modules/freifunk/htdocs/luci-static/resources/freifunk-map/hna.gif [new file with mode: 0644]
modules/freifunk/htdocs/luci-static/resources/freifunk-map/node.gif [new file with mode: 0644]
modules/freifunk/luasrc/controller/freifunk/freifunk.lua
modules/freifunk/luasrc/view/freifunk-map/frame.htm [new file with mode: 0644]
modules/freifunk/luasrc/view/freifunk-map/map.htm [new file with mode: 0644]
modules/freifunk/root/etc/init.d/freifunk

diff --git a/modules/freifunk/htdocs/luci-static/resources/freifunk-map/hna.gif b/modules/freifunk/htdocs/luci-static/resources/freifunk-map/hna.gif
new file mode 100644 (file)
index 0000000..818780d
Binary files /dev/null and b/modules/freifunk/htdocs/luci-static/resources/freifunk-map/hna.gif differ
diff --git a/modules/freifunk/htdocs/luci-static/resources/freifunk-map/node.gif b/modules/freifunk/htdocs/luci-static/resources/freifunk-map/node.gif
new file mode 100644 (file)
index 0000000..f64ab16
Binary files /dev/null and b/modules/freifunk/htdocs/luci-static/resources/freifunk-map/node.gif differ
index 6c8911b76fdf42d6a5f60b462cd1d7bd5be330de..fd61bb3bdef7244547922a6c9947c4336225dbc1 100644 (file)
@@ -71,6 +71,9 @@ function index()
        page.target = cbi("freifunk/contact")
        page.title  = "Kontakt"
        page.order  = 40
+
+       entry({"freifunk", "map"}, template("freifunk-map/frame"), translate("freifunk_map", "Karte"), 50)
+       entry({"freifunk", "map", "content"}, template("freifunk-map/map"), nil, 51)
 end
 
 local function fetch_olsrd()
diff --git a/modules/freifunk/luasrc/view/freifunk-map/frame.htm b/modules/freifunk/luasrc/view/freifunk-map/frame.htm
new file mode 100644 (file)
index 0000000..9ec4f1c
--- /dev/null
@@ -0,0 +1,21 @@
+<%+header%>
+
+<%
+       local has_latlon = false
+       local uci = require "luci.model.uci".cursor()
+       uci:foreach("olsrd", "LoadPlugin", function(s)
+               if s.library == "olsrd_nameservice.so.0.3" and s.latlon_file then
+                       has_latlon = true
+               end
+       end)
+%>
+
+<% if has_latlon then %>
+       <iframe style="width:100%; height:640px; border:none" src="<%=luci.dispatcher.build_url("freifunk/map/content")%>"></iframe>
+<% else %>
+       <h2><%:freifunk_map_error Map Error%></h2>
+       <p><%:freifunk_map_nodata The OLSRd service is not configured to capture position data from the network.<br />
+               Please make sure that the nameservice plugin is properly configured and that the <em>latlon_file</em> option is enabled.%></p>
+<% end %>
+
+<%+footer%>
diff --git a/modules/freifunk/luasrc/view/freifunk-map/map.htm b/modules/freifunk/luasrc/view/freifunk-map/map.htm
new file mode 100644 (file)
index 0000000..7ecf495
--- /dev/null
@@ -0,0 +1,97 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+       <head>
+               <title>Map</title>
+       </head>
+
+       <body style="margin:0">
+               <script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1" type="text/javascript"></script>
+               <script type="text/javascript">
+                       var alias = new Array;
+                       var points = new Array;
+                       var unkpos = new Array;
+                       var lineid = 0;
+                       onload=new Function("if(null!=window.ffmapinit)ffmapinit();");
+
+                       function Mid(mainip,aliasip)
+                       {
+                               alias[aliasip]=mainip;
+                       }
+
+                       function Node(mainip,lat,lon,ishna,hnaip,name)
+                       {
+                               points[mainip] = new VELatLong(lat, lon);
+                               map.AddPushpin(new VEPushpin(mainip, points[mainip],
+                               '<%=luci.config.main.resourcebase%>/freifunk-map/'+(ishna?'hna':'node')+'.gif', 'Node:'+name,
+                               '<br><img src="<%=luci.config.main.resourcebase%>/freifunk-map/'+(ishna?'hna':'node')+'.gif">'+
+                               '<br>IP:'+mainip+'<br>DefGW:'+hnaip));
+                       }
+
+                       function Self(mainip,lat,lon,ishna,hnaip,name)
+                       {
+                               //map.SetDashboardSize(VEDashboardSize.Small);
+                               map.LoadMap(new VELatLong(lat, lon), 15, VEMapStyle.Hybrid);
+                               map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
+                               map.ShowMiniMap(14, 474);
+                               Node(mainip,lat,lon,ishna,hnaip,name);
+                       }
+
+                       function Link(fromip,toip,lq,nlq,etx)
+                       {
+                               if (0==lineid && null!=window.ffmapstatic) ffmapstatic();
+                               if (null != alias[toip]) toip = alias[toip];
+                               if (null != alias[fromip]) fromip = alias[fromip];
+                               if (null != points[fromip] && null != points[toip])
+                               {
+                                       var w = 1;
+                                       if (etx < 4) w++;
+                                       if (etx < 2) w++;
+                                       map.AddPolyline(new VEPolyline('id'+lineid, [points[fromip], points[toip]],
+                                       new VEColor(102,Math.floor(lq*255.0),Math.floor(nlq*255.0),1.0), w));
+                               }
+                               else
+                               {
+                                       if (null == points[toip]) unkpos[toip] = '';
+                                       if (null == points[fromip]) unkpos[fromip] = '';
+                               }
+                               lineid++;
+                       }
+
+                       function PLink(fromip,toip,lq,nlq,etx,lata,lona,ishnaa,latb,lonb,ishnab)
+                       {
+                               Link(fromip,toip,lq,nlq,etx);
+                       }
+
+                       function ffmapinit()
+                       {
+                               if(null!=window.map)map.Dispose();
+                               map = new VEMap('ffmap');
+                               <%
+                                       local fd
+                                       local uci = require "luci.model.uci".cursor()
+
+                                       uci:foreach("olsrd", "LoadPlugin", function(s)
+                                               if s.library == "olsrd_nameservice.so.0.3" and s.latlon_file then
+                                                       fd = io.open(s.latlon_file)
+                                               end
+                                       end)
+
+                                       if fd then
+                                               while true do
+                                                       local ln = fd:read("*l")
+                                                       if not ln then break end
+                                                       write(ln)
+                                               end
+                                               fd:close()
+                                       end
+                               %>
+                       }
+
+                       function ffgoto(ip)
+                       {
+                               map.SetCenter(points[ip]);
+                       }
+               </script>
+               <div id="ffmap" style="position:relative; width:100%; height:640px;"></div>
+       </body>
+</html>
index 3a668b11f5dc9f931838ca2a7bb6616753edc97c..8b280cd51f0d7bf1c3ed03ee32665524deec6b94 100755 (executable)
@@ -24,7 +24,7 @@ boot() {
        }
 
        grep -q '/usr/sbin/ff_mapupdate' /etc/crontabs/root || {
-               echo "17 * * * *        /usr/sbin/ff_mapupdate >> /etc/crontabs/root
+               echo "17 * * * *        /usr/sbin/ff_mapupdate" >> /etc/crontabs/root
        }
 
        [ -f /etc/rc.local ] && . /etc/rc.local