work on forum
This commit is contained in:
23
app/views/forum_posts/_forum_post.html.erb
Normal file
23
app/views/forum_posts/_forum_post.html.erb
Normal file
@@ -0,0 +1,23 @@
|
||||
<article data-forum-post-id="<%= forum_post.id %>">
|
||||
<div class="author">
|
||||
<h1><%= link_to forum_post.creator.name, user_path(forum_post.creator_id) %></h1>
|
||||
<p>
|
||||
<time datetime="<%= forum_post.created_at %>">
|
||||
<%= time_ago_in_words(forum_post.created_at) %> ago
|
||||
</time>
|
||||
</p>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div>
|
||||
<%= format_text(forum_post.body) %>
|
||||
</div>
|
||||
<menu>
|
||||
<li><%= link_to "Reply", new_forum_post_path(:post_id => forum_post.id) %></li>
|
||||
<% if CurrentUser.user.is_janitor? || CurrentUser.user.id == forum_post.creator_id %>
|
||||
<li><%= link_to "Delete", forum_post_path(forum_post.id), :confirm => "Do you really want to delete this post?", :method => :delete, :remote => true %></li>
|
||||
<li><%= link_to "Edit", edit_forum_post_path(forum_post.id) %></li>
|
||||
<% end %>
|
||||
</menu>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</article>
|
||||
6
app/views/forum_posts/_listing.html.erb
Normal file
6
app/views/forum_posts/_listing.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<div class="list-of-forum-posts">
|
||||
<% forum_posts.each do |forum_post| %>
|
||||
<%= render :partial => "forum_posts/forum_post", :locals => {:forum_post => forum_post} %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
1
app/views/forum_posts/destroy.js.erb
Normal file
1
app/views/forum_posts/destroy.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$("article[data-forum-post-id=<%= @forum_post.id %>]").remove();
|
||||
@@ -1,6 +1,10 @@
|
||||
<h1>Edit Post</h1>
|
||||
<div id="c-forum-topics">
|
||||
<div id="a-edit">
|
||||
<h1>Edit Forum Post</h1>
|
||||
|
||||
<%= simple_form_for(@forum_post) do |f| %>
|
||||
<%= f.input :body %>
|
||||
<%= f.button :submit %>
|
||||
<% end %>
|
||||
<%= simple_form_for(@forum_post) do |f| %>
|
||||
<%= f.input :body %>
|
||||
<%= f.button :submit, "Submit" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
<h1>New Post</h1>
|
||||
<div id="c-forum-topics">
|
||||
<div id="a-new">
|
||||
<h1>New Forum Post</h1>
|
||||
|
||||
<%= simple_form_for(@forum_post) do |f| %>
|
||||
<%= f.input :topic_id, :as => :hidden %>
|
||||
<%= f.input :body %>
|
||||
<%= f.button :submit %>
|
||||
<% end %>
|
||||
<%= simple_form_for(@forum_post) do |f| %>
|
||||
<%= f.input :topic_id, :as => :hidden %>
|
||||
<%= f.input :body %>
|
||||
<%= f.button :submit, "Submit" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user