Class: App::Views::PlaceShow

Inherits:
Layout
  • Object
show all
Includes:
App::ViewHelpers
Defined in:
app/views/place_show.rb

Instance Method Summary collapse

Methods included from App::ViewHelpers

#add_book_button, #admin, #admin?, #app_name, #base_url, #book_permitted, #count_instances, #external_link_glyph, #flag_modal_button, #flags, #get_instances_per_page, #instance_permitted, #instances_by_names, #javascripts, #json_file, #logged_in, #metadata, #not_empty, #place_permitted, #places, #rendered_flash, #stylesheets, #user_name

Methods inherited from Layout

#page_title, #selected_item

Instance Method Details

#added_onObject


27
28
29
# File 'app/views/place_show.rb', line 27

def added_on
  @place.added_on
end

#booksObject


80
81
82
# File 'app/views/place_show.rb', line 80

def books
  @books.map{|b| { book_slug: b.slug, book_title: b.title, instances: Instance.where(place: @place, book: b).all.length } }
end

#bounding_boxObject

def source_button

@place.source =~ URI::regexp(['http', 'https'])

end


64
65
66
# File 'app/views/place_show.rb', line 64

def bounding_box
  @place.bounding_box_string
end

#bounding_box_polygonObject


107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'app/views/place_show.rb', line 107

def bounding_box_polygon
  if @place.bounding_box_string =~ /^\[.*\]$/
    string = "var boundingBox = L.polygon(["
    bbox = @place.bounding_box_string.gsub(/^\[/, "").gsub(/\]$/, "").split(", ").map{ |n| n.to_f }
    string = string + "[#{bbox[1]}, #{bbox[0]}],"
    string = string + "[#{bbox[1]}, #{bbox[3]}],"
    string = string + "[#{bbox[2]}, #{bbox[3]}],"
    string = string + "[#{bbox[2]}, #{bbox[0]}]"
    string = string + "], {color: '#fff', opacity: 0.8}).addTo(map);\n"
    string = string + "map.fitBounds([[#{bbox[1]}, #{bbox[3]}], [#{bbox[2]}, #{bbox[0]}]]);\n"
  else
    ""
  end
end

#confidenceObject


39
40
41
# File 'app/views/place_show.rb', line 39

def confidence
  @place.confidence
end

#flaggedObject


52
53
54
# File 'app/views/place_show.rb', line 52

def flagged
  @place.flagged
end

#geonameidObject


68
69
70
# File 'app/views/place_show.rb', line 68

def geonameid
  @place.geonameid
end

#latObject


31
32
33
# File 'app/views/place_show.rb', line 31

def lat
  @place.lat
end

#lonObject


35
36
37
# File 'app/views/place_show.rb', line 35

def lon
  @place.lon
end

#map_heightObject


122
123
124
# File 'app/views/place_show.rb', line 122

def map_height
  "300px;"
end

#nameObject


11
12
13
# File 'app/views/place_show.rb', line 11

def name
  @place.name
end

#nicknamesObject


76
77
78
# File 'app/views/place_show.rb', line 76

def nicknames
  Nickname.where(place: @place).map(:name).to_sentence
end

#nicknames_sentenceObject


102
103
104
105
# File 'app/views/place_show.rb', line 102

def nicknames_sentence
  names = @place.nicknames.map{|n| n.name}
  names.to_sentence
end

#noteObject


19
20
21
# File 'app/views/place_show.rb', line 19

def note
  @place.note
end

#note?Boolean


15
16
17
# File 'app/views/place_show.rb', line 15

def note?
  @place.note.nil? || @place.note.length == 0 ? false : true
end

#object_id_for_flagObject


7
8
9
# File 'app/views/place_show.rb', line 7

def object_id_for_flag
  @place.id
end

#slugObject


43
44
45
# File 'app/views/place_show.rb', line 43

def slug
  @place.slug
end

#sourceObject


56
57
58
# File 'app/views/place_show.rb', line 56

def source
  @place.source
end

84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'app/views/place_show.rb', line 84

def source_link
  if @place.source == "GeoNames"
    url = "http://www.geonames.org/#{geonameid}/"
    text = "GeoNames (#{geonameid})"
  elsif @place.source =~ /\A#{URI::regexp(['http', 'https'])}\z/
    url = @place.source
    text = @place.source
  else
    url = nil
    text = @place.source
  end
  if url.nil?
    text
  else
    "<a href='#{url}' target='_blank'>#{text} <span class='fa fa-external-link' aria-hidden='true'></span></a>"
  end
end

#typeObject


47
48
49
50
# File 'app/views/place_show.rb', line 47

def type  # object.class.to_s.downcase

  "place"
end

#userObject


23
24
25
# File 'app/views/place_show.rb', line 23

def user
  @place.user.name
end

#w3wObject


72
73
74
# File 'app/views/place_show.rb', line 72

def w3w
  @place.what3word
end