mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-01-06 00:17:49 -05:00
Posts actions in dropdown menus
This commit is contained in:
@@ -21,6 +21,10 @@ module IconsHelper
|
||||
icon('fas', 'heart')
|
||||
end
|
||||
|
||||
def comment_icon
|
||||
icon('fas', 'comment')
|
||||
end
|
||||
|
||||
def finished_icon
|
||||
icon('fas', 'calendar')
|
||||
end
|
||||
|
||||
@@ -1,6 +1,27 @@
|
||||
module PostsHelper
|
||||
def display_post_truncated(post)
|
||||
length = 300
|
||||
return truncate(post.body, length: length, separator: ' ', omission: '... ') { link_to "Read more", post_path(post) }
|
||||
return truncate(strip_tags(post.body), length: length, separator: ' ', omission: '... ') { link_to "Read more", post_path(post) }
|
||||
end
|
||||
|
||||
def post_byline(post)
|
||||
byline = 'Posted by '
|
||||
|
||||
if post.author
|
||||
byline += link_to post.author.login_name, member_path(post.author)
|
||||
else
|
||||
byline += 'Member Deleted'
|
||||
end
|
||||
|
||||
if post.forum
|
||||
byline += ' in '
|
||||
byline += link_to post.forum, post.forum
|
||||
end
|
||||
|
||||
byline += " on #{post.created_at}"
|
||||
|
||||
byline += " and edited at #{post.updated_at}" if post.updated_at > post.created_at
|
||||
|
||||
byline.html_safe
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +1,23 @@
|
||||
.well
|
||||
.comment
|
||||
.card.comment
|
||||
.card-body
|
||||
.row
|
||||
.col-md-1
|
||||
= render partial: "members/avatar", locals: { member: comment.author }
|
||||
.col-md-11
|
||||
.comment-meta
|
||||
.col-md-11.border-left
|
||||
- if can?(:edit, comment) || can?(:destroy, comment)
|
||||
.dropdown.float-right
|
||||
%button#comment-edit-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button"} Actions
|
||||
.dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "comment-edit-button"}
|
||||
- if can? :edit, comment
|
||||
= link_to edit_comment_path(comment), class: 'dropdown-item' do
|
||||
= edit_icon
|
||||
Edit
|
||||
- if can? :destroy, comment
|
||||
= link_to comment, method: :delete,
|
||||
data: { confirm: 'Are you sure?' }, class: 'dropdown-item text-danger' do
|
||||
= delete_icon
|
||||
Delete
|
||||
.comment-meta.text-muted
|
||||
Posted by
|
||||
- if comment.author.deleted?
|
||||
Member Deleted
|
||||
@@ -20,10 +33,3 @@
|
||||
:growstuff_markdown
|
||||
#{ strip_tags comment.body }
|
||||
|
||||
- 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'
|
||||
- if can? :destroy, comment
|
||||
= link_to 'Delete', comment, method: :delete,
|
||||
data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs'
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
= content_for :title, "New comment"
|
||||
|
||||
= render partial: "posts/single", locals: { post: @post || @comment.post, subject: true }
|
||||
%section.blog-post
|
||||
.card.post{ id: "post-#{@post.id}" }
|
||||
.card-header
|
||||
%h2.display-3= @post.subject
|
||||
.card-body= render "posts/single", post: @post || @comment.post, subject: true
|
||||
|
||||
= render partial: "posts/comments", locals: { post: @post || @comment.post }
|
||||
|
||||
|
||||
@@ -1,56 +1,72 @@
|
||||
%p
|
||||
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
|
||||
:growstuff_markdown
|
||||
#{ strip_tags @post.body }
|
||||
|
||||
.card
|
||||
.post{ id: "post-#{post.id}" }
|
||||
.row
|
||||
.col-md-1
|
||||
= render partial: "members/avatar", locals: { member: post.author }
|
||||
.col-md-11
|
||||
- if defined?(subject)
|
||||
%h3= link_to strip_tags(post.subject), post
|
||||
-# .card
|
||||
-# .post{ id: "post-#{post.id}" }
|
||||
-# .row
|
||||
-# .col-md-1
|
||||
-# = render partial: "members/avatar", locals: { member: post.author }
|
||||
-# .col-md-11
|
||||
-# - if defined?(subject)
|
||||
-# %h3= link_to strip_tags(post.subject), post
|
||||
|
||||
.post-meta
|
||||
%p
|
||||
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
|
||||
-# .post-meta
|
||||
-# %p
|
||||
-# 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
|
||||
|
||||
.post-body
|
||||
:growstuff_markdown
|
||||
#{ strip_tags post.body }
|
||||
-# .post-body
|
||||
-# :growstuff_markdown
|
||||
-# #{ strip_tags post.body }
|
||||
|
||||
- unless defined?(hide_comments)
|
||||
.post-comments
|
||||
%ul.list-inline
|
||||
%li.first
|
||||
= link_to localize_plural(post.comments, Comment),
|
||||
post_path(post, anchor: 'comments')
|
||||
- if can? :create, Comment
|
||||
%li= link_to "Reply", new_comment_path(post_id: post.id)
|
||||
%li= link_to "Permalink", post
|
||||
- if can? :edit, post
|
||||
%li= link_to "Edit", edit_post_path(post)
|
||||
-# - unless defined?(hide_comments)
|
||||
-# .post-comments
|
||||
-# %ul.list-inline
|
||||
-# %li.first
|
||||
-# = link_to localize_plural(post.comments, Comment),
|
||||
-# post_path(post, anchor: 'comments')
|
||||
-# - if can? :create, Comment
|
||||
-# %li= link_to "Reply", new_comment_path(post_id: post.id)
|
||||
-# %li= link_to "Permalink", post
|
||||
-# - if can? :edit, post
|
||||
-# %li= link_to "Edit", edit_post_path(post)
|
||||
|
||||
.like-count
|
||||
= pluralize(post.likes.count, "like") unless post.likes.empty?
|
||||
- if member_signed_in?
|
||||
- if !post.members.include? current_member
|
||||
- if can?(:new, Like)
|
||||
= link_to 'Like', likes_path(post_id: post.id, format: :json),
|
||||
method: :post, remote: true, class: 'post-like'
|
||||
- else
|
||||
- like = post.likes.find_by(member: current_member)
|
||||
- if like && can?(:destroy, like)
|
||||
= link_to 'Unlike', like_path(id: like.id, format: :json),
|
||||
method: :delete, remote: true, class: 'post-like'
|
||||
-# .like-count
|
||||
-# = pluralize(post.likes.count, "like") unless post.likes.empty?
|
||||
-# - if member_signed_in?
|
||||
-# - if !post.members.include? current_member
|
||||
-# - if can?(:new, Like)
|
||||
-# = link_to 'Like', likes_path(post_id: post.id, format: :json),
|
||||
-# method: :post, remote: true, class: 'post-like'
|
||||
-# - else
|
||||
-# - like = post.likes.find_by(member: current_member)
|
||||
-# - if like && can?(:destroy, like)
|
||||
-# = link_to 'Unlike', like_path(id: like.id, format: :json),
|
||||
-# method: :delete, remote: true, class: 'post-like'
|
||||
|
||||
|
||||
|
||||
@@ -18,14 +18,16 @@
|
||||
.card
|
||||
.card-body
|
||||
.row
|
||||
.col-4= render 'members/avatar', member: post.author
|
||||
.col-8
|
||||
.col-2.text-right
|
||||
= render 'members/avatar', member: post.author
|
||||
.col-10.border-left
|
||||
%h5.card-title
|
||||
= link_to 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= post_byline(post)
|
||||
%p.card-text= display_post_truncated(post)
|
||||
- post.crops.each do |crop|
|
||||
%span.badge.badge-pill.badge-primary= link_to crop, crop
|
||||
|
||||
@@ -22,23 +22,9 @@
|
||||
to: "or to start using #{ENV['GROWSTUFF_SITE_NAME']} to track what you're planting and harvesting"
|
||||
|
||||
- content_for :buttonbar do
|
||||
- if can?(:edit, @post) || can?(:destroy, @post)
|
||||
- if can? :edit, @post
|
||||
= link_to edit_post_path(@post), class: 'btn' do
|
||||
= edit_icon
|
||||
edit
|
||||
|
||||
- if can? :destroy, @post
|
||||
= link_to @post, method: :delete,
|
||||
data: { confirm: 'Are you sure?' },
|
||||
class: 'btn btn-danger' do
|
||||
= delete_icon
|
||||
delete
|
||||
|
||||
- if @post.comments.count > 10 && can?(:create, Comment)
|
||||
= link_to 'Comment', new_comment_path(post_id: @post.id), class: 'btn'
|
||||
|
||||
|
||||
- content_for :breadcrumbs do
|
||||
%nav{"aria-label" => "breadcrumb"}
|
||||
%ol.breadcrumb
|
||||
@@ -50,36 +36,32 @@
|
||||
|
||||
.row
|
||||
.col-8.col-xs-12
|
||||
|
||||
/ Section: Blog v.4
|
||||
%section.blog-post
|
||||
.card.post{ id: "post-#{@post.id}" }
|
||||
.card-header
|
||||
%h2.display-3= @post.subject
|
||||
.card-body
|
||||
%p
|
||||
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
|
||||
:growstuff_markdown
|
||||
#{ strip_tags @post.body }
|
||||
%h2.display-3.float-left
|
||||
= @post.subject
|
||||
.dropdown.float-right
|
||||
%button#post-edit-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions
|
||||
.dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "post-edit-button"}
|
||||
- if can? :edit, @post
|
||||
= link_to edit_post_path(@post), class: 'dropdown-item' do
|
||||
= edit_icon
|
||||
Edit
|
||||
- if can? :delete, @post
|
||||
= link_to post_path(@post), class: 'dropdown-item text-danger', data: { confirm: 'Are you sure?' } do
|
||||
= delete_icon
|
||||
Delete
|
||||
.card-body= render 'posts/single', post: @post
|
||||
|
||||
.card-footer
|
||||
- if can? :create, Comment
|
||||
= link_to new_comment_path(post_id: @post.id), class: 'btn' do
|
||||
= icon 'fas', 'comment'
|
||||
Comment
|
||||
.float-right
|
||||
- if can? :create, Comment
|
||||
= link_to new_comment_path(post_id: @post.id), class: 'btn' do
|
||||
= icon 'fas', 'comment'
|
||||
Comment
|
||||
|
||||
= render "comments", post: @post
|
||||
|
||||
.col-4.col-xs-12
|
||||
= render @post.author
|
||||
@@ -94,6 +76,4 @@
|
||||
|
||||
|
||||
|
||||
.col-md-12
|
||||
= render "comments", post: @post
|
||||
|
||||
|
||||
Reference in New Issue
Block a user