root/platform/tdiary/plugin/everytrail.rb @ 37030

Revision 37030, 1.9 kB (checked in by sho, 4 years ago)

collected copyright.

Line 
1#
2# everytrail.rb: plugin embedding trip map on everytrail.com.
3#
4# Copyright (C) 2010 TADA Tadashi <t@tdtds.jp>
5# You can redistribute it and/or modify it under GPL2.
6#
7
8def everytrail( trip_id, label = nil, size = [400,300] )
9        size.collect! {|i| i.to_i }
10        size[0] = 400 if size[0] == 0
11        size[0] = 300 if @conf.iphone?
12        size[1] = 300 if size[1] == 0
13        l = label ? %Q|<a href="http://www.everytrail.com/view_trip.php?trip_id=#{h trip_id}">#{h label}</a>| : ''
14        %Q|<iframe src="http://www.everytrail.com/iframe2.php?trip_id=#{h trip_id}&width=#{size[0]}&height=#{size[1]}" marginheight=0 marginwidth=0 frameborder=0 scrolling=no width=#{size[0]} height=#{size[1]}>#{l}</iframe>|
15end
16
17def everytrail_widget( trip_id, latitude = nil, longtitude = nil, label = nil, size = [400, 300] )
18   if @conf.iphone?
19      return ''
20   end
21
22   size.collect! {|i| i.to_i }
23   size[0] = 400 if size[0] == 0
24   size[1] = 300 if size[1] == 0
25   r = label ? %Q|<h3><a href="http://www.everytrail.com/view_trip.php?trip_id=#{h trip_id}">#{h label}</a></h3>| : ''
26   lat_param = latitude ? "&startLat=#{latitude}" : ''
27   lon_param = longtitude ? "&startLon=#{longtitude}" : ''
28
29   r << %Q|<object width="#{size[0]}" height="#{size[1]}" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"><param name="movie" value="http://www.everytrail.com/swf/widget.swf"/><param name="FlashVars" value="tripId=#{h trip_id}&units=metric&mode=0#{lon_param}#{lat_param}&stats=off&mapType=Terrain"><embed src="http://www.everytrail.com/swf/widget.swf" quality="high" width="#{size[0]}" height="#{size[1]}" FlashVars="tripId=#{h trip_id}&units=metric&mode=0#{lon_param}#{lat_param}&stats=off&mapType=Terrain" play="true"  quality="high" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"></embed></object><br/><a href="http://www.everytrail.com" >Map your trip with EveryTrail</a>|
30      return r
31end
32
Note: See TracBrowser for help on using the browser.