work on forum

This commit is contained in:
albert
2011-03-11 19:24:19 -05:00
parent 7dd345ca75
commit 21cc1cbafa
24 changed files with 343 additions and 1306 deletions

View File

@@ -0,0 +1 @@
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

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

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

View File

@@ -0,0 +1 @@
$("article[data-forum-post-id=<%= @forum_post.id %>]").remove();

View File

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

View File

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

View File

@@ -0,0 +1,3 @@
<div class="paginator">
<%= @forum_topic.presenter(@forum_posts).pagination_html(self) %>
</div>

View File

@@ -1,7 +1,6 @@
<div>
<%= simple_form_for @search do |f| %>
<%= f.input :title_matches %>
<%= f.input :creator_name_equals %>
<%= f.button :submit %>
<div id="search">
<%= form_tag(forum_posts_path, :method => :get) do %>
<%= text_field_tag "title_matches" %>
<%= submit_tag "Search" %>
<% end %>
</div>

View File

@@ -0,0 +1,17 @@
<% content_for(:secondary_links) do %>
<menu>
<li><%= link_to "Listing", forum_topics_path %></li>
<li><%= link_to "New", new_forum_topic_path %></li>
<li><%= link_to "Help", wiki_pages_path(:title => "help:forum") %></li>
<% if @forum_topic %>
<li>|</li>
<li><%= link_to "Reply", new_forum_post_path(:topic_id => @forum_topic.id) %></li>
<% unless @forum_topic.new_record? %>
<li><%= link_to "Edit", edit_forum_topic_path(@forum_topic) %></li>
<% if CurrentUser.is_moderator? %>
<li><%= link_to "Delete", forum_topic_path(@forum_topic), :remote => true, :method => :delete, :confirm => "Do you want to delete this forum topic?" %></li>
<% end %>
<% end %>
<% end %>
</menu>
<% end %>

View File

@@ -1,12 +1,19 @@
<h1>Edit Topic</h1>
<div id="c-forum-topics">
<div id="a-edit">
<h1>Edit Forum Topic</h1>
<%= simple_form_for(@forum_topic) do |f| %>
<%= f.input :title %>
<%= simple_form_for(@forum_topic) do |f| %>
<%= f.input :title %>
<%= f.simple_fields_for :original_post do |pf| %>
<%= text_field_tag "forum_topic[original_post_attributes][topic_id]", @forum_topic.id %>
<%= pf.input :body %>
<% end %>
<%= f.simple_fields_for :original_post do |pf| %>
<%= hidden_field_tag "forum_topic[original_post_attributes][topic_id]", @forum_topic.id %>
<%= pf.input :body %>
<% end %>
<%= f.button :submit %>
<% end %>
<%= f.input :is_sticky %>
<%= f.input :is_locked %>
<%= f.button :submit, "Submit" %>
<% end %>
</div>
</div>

View File

@@ -2,11 +2,11 @@
<%= render "search" %>
<table>
<table width="100%">
<thead>
<tr>
<th>Creator</th>
<th>Title</th>
<th>Creator</th>
<th>Updated by</th>
<th>Updated at</th>
</tr>
@@ -14,11 +14,13 @@
<tbody>
<% @forum_topics.each do |topic| %>
<tr>
<td><%= topic.creator.name %></td>
<td><%= topic.title %></td>
<td><%= topic.creator.name %></td>
<td><%= topic.updater.name %></td>
<td><%= compact_time topic.updated_at %></td>
</tr>
<% end %>
</tbody>
</table>
<%= render "secondary_links" %>

View File

@@ -1,11 +1,23 @@
<h1>New Topic</h1>
<div id="c-forum-topics">
<div id="a-new">
<h1>New Forum Topic</h1>
<%= simple_form_for(@forum_topic) do |f| %>
<%= f.input :title %>
<%= f.simple_fields_for :original_post do |pf| %>
<%= pf.input :body %>
<% end %>
<%= f.button :submit %>
<% end %>
<div id="form-content">
<%= simple_form_for(@forum_topic) do |f| %>
<%= f.input :title %>
<%= f.simple_fields_for :original_post do |pf| %>
<%= pf.input :body %>
<% end %>
<%= f.button :submit, "Submit" %>
<% end %>
</div>
<div id="dtext-help">
<%= render "dtext/help" %>
</div>
</div>
</div>
<%= render "secondary_links" %>

View File

@@ -0,0 +1,18 @@
<div id="c-forum-topics">
<div id="a-show">
<h1 id="forum-topic-title">
<%= @forum_topic.title %>
<% if @forum_topic.is_locked? %>
<span class="info">(locked)</span>
<% end %>
<% if @forum_topic.is_sticky? %>
<span class="info">(sticky)</span>
<% end %>
</h1>
<%= render :partial => "forum_posts/listing", :locals => {:forum_posts => @forum_posts} %>
<%= render "paginator" %>
</div>
</div>
<%= render "secondary_links" %>