/
milieu.rb
65 lines (58 loc) · 2.25 KB
/
milieu.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
helpers do
def user_times_at
if logged_in?
times = 'You have checked in here '
if !@suser.checkins.nil? && !@suser.checkins[params[:_id]].nil?
times << @suser.checkins[params[:_id]]['count'].to_s
else
times << '0'
end
times << ' times'
if !@suser.checkins.nil? && !@suser.checkins[params[:_id]].nil?
times << '<br/>You checked in here last on ' << @suser.checkins[params[:_id]]['last_checkin_ts'].to_s
end
else
times = 'Please <a href=\'/login\'>login</a> to join them.'
end
end
def gmap_multi_url(venues, options = {})
default_options = {:zoom => 1, :center => MapLocation.new(:longitude => 0.0, :latitude => 0.0)}
map = GoogleStaticMap.new(default_options.merge(options))
if venues != nil
venues.each do |venue|
maplocation = MapLocation.new(:longitude => venue['location']['geo'][0], :latitude => venue['location']['geo'][1] )
map.markers << MapMarker.new(:color => "blue", :location => maplocation)
end
end
map.url(:auto)
end
def gmap_url(venue, options = {})
maplocation = MapLocation.new(:longitude => venue['location']['geo'][0], :latitude => venue['location']['geo'][1] )
default_options = {:zoom => 16, :center => maplocation}
map = GoogleStaticMap.new(default_options.merge(options))
map.markers << MapMarker.new(:color => "blue", :location => maplocation)
map.url(:auto)
end
def pager(cur_path)
str_out = '<div class="pagination pagination-centered"> <ul>'
if @page != 1
str_out << "<li><a href='#{cur_path}/" << (@page - 1).to_s << "'>Prev</a></li>"
else
str_out << "<li class='disabled'><a>Prev</a></li>"
end
(1 .. @total_pages).each do |i|
if @page == i
str_out << "<li class='active'><a href='#{cur_path}/#{i}'>#{i}</a></li>"
else
str_out << "<li><a href='#{cur_path}/#{i}'>#{i}</a></li>"
end
end
if @page != @total_pages
str_out << "<li><a href='#{cur_path}/" << (@page + 1).to_s << "'>Next</a></li>"
else
str_out << "<li class='disabled'><a>Next</a></li>"
end
str_out << "</ul></div>"
str_out
end
end