From 972518e9fcc2781523a48e782ee20d2c6c9bafee Mon Sep 17 00:00:00 2001 From: Mackenzie Morgan Date: Wed, 25 May 2016 23:15:36 -0400 Subject: [PATCH] Stop hard-coding strings for pagination Use translation template to set singular/other strings for .model_name Fixes #855 --- app/views/comments/index.html.haml | 4 +-- app/views/crops/show.html.haml | 4 +-- app/views/crops/wrangle.html.haml | 4 +-- app/views/gardens/index.html.haml | 4 +-- app/views/harvests/index.html.haml | 4 +-- app/views/members/index.html.haml | 4 +-- app/views/members/view_followers.html.haml | 6 ++--- app/views/members/view_follows.html.haml | 6 ++--- app/views/photos/index.html.haml | 4 +-- app/views/photos/new.html.haml | 2 +- app/views/plantings/index.html.haml | 4 +-- app/views/posts/index.html.haml | 4 +-- app/views/seeds/index.html.haml | 4 +-- config/locales/en.yml | 29 ++++++++++++++++++++++ 14 files changed, 56 insertions(+), 27 deletions(-) diff --git a/app/views/comments/index.html.haml b/app/views/comments/index.html.haml index 540773b41..e04707fc7 100644 --- a/app/views/comments/index.html.haml +++ b/app/views/comments/index.html.haml @@ -1,7 +1,7 @@ = content_for :title, "Recent comments" %div.pagination - = page_entries_info @comments, :model => "comments" + = page_entries_info @comments = will_paginate @comments - @comments.each do |comment| @@ -11,7 +11,7 @@ = render :partial => "single", :locals => { :comment => comment } %div.pagination - = page_entries_info @comments, :model => "comments" + = page_entries_info @comments = will_paginate @comments %p diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index c32fc12c8..40c5d1812 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -54,13 +54,13 @@ = render :partial => "shared/signin_signup", :locals => { :to => "post your tips and experiences growing #{ @crop.name.pluralize }" } - else %div.pagination - = page_entries_info @posts, :model => "posts" + = page_entries_info @posts = will_paginate @posts, :params => {:anchor => "posts"} - @posts.each do |post| = render :partial => "posts/single", :locals => { :post => post, :subject => true } %div.pagination - = page_entries_info @posts, :model => "posts" + = page_entries_info @posts = will_paginate @posts, :params => {:anchor => "posts"} .col-md-3 diff --git a/app/views/crops/wrangle.html.haml b/app/views/crops/wrangle.html.haml index 3a13ec68e..4c0448b01 100644 --- a/app/views/crops/wrangle.html.haml +++ b/app/views/crops/wrangle.html.haml @@ -34,7 +34,7 @@ %div.pagination - = page_entries_info @crops, :model => "crops" + = page_entries_info @crops = will_paginate @crops %table{:class => "table table-striped", :id => @approval_status.blank? ? 'recently-added-crops' : "#{@approval_status}-crops"} @@ -64,7 +64,7 @@ ago. %div.pagination - = page_entries_info @crops, :model => "crops" + = page_entries_info @crops = will_paginate @crops diff --git a/app/views/gardens/index.html.haml b/app/views/gardens/index.html.haml index 12928b051..0323d0be1 100644 --- a/app/views/gardens/index.html.haml +++ b/app/views/gardens/index.html.haml @@ -15,7 +15,7 @@ = render :partial => 'shared/signin_signup', :locals => { :to => 'add a new garden' } %div.pagination - = page_entries_info @gardens, :model => "gardens" + = page_entries_info @gardens = will_paginate @gardens .row @@ -27,6 +27,6 @@ %p There are no gardens to display. %div.pagination - = page_entries_info @gardens, :model => "gardens" + = page_entries_info @gardens = will_paginate @gardens diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index a99097d81..f6f5fff7f 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -21,7 +21,7 @@ = render :partial => 'shared/signin_signup', :locals => { :to => 'track your harvests' } %div.pagination - = page_entries_info @harvests, :model => "harvests" + = page_entries_info @harvests = will_paginate @harvests .row - if @harvests.size > 0 @@ -30,7 +30,7 @@ =render :partial => 'harvests/thumbnail', :locals => {:harvest => harvest} %div.pagination - = page_entries_info @harvests, :model => "harvests" + = page_entries_info @harvests = will_paginate @harvests %ul.list-inline diff --git a/app/views/members/index.html.haml b/app/views/members/index.html.haml index 705d69594..43f3b2867 100644 --- a/app/views/members/index.html.haml +++ b/app/views/members/index.html.haml @@ -7,7 +7,7 @@ = submit_tag "Show", :class => 'btn btn-primary' %div.pagination - = page_entries_info @members, :model => "members" + = page_entries_info @members = will_paginate @members .member-cards @@ -15,5 +15,5 @@ = render :partial => "members/thumbnail", :locals => { :member => m } %div.pagination - = page_entries_info @members, :model => "members" + = page_entries_info @members = will_paginate @members diff --git a/app/views/members/view_followers.html.haml b/app/views/members/view_followers.html.haml index 25a10a860..6600c737c 100644 --- a/app/views/members/view_followers.html.haml +++ b/app/views/members/view_followers.html.haml @@ -1,7 +1,7 @@ - content_for :title, "#{@member.login_name}'s followers" %div.pagination - = page_entries_info @followers, :model => "members" + = page_entries_info @followers = will_paginate @followers .row @@ -12,5 +12,5 @@ = render :partial => "members/thumbnail", :locals => { :member => f } %div.pagination - = page_entries_info @followers, :model => "members" - = will_paginate @followers \ No newline at end of file + = page_entries_info @followers + = will_paginate @followers diff --git a/app/views/members/view_follows.html.haml b/app/views/members/view_follows.html.haml index 93d2695ac..cd0c522de 100644 --- a/app/views/members/view_follows.html.haml +++ b/app/views/members/view_follows.html.haml @@ -1,7 +1,7 @@ - content_for :title, "#{@member.login_name}'s follows" %div.pagination - = page_entries_info @follows, :model => "members" + = page_entries_info @follows = will_paginate @follows .row @@ -12,5 +12,5 @@ = render :partial => "members/thumbnail", :locals => { :member => f } %div.pagination - = page_entries_info @follows, :model => "members" - = will_paginate @follows \ No newline at end of file + = page_entries_info @follows + = will_paginate @follows diff --git a/app/views/photos/index.html.haml b/app/views/photos/index.html.haml index 10a14f88e..f7791cdc0 100644 --- a/app/views/photos/index.html.haml +++ b/app/views/photos/index.html.haml @@ -3,7 +3,7 @@ %p Most recent photos added to #{ENV['GROWSTUFF_SITE_NAME']}. %div.pagination - = page_entries_info @photos, :model => "photos" + = page_entries_info @photos = will_paginate @photos .row @@ -17,7 +17,7 @@ = link_to p.owner, p.owner %div.pagination - = page_entries_info @photos, :model => "photos" + = page_entries_info @photos = will_paginate @photos diff --git a/app/views/photos/new.html.haml b/app/views/photos/new.html.haml index 802281b99..6c8a525b6 100644 --- a/app/views/photos/new.html.haml +++ b/app/views/photos/new.html.haml @@ -20,7 +20,7 @@ = submit_tag "Search", :class => 'btn btn-primary' %div.pagination - = page_entries_info @photos, :model => "photos" + = page_entries_info @photos = will_paginate @photos .row diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index d048a0e89..14c319a5b 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -17,7 +17,7 @@ = render :partial => 'shared/signin_signup', :locals => { :to => "track what you've planted" } %div.pagination - = page_entries_info @plantings, :model => "plantings" + = page_entries_info @plantings = will_paginate @plantings .row @@ -27,7 +27,7 @@ = render partial: "plantings/thumbnail", locals: {:planting => planting} %div.pagination - = page_entries_info @plantings, :model => "plantings" + = page_entries_info @plantings = will_paginate @plantings %ul.list-inline diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index 9eee54694..fa2156dcd 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -15,7 +15,7 @@ = render :partial => 'shared/signin_signup', :locals => { :to => 'write a post' } %div.pagination - = page_entries_info @posts, :model => "posts" + = page_entries_info @posts = will_paginate @posts - unless @posts.empty? @@ -23,7 +23,7 @@ = render :partial => "single", :locals => { :post => post, :subject => true } %div.pagination - = page_entries_info @posts, :model => "posts" + = page_entries_info @posts = will_paginate @posts %p diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index 9bd5cde84..86329147c 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -21,7 +21,7 @@ = render :partial => 'shared/signin_signup', :locals => { :to => 'add seeds to your stash' } %div.pagination - = page_entries_info @seeds, :model => "seeds" + = page_entries_info @seeds = will_paginate @seeds .row - if @seeds.size > 0 @@ -30,7 +30,7 @@ =render :partial => 'seeds/thumbnail', :locals => {:seed => seed} %div.pagination - = page_entries_info @seeds, :model => "seeds" + = page_entries_info @seeds = will_paginate @seeds %ul.list-inline diff --git a/config/locales/en.yml b/config/locales/en.yml index 8d77afdc8..27e8c5a91 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -151,3 +151,32 @@ en: post: "Post" edit_profile: "Edit profile" + activerecord: + models: + comment: + one: "comment" + other: "comments" + crop: + one: "crop" + other: "crops" + garden: + one: "garden" + other: "gardens" + harvest: + one: "harvest" + other: "harvests" + member: + one: "member" + other: "members" + photo: + one: "photo" + other: "photos" + planting: + one: "planting" + other: "plantings" + post: + one: "post" + other: "posts" + seed: + one: "seed" + other: "seeds"