roughly got crops/plantings working for new homepage

This commit is contained in:
Skud
2013-07-29 17:07:02 +10:00
parent 2daa4369aa
commit b27d3d8385
6 changed files with 78 additions and 25 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,2 @@