Haml clean up for comments views

This commit is contained in:
Brenda Wallace
2017-02-04 14:07:59 +13:00
parent c43c1686a3
commit 785ae33a42
6 changed files with 24 additions and 22 deletions

View File

@@ -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

View File

@@ -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'

View File

@@ -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')

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
%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)

View File

@@ -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'

View File

@@ -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)