From b27d3d8385538e807e4703c7b7db9da024e482bd Mon Sep 17 00:00:00 2001 From: Skud Date: Mon, 29 Jul 2013 17:07:02 +1000 Subject: [PATCH] roughly got crops/plantings working for new homepage --- app/controllers/home_controller.rb | 8 ++-- app/views/crops/_image_with_popover.html.haml | 11 +++++ app/views/crops/_popover.html.haml | 10 +++++ app/views/home/_crops.html.haml | 40 ++++++++++++++++++- app/views/home/index.html.haml | 32 ++++++--------- app/views/plantings/_list.html.haml | 2 + 6 files changed, 78 insertions(+), 25 deletions(-) create mode 100644 app/views/crops/_image_with_popover.html.haml create mode 100644 app/views/crops/_popover.html.haml create mode 100644 app/views/plantings/_list.html.haml diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 7ad499d9a..6c7f3c8f3 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -7,14 +7,14 @@ class HomeController < ApplicationController @planting_count = Planting.count @garden_count = Garden.count + @member = current_member + + @recent_crops = Crop.recent.first(12) + # choose 6 recently-signed-in members sort of at random @interesting_members = Member.interesting.limit(30).shuffle.first(6) - # customise what we show on the homepage based on whether you're - # logged in or not. - @member = current_member @plantings = Planting.limit(15) - @posts = Post.limit(10) respond_to do |format| format.html # index.html.haml diff --git a/app/views/crops/_image_with_popover.html.haml b/app/views/crops/_image_with_popover.html.haml new file mode 100644 index 000000000..c8c3de8b4 --- /dev/null +++ b/app/views/crops/_image_with_popover.html.haml @@ -0,0 +1,11 @@ += link_to | + image_tag( | + crop.default_photo ? crop.default_photo.thumbnail_url : 'placeholder_150.png', | + :alt => crop.system_name | + ), | + '#', | + :rel => "popover", | + 'data-trigger' => 'hover', | + 'data-title' => crop.system_name, | + 'data-content' => "#{ render :partial => 'crops/popover', :locals => { :crop => crop } }", | + 'data-html' => true diff --git a/app/views/crops/_popover.html.haml b/app/views/crops/_popover.html.haml new file mode 100644 index 000000000..f51adef17 --- /dev/null +++ b/app/views/crops/_popover.html.haml @@ -0,0 +1,10 @@ +%p + - if crop.scientific_names.count > 0 + %i + %small + = crop.scientific_names.first.scientific_name + %br/ + %small + Planted + = pluralize(crop.plantings_count, "time") += link_to "More detail", crop diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index 6a41efc25..6b3dcca4f 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -1,3 +1,39 @@ -%h2 Crops +.row-fluid + .span6 + %h3 Some of our crops + - count = 0 + - Crop.all.shuffle.each do |c| + - next unless c.photos.present? + - count += 1 + .span3{:style => 'margin:0px; padding: 3px'} + = render :partial => 'crops/image_with_popover.html.haml', :locals => { :crop => c } + - break if count == 12 + + .span6 + %h3 Recently planted + - count = 0 + - Planting.all.each do |p| + - next unless p.photos.present? + - count += 1 + .row + .span2{:style => 'padding-bottom: 6px'} + =link_to image_tag(p.photos.first.thumbnail_url, :alt => p.to_s), p + .span10 + = link_to p.crop, p.crop + in + = succeed "'s" do + = link_to p.owner, p.owner + = link_to p.garden, p.garden + %br/ + %small + %i + = p.owner.location + - break if count == 4 + +.row-fluid + .span12 + %p + %strong + Recently added crops: + != @recent_crops.map {|c| link_to(c, c) }.join(", ") -%p Here are some crops diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index f8f116c84..39d5a8c44 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,24 +1,18 @@ -- if member_signed_in? - = render :partial => 'signed_in' +.row + = render :partial => 'blurb' +.row + .span8 + = render :partial => 'crops' + = render :partial => 'seeds' + = render :partial => 'people' -- else + .span4 + %h2 Keep in touch - .row - = render :partial => 'blurb' - .row - .span8 - = render :partial => 'crops' - = render :partial => 'seeds' - = render :partial => 'people' + %h2 Open Source + %h2 Open Data and APIs - .span4 - %h2 Keep in touch + %h2 Get Involved - %h2 Open Source - - %h2 Open Data and APIs - - %h2 Get Involved - - %h2 Support Growstuff + %h2 Support Growstuff diff --git a/app/views/plantings/_list.html.haml b/app/views/plantings/_list.html.haml new file mode 100644 index 000000000..139597f9c --- /dev/null +++ b/app/views/plantings/_list.html.haml @@ -0,0 +1,2 @@ + +