From 9dfd6dbc7306d0997a1539bc3a6b8c0ada856fb4 Mon Sep 17 00:00:00 2001 From: Brenda Date: Mon, 10 Feb 2020 09:47:37 +1300 Subject: [PATCH 1/4] Tidy up index pages --- .editorconfig | 13 ++++++ app/views/harvests/index.html.haml | 13 ++---- app/views/home/_discuss.html.haml | 20 +------- app/views/layouts/_nav.haml | 15 +++--- app/views/plantings/index.html.haml | 9 ++-- app/views/posts/_preview.haml | 26 ++++++++--- app/views/posts/index.html.haml | 71 ++++++++++------------------- app/views/seeds/index.html.haml | 9 ++-- config/locales/en.yml | 2 +- 9 files changed, 82 insertions(+), 96 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..d2466d8ed --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 2 diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index 71c724c68..ddee6bab7 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -6,16 +6,13 @@ %li.breadcrumb-item.active= link_to "#{@owner}'s harvests", harvests_path(owner: @owner) - else %li.breadcrumb-item.active= link_to "Harvests", harvests_path - -%h1.display-2.text-center - = harvest_icon - = title('harvests', @owner, @crop, @planting) -%p.text-center - #{ENV['GROWSTUFF_SITE_NAME']} helps you track what you're - harvesting from your home garden and see how productive it is. .row .col-md-2 + %h1 + = harvest_icon + = title('harvests', @owner, @crop, @planting) = render 'layouts/nav', model: Harvest + %hr/ - if @owner = render @owner %section.open-data @@ -29,7 +26,7 @@ .badge.badge-success= link_to 'API Methods', '/api-docs' .col-md-10 %section - %h2= page_entries_info @harvests + %h2= title('harvests', @owner, @crop, @planting) = will_paginate @harvests .index-cards - @harvests.each do |h| diff --git a/app/views/home/_discuss.html.haml b/app/views/home/_discuss.html.haml index 23bdb5a0b..88c768ab0 100644 --- a/app/views/home/_discuss.html.haml +++ b/app/views/home/_discuss.html.haml @@ -3,25 +3,7 @@ .row - Post.includes(:author, :crop_posts, :crops).order(created_at: :desc).limit(3).each do |post| .col-lg-4.col-md-12.mb-4 - .view - = link_to post do - = image_tag post_image_path(post), class: 'img img-cover' - %h4.font-weight-bold.mb-3 - %strong - = link_to post do - = post.subject - %p - by - = succeed "," do - %a.font-weight-bold= post.author - %p= post_stripped_tags(post, length: 300) - %h6.font-weight-bold.mb-3 - - post.crops.each do |crop| - = link_to crop do - = crop_icon(crop) - = crop.name.pluralize - / = image_tag avatar_uri(post.author, 50), class: 'avatar' - = link_to 'Read more', post, class: 'btn btn-pink btn-rounded btn-md' + = render 'posts/preview', post: post %p.text-right = link_to "#{t('.view_all')} ยป", posts_path, class: 'btn btn-block' diff --git a/app/views/layouts/_nav.haml b/app/views/layouts/_nav.haml index f363b0aac..0d14e22e4 100644 --- a/app/views/layouts/_nav.haml +++ b/app/views/layouts/_nav.haml @@ -1,14 +1,17 @@ - if current_member.present? - .card.button-bar - .card-header - %h2.card-title #{model} links - = link_to url_for([current_member, model]), class: 'btn' do + .flex-column.nav-pills + / %h2.card-title #{model} links + = link_to url_for([current_member, model]), class: 'nav-link' do My #{model.model_name.human.pluralize} - = link_to model, class: 'btn' do + = link_to model, class: 'nav-link' do Everyone's #{model.model_name.human.pluralize} - if can?(:create, model) = link_to url_for([model, action: :new]), class: 'btn' do Add a #{model.model_name.human} - - else = render 'shared/signin_signup', to: "record your #{model.to_s.pluralize.downcase}" + +%hr/ +%p.text-center + #{ENV['GROWSTUFF_SITE_NAME']} helps you track what you're + harvesting from your home garden and see how productive it is. diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index b7f3a4689..f20a0eba6 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -7,13 +7,12 @@ - else %li.breadcrumb-item.active= link_to 'Plantings', plantings_path -%h1.display-2.text-center - = planting_icon - = title('plantings', @owner, @crop, @planting) .row .col-md-2 + %h1 + = planting_icon + = title('plantings', @owner, @crop, @planting) = render 'layouts/nav', model: Planting - %hr/ = link_to show_inactive_tickbox_path('plantings', owner: @owner, crop: @crop, show_all: @show_all) do = check_box_tag 'active', 'all', @show_all include finished plantings @@ -36,7 +35,7 @@ .col-md-10 %section - %h2= page_entries_info @plantings + %h2= title('plantings', @owner, @crop, @planting) = will_paginate @plantings .index-cards - @plantings.each do |p| diff --git a/app/views/posts/_preview.haml b/app/views/posts/_preview.haml index 275e5f1fa..ae58d57a6 100644 --- a/app/views/posts/_preview.haml +++ b/app/views/posts/_preview.haml @@ -1,6 +1,20 @@ -.card.card-cascade - .card-header - %h3= link_to post.subject, post - = render 'members/tiny', member: post.author - .card-body - %p= truncate(strip_tags(post.body), length: 200) + +.view + = link_to post do + = image_tag post_image_path(post), class: 'img img-cover' +%h4.font-weight-bold.mb-3 + %strong + = link_to post do + = post.subject +%p + by + = succeed "," do + %a.font-weight-bold= post.author +%p= post_stripped_tags(post, length: 300) +%h6.font-weight-bold.mb-3 + - post.crops.each do |crop| + = link_to crop do + = crop_icon(crop) + = crop.name.pluralize +/ = image_tag avatar_uri(post.author, 50), class: 'avatar' += link_to 'Read more', post, class: 'btn btn-rounded btn-md' diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index 9e1ffc35b..5c958ca2a 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -8,50 +8,29 @@ %h1= @author ? t('.title.author_posts', author: @author) : t('.title.default') -= render 'layouts/nav', model: Post +.row + .col-2 + .col-8= will_paginate @posts +.row + .col-2 + = render 'layouts/nav', model: Post + %hr/ + %p + - if @author + = render @author + Subscribe to + = succeed "." do + = link_to "#{@author}'s posts RSS feed", member_posts_path(@author, format: 'rss') -= will_paginate @posts - -- @posts.each do |post| - .card.post - .card-body - %h5.card-title - = link_to strip_tags(post.subject), post - - if post.comments.size.positive? - %span.badge.badge-pill.badge-info.float-right - = icon 'fas', 'comment' -   - = post.comments.size - %p.text-muted - Posted by - - if post.author - = link_to post.author.login_name, member_path(post.author) - - else - Member Deleted - - - if post.forum - in #{link_to post.forum, post.forum} - on #{post.created_at}" - - if post.updated_at > post.created_at - and edited at #{post.updated_at} - = render 'members/tiny', member: post.author - .card-body - .post-body= display_post_truncated(post) - - post.crops.each do |crop| - = render 'crops/tiny', crop: crop - - -= will_paginate @posts - -%p - - if @author - Subscribe to - = succeed "." do - = link_to "#{@author}'s posts RSS feed", member_posts_path(@author, format: 'rss') - - - else - Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} - = link_to "posts RSS feed", posts_path(format: 'rss') - or - = succeed "." do - = link_to "comments RSS feed", comments_path(format: 'rss') + - else + Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} + = link_to "posts RSS feed", posts_path(format: 'rss') + or + = succeed "." do + = link_to "comments RSS feed", comments_path(format: 'rss') + .col-10 + .row + - @posts.includes(:author, :crop_posts, :crops).order(created_at: :desc).each do |post| + .col-lg-3.col-md-6.mb-3 + = render 'posts/preview', post: post + = will_paginate @posts diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index 47e349278..05a9cb5ee 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -6,14 +6,13 @@ %li.breadcrumb-item.active= link_to 'Seeds', seeds_path - content_for :title, title('seeds', @owner, @crop, @planting) -%h1.display-2.text-center - = seed_icon - = title('seeds', @owner, @crop, @planting) .row .col-md-2 + %h1 + = seed_icon + = title('seeds', @owner, @crop, @planting) = render 'layouts/nav', model: Seed - %hr/ = link_to show_inactive_tickbox_path('seeds', owner: @owner, crop: @crop, show_all: @show_all) do = check_box_tag 'active', 'all', @show_all include finished @@ -34,7 +33,7 @@ .badge.badge-success= link_to 'API Methods', '/api-docs' .col-md-10 %section - %h2= page_entries_info @seeds + %h2= title('seeds', @owner, @crop, @planting) = will_paginate @seeds .index-cards diff --git a/config/locales/en.yml b/config/locales/en.yml index fccdaf455..0027f3698 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -293,7 +293,7 @@ en: title: crop_plantings: Everyone's %{crop} plantings default: Everyone's plantings - owner_plantings: "%{owner} plantings" + owner_plantings: "%{owner}'s plantings" view_owners_profile: View %{owner}'s profile >> string: "%{crop} planting in %{garden} by %{owner}" progress: From dcb05c2e1e2ff60979cce898a27bcc1cdfc467d5 Mon Sep 17 00:00:00 2001 From: Brenda Date: Mon, 10 Feb 2020 10:03:49 +1300 Subject: [PATCH 2/4] tidy up posts on crops page --- app/views/crops/_posts.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/crops/_posts.html.haml b/app/views/crops/_posts.html.haml index 1ce1bc7ff..ad0c615ed 100644 --- a/app/views/crops/_posts.html.haml +++ b/app/views/crops/_posts.html.haml @@ -16,7 +16,7 @@ .index-cards - @posts.each do |post| - = render 'posts/preview', post: post + .card.card-double= render 'posts/preview', post: post = will_paginate @posts From 821ddd90cbc091d399cdc43a98aefabdb8570353 Mon Sep 17 00:00:00 2001 From: Brenda Date: Mon, 10 Feb 2020 11:02:16 +1300 Subject: [PATCH 3/4] fix specs --- app/controllers/posts_controller.rb | 4 +++- app/views/layouts/_nav.haml | 2 +- app/views/posts/_preview.haml | 2 +- app/views/posts/index.html.haml | 6 +++--- spec/features/gardens/actions_spec.rb | 2 +- spec/views/posts/index.html.haml_spec.rb | 8 +++++--- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 40a70fade..b1affe635 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -54,6 +54,8 @@ class PostsController < ApplicationController @author.posts else Post - end.order(created_at: :desc).includes(:author, comments: :author).paginate(page: params[:page], per_page: 12) + end.order(created_at: :desc) + .includes(:author, :crop_posts, :crops, comments: :author) + .paginate(page: params[:page], per_page: 12) end end diff --git a/app/views/layouts/_nav.haml b/app/views/layouts/_nav.haml index 0d14e22e4..158f9043d 100644 --- a/app/views/layouts/_nav.haml +++ b/app/views/layouts/_nav.haml @@ -1,5 +1,5 @@ - if current_member.present? - .flex-column.nav-pills + .flex-column.nav-pills.layout-nav / %h2.card-title #{model} links = link_to url_for([current_member, model]), class: 'nav-link' do My #{model.model_name.human.pluralize} diff --git a/app/views/posts/_preview.haml b/app/views/posts/_preview.haml index ae58d57a6..711618bd6 100644 --- a/app/views/posts/_preview.haml +++ b/app/views/posts/_preview.haml @@ -10,7 +10,7 @@ by = succeed "," do %a.font-weight-bold= post.author -%p= post_stripped_tags(post, length: 300) +%p.post-body= post_stripped_tags(post, length: 300) %h6.font-weight-bold.mb-3 - post.crops.each do |crop| = link_to crop do diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index 5c958ca2a..6081aa608 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -29,8 +29,8 @@ = succeed "." do = link_to "comments RSS feed", comments_path(format: 'rss') .col-10 - .row - - @posts.includes(:author, :crop_posts, :crops).order(created_at: :desc).each do |post| - .col-lg-3.col-md-6.mb-3 + .row.posts + - @posts.each do |post| + .col-lg-3.col-md-6.mb-3.post = render 'posts/preview', post: post = will_paginate @posts diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb index 6c1fc8b49..a127ead47 100644 --- a/spec/features/gardens/actions_spec.rb +++ b/spec/features/gardens/actions_spec.rb @@ -14,7 +14,7 @@ describe "Gardens" do describe '#index' do shared_examples "has buttons bar at top" do it "has buttons bar at top" do - within '.button-bar' do + within '.layout-nav' do expect(subject).to have_link 'Add a garden' expect(subject).to have_link 'My gardens' expect(subject).to have_link "Everyone's gardens" diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb index 613f8dc59..c1eea3af5 100644 --- a/spec/views/posts/index.html.haml_spec.rb +++ b/spec/views/posts/index.html.haml_spec.rb @@ -23,12 +23,14 @@ describe "posts/index" do it "renders a list of posts" do assert_select "div.post", count: 2 - assert_select "h5", text: "A Post", count: 2 - assert_select "div.post-body", text: "This is some text.".to_s, count: 2 + assert_select "h4", text: "A Post", count: 2 + assert_select "p.post-body", text: "This is some text.", count: 2 end it "contains two gravatar icons" do - assert_select "img", src: %r{gravatar\.com/avatar}, count: 2 + within '.posts' do + assert_select "img", src: %r{gravatar\.com/avatar}, count: 2 + end end it "contains RSS feed links for posts and comments" do From b5946b5c818bf5547c4d36ce5b3ae86bff546eab Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 9 Feb 2020 09:40:04 +0000 Subject: [PATCH 4/4] Bump haml_lint from 0.34.1 to 0.34.2 Bumps [haml_lint](https://github.com/sds/haml-lint) from 0.34.1 to 0.34.2. - [Release notes](https://github.com/sds/haml-lint/releases) - [Changelog](https://github.com/sds/haml-lint/blob/master/CHANGELOG.md) - [Commits](https://github.com/sds/haml-lint/compare/v0.34.1...v0.34.2) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 760b58f7e..cc8ad62db 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -221,7 +221,7 @@ GEM haml (>= 4.0.6, < 6.0) html2haml (>= 1.0.1) railties (>= 5.1) - haml_lint (0.34.1) + haml_lint (0.34.2) haml (>= 4.0, < 5.2) rainbow rubocop (>= 0.50.0)