From a806b3e9a698b685a05daf95f38cb986317ad78f Mon Sep 17 00:00:00 2001 From: Skud Date: Mon, 29 Jul 2013 15:34:29 +1000 Subject: [PATCH 01/11] added recent scope for crops --- app/models/crop.rb | 1 + app/views/home/index.html.haml | 76 ++++++++-------------------------- spec/models/crop_spec.rb | 29 ++++++++----- 3 files changed, 37 insertions(+), 69 deletions(-) diff --git a/app/models/crop.rb b/app/models/crop.rb index 5fbf8a485..df9d3fdc0 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -12,6 +12,7 @@ class Crop < ActiveRecord::Base has_many :varieties, :class_name => 'Crop', :foreign_key => 'parent_id' default_scope order("lower(system_name) asc") + scope :recent, reorder("created_at desc") validates :en_wikipedia_url, :format => { diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index c2f3712bf..f8f116c84 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,64 +1,24 @@ - if member_signed_in? - - %h1= "Welcome, #{current_member.login_name}" - - .row - .visible-desktop.visible-tablet - .span2 - = render :partial => "members/avatar", :locals => { :member => current_member } - .span6 - %p - %b Your profile: - =link_to current_member, current_member - = link_to "Edit", edit_registration_path(current_member), :class => 'btn btn-mini' - - %p - %b Your location: - = current_member.location ? current_member.location : 'Not set' - = link_to "Edit", edit_registration_path(current_member), :class => 'btn btn-mini' - - %ul.inline - %li.first - %b Your gardens: - - current_member.gardens.each do |g| - %li= link_to g.name, g - - if can? :create, Garden - %li - = link_to 'Add', new_garden_path, :class => 'btn btn-mini' - - %p - %b Your seed stash: - = link_to pluralize(current_member.seeds.count, "variety"), seeds_by_owner_path(:owner => current_member.slug) - = link_to 'Add', new_seed_path, :class => 'btn btn-mini' - - .span4 - %p - Your account: - %strong - = current_member.account_type - account - %br/ - - if current_member == current_member && !current_member.is_paid? - = link_to "Upgrade and Support #{Growstuff::Application.config.site_name}", shop_path, :class => 'btn btn-primary' + = render :partial => 'signed_in' - else - .visible-desktop.visible-tablet - .hero-unit - = render :partial => 'blurb' - .visible-phone + + .row = render :partial => 'blurb' + .row + .span8 + = render :partial => 'crops' + = render :partial => 'seeds' + = render :partial => 'people' - - if @interesting_members.present? - %h2 Some of our members - %ul.thumbnails - - @interesting_members.each do |m| - %li.span2 - = render :partial => "members/thumbnail", :locals => { :member => m } -.row - .span6 - %h2 Recent plantings - = render :partial => 'shared/recent_plantings' - .span6 - %h2 Recent posts - = render :partial => 'shared/recent_posts' + .span4 + %h2 Keep in touch + + %h2 Open Source + + %h2 Open Data and APIs + + %h2 Get Involved + + %h2 Support Growstuff diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 6c66d2399..6e021abc1 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -33,25 +33,32 @@ describe Crop do end context 'ordering' do + before(:each) do + @uppercase = FactoryGirl.create(:uppercasecrop, :created_at => 1.minute.ago) + @lowercase = FactoryGirl.create(:lowercasecrop, :created_at => 2.days.ago) + end + it "should be sorted case-insensitively" do - uppercase = FactoryGirl.create(:uppercasecrop) - lowercase = FactoryGirl.create(:lowercasecrop) - Crop.first.should == lowercase + Crop.first.should == @lowercase + end + + it 'recent scope sorts by creation date' do + Crop.recent.first.should == @uppercase end end it 'finds a default scientific name' do - @c = FactoryGirl.create(:tomato) - @c.default_scientific_name.should eq nil - @sn = FactoryGirl.create(:solanum_lycopersicum, :crop => @c) - @c.default_scientific_name.should eq @sn.scientific_name + @crop = FactoryGirl.create(:tomato) + @crop.default_scientific_name.should eq nil + @sn = FactoryGirl.create(:solanum_lycopersicum, :crop => @crop) + @crop.default_scientific_name.should eq @sn.scientific_name end it 'counts plantings' do - @c = FactoryGirl.create(:tomato) - @c.plantings_count.should eq 0 - FactoryGirl.create(:planting, :crop => @c) - @c.plantings_count.should eq 1 + @crop = FactoryGirl.create(:tomato) + @crop.plantings_count.should eq 0 + FactoryGirl.create(:planting, :crop => @crop) + @crop.plantings_count.should eq 1 end it 'validates en_wikipedia_url' do From 8be8c66344928c3b9af087a14360218073241bd7 Mon Sep 17 00:00:00 2001 From: Skud Date: Mon, 29 Jul 2013 15:34:55 +1000 Subject: [PATCH 02/11] roughed in the framework for new homepage design --- app/views/home/_crops.html.haml | 3 +++ app/views/home/_people.html.haml | 9 +++++++ app/views/home/_seeds.html.haml | 3 +++ app/views/home/_signed_in.html.haml | 40 +++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 app/views/home/_crops.html.haml create mode 100644 app/views/home/_people.html.haml create mode 100644 app/views/home/_seeds.html.haml create mode 100644 app/views/home/_signed_in.html.haml diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml new file mode 100644 index 000000000..6a41efc25 --- /dev/null +++ b/app/views/home/_crops.html.haml @@ -0,0 +1,3 @@ +%h2 Crops + +%p Here are some crops diff --git a/app/views/home/_people.html.haml b/app/views/home/_people.html.haml new file mode 100644 index 000000000..c3aadc240 --- /dev/null +++ b/app/views/home/_people.html.haml @@ -0,0 +1,9 @@ +%h2 People + +%p Here are some people + +- if @interesting_members.present? + %ul.thumbnails + - @interesting_members.each do |m| + %li.span2 + = render :partial => "members/thumbnail", :locals => { :member => m } diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml new file mode 100644 index 000000000..933962335 --- /dev/null +++ b/app/views/home/_seeds.html.haml @@ -0,0 +1,3 @@ +%h2 Seeds + +%p Here are some seeds diff --git a/app/views/home/_signed_in.html.haml b/app/views/home/_signed_in.html.haml new file mode 100644 index 000000000..f2625b1a4 --- /dev/null +++ b/app/views/home/_signed_in.html.haml @@ -0,0 +1,40 @@ +%h1= "Welcome, #{current_member.login_name}" + +.row + .visible-desktop.visible-tablet + .span2 + = render :partial => "members/avatar", :locals => { :member => current_member } + .span6 + %p + %b Your profile: + =link_to current_member, current_member + = link_to "Edit", edit_registration_path(current_member), :class => 'btn btn-mini' + + %p + %b Your location: + = current_member.location ? current_member.location : 'Not set' + = link_to "Edit", edit_registration_path(current_member), :class => 'btn btn-mini' + + %ul.inline + %li.first + %b Your gardens: + - current_member.gardens.each do |g| + %li= link_to g.name, g + - if can? :create, Garden + %li + = link_to 'Add', new_garden_path, :class => 'btn btn-mini' + + %p + %b Your seed stash: + = link_to pluralize(current_member.seeds.count, "variety"), seeds_by_owner_path(:owner => current_member.slug) + = link_to 'Add', new_seed_path, :class => 'btn btn-mini' + + .span4 + %p + Your account: + %strong + = current_member.account_type + account + %br/ + - if current_member == current_member && !current_member.is_paid? + = link_to "Upgrade and Support #{Growstuff::Application.config.site_name}", shop_path, :class => 'btn btn-primary' From 0be5833b84fced3c18889c34db0c1588c30df838 Mon Sep 17 00:00:00 2001 From: Skud Date: Mon, 29 Jul 2013 17:07:02 +1000 Subject: [PATCH 03/11] 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 @@ + + From 5caaf23be6868aa5ad773a778ec5dce8783c2763 Mon Sep 17 00:00:00 2001 From: Skud Date: Tue, 30 Jul 2013 11:45:18 +1000 Subject: [PATCH 04/11] Added blog and email icons Both are free/unrestricted use: Blog icon from http://theblogicon.com/ Email icon from http://commons.wikimedia.org/wiki/File:Email_social_icon.svg --- app/assets/images/blog_32.png | Bin 0 -> 5165 bytes app/assets/images/email_32.png | Bin 0 -> 1091 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/assets/images/blog_32.png create mode 100644 app/assets/images/email_32.png diff --git a/app/assets/images/blog_32.png b/app/assets/images/blog_32.png new file mode 100644 index 0000000000000000000000000000000000000000..a599254f8991dd59cc8ee2ad0584c1f26dbb892f GIT binary patch literal 5165 zcmeHLc{o&UA0GRdOlXlMI);d3#*kqcOZG$z*-DI=gUOhgZ{}!*h=>ST+e8Xk3nf{y zrQTlgT8lQa^;MQoiC&3s(AWEZe|BBp`(Mv>&Uw!BJooRupWl6ce>~TTbFjBUB4iOT z7z}A+ZBFF%z{(95<~`XVA+x+r2C{I2oEW|khr|M5rWA$`2-pOY{6Hc|q6Giz5oid5 zA?m2kZjhVZK0KKbs7YGEXmSIYyl5EA(3s04kpn;o@B#g(bOLJnZX*hyQV1y5-F6r| zrWxo@wGLr{P9gTrhG&&p4C7@P$@x1qyX*3F0g+KuW z)Y_)p>>L0y1`7mqG_`h-G1|I-j;%#)+6cRm<3X%Om8cmZYvzj4bNFn3bbXF4np0X(oS{to7K%=hY ziKmh1egqVE7X|bs1<@dsk+VOQ4e%}o6Ql#a3>HA52Q%m(05Jf6(os+YU~uSw3Mr6j z00gl?O+)mGeKhKKq1DlUl?>7UvyV0C-<;>gtj+PhD6gK-KMLymK3BH>54Kfn{z3j# z>R%#1!%#}De$lA`oGzQ`0Gf@JK_*f9NvMm>|pOx7)(^e z#@y7I`{JbQu>|K{ndL0@6xo+^Y5??ecT?b}yDGS7cspTGXvgF`cb347LbmZ?=3g;B zwEq0WKqAJD+~tG3J-k0~p7{RWct zH@eEZ*RU7U8e8aSiDhzN)L%{RID5beN{lo*>n7Vsx@HsH6DJpJSspDlYY>tc#M+ zJ>_s%ZDQAG&5*j7q+syC%usxJ#umla^}yCiQ|Ksm5bnnp05r)2fKh%!2(B8E2cu z@A5SkCe94@CzY3MOdz&wsN8(yoet}MZh78R0%hQJ2{lO&NDy~y@k_4KR=+coZy|x}7kUFKqQ9lR zq6UcX@sjkEF?EEi?Ga4fmc$=_(c|&Zp;H;LmgbSnmH8P#mOJjuQFV?Bi&Ew7-++oO;s}u0DfR<)X)|(e58pFIk0nOG|pecAAxzi=L+(+*E zoytwob@oxH99@&QE)Rl?t`+(7Ilcb$XtZYsg(^nNw8pU{yT6v@K;9yeQ3fX_&$cqI zwSwZSs%=InZTnR7JrXKchZR|9q9jh~E=Hz$vJ9*uq+ zZtC13`;ur^zNIWj*hMF@RY!zkakN0*dA{$XL4Ln-=i4yhK0>Ei=oFuzzPi<2g=;c!MSaY4Y-Xr zA4+nK>Z;ZsK)P|29B}JMMoB%<>;q?RYoOc$P$I>0}=}E~Ad3g%i| zceBp9e>`LV8$=K|iAbh)>{QCDRc*rqiSv+*x1# zKep%Cv~qSi$JxlCYzfIL(jfA20FXN@snz# zu7}7yzuGT4=emHgsmf16AKd+N^Dx}5><_W^54e4|5;9s{Wc5lP=W^2JW9IJ}V~#Ii z7E7Y?($z+TyiHIGWs^6$`Sw{yb;rcUbnD~(csTT|9LLmRYftpMnRScJ|G~(<%NZ_^ zoyEvTw~P(KRVAY)BlG;uE6sCXijVuHyd9g<`8cen zx%Bm8?rd0fC$VOW)F7v50=x6|X?gY*TyLM=-ptUEXxsX1Ygy@u-Y?3dJy`uDs}ih( z8!}jbaok9?SwBcKdSH)=cILLa^x()habY3S_}U^BDZ&O><2oC?zEWpG*yX1+RE6+! zZ8o0Gp&ZwSj?YdN`hJ~GKGBT_7nO^yU NXJcV+Ub@FS@;_9@S8V_Q literal 0 HcmV?d00001 diff --git a/app/assets/images/email_32.png b/app/assets/images/email_32.png new file mode 100644 index 0000000000000000000000000000000000000000..160ee6396be8de9b250e70b6dd9502de36374f7c GIT binary patch literal 1091 zcmV-J1ibr+P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2i*rA z0V@GuC;lY>00YBGL_t(o!?l-Na@t4~hCj805LerPZ(vJgDY0I%keOM*R2Gq%70k>+ z=7sW7f{1~{x)@`yB>~bra4}#RutQFj>XeSU`~UU#>C@d33D#&da)82qZETw6a6Kq3 zfu?~!RaN~%)6%*mNqa?);~3u$T45OeElJW}S65fTf z08UO$R^np4a2SS;Vr91edP{O+#DU@+w3 zqL%nwBnD?By4~+QK0dx1yx;HB>-Es}OJ3Vs#A}^pS*Bh$=ybX~J^6129}b7uwu52l zY}(kwra=@%!7y}gZf*#IU}x~Brzg7I@6_uCLTrTCOklbnot-Y~d(uhhrw9Z=K=1y3@t(`&I6ptbaU2}S=JfQGd_KRT$nC97 z6h&Ld-kK?47;@LU=j6DurbKq-kJoF+!Qlb6<8WN5Y+Q;P6&Q_1cy~RHE9I^0`9;2@ z(;O5JupO5uir-FPG#=x69>0O>-b-nf|Zix;VDO(cvMgx?k|+8j{OpX?Hq=VffE-4t(i$y4TZ^ ztMV%?@O}FC{cGUMhRdn;i!P^r^5rz)dY%XNJr5((GzaU!{{cmXO*eogb4>sM002ov JPDHLkV1oR62bBN- literal 0 HcmV?d00001 From 4752d16493b876cf80f779fbfc9b718166bdb031 Mon Sep 17 00:00:00 2001 From: Skud Date: Tue, 30 Jul 2013 11:46:22 +1000 Subject: [PATCH 05/11] Added "keep in touch" links to sidebar --- app/views/home/index.html.haml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 39d5a8c44..16f93ff8a 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -9,6 +9,24 @@ .span4 %h2 Keep in touch + %p + =image_tag("twitter_32.png", :alt => '') + Follow + =link_to '@growstufforg', 'http://twitter.com/growstufforg' + on Twitter. + + %p + =image_tag("blog_32.png", :alt => '') + Subscribe to the + =link_to 'Growstuff Blog', 'http://blog.growstuff.org/' + + %p + =image_tag("email_32.png", :alt => '') + Subscribe to our + =link_to 'email newsletter', 'http://blog.growstuff.org/newsletter' + + %p + %h2 Open Source %h2 Open Data and APIs From 636e5670b2a480fc44e019c3ad796216d16a925b Mon Sep 17 00:00:00 2001 From: Skud Date: Tue, 30 Jul 2013 12:44:11 +1000 Subject: [PATCH 06/11] Sidebar: keep in touch, and open stuff --- app/views/home/_keep_in_touch.html.haml | 17 +++++++++ app/views/home/_open.html.haml | 50 +++++++++++++++++++++++++ app/views/home/index.html.haml | 37 +++--------------- 3 files changed, 73 insertions(+), 31 deletions(-) create mode 100644 app/views/home/_keep_in_touch.html.haml create mode 100644 app/views/home/_open.html.haml diff --git a/app/views/home/_keep_in_touch.html.haml b/app/views/home/_keep_in_touch.html.haml new file mode 100644 index 000000000..34365352b --- /dev/null +++ b/app/views/home/_keep_in_touch.html.haml @@ -0,0 +1,17 @@ +%h2 Keep in touch + +%p + =image_tag("twitter_32.png", :alt => '') + Follow + =link_to '@growstufforg', 'http://twitter.com/growstufforg' + on Twitter. + +%p + =image_tag("blog_32.png", :alt => '') + Subscribe to the + =link_to 'Growstuff Blog', 'http://blog.growstuff.org/' + +%p + =image_tag("email_32.png", :alt => '') + Subscribe to our + =link_to 'email newsletter', 'http://blog.growstuff.org/newsletter' diff --git a/app/views/home/_open.html.haml b/app/views/home/_open.html.haml new file mode 100644 index 000000000..2d294b062 --- /dev/null +++ b/app/views/home/_open.html.haml @@ -0,0 +1,50 @@ +%h2 Open Source + +%p + #{Growstuff::Application.config.site_name} is open source software, + which means that we're sharing this website's code for free with our + community and the world. We believe that open source, + sustainability, and social good go hand in hand. You can read more + about + =link_to "why Growstuff is open source", "http://blog.growstuff.org/2013/02/20/why-growstuff-is-open-source/" + or check out our code on + =succeed '.' do + = link_to 'Github', 'http://github.com/Growstuff/growstuff' + +%h2 Open Data and APIs + +%p + We're building a database + of crops, planting advice, seed sources, and other information + that anyone can use for free, under a + = succeed '.' do + = link_to 'Creative Commons license', 'http://creativecommons.org/licenses/by-sa/3.0/' + You can use this data for research, to build apps, or for any + purpose at all. Read more about our + + = link_to 'open data', 'http://wiki.growstuff.org/index.php/Open_data' + and + = succeed '.' do + = link_to 'API documentation', 'http://wiki.growstuff.org/index.php/API' + +%h2 Get Involved + +%p + We believe in collaboration, and we work closely with our members + and the wider food-growing community to make sure we're building + what you want. Our team includes volunteers from all walks of life + and all skills levels, and we'd love to have you, too. To get + involved, + = link_to 'join our discussion mailing list', 'http://lists.growstuff.org/mailman/listinfo/discuss' + or find more information on the + = succeed "." do + = link_to 'Growstuff Wiki', 'http://wiki.growstuff.org/' + +%h2 Support Growstuff + +%p + Growstuff is supported by our community. We are + =link_to 'ad-free', 'http://wiki.growstuff.org/index.php/Why_no_ads%3F' + and have no outside investment. You can support us by + =succeed "." do + =link_to 'buying a paid account', shop_path diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 16f93ff8a..770f05d4a 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,36 +1,11 @@ -.row +.row-fluid = render :partial => 'blurb' -.row - .span8 +.row-fluid + .span8.main = render :partial => 'crops' = render :partial => 'seeds' = render :partial => 'people' - .span4 - %h2 Keep in touch - - %p - =image_tag("twitter_32.png", :alt => '') - Follow - =link_to '@growstufforg', 'http://twitter.com/growstufforg' - on Twitter. - - %p - =image_tag("blog_32.png", :alt => '') - Subscribe to the - =link_to 'Growstuff Blog', 'http://blog.growstuff.org/' - - %p - =image_tag("email_32.png", :alt => '') - Subscribe to our - =link_to 'email newsletter', 'http://blog.growstuff.org/newsletter' - - %p - - %h2 Open Source - - %h2 Open Data and APIs - - %h2 Get Involved - - %h2 Support Growstuff + .span4.sidebar + = render :partial => 'keep_in_touch' + = render :partial => 'open' From a49014ae5cfe2d08756730594b935dc50a0badac Mon Sep 17 00:00:00 2001 From: Skud Date: Tue, 30 Jul 2013 12:44:52 +1000 Subject: [PATCH 07/11] style tweaking --- .../bootstrap_and_overrides.css.less | 16 ++++++++++- app/views/home/_blurb.html.haml | 28 +++++++++++-------- app/views/home/_crops.html.haml | 4 +-- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less index 328ac5b25..76c596249 100644 --- a/app/assets/stylesheets/bootstrap_and_overrides.css.less +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less @@ -51,7 +51,7 @@ @serifFontFamily: Georgia, "Times New Roman", Times, serif; @monoFontFamily: Monaco, Menlo, Consolas, "Courier New", monospace; -@baseFontSize: 16px; +@baseFontSize: 15px; @baseFontFamily: @serifFontFamily; @baseLineHeight: @baseFontSize * 1.5; @altFontFamily: @sansFontFamily; @@ -84,3 +84,17 @@ body { ul.inline > li.first { padding-left: 0px; } + +h2 { + font-size: 150%; +} + +.main { + padding-right: 1em; +} + +.sidebar { + margin-left: -1px; + border-left: 1px solid darken(@beige, 10%); + padding-left: 1em; +} diff --git a/app/views/home/_blurb.html.haml b/app/views/home/_blurb.html.haml index f5f4b4676..212eca76c 100644 --- a/app/views/home/_blurb.html.haml +++ b/app/views/home/_blurb.html.haml @@ -1,15 +1,19 @@ -%h1= Growstuff::Application.config.site_name +.span12 -%p - #{Growstuff::Application.config.site_name} is a community of food gardeners. We're building an open source platform to track, share, and discuss edible gardens and sustainable lifestyles. We offer growing information tailored to your location, and help you connect with your local food-growing community. + %h1= Growstuff::Application.config.site_name - %strong - So far, - = link_to "#{@member_count} members", members_path - have planted - = link_to "#{@crop_count} crops", crops_path - #{@planting_count} times in #{@garden_count} gardens. + %p + #{Growstuff::Application.config.site_name} is a community of food gardeners. We're building an open source platform to track, share, and discuss edible gardens and sustainable lifestyles. We offer growing information tailored to your location, and help you connect with your local food-growing community. - You could be one of them. Sign up for a free account and start tracking your food garden today. -%p - = link_to 'Join now', new_member_registration_path, :class => 'btn btn-primary btn-large' + %p + %strong + So far, + = link_to "#{@member_count} members", members_path + have planted + = link_to "#{@crop_count} crops", crops_path + #{@planting_count} times in #{@garden_count} gardens. + + %p + You could be one of them. Sign up for a free account and start tracking your food garden today. + %p + = link_to 'Join now', new_member_registration_path, :class => 'btn btn-primary' diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index 6b3dcca4f..78fda3977 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -1,6 +1,6 @@ .row-fluid .span6 - %h3 Some of our crops + %h2 Some of our crops - count = 0 - Crop.all.shuffle.each do |c| - next unless c.photos.present? @@ -10,7 +10,7 @@ - break if count == 12 .span6 - %h3 Recently planted + %h2 Recently planted - count = 0 - Planting.all.each do |p| - next unless p.photos.present? From 7190352ad2c40fda0e0ed564ea22ce2b5f4b49cf Mon Sep 17 00:00:00 2001 From: Skud Date: Tue, 30 Jul 2013 16:11:31 +1000 Subject: [PATCH 08/11] Added a popover for planting images too. --- app/views/crops/_image_with_popover.html.haml | 2 +- app/views/crops/_popover.html.haml | 12 +++++------- app/views/home/_crops.html.haml | 2 +- app/views/plantings/_image_with_popover.html.haml | 11 +++++++++++ app/views/plantings/_popover.html.haml | 7 +++++++ 5 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 app/views/plantings/_image_with_popover.html.haml create mode 100644 app/views/plantings/_popover.html.haml diff --git a/app/views/crops/_image_with_popover.html.haml b/app/views/crops/_image_with_popover.html.haml index c8c3de8b4..2937ef22a 100644 --- a/app/views/crops/_image_with_popover.html.haml +++ b/app/views/crops/_image_with_popover.html.haml @@ -3,7 +3,7 @@ crop.default_photo ? crop.default_photo.thumbnail_url : 'placeholder_150.png', | :alt => crop.system_name | ), | - '#', | + crop, | :rel => "popover", | 'data-trigger' => 'hover', | 'data-title' => crop.system_name, | diff --git a/app/views/crops/_popover.html.haml b/app/views/crops/_popover.html.haml index f51adef17..c692f3d51 100644 --- a/app/views/crops/_popover.html.haml +++ b/app/views/crops/_popover.html.haml @@ -1,10 +1,8 @@ %p - - if crop.scientific_names.count > 0 - %i - %small + %small + - if crop.scientific_names.count > 0 + %i = crop.scientific_names.first.scientific_name %br/ - %small - Planted - = pluralize(crop.plantings_count, "time") -= link_to "More detail", crop + Planted + = pluralize(crop.plantings_count, "time") diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index 78fda3977..bd3690469 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -17,7 +17,7 @@ - count += 1 .row .span2{:style => 'padding-bottom: 6px'} - =link_to image_tag(p.photos.first.thumbnail_url, :alt => p.to_s), p + = render :partial => 'plantings/image_with_popover.html.haml', :locals => { :planting => p } .span10 = link_to p.crop, p.crop in diff --git a/app/views/plantings/_image_with_popover.html.haml b/app/views/plantings/_image_with_popover.html.haml new file mode 100644 index 000000000..8c36d26c9 --- /dev/null +++ b/app/views/plantings/_image_with_popover.html.haml @@ -0,0 +1,11 @@ += link_to | + image_tag( | + planting.photos.present? ? planting.photos.first.thumbnail_url : 'placeholder_150.png', | + :alt => planting.to_s | + ), | + planting, | + :rel => "popover", | + 'data-trigger' => 'hover', | + 'data-title' => planting.to_s, | + 'data-content' => "#{ render :partial => 'plantings/popover', :locals => { :planting => planting } }", | + 'data-html' => true diff --git a/app/views/plantings/_popover.html.haml b/app/views/plantings/_popover.html.haml new file mode 100644 index 000000000..d7a83f616 --- /dev/null +++ b/app/views/plantings/_popover.html.haml @@ -0,0 +1,7 @@ +%p + %small + Quantity: + = planting.quantity ? planting.quantity : 'unknown' + %br/ + Planted on: + = planting.planted_at.to_s From 18aee37e106b8876d4dfbe4c14d57301c9197662 Mon Sep 17 00:00:00 2001 From: Skud Date: Tue, 30 Jul 2013 16:15:00 +1000 Subject: [PATCH 09/11] refactored 'interesting plantings' --- app/models/planting.rb | 21 ++++++++ app/views/home/_crops.html.haml | 21 +------- app/views/plantings/_list.html.haml | 16 +++++- spec/models/planting_spec.rb | 76 +++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 21 deletions(-) diff --git a/app/models/planting.rb b/app/models/planting.rb index 05c2a7024..c82b61fa3 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -53,10 +53,12 @@ class Planting < ActiveRecord::Base "#{owner.login_name}-#{garden}-#{crop}".downcase.gsub(' ', '-') end + # location = owner + garden, i.e. "Skud's backyard" def location return "#{garden.owner.login_name}'s #{garden}" end + # stringify as "beet in Skud's backyard" or similar def to_s self.crop_system_name + " in " + self.location end @@ -64,4 +66,23 @@ class Planting < ActiveRecord::Base def default_photo return photos.first end + + # return a list of interesting plantings, for the homepage etc. + # we can't do this via a scope (as far as we know) so sadly we have to + # do it this way. + def Planting.interesting(howmany=10) + interesting_plantings = Array.new + seen_owners = Hash.new(false) # keep track of which owners we've seen already + + Planting.all.each do |p| + break if interesting_plantings.count == howmany # got enough yet? + next unless p.photos.present? # skip those that don't have photos + next if seen_owners[p.owner] # skip if we already have one from this owner + + seen_owners[p.owner] = true # we've seen this owner + interesting_plantings.push(p) + end + + return interesting_plantings + end end diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index bd3690469..f3c0b8309 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -6,29 +6,12 @@ - next unless c.photos.present? - count += 1 .span3{:style => 'margin:0px; padding: 3px'} - = render :partial => 'crops/image_with_popover.html.haml', :locals => { :crop => c } + = render :partial => 'crops/image_with_popover', :locals => { :crop => c } - break if count == 12 .span6 %h2 Recently planted - - count = 0 - - Planting.all.each do |p| - - next unless p.photos.present? - - count += 1 - .row - .span2{:style => 'padding-bottom: 6px'} - = render :partial => 'plantings/image_with_popover.html.haml', :locals => { :planting => 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 + = render :partial => 'plantings/list', :locals => { :plantings => Planting.interesting(4) } .row-fluid .span12 diff --git a/app/views/plantings/_list.html.haml b/app/views/plantings/_list.html.haml index 139597f9c..bbf6323f9 100644 --- a/app/views/plantings/_list.html.haml +++ b/app/views/plantings/_list.html.haml @@ -1,2 +1,14 @@ - - +- plantings.each do |p| + .row + .span2{:style => 'padding-bottom: 6px'} + = render :partial => 'plantings/image_with_popover', :locals => { :planting => 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 diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index bb5d87e0a..de2c24b65 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -148,4 +148,80 @@ describe Planting do end end + context 'interesting crops' do + it 'picks up interesting plantings' do + # plantings have members created implicitly for them + # each member is different, hence these are all interesting + @planting1 = FactoryGirl.create(:planting, :created_at => 5.days.ago) + @planting2 = FactoryGirl.create(:planting, :created_at => 4.days.ago) + @planting3 = FactoryGirl.create(:planting, :created_at => 3.days.ago) + @planting4 = FactoryGirl.create(:planting, :created_at => 2.days.ago) + + # plantings need photos to be interesting + @photo = FactoryGirl.create(:photo) + [@planting1, @planting2, @planting3, @planting4].each do |p| + p.photos << @photo + p.save + end + + Planting.interesting.should eq [ + @planting4, + @planting3, + @planting2, + @planting1 + ] + end + + it 'ignores plantings without photos' do + # first, an interesting planting + @planting = FactoryGirl.create(:planting) + @planting.photos << FactoryGirl.create(:photo) + @planting.save + + # this one doesn't have a photo + @boring_planting = FactoryGirl.create(:planting) + + Planting.interesting.should include @planting + Planting.interesting.should_not include @boring_planting + end + + it 'ignores plantings with the same owner' do + # this planting is older + @planting1 = FactoryGirl.create(:planting, :created_at => 1.day.ago) + @planting1.photos << FactoryGirl.create(:photo) + @planting1.save + + # this one is newer, and has the same owner, through the garden + @planting2 = FactoryGirl.create(:planting, + :created_at => 1.minute.ago, + :garden_id => @planting1.garden.id + ) + @planting2.photos << FactoryGirl.create(:photo) + @planting2.save + + # result: the newer one is interesting, the older one isn't + Planting.interesting.should include @planting2 + Planting.interesting.should_not include @planting1 + end + + it 'only gives you as many as you ask for' do + # plantings have members created implicitly for them + # each member is different, hence these are all interesting + @planting1 = FactoryGirl.create(:planting, :created_at => 5.days.ago) + @planting2 = FactoryGirl.create(:planting, :created_at => 4.days.ago) + @planting3 = FactoryGirl.create(:planting, :created_at => 3.days.ago) + @planting4 = FactoryGirl.create(:planting, :created_at => 2.days.ago) + + # plantings need photos to be interesting + @photo = FactoryGirl.create(:photo) + [@planting1, @planting2, @planting3, @planting4].each do |p| + p.photos << @photo + p.save + end + + Planting.interesting(2).length.should == 2 + end + + end + end From c1ee15393b3e92f7385e90b95a9a3e7691422bdb Mon Sep 17 00:00:00 2001 From: Skud Date: Tue, 30 Jul 2013 18:23:04 +1000 Subject: [PATCH 10/11] refactored interesting crops --- app/models/crop.rb | 30 +++++++++ app/views/home/_crops.html.haml | 5 +- spec/models/crop_spec.rb | 104 ++++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+), 4 deletions(-) diff --git a/app/models/crop.rb b/app/models/crop.rb index df9d3fdc0..d0c1c9294 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -41,10 +41,19 @@ class Crop < ActiveRecord::Base return plantings.count end + # crop.default_photo + # currently returns the first available photo, but exists so that + # later we can choose a default photo based on different criteria, + # eg. popularity def default_photo return photos.first end + # crop.sunniness + # returns hash indicating whether this crop is grown in + # sun/semi-shade/shade + # key: sunniness (eg. 'sun') + # value: count of how many times it's been used by plantings def sunniness sunniness = Hash.new(0) plantings.each do |p| @@ -55,6 +64,10 @@ class Crop < ActiveRecord::Base return sunniness end + # crop.planted_from + # returns a hash of propagation methods (seed, seedling, etc), + # key: propagation method (eg. 'seed') + # value: count of how many times it's been used by plantings def planted_from planted_from = Hash.new(0) plantings.each do |p| @@ -65,4 +78,21 @@ class Crop < ActiveRecord::Base return planted_from end + # Crop.interesting(howmany) + # returns a list of interesting crops, for use on the homepage etc + def Crop.interesting(howmany=12) + interesting_crops = Array.new + min_plantings = 3 # needs this many plantings to be interesting + min_photos = 3 # needs this many photos to be interesting + + Crop.all.each do |c| + break if interesting_crops.length == howmany + next unless c.photos.count >= min_photos + next unless c.plantings_count >= min_plantings + interesting_crops.push(c) + end + + return interesting_crops + end + end diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index f3c0b8309..11762b834 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -1,13 +1,10 @@ .row-fluid .span6 %h2 Some of our crops - - count = 0 - - Crop.all.shuffle.each do |c| + - Crop.interesting(12).each do |c| - next unless c.photos.present? - - count += 1 .span3{:style => 'margin:0px; padding: 3px'} = render :partial => 'crops/image_with_popover', :locals => { :crop => c } - - break if count == 12 .span6 %h2 Recently planted diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 6e021abc1..d4890a75e 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -145,5 +145,109 @@ describe Crop do end end + context 'interesting' do + it 'lists interesting crops' do + # first, a couple of candidate crops + @crop1 = FactoryGirl.create(:crop) + @crop2 = FactoryGirl.create(:crop) + + # they need 3+ plantings each to be interesting + (1..3).each do + FactoryGirl.create(:planting, :crop => @crop1) + end + (1..3).each do + FactoryGirl.create(:planting, :crop => @crop2) + end + + # crops need 3+ photos to be interesting + @photo = FactoryGirl.create(:photo) + [@crop1, @crop2].each do |c| + (1..3).each do + c.plantings.first.photos << @photo + c.plantings.first.save + end + end + + Crop.interesting.should include @crop1 + Crop.interesting.should include @crop2 + Crop.interesting.length.should == 2 + end + + it 'ignores crops without plantings' do + # first, a couple of candidate crops + @crop1 = FactoryGirl.create(:crop) + @crop2 = FactoryGirl.create(:crop) + + # only crop1 has plantings + (1..3).each do + FactoryGirl.create(:planting, :crop => @crop1) + end + + # ... and photos + @photo = FactoryGirl.create(:photo) + (1..3).each do + @crop1.plantings.first.photos << @photo + @crop1.plantings.first.save + end + + Crop.interesting.should include @crop1 + Crop.interesting.should_not include @crop2 + Crop.interesting.length.should == 1 + + end + + it 'ignores crops without photos' do + # first, a couple of candidate crops + @crop1 = FactoryGirl.create(:crop) + @crop2 = FactoryGirl.create(:crop) + + # both crops have plantings + (1..3).each do + FactoryGirl.create(:planting, :crop => @crop1) + end + (1..3).each do + FactoryGirl.create(:planting, :crop => @crop2) + end + + # but only crop1 has photos + @photo = FactoryGirl.create(:photo) + (1..3).each do + @crop1.plantings.first.photos << @photo + @crop1.plantings.first.save + end + + Crop.interesting.should include @crop1 + Crop.interesting.should_not include @crop2 + Crop.interesting.length.should == 1 + end + + it 'only gives you as many as you ask for' do + # first, a couple of candidate crops + @crop1 = FactoryGirl.create(:crop, :system_name => 'aaa') + @crop2 = FactoryGirl.create(:crop, :system_name => 'zzz') + + # they need 3+ plantings each to be interesting + (1..3).each do + FactoryGirl.create(:planting, :crop => @crop1) + end + (1..3).each do + FactoryGirl.create(:planting, :crop => @crop2) + end + + # crops need 3+ photos to be interesting + @photo = FactoryGirl.create(:photo) + [@crop1, @crop2].each do |c| + (1..3).each do + c.plantings.first.photos << @photo + c.plantings.first.save + end + end + + Crop.interesting(1).should include @crop1 + Crop.interesting(1).should_not include @crop2 + Crop.interesting(1).length.should == 1 + end + + end end From eeb343f99c6749b57ecd43af83890641fff4a33e Mon Sep 17 00:00:00 2001 From: Skud Date: Wed, 31 Jul 2013 11:50:25 +1000 Subject: [PATCH 11/11] Added seeds and people to homepage --- app/controllers/home_controller.rb | 7 +++-- app/models/member.rb | 14 +++++++--- app/views/home/_people.html.haml | 26 +++++++++++++------ app/views/home/_seeds.html.haml | 26 +++++++++++++++++-- .../members/_image_with_popover.html.haml | 14 ++++++++++ app/views/members/_popover.html.haml | 5 ++++ spec/models/member_spec.rb | 13 +++++++--- 7 files changed, 84 insertions(+), 21 deletions(-) create mode 100644 app/views/members/_image_with_popover.html.haml create mode 100644 app/views/members/_popover.html.haml diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 6c7f3c8f3..80a4f3cd7 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -9,12 +9,11 @@ class HomeController < ApplicationController @member = current_member - @recent_crops = Crop.recent.first(12) + @recent_crops = Crop.recent.limit(12) + @seeds = Seed.tradable.limit(6) # choose 6 recently-signed-in members sort of at random - @interesting_members = Member.interesting.limit(30).shuffle.first(6) - - @plantings = Planting.limit(15) + @interesting_members = Member.interesting(6) respond_to do |format| format.html # index.html.haml diff --git a/app/models/member.rb b/app/models/member.rb index 5c4e8b263..212196dcd 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -29,10 +29,6 @@ class Member < ActiveRecord::Base scope :located, where('location IS NOT NULL') scope :recently_signed_in, reorder('updated_at DESC') - # this is used on the signed-out homepage so we're basically - # just trying to select some members who look good. - scope :interesting, confirmed.located.recently_signed_in - # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable @@ -185,6 +181,16 @@ class Member < ActiveRecord::Base return sets end + def Member.interesting(howmany=12) + interesting_members = Array.new + Member.confirmed.located.recently_signed_in.each do |m| + break if interesting_members.length == howmany + next unless m.plantings.present? + interesting_members.push(m) + end + return interesting_members + end + protected def empty_unwanted_geocodes if self.location.to_s == '' diff --git a/app/views/home/_people.html.haml b/app/views/home/_people.html.haml index c3aadc240..c87a56f73 100644 --- a/app/views/home/_people.html.haml +++ b/app/views/home/_people.html.haml @@ -1,9 +1,19 @@ -%h2 People - -%p Here are some people - - if @interesting_members.present? - %ul.thumbnails - - @interesting_members.each do |m| - %li.span2 - = render :partial => "members/thumbnail", :locals => { :member => m } + %h2 Some of our members + + .row-fluid + - @interesting_members.first(6).each do |m| + .span6 + .row-fluid{:style => 'padding-bottom: 1em'} + .span3 + = render :partial => "members/image_with_popover", :locals => { :member => m } + .span9 + %p + = link_to m.login_name, m + %br/ + %i= m.location + %br/ + Recently planted: + != m.plantings.first(4).map{|p| link_to p.crop_system_name, p }.join(", ") + + diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml index 933962335..1c3014a0f 100644 --- a/app/views/home/_seeds.html.haml +++ b/app/views/home/_seeds.html.haml @@ -1,3 +1,25 @@ -%h2 Seeds +%h2 Seeds available to trade -%p Here are some seeds +- if @seeds.length > 0 + + %table.table.table-striped + %tr + %th Owner + %th Crop + %th.hidden-phone.hidden-tablet Description + %th Will trade to + %th From location + %th + + - @seeds.each do |seed| + %tr + %td= link_to seed.owner.login_name, seed.owner + %td= link_to seed.crop.system_name, seed.crop + %td.hidden-phone.hidden-tablet= truncate(seed.description, :length => 40, :separator => ' ') + %td= seed.tradable? ? seed.tradable_to : '' + %td + - if seed.tradable? + = seed.owner.location.blank? ? "unspecified" : truncate(seed.owner.location, :length => 25, :separator => ', ') + %td= link_to 'Details', seed, :class => 'btn btn-mini' + +%p= link_to "View all seeds", seeds_path, :class => 'btn btn-primary' diff --git a/app/views/members/_image_with_popover.html.haml b/app/views/members/_image_with_popover.html.haml new file mode 100644 index 000000000..4332b0e51 --- /dev/null +++ b/app/views/members/_image_with_popover.html.haml @@ -0,0 +1,14 @@ += link_to | + image_tag( | + Gravatar.new(member.email).image_url( | + options = { | + :size => defined?(size) ? size : 150, | + :default => :identicon }), | + :alt => member.login_name, | + ), | + member, | + :rel => "popover", | + 'data-trigger' => 'hover', | + 'data-title' => member.login_name, | + 'data-content' => "#{ render :partial => 'members/popover', :locals => { :member => member } }", | + 'data-html' => true diff --git a/app/views/members/_popover.html.haml b/app/views/members/_popover.html.haml new file mode 100644 index 000000000..499685233 --- /dev/null +++ b/app/views/members/_popover.html.haml @@ -0,0 +1,5 @@ +%p + %small + - if member.location + %i + = member.location diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index 86f1cece1..88010d760 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -227,17 +227,24 @@ describe 'member' do end end - context 'interesting scope' do + context 'interesting' do - # active members are defined as: + # interesting members are defined as: # 1) confirmed - # 2) ordered by the most recent sign in + # 2) have a location + # 3) have at least one planting + # 4) ordered by the most recent sign in + it 'finds interesting members' do @member1 = FactoryGirl.create(:london_member) @member2 = FactoryGirl.create(:london_member) @member3 = FactoryGirl.create(:london_member) @member4 = FactoryGirl.create(:unconfirmed_member) + [@member1, @member2, @member3, @member4].each do |m| + FactoryGirl.create(:planting, :garden => m.gardens.first) + end + @member1.updated_at = 3.days.ago @member2.updated_at = 2.days.ago @member3.updated_at = 1.days.ago