mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-19 06:15:44 -04:00
roughly got crops/plantings working for new homepage
This commit is contained in:
@@ -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
|
||||
|
||||
11
app/views/crops/_image_with_popover.html.haml
Normal file
11
app/views/crops/_image_with_popover.html.haml
Normal 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
|
||||
10
app/views/crops/_popover.html.haml
Normal file
10
app/views/crops/_popover.html.haml
Normal 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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
2
app/views/plantings/_list.html.haml
Normal file
2
app/views/plantings/_list.html.haml
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
Reference in New Issue
Block a user