From 785ae33a42b4e514aba1fd49adfe50d35e738551 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 4 Feb 2017 14:07:59 +1300 Subject: [PATCH] Haml clean up for comments views --- app/views/comments/_form.html.haml | 14 ++++++++------ app/views/comments/_single.html.haml | 10 +++++----- app/views/comments/index.html.haml | 8 ++++---- app/views/comments/index.rss.haml | 4 ++-- app/views/comments/new.html.haml | 4 ++-- app/views/comments/show.html.haml | 6 +++--- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/app/views/comments/_form.html.haml b/app/views/comments/_form.html.haml index 14af354aa..ab41c70e5 100644 --- a/app/views/comments/_form.html.haml +++ b/app/views/comments/_form.html.haml @@ -1,18 +1,20 @@ -= form_for(@comment, :html => {:class => "form-horizontal", :role => "form"}) do |f| += form_for(@comment, html: { class: "form-horizontal", role: "form" }) do |f| - if @comment.errors.any? #error_explanation - %h2= "#{pluralize(@comment.errors.size, "error")} prohibited this comment from being saved:" + %h2 + = pluralize(@comment.errors.size, "error") + prohibited this comment from being saved:" %ul - @comment.errors.full_messages.each do |msg| %li= msg .form-group = f.label :body, "Your comment:" - = f.text_area :body, :rows => 6, :class => 'form-control', :autofocus => 'autofocus' + = f.text_area :body, rows: 6, class: 'form-control', autofocus: 'autofocus' %span.help-block - = render :partial => "shared/markdown_help" + = render partial: "shared/markdown_help" .actions - = f.submit 'Post comment', :class => 'btn btn-primary' + = f.submit 'Post comment', class: 'btn btn-primary' - if defined?(@post) .field - = f.hidden_field :post_id, :value => @post.id + = f.hidden_field :post_id, value: @post.id diff --git a/app/views/comments/_single.html.haml b/app/views/comments/_single.html.haml index 895002b1e..d27300067 100644 --- a/app/views/comments/_single.html.haml +++ b/app/views/comments/_single.html.haml @@ -2,7 +2,7 @@ .comment .row .col-md-1 - = render :partial => "members/avatar", :locals => { :member => comment.author } + = render partial: "members/avatar", locals: { member: comment.author } .col-md-11 .comment-meta Posted by @@ -17,11 +17,11 @@ :growstuff_markdown #{ strip_tags comment.body } - - if can? :edit, comment or can? :destroy, comment + - if can?(:edit, comment) || can?(:destroy, comment) .comment-actions - if can? :edit, comment - = link_to 'Edit', edit_comment_path(comment), :class => 'btn btn-default btn-xs' + = link_to 'Edit', edit_comment_path(comment), class: 'btn btn-default btn-xs' - if can? :destroy, comment - = link_to 'Delete', comment, method: :delete, | - data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs' + = link_to 'Delete', comment, method: :delete, + data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' diff --git a/app/views/comments/index.html.haml b/app/views/comments/index.html.haml index e04707fc7..d57c1c33b 100644 --- a/app/views/comments/index.html.haml +++ b/app/views/comments/index.html.haml @@ -1,6 +1,6 @@ = content_for :title, "Recent comments" -%div.pagination +.pagination = page_entries_info @comments = will_paginate @comments @@ -8,13 +8,13 @@ %h2 Comment on = link_to comment.post.subject, comment.post - = render :partial => "single", :locals => { :comment => comment } + = render partial: "single", locals: { comment: comment } -%div.pagination +.pagination = page_entries_info @comments = will_paginate @comments %p Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} = succeed "." do - = link_to "comments RSS feed", comments_path(:format => 'rss') + = link_to "comments RSS feed", comments_path(format: 'rss') diff --git a/app/views/comments/index.rss.haml b/app/views/comments/index.rss.haml index 5df3b3403..406a58c41 100644 --- a/app/views/comments/index.rss.haml +++ b/app/views/comments/index.rss.haml @@ -1,5 +1,5 @@ -%rss{:version => 2.0} +%rss{ version: 2.0 } %channel %title Recent comments on all posts (#{ENV['GROWSTUFF_SITE_NAME']}) %link= comments_url @@ -16,6 +16,6 @@ :escaped_markdown #{ strip_tags comment.body } - %pubDate= comment.created_at.to_s(:rfc822) + %pubdate= comment.created_at.to_s(:rfc822) %link= post_url(comment.post) %guid= comment_url(comment) diff --git a/app/views/comments/new.html.haml b/app/views/comments/new.html.haml index ca74fb99b..91f8eef79 100644 --- a/app/views/comments/new.html.haml +++ b/app/views/comments/new.html.haml @@ -1,7 +1,7 @@ = content_for :title, "New comment" -= render :partial => "posts/single", :locals => { :post => @post || @comment.post, :subject => true } += render partial: "posts/single", locals: { post: @post || @comment.post, subject: true } -= render :partial => "posts/comments", :locals => {:post => @post || @comment.post} += render partial: "posts/comments", locals: { post: @post || @comment.post } = render 'form' diff --git a/app/views/comments/show.html.haml b/app/views/comments/show.html.haml index fd92fd4c2..13c45f837 100644 --- a/app/views/comments/show.html.haml +++ b/app/views/comments/show.html.haml @@ -8,10 +8,10 @@ = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) -= render :partial => "posts/single", :locals => { :post => @comment.post } += render partial: "posts/single", locals: { post: @comment.post } %h2 Showing 1 comment -= render :partial => "single", :locals => { :comment => @comment } += render partial: "single", locals: { comment: @comment } -=link_to "View all comments", post_path(@comment.post) += link_to "View all comments", post_path(@comment.post)