From 1db30d98cedd75b3bf902c650f58d66188bc9707 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 7 Feb 2017 07:38:37 +1300 Subject: [PATCH] Haml clean up for members --- app/views/members/_avatar.html.haml | 7 +++---- app/views/members/_contact.html.haml | 12 ++++++------ app/views/members/_gardens.html.haml | 8 ++++---- app/views/members/_location.html.haml | 2 +- app/views/members/_map.html.haml | 10 +++++----- app/views/members/_stats.html.haml | 12 ++++++------ app/views/members/_thumbnail.html.haml | 6 +++--- app/views/members/finish_signup.haml | 12 ++++++------ app/views/members/index.html.haml | 14 +++++++------- app/views/members/nearby.html.haml | 14 +++++++------- app/views/members/show.html.haml | 18 +++++++++--------- app/views/members/show.rss.haml | 2 +- app/views/members/view_followers.html.haml | 6 +++--- app/views/members/view_follows.html.haml | 6 +++--- 14 files changed, 64 insertions(+), 65 deletions(-) diff --git a/app/views/members/_avatar.html.haml b/app/views/members/_avatar.html.haml index 3089dc4be..8570c4227 100644 --- a/app/views/members/_avatar.html.haml +++ b/app/views/members/_avatar.html.haml @@ -1,5 +1,4 @@ -= link_to | - image_tag(avatar_uri(member, 150), | - :alt => '', | - :class => 'img img-responsive avatar' ), | += link_to image_tag(avatar_uri(member, 150), + alt: '', + class: 'img img-responsive avatar'), member_path(member) diff --git a/app/views/members/_contact.html.haml b/app/views/members/_contact.html.haml index 714bf5a92..224d9c491 100644 --- a/app/views/members/_contact.html.haml +++ b/app/views/members/_contact.html.haml @@ -3,18 +3,18 @@ - if twitter_auth %p - = image_tag "twitter_32.png", :size => "32x32", :alt => 'Twitter logo' - =link_to twitter_auth.name, "http://twitter.com/#{twitter_auth.name}" + = image_tag "twitter_32.png", :size => "32x32", alt: 'Twitter logo' + = link_to twitter_auth.name, "http://twitter.com/#{twitter_auth.name}" - if flickr_auth %p - = image_tag "flickr_32.png", :size => "32x32", :alt => 'Flickr logo' - =link_to flickr_auth.name, "http://flickr.com/photos/#{flickr_auth.uid}" + = image_tag "flickr_32.png", :size => "32x32", alt: 'Flickr logo' + = link_to flickr_auth.name, "http://flickr.com/photos/#{flickr_auth.uid}" - if facebook_auth %p - = image_tag "facebook_32.png", :size => "32x32", :alt => 'Facebook logo' - =link_to facebook_auth.name, "http://facebook.com/profile/#{facebook_auth.uid}" + = image_tag "facebook_32.png", :size => "32x32", alt: 'Facebook logo' + = link_to facebook_auth.name, "http://facebook.com/profile/#{facebook_auth.uid}" - if member.show_email %p diff --git a/app/views/members/_gardens.html.haml b/app/views/members/_gardens.html.haml index b860f8640..798ae961b 100644 --- a/app/views/members/_gardens.html.haml +++ b/app/views/members/_gardens.html.haml @@ -3,7 +3,7 @@ %ul.nav.nav-tabs - first_garden = true - gardens.each do |g| - %li{:class => first_garden ? 'active' : '' } + %li{ class: first_garden ? 'active' : '' } - first_garden = false = link_to display_garden_name(g), "#garden#{g.id}", 'data-toggle' => 'tab' - if current_member == member @@ -14,7 +14,7 @@ - first_garden = true - gardens.each do |g| - %div{:class => ['tab-pane', first_garden ? 'active' : ''], :id => "garden#{g.id}"} + %div{ class: ['tab-pane', first_garden ? 'active' : ''], id: "garden#{g.id}"} - first_garden = false .container @@ -38,11 +38,11 @@ %ul.thumbnails - g.photos.each do |p| .col-md-2.six-across - = render :partial => 'photos/thumbnail', :locals => { :photo => p } + = render partial: 'photos/thumbnail', locals: { photo: p } .row - if can? :create, Photo and can? :edit, g %p - = link_to "Add photo", new_photo_path(:type => "garden", :id => g.id), :class => 'btn btn-primary' + = link_to "Add photo", new_photo_path(type: "garden", id: g.id), class: 'btn btn-primary' %h3 What's planted here? .row diff --git a/app/views/members/_location.html.haml b/app/views/members/_location.html.haml index a8442afe2..884ff04b2 100644 --- a/app/views/members/_location.html.haml +++ b/app/views/members/_location.html.haml @@ -2,4 +2,4 @@ - if member.location.blank? unknown location - else - = link_to member.location, place_path(:place => member.location, anchor: "members") + = link_to member.location, place_path(place: member.location, anchor: "members") diff --git a/app/views/members/_map.html.haml b/app/views/members/_map.html.haml index cbf32ea6e..253f3b3ec 100644 --- a/app/views/members/_map.html.haml +++ b/app/views/members/_map.html.haml @@ -1,9 +1,9 @@ -- if member.latitude and member.longitude - %div#membermap +- if member.latitude && member.longitude + #membermap %p See other members, plantings, seeds and more near = link_to member.location, place_path(member.location, anchor: "members") - else - %div.location-not-set - %div.sr-only Location not known - %div.sr-only We can't show you what's nearby \ No newline at end of file + .location-not-set + .sr-only Location not known + .sr-only We can't show you what's nearby diff --git a/app/views/members/_stats.html.haml b/app/views/members/_stats.html.haml index a6a04fcb8..586ae6d04 100644 --- a/app/views/members/_stats.html.haml +++ b/app/views/members/_stats.html.haml @@ -2,34 +2,34 @@ %ul.list-inline %li - - if member.plantings.size > 0 + - unless member.plantings.empty? = link_to localize_plural(member.plantings, Planting), plantings_by_owner_path(owner: member) - else 0 plantings %li - - if member.harvests.size > 0 + - unless member.harvests.empty? = link_to localize_plural(member.harvests, Harvest), harvests_by_owner_path(owner: member) - else 0 harvests %li - - if member.seeds.size > 0 + - unless member.seeds.empty? = link_to localize_plural(member.seeds, Seed), seeds_by_owner_path(owner: member) - else 0 seeds %li - - if member.posts.size > 0 + - unless member.posts.empty? = link_to localize_plural(member.posts, Post), posts_by_author_path(author: member) - else 0 posts %li - - if member.followed.size > 0 + - unless member.followed.empty? = link_to localize_plural(member.followed, Follow), member_follows_path(member) - else 0 following %li - - if member.followers.size > 0 + - unless member.followers.empty? = link_to pluralize(member.followers.size, "follower"), member_followers_path(member) - else 0 followers diff --git a/app/views/members/_thumbnail.html.haml b/app/views/members/_thumbnail.html.haml index af3330ca7..4b57feb78 100644 --- a/app/views/members/_thumbnail.html.haml +++ b/app/views/members/_thumbnail.html.haml @@ -1,15 +1,15 @@ - cache member do .member-thumbnail.panel %div - = render :partial => "members/avatar", :locals => { :member => member } + = render partial: "members/avatar", locals: { member: member } %div %p.login-name = link_to member.login_name, member - - if !member.location.blank? + - unless member.location.blank? %small %br/ %i= member.location - - if !member.plantings.empty? + - unless member.plantings.empty? %small %br/ Recently planted: diff --git a/app/views/members/finish_signup.haml b/app/views/members/finish_signup.haml index 5d88cf43b..3f0ec03c8 100644 --- a/app/views/members/finish_signup.haml +++ b/app/views/members/finish_signup.haml @@ -2,9 +2,9 @@ %p Sign up for a Growstuff account to track your veggie garden and connect with other local growers. -= form_for(current_member, :as => 'member', :url => finish_signup_path(current_member), :html => { role: 'form'}) do |f| += form_for(current_member, as: 'member', url: finish_signup_path(current_member), html: { role: 'form'}) do |f| - if @show_errors && current_member.errors.any? - %div.alert.alert-danger + .alert.alert-danger - current_member.errors.full_messages.each do |msg| = msg %br @@ -12,7 +12,7 @@ .form-group = f.label :login_name .controls - = f.text_field :login_name, :autofocus => true, class: 'form-control input-lg' + = f.text_field :login_name, autofocus: true, class: 'form-control input-lg' %p.help-block Choose a login name .form-group @@ -34,7 +34,7 @@ = f.check_box :newsletter, :checked => true Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} newsletter .help-inline - = render :partial => 'devise/registrations/newsletter_blurb' + = render partial: 'devise/registrations/newsletter_blurb' - %div.actions - = f.submit 'Continue', :class => 'btn btn-primary' \ No newline at end of file + .actions + = f.submit 'Continue', class: 'btn btn-primary' \ No newline at end of file diff --git a/app/views/members/index.html.haml b/app/views/members/index.html.haml index 43f3b2867..878c02ea4 100644 --- a/app/views/members/index.html.haml +++ b/app/views/members/index.html.haml @@ -1,19 +1,19 @@ = content_for :title, t(".title", site_name: "#{ENV['GROWSTUFF_SITE_NAME']}") -= form_tag(members_path, :method => :get, :class => 'form-inline', :role => 'form') do += form_tag(members_path, method: :get, class: 'form-inline', role: 'form') do .form-group - = label_tag :sort, "Sort by:", :class => 'sr-only' - = select_tag "sort", options_for_select({"Sort alphabetically" => 'alpha', "Sort by recently joined" => "recently_joined"}, @sort || 'alpha'), :class => 'form-control' - = submit_tag "Show", :class => 'btn btn-primary' + = label_tag :sort, "Sort by:", class: 'sr-only' + = select_tag "sort", options_for_select({"Sort alphabetically" => 'alpha', "Sort by recently joined" => "recently_joined"}, @sort || 'alpha'), class: 'form-control' + = submit_tag "Show", class: 'btn btn-primary' -%div.pagination +.pagination = page_entries_info @members = will_paginate @members .member-cards - @members.each do |m| - = render :partial => "members/thumbnail", :locals => { :member => m } + = render partial: "members/thumbnail", locals: { member: m } -%div.pagination +.pagination = page_entries_info @members = will_paginate @members diff --git a/app/views/members/nearby.html.haml b/app/views/members/nearby.html.haml index 59c7056f6..a99ce90da 100644 --- a/app/views/members/nearby.html.haml +++ b/app/views/members/nearby.html.haml @@ -3,13 +3,13 @@ - else content_for :title, "Find nearby members" %p - = form_tag(nearby_members_path, :method => :get, :class => 'form-inline') do - = label_tag :distance, "Find members within", :class => 'control-label' - = text_field_tag :distance, @distance, :class => 'input-mini' - = select_tag :units, options_for_select({"miles" => :mi, "km" => :km}, @units), :class => 'input-small' - = label_tag :location, "of", :class => 'control-label' + = form_tag(nearby_members_path, method: :get, class: 'form-inline') do + = label_tag :distance, "Find members within", class: 'control-label' + = text_field_tag :distance, @distance, class: 'input-mini' + = select_tag :units, options_for_select({"miles" => :mi, "km" => :km}, @units), class: 'input-small' + = label_tag :location, "of", class: 'control-label' = text_field_tag :location, @location - = submit_tag "Search", :class => 'btn btn-primary' + = submit_tag "Search", class: 'btn btn-primary' - if can? :update, current_member %p @@ -20,6 +20,6 @@ .row - @nearby_members.each do |member| .col-md-4.three-across - = render :partial => "members/thumbnail", :locals => { :member => member } + = render partial: "members/thumbnail", locals: { member: member } - elsif @location %h3 No results found diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 9875d43a8..0633eacae 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -9,18 +9,18 @@ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) - content_for :buttonbar do - if can? :update, @member - = link_to 'Edit profile', edit_member_registration_path, :class => 'btn btn-default' + = link_to 'Edit profile', edit_member_registration_path, class: 'btn btn-default' - if @member == current_member && !@member.paid? - = link_to "Upgrade account", shop_path, :class => 'btn btn-default' + = link_to "Upgrade account", shop_path, class: 'btn btn-default' - if can? :create, Notification and current_member != @member - = link_to 'Send message', new_notification_path(:recipient_id => @member.id), :class => 'btn btn-default' + = link_to 'Send message', new_notification_path(:recipient_id => @member.id), class: 'btn btn-default' - if current_member and current_member != @member # must be logged in, can't follow yourself - follow = current_member.get_follow(@member) - if !follow and can? :create, Follow # not already following - = link_to 'Follow', follows_path(:followed_id => @member.id), :method => :post, :class => 'btn btn-default' + = link_to 'Follow', follows_path(:followed_id => @member.id), method: :post, class: 'btn btn-default' - if follow and can? :destroy, follow # already following - = link_to 'Unfollow', follow_path(follow), :method => :delete, :class => 'btn btn-default' + = link_to 'Unfollow', follow_path(follow), method: :delete, class: 'btn btn-default' - content_for :member_rss_login_name, @member.login_name - content_for :member_rss_slug, @member.slug @@ -32,7 +32,7 @@ = render partial: "bio", locals: { member: @member } = render partial: "gardens", locals: { member: @member, gardens: @gardens } .col-md-3 - = render :partial => "avatar", :locals => { :member => @member } - = render :partial => "account", :locals => { :member => @member } - = render :partial => "stats", :locals => { :member => @member } - = render :partial => "contact", :locals => { :member => @member, :twitter_auth => @twitter_auth, :flickr_auth => @flickr_auth, :facebook_auth => @facebook_auth } + = render partial: "avatar", locals: { member: @member } + = render partial: "account", locals: { member: @member } + = render partial: "stats", locals: { member: @member } + = render partial: "contact", locals: { member: @member, :twitter_auth => @twitter_auth, :flickr_auth => @flickr_auth, :facebook_auth => @facebook_auth } diff --git a/app/views/members/show.rss.haml b/app/views/members/show.rss.haml index 6d727fbbe..fa88b66a9 100644 --- a/app/views/members/show.rss.haml +++ b/app/views/members/show.rss.haml @@ -1,5 +1,5 @@ -%rss{:version => 2.0} +%rss{version: 2.0} %channel %title #{@member.login_name}'s recent posts (#{ENV['GROWSTUFF_SITE_NAME']}) %link= member_url(@member) diff --git a/app/views/members/view_followers.html.haml b/app/views/members/view_followers.html.haml index aeea18b8c..1aea716bd 100644 --- a/app/views/members/view_followers.html.haml +++ b/app/views/members/view_followers.html.haml @@ -1,6 +1,6 @@ - content_for :title, "#{@member.login_name}'s followers" -%div.pagination +.pagination = page_entries_info @followers = will_paginate @followers @@ -9,8 +9,8 @@ - @followers.each do |f| .col-md-4.three-across .thumbnail - = render :partial => "members/thumbnail", :locals => { :member => f } + = render partial: "members/thumbnail", locals: { member: f } -%div.pagination +.pagination = 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 a5f293737..ecd7bae2e 100644 --- a/app/views/members/view_follows.html.haml +++ b/app/views/members/view_follows.html.haml @@ -1,6 +1,6 @@ - content_for :title, "#{@member.login_name}'s follows" -%div.pagination +.pagination = page_entries_info @follows = will_paginate @follows @@ -9,8 +9,8 @@ - @follows.each do |f| .col-md-4.three-across .thumbnail - = render :partial => "members/thumbnail", :locals => { :member => f } + = render partial: "members/thumbnail", locals: { member: f } -%div.pagination +.pagination = page_entries_info @follows = will_paginate @follows