travlrmap 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'sinatra'
4
+ gem 'httparty'
data/Gemfile.lock ADDED
@@ -0,0 +1,23 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ httparty (0.11.0)
5
+ multi_json (~> 1.0)
6
+ multi_xml (>= 0.5.2)
7
+ multi_json (1.5.0)
8
+ multi_xml (0.5.5)
9
+ rack (1.5.2)
10
+ rack-protection (1.3.2)
11
+ rack
12
+ sinatra (1.4.5)
13
+ rack (~> 1.4)
14
+ rack-protection (~> 1.3)
15
+ tilt (~> 1.3, >= 1.3.3)
16
+ tilt (2.0.1)
17
+
18
+ PLATFORMS
19
+ ruby
20
+
21
+ DEPENDENCIES
22
+ httparty
23
+ sinatra
@@ -0,0 +1,31 @@
1
+ :map:
2
+ :data:
3
+ - europe.yaml
4
+ - america.yaml
5
+ :width: "80%"
6
+ :height: "90%"
7
+ :zoom_control: true
8
+ :map_type_control: true
9
+ :street_view_control: true
10
+ :overview_control: false
11
+ :pan_control: true
12
+
13
+ :views:
14
+ :default:
15
+ :lat: 20
16
+ :lon: 0
17
+ :zoom: 2
18
+ :description: World
19
+ :europe:
20
+ :lat: 48.195387
21
+ :lon: 10.634766
22
+ :zoom: 6
23
+ :description: Europe
24
+
25
+ :types:
26
+ :visit:
27
+ :icon: http://www.google.com/intl/en_us/mapfiles/ms/micons/orange-dot.png
28
+ :transit:
29
+ :icon: http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png
30
+ :lived:
31
+ :icon: http://www.google.com/intl/en_us/mapfiles/ms/micons/green-dot.png
data/config.ru ADDED
@@ -0,0 +1,12 @@
1
+ $: << File.join(File.dirname(__FILE__), "lib")
2
+
3
+ require 'bundler/setup'
4
+
5
+ require 'travlrmap'
6
+ require 'yaml'
7
+
8
+ set :run, false
9
+
10
+ config = YAML.load_file(File.expand_path("../config/travlrmap.yaml", __FILE__))
11
+
12
+ run Travlrmap::SinatraApp.new(config)
@@ -0,0 +1,55 @@
1
+ module Travlrmap
2
+ class SinatraApp < ::Sinatra::Base
3
+ def initialize(config)
4
+ @config = config
5
+ @map = @config[:map]
6
+ @types = @config[:types]
7
+
8
+ load_map
9
+
10
+ super()
11
+ end
12
+
13
+ set :static, true
14
+ set :views, File.join(File.expand_path(File.dirname(__FILE__)), "../..", "views")
15
+ set :public_folder, File.join(File.expand_path(File.dirname(__FILE__)), "../..", "public")
16
+
17
+ helpers do
18
+ include Rack::Utils
19
+
20
+ alias_method :h, :escape_html
21
+ end
22
+
23
+ def load_map
24
+ @points = []
25
+
26
+ Array(@config[:map][:data]).each do |map|
27
+ point_file = File.join(File.expand_path(File.dirname(__FILE__)), "../..", "config", map)
28
+ data = YAML.load_file(point_file)
29
+
30
+ @points.concat(data[:points])
31
+ end
32
+ end
33
+
34
+ def set_map_vars(view)
35
+ @map_view = @config[:views][view]
36
+ @zoom_control = @map[:zoom_control].nil? ? true : @map[:zoom_control]
37
+ @map_type_control = @map[:map_type_control].nil? ? true : @map[:map_type_control]
38
+ @street_view_control = @map[:street_view_control].nil? ? false : @map[:street_view_control]
39
+ @overview_control = @map[:overview_control].nil? ? false : @map[:overview_control]
40
+ @pan_control = @map[:pan_control].nil? ? true : @map[:pan_control]
41
+ end
42
+
43
+ get '/view/:view' do
44
+ params[:view] ? view = params[:view].intern : view = :default
45
+
46
+ set_map_vars(view)
47
+ erb :index
48
+ end
49
+
50
+ get '/' do
51
+ set_map_vars(:default)
52
+ erb :index
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ module Travlmap
2
+ VERSION = "0.0.1"
3
+ end
data/lib/travlrmap.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ Bundler.require(:default)
5
+
6
+ module Travlrmap
7
+ require 'travlrmap/version'
8
+ require 'travlrmap/sinatra_app'
9
+ end
Binary file