updated readme

This commit is contained in:
Mike Kelley
2011-08-27 01:41:48 -06:00
commit 17fee3c6d5
98 changed files with 11421 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
class ApplicationController < ActionController::Base
protect_from_forgery
end

View File

@@ -0,0 +1,26 @@
class CategoriesController < ApplicationController
load_and_authorize_resource :category
def create
if @category.save
flash[:notice] = "Category was successfully created."
redirect_to forums_url
else
render :action => 'new'
end
end
def update
if @category.update_attributes(params[:category])
flash[:notice] = "Category was updated successfully."
redirect_to forums_url
end
end
def destroy
if @category.destroy
flash[:notice] = "Category was deleted."
redirect_to forums_url
end
end
end

View File

@@ -0,0 +1,27 @@
class ForumsController < ApplicationController
load_and_authorize_resource :category
load_and_authorize_resource :forum, :through => :category, :shallow => true
def create
if @forum.save
flash[:notice] = "Forum was successfully created."
redirect_to forums_url
else
render :action => 'new'
end
end
def update
if @forum.update_attributes(params[:forum])
flash[:notice] = "Forum was updated successfully."
redirect_to forum_url(@forum)
end
end
def destroy
if @forum.destroy
flash[:notice] = "Category was deleted."
redirect_to forums_url
end
end
end

View File

@@ -0,0 +1,45 @@
class PostsController < ApplicationController
load_and_authorize_resource :topic
load_and_authorize_resource :post, :through => :topic, :shallow => true
def new
if params[:quote]
quote_post = Post.find(params[:quote])
if quote_post
@post.body = "[quote]#{quote_post.body}[/quote]"
end
end
end
def create
@post.user = current_user
if @post.save
flash[:notice] = "Post was successfully created."
redirect_to topic_path(@post.topic)
else
render :action => 'new'
end
end
def update
if @post.update_attributes(params[:post])
flash[:notice] = "Post was successfully updated."
redirect_to topic_path(@post.topic)
end
end
def destroy
if @post.topic.posts_count > 1
if @post.destroy
flash[:notice] = "Post was successfully destroyed."
redirect_to topic_path(@post.topic)
end
else
if @post.topic.destroy
flash[:notice] = "Topic was successfully deleted."
redirect_to forum_path(@post.forum)
end
end
end
end

View File

@@ -0,0 +1,34 @@
class TopicsController < ApplicationController
load_and_authorize_resource :forum
load_and_authorize_resource :topic, :through => :forum, :shallow => true
def show
@topic.hit! if @topic
end
def create
@topic.user = current_user
if @topic.save
flash[:notice] = "Topic was successfully created."
redirect_to topic_url(@topic)
else
render :action => 'new'
end
end
def update
if @topic.update_attributes(params[:topic])
flash[:notice] = "Topic was updated successfully."
redirect_to topic_url(@topic)
end
end
def destroy
if @topic.destroy
flash[:notice] = "Topic was deleted successfully."
redirect_to forum_url(@topic.forum)
end
end
end

View File

@@ -0,0 +1,11 @@
module ApplicationHelper
@my_blockquote = {
'Quote' => [
/\[quote\](.*?)\[\/quote\1?\]/mi,
'<blockquote>\3</blockquote>',
'Quote with citation',
'[quote=mike]please quote me[/quote]',
:quote
],
}
end

View File

@@ -0,0 +1,23 @@
module ErrorMessagesHelper
# Render error messages for the given objects. The :message and :header_message options are allowed.
def error_messages_for(*objects)
options = objects.extract_options!
options[:header_message] ||= I18n.t(:"activerecord.errors.header", :default => "Invalid Fields")
options[:message] ||= I18n.t(:"activerecord.errors.message", :default => "Correct the following errors and try again.")
messages = objects.compact.map { |o| o.errors.full_messages }.flatten
unless messages.empty?
content_tag(:div, :class => "error_messages") do
list_items = messages.map { |msg| content_tag(:li, msg) }
content_tag(:h2, options[:header_message]) + content_tag(:p, options[:message]) + content_tag(:ul, list_items.join.html_safe)
end
end
end
module FormBuilderAdditions
def error_messages(options = {})
@template.error_messages_for(@object, options)
end
end
end
ActionView::Helpers::FormBuilder.send(:include, ErrorMessagesHelper::FormBuilderAdditions)

View File

@@ -0,0 +1,22 @@
# These helper methods can be called in your template to set variables to be used in the layout
# This module should be included in all views globally,
# to do so you may need to add this line to your ApplicationController
# helper :layout
module LayoutHelper
def title(page_title, show_title = true)
content_for(:title) { h(page_title.to_s) }
@show_title = show_title
end
def show_title?
@show_title
end
def stylesheet(*args)
content_for(:head) { stylesheet_link_tag(*args) }
end
def javascript(*args)
content_for(:head) { javascript_include_tag(*args) }
end
end

20
app/models/ability.rb Normal file
View File

@@ -0,0 +1,20 @@
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
can :manage, :all if user.admin?
can :read, Category, :state => true
can :read, Forum, :state => true, :category => { :state => true }
can :read, Topic, :forum => { :state => true, :category => { :state => true } }
can :read, Post, :topic => { :forum => { :state => true, :category => { :state => true } } }
can :update, Post, :user_id => user.id
can :destroy, [Topic,Post], :user_id => user.id
can :create, Post unless user.new_record?
can :create, Topic unless user.new_record?
end
end

14
app/models/category.rb Normal file
View File

@@ -0,0 +1,14 @@
class Category < ActiveRecord::Base
# Associations
has_many :forums, :dependent => :destroy
# Accessors
attr_accessible :title, :state, :position, :category_id
# Scopes
default_scope :order => 'position ASC'
# Validations
validates :title, :presence => true
end

19
app/models/forum.rb Normal file
View File

@@ -0,0 +1,19 @@
class Forum < ActiveRecord::Base
# Associations
has_many :topics, :dependent => :destroy
has_many :posts, :through => :topics
belongs_to :category
# Accessors
attr_accessible :title, :description, :state, :position, :category_id
# Scopes
default_scope :order => 'position ASC'
# Validations
validates :title, :presence => true
validates :description, :presence => true
validates :category_id, :presence => true
end

34
app/models/post.rb Normal file
View File

@@ -0,0 +1,34 @@
class Post < ActiveRecord::Base
# Associations
belongs_to :forum, :counter_cache => true
belongs_to :topic, :counter_cache => true, :touch => true
belongs_to :user, :class_name => "User", :counter_cache => true
# Accessors
attr_accessible :body
# Validations
validates :body, :presence => true
validates :user, :presence => true
# Default Scope
default_scope :order => 'created_at ASC'
# Scope to display only the last n posts. Used for "Recent Posts" display
scope :recent, lambda {
|c| reorder('created_at desc').limit(c)
}
# Callbacks
before_save :topic_locked?
# Methods
private
def topic_locked?
if topic.locked?
errors.add(:base, "That topic is locked")
false
end
end
end

37
app/models/topic.rb Normal file
View File

@@ -0,0 +1,37 @@
class Topic < ActiveRecord::Base
# Associations
has_many :posts, :dependent => :destroy
belongs_to :forum, :counter_cache => true
belongs_to :user, :class_name => "User", :counter_cache => true
# Accessors
attr_accessor :body
attr_accessible :title, :body, :sticky, :locked
# Validations
validates :title, :presence => true
validates :body, :presence => true, :on => :create
validates :posts, :presence => true, :allow_nil => false, :on => :update
validates :user, :presence => true
# Scopes
default_scope :order => 'sticky DESC, updated_at DESC'
# Callbacks
after_create :create_initial_post
# Methods
def hit!
self.class.increment_counter :hits, id
end
private
def create_initial_post
returning self.posts.build(:body => self.body) do |post|
post.forum = self.forum
post.user = self.user
post.save
end
end
end

21
app/models/user.rb Normal file
View File

@@ -0,0 +1,21 @@
class User < ActiveRecord::Base
include Gravtastic
gravtastic :size => 165, :filetype => :png, :rating => 'R'
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
validates :username, :presence => true, :uniqueness => true
# Setup accessible (or protected) attributes for your model
attr_accessible :username, :email, :password, :password_confirmation, :remember_me
has_many :topics, :dependent => :destroy
has_many :posts, :dependent => :destroy
def admin?
true if self.username == 'codezombie'
end
end

View File

@@ -0,0 +1,41 @@
<div class="module">
<div class="module_header"><%= action_name.humanize %> Category</div>
<div class="module_subheader smaller"></div>
<div class="module_body">
<%= form_for @category do |f| %>
<% if @category.errors.any? %>
<% flash.now[:error] = @category.errors.full_messages.join(', and ') %>
<% end %>
<div class="fieldset">
<span class="label indent smaller">
<%= f.label :title %><br />
<small>(Required)</small>
</span>
<span class="input indent smaller"><%= f.text_field :title, :size => 75 %></span>
<div class="clear"></div>
</div>
<div class="fieldset">
<span class="label indent smaller">
<%= f.label :position %>
</span>
<span class="input indent smaller"><%= f.text_field :position %></span>
<div class="clear"></div>
</div>
<div class="fieldset">
<span class="label indent smaller"></span>
<span class="input indent smaller">
<%= f.check_box :state %>
<%= f.label :state %>
</span>
<div class="clear"></div>
</div>
</div>
<div class="module_footer">
<div class="fieldset">
<span class="input"><%= f.submit "submit" %> or <%= link_to "cancel", forums_path %></span>
<div class="clear"></div>
</div>
</div>
<% end %>
</div>
</div>

View File

@@ -0,0 +1 @@
<%= render :partial => 'form' %>

View File

@@ -0,0 +1,47 @@
<div class="right controls"><%= link_to "New Forum Category", new_category_path if can? :create, Category %></div>
<% @categories.each do |category| %>
<div class="module">
<div class="module_header">
<%= category.title %>
<span class="controls right smaller">
<%= link_to "New Forum", new_forum_path if can? :create, Forum %>
<%= link_to "Edit Category", edit_category_path(category) if can? :manage, category %>
<%= link_to "Delete Category", category_path(category), :confirm => "Are you sure you want to delete this category?", :method => :delete if can? :manage, category %>
</span>
</div>
<% if category.forums.size > 0 %>
<div>
<table>
<tr class="smaller">
<th colspan="2" align="left">Forum</th>
<th>Topics</th>
<th>Posts</th>
<th class="last_post" align="left">Last Post</th>
</tr>
<% category.forums.each do |forum| %>
<tr>
<td class="icon"><%= image_tag 'ruby.png' %></td>
<td class="description">
<%= link_to forum.title, forum_path(forum) %><br />
<span class="smaller"><%= forum.description %></span><br />
</td>
<td class="counts smaller"><%= forum.topics.size %></td>
<td class="counts smaller"><%= forum.posts.size - forum.topics.size %></td>
<td class="last_post smaller">
<% if forum.posts.size > 0 %>
<%= forum.posts.last.created_at %><br />
<%= forum.posts.last.user.username %>
<% else %>
No Topics / Posts
<% end %>
</td>
</tr>
<% end %>
</table>
</div>
<% else %>
<div class="module_body">There are currently no forums.</div>
<% end %>
</div>
<% end %>

View File

@@ -0,0 +1 @@
<%= render :partial => 'form' %>

View File

@@ -0,0 +1,12 @@
<h2>Resend confirmation instructions</h2>
<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
<%= devise_error_messages! %>
<p><%= f.label :email %><br />
<%= f.email_field :email %></p>
<p><%= f.submit "Resend confirmation instructions" %></p>
<% end %>
<%= render :partial => "devise/shared/links" %>

View File

@@ -0,0 +1,5 @@
<p>Welcome <%= @resource.email %>!</p>
<p>You can confirm your account through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>

View File

@@ -0,0 +1,8 @@
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>

View File

@@ -0,0 +1,7 @@
<p>Hello <%= @resource.email %>!</p>
<p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
<p>Click the link below to unlock your account:</p>
<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>

View File

@@ -0,0 +1,16 @@
<h2>Change your password</h2>
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
<p><%= f.label :password, "New password" %><br />
<%= f.password_field :password %></p>
<p><%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation %></p>
<p><%= f.submit "Change my password" %></p>
<% end %>
<%= render :partial => "devise/shared/links" %>

View File

@@ -0,0 +1,12 @@
<h2>Forgot your password?</h2>
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
<%= devise_error_messages! %>
<p><%= f.label :email %><br />
<%= f.email_field :email %></p>
<p><%= f.submit "Send me reset password instructions" %></p>
<% end %>
<%= render :partial => "devise/shared/links" %>

View File

@@ -0,0 +1,25 @@
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>
<p><%= f.label :email %><br />
<%= f.email_field :email %></p>
<p><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password %></p>
<p><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></p>
<p><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password %></p>
<p><%= f.submit "Update" %></p>
<% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
<%= link_to "Back", :back %>

View File

@@ -0,0 +1,21 @@
<h2>Sign up</h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<p><%= f.label :username %><br />
<%= f.text_field :username %></p>
<p><%= f.label :email %><br />
<%= f.email_field :email %></p>
<p><%= f.label :password %><br />
<%= f.password_field :password %></p>
<p><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></p>
<p><%= f.submit "Sign up" %></p>
<% end %>
<%= render :partial => "devise/shared/links" %>

View File

@@ -0,0 +1,17 @@
<h2>Sign in</h2>
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<p><%= f.label :email %><br />
<%= f.email_field :email %></p>
<p><%= f.label :password %><br />
<%= f.password_field :password %></p>
<% if devise_mapping.rememberable? -%>
<p><%= f.check_box :remember_me %> <%= f.label :remember_me %></p>
<% end -%>
<p><%= f.submit "Sign in" %></p>
<% end %>
<%= render :partial => "devise/shared/links" %>

View File

@@ -0,0 +1,25 @@
<%- if controller_name != 'sessions' %>
<%= link_to "Sign in", new_session_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
<% end -%>

View File

@@ -0,0 +1,12 @@
<h2>Resend unlock instructions</h2>
<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
<%= devise_error_messages! %>
<p><%= f.label :email %><br />
<%= f.email_field :email %></p>
<p><%= f.submit "Resend unlock instructions" %></p>
<% end %>
<%= render :partial => "devise/shared/links" %>

View File

@@ -0,0 +1,61 @@
<div class="module">
<div class="module_header"><%= action_name.humanize %> Forum</div>
<div class="module_subheader smaller">
<em>To create a category, leave the category field unselected.</em>
</div>
<div class="module_body">
<%= form_for @forum do |f| %>
<% if @forum.errors.any? %>
<% flash.now[:error] = @forum.errors.full_messages.join(', and ') %>
<% end %>
<div class="fieldset">
<span class="label indent smaller">
<%= f.label :category_id %><br />
<small>(Required)</small>
</span>
<span class="input indent smaller">
<%= f.collection_select :category_id, Category.all, :id, :title %>
</span>
<div class="clear"></div>
</div>
<div class="fieldset">
<span class="label indent smaller">
<%= f.label :title %><br />
<small>(Required)</small>
</span>
<span class="input indent smaller"><%= f.text_field :title, :size => 75 %></span>
<div class="clear"></div>
</div>
<div class="fieldset">
<span class="label indent smaller">
<%= f.label :description %><br />
<small>(Required)</small>
</span>
<span class="input indent smaller"><%= f.text_area :description, :cols => 60, :rows => 5 %></span>
<div class="clear"></div>
</div>
<div class="fieldset">
<span class="label indent smaller">
<%= f.label :position %>
</span>
<span class="input indent smaller"><%= f.text_field :position %></span>
<div class="clear"></div>
</div>
<div class="fieldset">
<span class="label indent smaller"></span>
<span class="input indent smaller">
<%= f.check_box :state %>
<%= f.label :state %>
</span>
<div class="clear"></div>
</div>
</div>
<div class="module_footer">
<div class="fieldset">
<span class="input"><%= f.submit "submit" %> or <%= link_to "cancel", @forum.nil? ? forum_path(@forum) : forums_path %></span>
<div class="clear"></div>
</div>
</div>
<% end %>
</div>
</div>

View File

@@ -0,0 +1 @@
<%= render :partial => 'form' %>

View File

@@ -0,0 +1,46 @@
<div class="right controls"><%= link_to "New Forum/Category", new_forum_path %></div>
<% @categories.each do |category| %>
<div class="module">
<div class="module_header">
<%= category.title %>
<span class="controls right smaller">
<%= link_to "New Forum", new_forum_path %>
<%= link_to "Edit Category", edit_forum_path(category) %>
<%= link_to "Delete Category", forum_path(category), :confirm => "Are you sure you want to delete this category?", :method => :delete %>
</span>
</div>
<% if category.forums.size > 0 %>
<div>
<table>
<tr class="smaller">
<th colspan="2" align="left">Forum</th>
<th>Topics</th>
<th>Posts</th>
<th class="last_post" align="left">Last Post</th>
</tr>
<% category.forums.each do |forum| %>
<tr>
<td class="icon"><%= image_tag 'ruby.png' %></td>
<td class="description">
<%= link_to forum.title, forum_path(forum) %><br />
<span class="smaller"><%= forum.description %></span><br />
</td>
<td class="counts smaller"><%= forum.topics.size %></td>
<td class="counts smaller"><%= forum.posts.size - forum.topics.size %></td>
<td class="last_post smaller">
<% if forum.posts.size > 0 %>
<%= forum.posts.last.created_at %><br />
<%= forum.posts.last.user.username %>
<% else %>
No Topics / Posts
<% end %>
</td>
</tr>
<% end %>
</table>
</div>
<% else %>
<div class="module_body">There are currently no forums.</div>
<% end %>
</div>
<% end %>

View File

@@ -0,0 +1 @@
<%= render :partial => 'form' %>

View File

@@ -0,0 +1,48 @@
<div class="right controls"><%= link_to "Back to Forum List", forums_path if can? :create, Forum %></div>
<div class="module">
<div class="module_header">
<%= @forum.title %>
<span class="controls right">
<%= link_to "New Topic", new_forum_topic_path(@forum) if can? :create, Topic %>
<%= link_to "Edit Forum", edit_forum_path(@forum) if can? :manage, @forum %>
<%= link_to "Delete Forum", forum_path(@forum), :confirm => "Are you sure you want to delete this forum?", :method => :delete if can? :manage, @forum %>
</span>
</div>
<div>
<table>
<% if @forum.topics.size > 0 %>
<tr class="smaller">
<th colspan="2" align="left">Topic</th>
<th>Replies</th>
<th>Views</th>
<th class="last_post" align="left">Last Post</th>
</tr>
<!-- No Topics -->
<% else %>
<tr>
<td colspan="5">
<strong><p>There aren't any topics yet <%= link_to "create one", new_forum_topic_path(@forum) if can? :create, Topic %></p></strong>
</td>
</tr>
<% end %>
<% @forum.topics.each do |topic| %>
<tr>
<td class="icon"><%= image_tag 'ruby.png' %></td>
<td class="description">
<%= link_to topic.title, topic_path(topic) %><br />
<span class="smaller">by <%= topic.user.username %></span>
</td>
<td class="counts smaller"><%= topic.posts.size - 1 %></td>
<td class="counts smaller"><%= topic.hits %></td>
<td class="last_post smaller">
<%= topic.posts.last.created_at %><br />
by <%= topic.posts.last.user.username %>
</td>
</tr>
<% end %>
</table>
</div>
</div>
<div class="right controls"><p><%= link_to "Back to Forum List", forums_path if can? :create, Forum %></p></div>

View File

@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html>
<head>
<title><%= content_for?(:title) ? yield(:title) : "Untitled" %></title>
<%= stylesheet_link_tag "application", "forum-monster" %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
<%= yield(:head) %>
</head>
<body>
<div class="container">
<%= content_tag :div, "This is just a demo, the database is reset every 24 hours.", :class => "demo_notice" %>
</div>
<div id="header">
<div id="logo">
<%= image_tag "rails.png" %>
<h1>Forum Monster</h1>
A Ruby on Rails Forum Gem
<div class="clear"></div>
</div>
<div id="menu_wrapper">
<ul>
<li><%= link_to "Forum Index", root_path %></li>
<% if user_signed_in? %>
<li><%= link_to "Logout", destroy_user_session_path, :method => :delete %></li>
<% else %>
<li><%= link_to "Login", new_user_session_path %></li>
<% end %>
</ul>
</div>
<div id="bottom">
<% if user_signed_in? %>
Welcome <strong><%= current_user.username %></strong>, your last login was <%= time_ago_in_words(current_user.last_sign_in_at) %> ago
<% else %>
You are not logged in. Please <%= link_to "login", new_user_session_path %> or <%= link_to "register", new_user_registration_path %>
<% end %>
</div>
</div>
<div class="container">
<% flash.each do |name, msg| %>
<%= content_tag :div, msg, :id => "flash_#{name}" %>
<% end %>
<%= yield %>
</div>
<% if %w(categories forums topics posts).include? controller_name %>
<div id="info_box">
<p>
Total number of registered users: <strong><%= User.count %></strong><br />
Newest registered user: <%= link_to User.last.username %>
</p>
</div>
<% end %>
</body>
</html>

View File

@@ -0,0 +1,26 @@
<div class="module">
<div class="module_header"><%= action_name.humanize %> Post</div>
<div class="module_subheader smaller"></div>
<div class="module_body">
<%= form_for [@topic, @post] do |f| %>
<% if @post.errors.any? %>
<% flash.now[:error] = @post.errors.full_messages.join(', and ') %>
<% end %>
<div class="fieldset">
<span class="label indent smaller">
<%= f.label :body %><br />
<small>(Required)</small>
</span>
<span class="input indent smaller"><%= f.text_area :body, :cols => 60, :rows => 15 %></span>
<div class="clear"></div>
</div>
</div>
<div class="module_footer">
<div class="fieldset">
<span class="input"><%= f.submit "submit" %> or <%= link_to "cancel", topic_path(@post.topic) %></span>
<div class="clear"></div>
</div>
</div>
<% end %>
</div>
</div>

View File

@@ -0,0 +1 @@
<%= render :partial => 'form' %>

View File

@@ -0,0 +1 @@
<%= render :partial => 'form' %>

View File

@@ -0,0 +1,36 @@
<%= form_for [@forum, @topic] do |f| %>
<% if @topic.errors.any? %>
<% flash.now[:error] = @topic.errors.full_messages.join(', and ') %>
<% end %>
<div class="module">
<div class="module_header"><%= action_name.humanize %> Topic</div>
<div class="module_subheader smaller"></div>
<div class="module_body">
<div class="fieldset">
<span class="label indent smaller">
<%= f.label :title %><br />
<small>(Required)</small>
</span>
<span class="input indent smaller"><%= f.text_field :title, :size => 75 %></span>
<div class="clear"></div>
</div>
<% unless @topic.id %>
<div class="fieldset">
<span class="label indent smaller">
<%= f.label :body %><br />
<small>(Required)</small>
</span>
<span class="input indent smaller"><%= f.text_area :body, :cols => 60, :rows => 15 %></span>
<div class="clear"></div>
</div>
</div>
<% end %>
<div class="module_footer">
<div class="fieldset">
<span class="input"><%= f.submit "submit" %> or <%= link_to "cancel", @topic.nil? ? @topic : @forum %></span>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<% end %>

View File

@@ -0,0 +1 @@
<%= render :partial => 'form' %>

View File

@@ -0,0 +1 @@
<%= render :partial => 'form' %>

View File

@@ -0,0 +1,44 @@
<div class="right controls"><%= link_to "Back to Forum", forum_path(@topic.forum) %></div>
<div class="module">
<div class="module_header">
<%= @topic.title %>
<span class="right controls">
<%= link_to "Edit", edit_topic_path(@topic) if can? :manage, @topic %>
<%= link_to "Delete", @topic, :confirm => "Are you sure?", :method => :delete if can? :manage, @topic %>
<%= link_to @topic.sticky ? "Unstick" : "Sticky", {:controller => 'topics', :action => 'update', :topic => {:sticky => @topic.sticky ? "false" : "true" }}, :method => :put if can? :moderate, @topic %>
<%= link_to @topic.locked ? "Unlock" : "Lock", {:controller => 'topics', :action => 'update', :topic => {:locked => @topic.locked ? "false" : "true" }}, :method => :put if can? :moderate, @topic %>
</span>
</div>
<div>
<table>
<% @topic.posts.each do |post| %>
<tr>
<td class="post_author" rowspan="2">
<span class="name"><%= post.user.username %></span>
<span class="avatar"><%= image_tag post.user.gravatar_url %></span>
<span class="info smaller">
<p><strong><%= "Administrator" if post.user.admin? %></strong></p>
Posts <%= post.user.posts.size %><br />
Registered <%= post.user.created_at.to_s(:joined) %><br />
</span>
</td>
<td class="post_header">
<span class="left post_date smaller">Posted <%= post.created_at %></span>
<span class="right controls">
<%= link_to "Reply", new_topic_post_path(@topic) if can? :create, Topic %>
<%= link_to "Quote", new_topic_post_path(@topic, :quote => post) if can? :create, Topic %>
<%= link_to "Edit", edit_post_path(post) if can? :update, post %>
<%= link_to "Delete", post, :confirm => "Are you sure?", :method => :delete if can? :destroy, post %>
</span>
</td>
</tr>
<tr>
<td class="post_body">
<%= post.body.bbcode_to_html().html_safe %>
</td>
</tr>
<% end %>
</table>
</div>
</div>
<div class="right controls"><p><%= link_to "Back to Forum", forum_path(@topic.forum) %></p></div>