From 948cb37d267f7204ba4976f52fc6554221937143 Mon Sep 17 00:00:00 2001 From: Skud Date: Sat, 23 Nov 2013 15:34:42 +1100 Subject: [PATCH 1/5] Specify ruby version for heroku's benefit --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index 357d3522e..ef4f5c5d0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,7 @@ source 'https://rubygems.org' +ruby "1.9.3" + gem 'bundler', '>=1.1.5' gem 'rails', '3.2.13' From c2435cfb8a1f3298eb46fd123c9c3829cef25c71 Mon Sep 17 00:00:00 2001 From: Amy Hendrix Date: Sun, 13 Jul 2014 21:08:44 -0400 Subject: [PATCH 2/5] catch up with upstream --- .travis.yml | 22 +---- CONTRIBUTORS.md | 3 + Gemfile | 9 +- Gemfile.lock | 6 +- app/assets/javascripts/crops.js.coffee | 3 - app/assets/javascripts/places.js.erb | 58 ++++++------ app/assets/stylesheets/application.css | 2 + .../bootstrap_and_overrides.css.less | 93 +++++++++++++++++-- app/controllers/crops_controller.rb | 8 +- app/models/crop.rb | 2 +- app/models/member.rb | 4 +- app/views/crops/_photos.html.haml | 4 +- app/views/crops/_varieties.html.haml | 2 +- app/views/crops/show.html.haml | 27 ++++-- app/views/layouts/_footer.html.haml | 6 +- app/views/photos/_thumbnail.html.haml | 17 ++-- app/views/places/index.html.haml | 4 +- app/views/places/show.html.haml | 8 +- config/database.yml | 18 ++-- config/environments/travis.rb | 1 - lib/tasks/growstuff.rake | 12 ++- spec/models/crop_spec.rb | 3 + spec/views/crops/show.html.haml_spec.rb | 34 ++++++- spec/views/places/index.html.haml_spec.rb | 2 +- spec/views/places/show.html.haml_spec.rb | 2 +- 25 files changed, 227 insertions(+), 123 deletions(-) delete mode 100644 app/assets/javascripts/crops.js.coffee delete mode 120000 config/environments/travis.rb diff --git a/.travis.yml b/.travis.yml index 8031ac51d..7746d903e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ --- language: ruby -bundler_args: --without development assets -env: RAILS_ENV=travis GROWSTUFF_SITE_NAME="Growstuff (travis)" +env: GROWSTUFF_SITE_NAME="Growstuff (travis)" +bundler_args: --without development assets production staging rvm: - 2.1.1 before_script: @@ -9,21 +9,3 @@ before_script: script: - bundle exec rake db:migrate --trace - bundle exec rspec spec/ - -# after_success: -# - if [[ "$TRAVIS_BRANCH" == "dev" ]]; then git remote add heroku git@heroku.com:growstuff-dev.git -# - wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh -# - echo "Host heroku.com" >> ~/.ssh/config -# - echo " StrictHostKeyChecking no" >> ~/.ssh/config -# - echo " CheckHostIP no" >> ~/.ssh/config -# - echo " UserKnownHostsFile=/dev/null" >> ~/.ssh/config -# - heroku keys:clear -# - yes | heroku keys:add -# - yes | git push heroku dev:master -# - heroku run rake db:migrate -# - heroku restart -# - fi - -# env: -# global: -# secure: "QFQbCdNGyjeatp/H0j0y0oGiue45fpG2w6eA2QAbq2RmvhabgXbd5WIobN90\ndrae3S7TRxPDpMpus90icykX6EzOTLXCEvaC4rh9pCcRktj3SZqq5b9rVTvs\n1MvlS6HhtsVqsrKjQUb0WmPpnganIzTs0RtGaQspo2joPJO18A4=" diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 2014f5e11..d62f62787 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -38,3 +38,6 @@ submit the change with your pull request. - Yaw Boakye / [yawboakye](https://github.com/yawboakye) - Ryan Clark / [IAMRYO](https://github.com/IAMRYO) - Marty Hines / [martyhines](https://github.com/martyhines) +- Mackenzie "Maco" King / [maco](https://github.com/maco) +- Amelia Greenhall / [ameliagreenhall](https://github.com/ameliagreenhall) +- Barb Natali / [barbnatali](https://github.com/barbnatali) diff --git a/Gemfile b/Gemfile index 050142197..b4ff013a0 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,8 @@ gem 'leaflet-rails' gem 'leaflet-markercluster-rails' gem 'unicorn' # http server +gem 'pg' + gem 'figaro' # for handling config via ENV variables gem 'cancan' # for checking member privileges @@ -29,7 +31,6 @@ gem 'active_utils', '1.0.5', :path => 'vendor/gems/active_utils-1.0.5' group :production, :staging do - gem 'pg' gem 'newrelic_rpm' gem 'dalli' gem 'memcachier' @@ -113,15 +114,11 @@ gem 'bootstrap-datepicker-rails' # For connecting to other services (eg Twitter) gem 'omniauth' gem 'omniauth-twitter' -gem 'omniauth-flickr' +gem 'omniauth-flickr', '>= 0.0.15' gem 'rake', '>= 10.0.0' group :development, :test do - gem 'sqlite3' # database engine -end - -group :development, :test, :travis do gem 'haml-rails' # HTML templating language gem 'rspec-rails', '~> 2.12.1' # unit testing framework gem 'webrat' # provides HTML matchers for view tests diff --git a/Gemfile.lock b/Gemfile.lock index 322d6e40a..e2bd35b31 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -180,7 +180,7 @@ GEM omniauth (1.2.1) hashie (>= 1.2, < 3) rack (~> 1.0) - omniauth-flickr (0.0.13) + omniauth-flickr (0.0.15) omniauth-oauth (~> 1.0) omniauth-oauth (1.0.1) oauth @@ -251,7 +251,6 @@ GEM multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.9) term-ansicolor (1.3.0) tins (~> 1.0) therubyracer (0.12.1) @@ -318,7 +317,7 @@ DEPENDENCIES memcachier newrelic_rpm omniauth - omniauth-flickr + omniauth-flickr (>= 0.0.15) omniauth-twitter pg rack (~> 1.4.5) @@ -327,7 +326,6 @@ DEPENDENCIES rake (>= 10.0.0) rspec-rails (~> 2.12.1) sass-rails (~> 3.2.3) - sqlite3 therubyracer (~> 0.12) twitter-bootstrap-rails! uglifier (>= 1.0.3) diff --git a/app/assets/javascripts/crops.js.coffee b/app/assets/javascripts/crops.js.coffee deleted file mode 100644 index 761567942..000000000 --- a/app/assets/javascripts/crops.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/javascripts/places.js.erb b/app/assets/javascripts/places.js.erb index bde724b19..f4758c561 100644 --- a/app/assets/javascripts/places.js.erb +++ b/app/assets/javascripts/places.js.erb @@ -1,37 +1,39 @@ -places_base_path = "/places"; -things_to_map = location.pathname + '.json'; -mapbox_map_id = "<%= Growstuff::Application.config.mapbox_map_id %>"; -base_url = "https://c.tiles.mapbox.com/v3/" + mapbox_map_id + "/{z}/{x}/{y}.png"; -nominatim_base_url = 'http://nominatim.openstreetmap.org/search/'; -nominatim_user_agent_email = "<%= Growstuff::Application.config.user_agent_email %>"; +if (document.getElementById("placesmap") !== null) { + places_base_path = "/places"; + mapbox_map_id = "<%= Growstuff::Application.config.mapbox_map_id %>"; + mapbox_base_url = "https://c.tiles.mapbox.com/v3/" + mapbox_map_id + "/{z}/{x}/{y}.png"; + nominatim_base_url = 'http://nominatim.openstreetmap.org/search/'; + nominatim_user_agent_email = "<%= Growstuff::Application.config.user_agent_email %>"; -L.Icon.Default.imagePath = '/assets' + L.Icon.Default.imagePath = '/assets' -if (location.pathname === places_base_path) { //places index page - map = L.map('map').setView([0.0, -0.0], 2); - showMap(map); -} else { // specific place page - place = location.pathname.replace(places_base_path + "/", ''); - nominatim_query_url = nominatim_base_url + place; - nominatim_options = { - format: "json", - callback: "placeholder", - limit: 1, - email: nominatim_user_agent_email - }; - $.getJSON(nominatim_query_url, nominatim_options, function(data) { - map = L.map('map').setView([data[0].lat, data[0].lon], 5); - showMap(map); - }) + if (location.pathname === places_base_path) { //places index page + placesmap = L.map('placesmap').setView([0.0, -0.0], 2); + showMap(placesmap); + } else { // specific place page + place = location.pathname.replace(places_base_path + "/", ''); + nominatim_query_url = nominatim_base_url + place; + nominatim_options = { + format: "json", + callback: "placeholder", + limit: 1, + email: nominatim_user_agent_email + }; + $.getJSON(nominatim_query_url, nominatim_options, function(data) { + placesmap = L.map('placesmap').setView([data[0].lat, data[0].lon], 5); + showMap(placesmap); + }) + } } -function showMap(map) { - L.tileLayer(base_url, { +function showMap(placesmap) { + L.tileLayer(mapbox_base_url, { attribution: 'Map data © OpenStreetMap contributors under ODbL | Map imagery © Mapbox', maxZoom: 18 - }).addTo(map); - markers = new L.MarkerClusterGroup({showCoverageOnHover: false}); + }).addTo(placesmap); + markers = new L.MarkerClusterGroup({showCoverageOnHover: false, maxClusterRadius: 20 }); + things_to_map = location.pathname + '.json'; $.getJSON(things_to_map, function(members) { $.each(members, function(i, m) { if (m.latitude && m.longitude) { @@ -44,5 +46,5 @@ function showMap(map) { }); }); - map.addLayer(markers); + placesmap.addLayer(markers); } diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 677a7521d..c1cc5e005 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -9,3 +9,5 @@ *= require leaflet.markercluster.default *= require_tree . */ + + diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less index a0970bd89..2540cf57c 100644 --- a/app/assets/stylesheets/bootstrap_and_overrides.css.less +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less @@ -2,8 +2,7 @@ // this padding needs to be done before the responsive stuff is imported body { - padding-top: @navbarHeight + 10px; - padding-bottom: @navbarHeight + 10px; + padding-top: @navbarHeight + 15px; } @import "twitter/bootstrap/responsive"; @@ -151,7 +150,7 @@ p.stats { margin-left: 0px; } -#map { +#placesmap, #cropmap { height: 500px; } @@ -164,6 +163,86 @@ p.stats { color: @brown; } +.crop-thumbnail { + position:relative; + padding:0; + img { + width:100%; + } + .text { + display:none; + color:#000; + position:absolute; + bottom:0; + background:rgba(0, 0, 0, 0.8); + width:100%; + margin:0; + } + p { + padding:5px; + margin:0; + color:#fff; + } + &:hover { + .text { + display:block; + } + } +} + + +li.crop-hierarchy { + list-style-type: disc; +} + +.navbar-inner { + border-width: 0px !important; +} + +.navbar-bottom { + margin: 40px 0px 0px 0px !important; +} + +// navbar centering +.navbar .nav { + float: none; + display: inline-block; + *display: inline; + /* ie7 fix */ + *zoom: 1; + /* hasLayout ie7 trigger */ + vertical-align: top; + > li { + float: none; + display: inline-block; + *display: inline; + /* ie7 fix */ + *zoom: 1; + /* hasLayout ie7 trigger */ + vertical-align: top; + } +} + +.navbar-inner { + border: none !important; + background-image: none !important; + -webkit-border-radius: 0px; + -moz-border-radius: 0px; + border-radius: 0px; +} + +.navbar-bottom .navbar-inner { + text-align: center; +} + +.navbar-bottom .container{ + padding: 20px 0px 40px 0px; +} + +.navbar-search{ + padding-bottom: 7px; +} + // Overrides applying only to mobile view @media only screen and (max-width: 767px) { @@ -176,8 +255,10 @@ p.stats { #map { height: 300px; } -} -li.crop-hierarchy { - list-style-type: disc; + .navbar .nav { + >li { + display: block; + } + } } diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index 94941c9ff..3bb020dda 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -10,7 +10,7 @@ class CropsController < ApplicationController @crops = Crop.includes(:scientific_names, {:plantings => :photos}).paginate(:page => params[:page]) respond_to do |format| - format.html + format.html format.json { render :json => @crops } format.rss do @crops = Crop.recent.includes(:scientific_names, :creator) @@ -62,7 +62,11 @@ class CropsController < ApplicationController respond_to do |format| format.html # show.html.haml - format.json { render json: @crop } + format.json do + render :json => @crop.to_json(:include => { + :plantings => { :include => { :owner => { :only => [:id, :login_name, :location, :latitude, :longitude] }}} + }) + end end end diff --git a/app/models/crop.rb b/app/models/crop.rb index b5340c71b..ba2b8acaa 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -174,7 +174,7 @@ class Crop < ActiveRecord::Base # searches for crops whose names match the string given # just uses SQL LIKE for now, but can be made fancier later def self.search(query) - where("name LIKE ?", "%#{query}%") + where("name ILIKE ?", "%#{query}%") end end diff --git a/app/models/member.rb b/app/models/member.rb index 1bacddbb6..608b32286 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -143,8 +143,8 @@ class Member < ActiveRecord::Base if @flickr.nil? flickr_auth = auth('flickr') if flickr_auth - FlickRaw.api_key = ENV['FLICKR_KEY'] - FlickRaw.shared_secret = ENV['FLICKR_SECRET'] + FlickRaw.api_key = ENV['GROWSTUFF_FLICKR_KEY'] + FlickRaw.shared_secret = ENV['GROWSTUFF_FLICKR_SECRET'] @flickr = FlickRaw::Flickr.new @flickr.access_token = flickr_auth.token @flickr.access_secret = flickr_auth.secret diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index 6ff8adb82..864560eb8 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -1,6 +1,6 @@ .row-fluid - if !crop.photos.empty? %ul.thumbnails - - crop.photos.first(4).each do |p| - %li.span2 + - crop.photos.first(3).each do |p| + %li.span4 = render :partial => "photos/thumbnail", :locals => { :photo => p } diff --git a/app/views/crops/_varieties.html.haml b/app/views/crops/_varieties.html.haml index 73068bd6c..434ea3c1f 100644 --- a/app/views/crops/_varieties.html.haml +++ b/app/views/crops/_varieties.html.haml @@ -5,6 +5,6 @@ = succeed "." do = link_to crop.parent, crop.parent - if crop.varieties.count > 0 - %p + %h3 Varieties: = render :partial => 'hierarchy', :locals => { :display_crops => [ crop ] } diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index a8aeb5c93..c174f325e 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -16,16 +16,7 @@ = render :partial => 'photos', :locals => { :crop => @crop } - = render :partial => 'varieties', :locals => { :crop => @crop } - - = render :partial => 'grown_for', :locals => { :crop => @crop } - - = render :partial => 'planting_advice', :locals => { :crop => @crop } - - - %h2 Who's planted this crop? - - %p + %h2 - if @crop.plantings.size > 0 = @crop.name.titleize has been planted @@ -34,8 +25,18 @@ - else Nobody is growing this yet. You could be the first! + %p + Only plantings by members who have set their locations are shown on this map. + - if current_member && current_member.location.blank? + = link_to "Set your location.", edit_member_registration_path + + + %div#cropmap - if @crop.plantings.size > 0 + + %h2 All plantings + - @crop.plantings.each do |p| = render :partial => "plantings/thumbnail", :locals => { :planting => p, :title => 'owner' } @@ -65,6 +66,12 @@ - if can? :edit, @crop = link_to 'Add', new_scientific_name_path( :crop_id => @crop.id ), { :class => 'btn btn-mini' } + = render :partial => 'varieties', :locals => { :crop => @crop } + + = render :partial => 'grown_for', :locals => { :crop => @crop } + + = render :partial => 'planting_advice', :locals => { :crop => @crop } + %h4 More information %ul %li= link_to 'Wikipedia (English)', @crop.en_wikipedia_url diff --git a/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml index 3cb6b1af3..b30d8e461 100644 --- a/app/views/layouts/_footer.html.haml +++ b/app/views/layouts/_footer.html.haml @@ -1,7 +1,7 @@ -.navbar.navbar-fixed-bottom +.navbar.navbar-bottom .navbar-inner - .container - %ul.nav + .container.center + %ul.nav.text-center %li= link_to "About", "http://wiki.growstuff.org/index.php/About%20Growstuff" %li= link_to "Contact", url_for(:controller => '/about', :action => 'contact') %li= link_to "Terms of Service", url_for(:controller => '/policy', :action => 'tos') diff --git a/app/views/photos/_thumbnail.html.haml b/app/views/photos/_thumbnail.html.haml index e0526d8cd..b6dace133 100644 --- a/app/views/photos/_thumbnail.html.haml +++ b/app/views/photos/_thumbnail.html.haml @@ -1,9 +1,10 @@ -.thumbnail(style='height: 220px') +.thumbnail.crop-thumbnail = link_to image_tag(photo.thumbnail_url, :alt => photo.title, :class => 'img-rounded'), photo - %p - = link_to photo.title, photo - %br/ - %small - %i - by - = link_to photo.owner, photo.owner + .text + %p + = link_to photo.title, photo + %br/ + %small + %i + by + = link_to photo.owner, photo.owner diff --git a/app/views/places/index.html.haml b/app/views/places/index.html.haml index 6b3e0d73c..135d3a113 100644 --- a/app/views/places/index.html.haml +++ b/app/views/places/index.html.haml @@ -1,4 +1,4 @@ --content_for :title, "Places" +-content_for :title, "#{ENV['GROWSTUFF_SITE_NAME']} Community Map" -%div#map +%div#placesmap diff --git a/app/views/places/show.html.haml b/app/views/places/show.html.haml index d93bd6026..60629a7ad 100644 --- a/app/views/places/show.html.haml +++ b/app/views/places/show.html.haml @@ -1,15 +1,13 @@ --content_for :title, @place +-content_for :title, "#{ENV['GROWSTUFF_SITE_NAME']} members near #{@place}" = form_tag(search_places_path, :method => :get, :class => 'form-inline') do = label_tag :place, "Change location:", :class => 'control-label' = text_field_tag :new_place = submit_tag "Search", :class => 'btn btn-primary' -%div#map{ :style => "height:300px"} +%div#placesmap{ :style => "height:300px"} -%h3 - = ENV['GROWSTUFF_SITE_NAME'] - members near #{@place} +%h3 Nearby members - if !@nearby_members.empty? %ul.thumbnails diff --git a/config/database.yml b/config/database.yml index 8dd0a9fba..6b0ab1503 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,20 +1,14 @@ development: - adapter: sqlite3 - database: db/growstuff_dev.sqlite3 - pool: 5 - timeout: 5000 + adapter: postgresql + database: growstuff_dev + host: localhost + user: postgres test: - adapter: sqlite3 - database: db/growstuff_test.sqlite3 - pool: 5 - timeout: 5000 - -# should be identical to test apart from running on postgres -travis: adapter: postgresql database: growstuff_test - username: postgres + host: localhost + user: postgres production: adapter: postgresql diff --git a/config/environments/travis.rb b/config/environments/travis.rb deleted file mode 120000 index 2e82190dd..000000000 --- a/config/environments/travis.rb +++ /dev/null @@ -1 +0,0 @@ -test.rb \ No newline at end of file diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake index 5d14c40c4..91814aff8 100644 --- a/lib/tasks/growstuff.rake +++ b/lib/tasks/growstuff.rake @@ -4,12 +4,20 @@ namespace :growstuff do # usage: rake growstuff:admin_user name=skud task :admin_user => :environment do - member = Member.find_by_login_name(ENV['name']) or raise "Usage: rake growstuff:admin_user name=whoever (login name is case-sensitive)" - admin = Role.find_or_create_by_name!('admin') + admin = Role.find('admin') member.roles << admin end + desc "Add a crop wrangler user, by name" + # usage: rake growstuff:cropwrangler_user name=skud + + task :cropwrangler_user => :environment do + member = Member.find_by_login_name(ENV['name']) or raise "Usage: rake growstuff:cropwrangler_user name=whoever (login name is case-sensitive)" + cw = Role.find('crop-wrangler') + member.roles << cw + end + desc "Upload crops from a CSV file" # usage: rake growstuff:import_crops file=filename.csv diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 1cc46fe93..c89328904 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -321,6 +321,9 @@ describe Crop do it "doesn't find non-matches" do Crop.search('mush').should_not include @crop end + it "searches case insensitively" do + Crop.search('mUsH').should include @mushroom + end end end diff --git a/spec/views/crops/show.html.haml_spec.rb b/spec/views/crops/show.html.haml_spec.rb index 4b637cc1d..1e0aaa528 100644 --- a/spec/views/crops/show.html.haml_spec.rb +++ b/spec/views/crops/show.html.haml_spec.rb @@ -15,13 +15,12 @@ describe "crops/show" do @photo1 = FactoryGirl.create(:photo) @photo2 = FactoryGirl.create(:photo) @photo3 = FactoryGirl.create(:photo) - @photo4 = FactoryGirl.create(:photo) - @planting.photos << [@photo1, @photo2, @photo3, @photo4] + @planting.photos << [@photo1, @photo2, @photo3] render end it 'shows 4 photos across the top of the page' do - assert_select "div.thumbnail>a>img", :count => 4 + assert_select "div.thumbnail>a>img", :count => 3 end it 'links to the photo detail page' do @@ -33,6 +32,35 @@ describe "crops/show" do end end + context "map" do + it "has a map" do + render + assert_select("div#cropmap") + end + + it "explains what's shown on the map" do + render + rendered.should contain "Only plantings by members who have set their locations are shown on this map" + end + + it "shows a 'set your location' link to people who need to" do + @nowhere = FactoryGirl.create(:member) + sign_in @nowhere + controller.stub(:current_user) { @nowhere } + render + rendered.should contain "Set your location" + end + + it "doesn't show 'set your location' to people who have one" do + @somewhere = FactoryGirl.create(:london_member) + sign_in @somewhere + controller.stub(:current_user) { @somewhere } + render + rendered.should_not contain "Set your location" + end + + end + it "shows the wikipedia URL" do render assert_select("a[href=#{@crop.en_wikipedia_url}]", 'Wikipedia (English)') diff --git a/spec/views/places/index.html.haml_spec.rb b/spec/views/places/index.html.haml_spec.rb index ffddf2c0b..0e4af0bb1 100644 --- a/spec/views/places/index.html.haml_spec.rb +++ b/spec/views/places/index.html.haml_spec.rb @@ -6,6 +6,6 @@ describe "places/index" do end it "shows a map" do - assert_select "div#map" + assert_select "div#placesmap" end end diff --git a/spec/views/places/show.html.haml_spec.rb b/spec/views/places/show.html.haml_spec.rb index 84364a811..987212740 100644 --- a/spec/views/places/show.html.haml_spec.rb +++ b/spec/views/places/show.html.haml_spec.rb @@ -11,7 +11,7 @@ describe "places/show" do end it "shows the selected place" do - view.content_for(:title).should == @place + view.content_for(:title).should match @place end it "shows the selected place in the textbox" do From 0714c2a38c9ce76a41ecdf15254ed93229764f79 Mon Sep 17 00:00:00 2001 From: Amy Hendrix Date: Sun, 13 Jul 2014 21:30:08 -0400 Subject: [PATCH 3/5] Menu items should be block, not inline-block, at mobile screen sizes --- .../bootstrap_and_overrides.css.less | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less index a9245820d..50c40ed6f 100644 --- a/app/assets/stylesheets/bootstrap_and_overrides.css.less +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less @@ -190,19 +190,6 @@ p.stats { } } -// Overrides applying only to mobile view - -@media only screen and (max-width: 767px) { - .sidebar { - margin-left: 0; - border-left: none; - padding-left: 0; - } - - #map { - height: 300px; - } -} li.crop-hierarchy { list-style-type: disc; @@ -254,4 +241,22 @@ li.crop-hierarchy { .navbar-search{ padding-bottom: 7px; -} \ No newline at end of file +} + +// Overrides applying only to mobile view. This must be at the end of the overrides file. + +@media only screen and (max-width: 767px) { + .sidebar { + margin-left: 0; + border-left: none; + padding-left: 0; + } + + #map { + height: 300px; + } + + .navbar .nav > li { + display: block; + } +} From 191363402af6b1af22bfacf8825cf82dc1530318 Mon Sep 17 00:00:00 2001 From: Amy Hendrix Date: Sun, 13 Jul 2014 21:45:19 -0400 Subject: [PATCH 4/5] Replace crops.js.erb --- app/assets/javascripts/crops.js.erb | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 app/assets/javascripts/crops.js.erb diff --git a/app/assets/javascripts/crops.js.erb b/app/assets/javascripts/crops.js.erb new file mode 100644 index 000000000..a85560e99 --- /dev/null +++ b/app/assets/javascripts/crops.js.erb @@ -0,0 +1,49 @@ +if (document.getElementById("cropmap") !== null) { + mapbox_map_id = "<%= Growstuff::Application.config.mapbox_map_id %>"; + mapbox_base_url = "https://c.tiles.mapbox.com/v3/" + mapbox_map_id + "/{z}/{x}/{y}.png"; + + L.Icon.Default.imagePath = '/assets' + + cropmap = L.map('cropmap').setView([0.0, -0.0], 2); + showCropMap(cropmap); +} + +function showCropMap(cropmap) { + + L.tileLayer(mapbox_base_url, { + attribution: 'Map data © OpenStreetMap contributors under ODbL | Map imagery © Mapbox', + maxZoom: 18 + }).addTo(cropmap); + markers = new L.MarkerClusterGroup({showCoverageOnHover: false, maxClusterRadius: 20 }); + + things_to_map = location.pathname + '.json'; + $.getJSON(things_to_map, function(crop) { + $.each(crop.plantings, function(i, planting) { + owner = planting.owner; + if (owner.latitude && owner.longitude) { + marker = new L.Marker(new L.LatLng(owner.latitude, owner.longitude)); + + planting_url = "/plantings/" + planting.id; + planting_link = "" + owner.login_name + "'s " + crop.name + ""; + + where = "

" + owner.location + "

"; + + details = "

"; + if (planting.quantity) { + details = details + "Quantity: " + planting.quantity + "
"; + } + if (planting.planted_from) { + details = details + "Planted from: " + planting.planted_from + "
"; + } + if (planting.sunniness) { + details = details + "Planted in: " + planting.sunniness+ "
"; + } + details = details + "

"; + marker.bindPopup(planting_link + where + details).openPopup(); + markers.addLayer(marker); + } + }); + }); + + cropmap.addLayer(markers); +} \ No newline at end of file From 10af60f30d255ab75e84d9fa4660a83a6262bf56 Mon Sep 17 00:00:00 2001 From: Amy Hendrix Date: Sun, 13 Jul 2014 21:46:33 -0400 Subject: [PATCH 5/5] Cleanup crops.js.erb --- app/assets/javascripts/crops.js.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/crops.js.erb b/app/assets/javascripts/crops.js.erb index a85560e99..3a3837633 100644 --- a/app/assets/javascripts/crops.js.erb +++ b/app/assets/javascripts/crops.js.erb @@ -46,4 +46,4 @@ function showCropMap(cropmap) { }); cropmap.addLayer(markers); -} \ No newline at end of file +}