Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Forem #19

Merged
merged 6 commits into from

1 participant

Commits on Jan 22, 2012
  1. @erebor

    Add forem gem and generate forum db, wire in route, add link in app l…

    erebor authored
    …ayout (still lacking user auth stuff to give user permissions to read forums, etc.)
Commits on Jan 23, 2012
  1. @erebor
  2. @erebor

    Explicitly include Forem default permissions, because pesky issue #88…

    erebor authored
    … isn't yet fixed in Forem
  3. @erebor

    Forem is an isolated engine, so have to use the namespace helper so F…

    erebor authored
    …orem can see the app's named routes
  4. @erebor
  5. @erebor
This page is out of date. Refresh to see the latest.
Showing with 561 additions and 15 deletions.
  1. +1 −1  Gemfile
  2. +33 −8 Gemfile.lock
  3. +6 −0 app/controllers/application_controller.rb
  4. +1 −1  app/models/user.rb
  5. +10 −0 app/views/forem/admin/base/index.html.erb
  6. +4 −0 app/views/forem/admin/categories/_form.html.erb
  7. +3 −0  app/views/forem/admin/categories/edit.html.erb
  8. +28 −0 app/views/forem/admin/categories/index.html.erb
  9. +3 −0  app/views/forem/admin/categories/new.html.erb
  10. +7 −0 app/views/forem/admin/forums/_form.html.erb
  11. +3 −0  app/views/forem/admin/forums/edit.html.erb
  12. +38 −0 app/views/forem/admin/forums/index.html.erb
  13. +3 −0  app/views/forem/admin/forums/new.html.erb
  14. +13 −0 app/views/forem/admin/topics/_form.html.erb
  15. +3 −0  app/views/forem/admin/topics/edit.html.erb
  16. 0  app/views/forem/admin/topics/index.html.erb
  17. +6 −0 app/views/forem/categories/_category.html.erb
  18. +2 −0  app/views/forem/categories/show.html.erb
  19. +19 −0 app/views/forem/forums/_forum.html.erb
  20. +14 −0 app/views/forem/forums/_head.html.erb
  21. +13 −0 app/views/forem/forums/_listing.html.erb
  22. +12 −0 app/views/forem/forums/index.html.erb
  23. +24 −0 app/views/forem/forums/show.html.erb
  24. +5 −0 app/views/forem/posts/_form.html.erb
  25. +42 −0 app/views/forem/posts/_post.html.erb
  26. +8 −0 app/views/forem/posts/edit.html.erb
  27. +8 −0 app/views/forem/posts/new.html.erb
  28. +9 −0 app/views/forem/topics/_form.html.erb
  29. +4 −0 app/views/forem/topics/_head.html.erb
  30. +24 −0 app/views/forem/topics/_topic.html.erb
  31. +5 −0 app/views/forem/topics/new.html.erb
  32. +29 −0 app/views/forem/topics/show.html.erb
  33. +4 −4 app/views/layouts/application.html.erb
  34. +2 −0  config/initializers/forem.rb
  35. +2 −0  config/routes.rb
  36. +13 −0 db/migrate/20120122052414_create_forem_forums.rb
  37. +11 −0 db/migrate/20120122052415_create_forem_topics.rb
  38. +11 −0 db/migrate/20120122052416_create_forem_posts.rb
  39. +5 −0 db/migrate/20120122052417_add_reply_to_to_forem_posts.rb
  40. +5 −0 db/migrate/20120122052418_add_locked_to_forem_topics.rb
  41. +5 −0 db/migrate/20120122052419_add_pinned_to_forem_topics.rb
  42. +9 −0 db/migrate/20120122052420_add_forem_views.rb
  43. +6 −0 db/migrate/20120122052421_add_updated_at_and_count_to_forem_views.rb
  44. +5 −0 db/migrate/20120122052422_add_hidden_to_forem_topics.rb
  45. +12 −0 db/migrate/20120122052423_add_indexes_to_topics_posts_views.rb
  46. +10 −0 db/migrate/20120122052424_create_forem_categories.rb
  47. +9 −0 db/migrate/20120122052425_add_category_id_to_forums.rb
  48. +8 −0 db/migrate/20120122052426_create_forem_subscriptions.rb
  49. +6 −0 db/migrate/20120122052427_add_forem_admin.rb
  50. +58 −1 db/schema.rb
View
2  Gemfile
@@ -3,7 +3,7 @@ source 'http://rubygems.org'
gem 'rails', '3.1.3'
gem 'mysql2'
-gem 'forem'
+gem 'forem', :git => "git://github.com/radar/forem.git"
gem 'omniauth'
gem 'omniauth-twitter'
View
41 Gemfile.lock
@@ -1,3 +1,14 @@
+GIT
+ remote: git://github.com/radar/forem.git
+ revision: 80e57e0eb47f1d9f6ceaf56942db906d39cdcc5d
+ specs:
+ forem (0.1)
+ cancan
+ forem-redcarpet (= 1.0.0)
+ kaminari
+ rails (~> 3.1)
+ simple_form
+
GEM
remote: http://rubygems.org/
specs:
@@ -34,18 +45,26 @@ GEM
addressable (2.2.6)
ansi (1.4.1)
arel (2.2.1)
+ blankslate (2.1.2.4)
builder (3.0.0)
+ cancan (1.6.7)
erubis (2.7.0)
- faraday (0.7.5)
- addressable (~> 2.2.6)
- multipart-post (~> 1.1.3)
- rack (>= 1.1.0, < 2)
- forem (0.0.1)
- simple_form
+ faraday (0.7.6)
+ addressable (~> 2.2)
+ multipart-post (~> 1.1)
+ rack (~> 1.1)
+ ffi (1.0.11)
+ forem-redcarpet (1.0.0)
+ pygments.rb (= 0.2.4)
+ redcarpet (= 2.0.1)
hashie (1.2.0)
hike (1.2.1)
i18n (0.6.0)
json (1.6.5)
+ kaminari (0.13.0)
+ actionpack (>= 3.0.0)
+ activesupport (>= 3.0.0)
+ railties (>= 3.0.0)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@@ -73,6 +92,8 @@ GEM
omniauth-twitter (0.0.7)
omniauth-oauth (~> 1.0)
polyglot (0.3.3)
+ pygments.rb (0.2.4)
+ rubypython (~> 0.5.3)
rack (1.3.6)
rack-cache (1.1)
rack (>= 0.4)
@@ -100,13 +121,17 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
+ redcarpet (2.0.1)
+ rubypython (0.5.3)
+ blankslate (>= 2.1.2.3)
+ ffi (~> 1.0.7)
simple_form (1.5.2)
actionpack (~> 3.0)
activemodel (~> 3.0)
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
- tilt (~> 1.1, != 1.3.0)
+ tilt (!= 1.3.0, ~> 1.1)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
@@ -121,7 +146,7 @@ PLATFORMS
DEPENDENCIES
acts-as-taggable-on (~> 2.2.2)
- forem
+ forem!
mysql2
omniauth
omniauth-github
View
6 app/controllers/application_controller.rb
@@ -1,4 +1,10 @@
class ApplicationController < ActionController::Base
+
+ def forem_user
+ current_user
+ end
+ helper_method :forem_user
+
protect_from_forgery
before_filter :check_profile
View
2  app/models/user.rb
@@ -1,6 +1,6 @@
class User < ActiveRecord::Base
has_one :profile
-
+
delegate :name, :email, :bio, :username, :url, :to => :profile
def self.create_with_omniauth(auth)
View
10 app/views/forem/admin/base/index.html.erb
@@ -0,0 +1,10 @@
+<h1><%= t('forem.admin.area') %></h1>
+
+<p>
+ <%= t('forem.admin.welcome') %>
+</p>
+
+<ul>
+ <li><%= link_to t('forem.admin.forum.index'), admin_forums_path %> </li>
+ <li><%= link_to t('forem.admin.category.index'), admin_categories_path %></li>
+</ul>
View
4 app/views/forem/admin/categories/_form.html.erb
@@ -0,0 +1,4 @@
+<%= simple_form_for [:admin, @category] do |f| %>
+ <%= f.input :name %>
+ <%= f.submit %>
+<% end %>
View
3  app/views/forem/admin/categories/edit.html.erb
@@ -0,0 +1,3 @@
+<h2><%= t("forem.category.edit", :title => @category.name) %></h2>
+
+<%= render "form" %>
View
28 app/views/forem/admin/categories/index.html.erb
@@ -0,0 +1,28 @@
+<h2><%= t("forem.admin.category.index") %></h2>
+
+<%= link_to t("forem.admin.category.new_link"), new_admin_category_path %>
+
+<table id='forums' class='forums subdued' cellspacing='0'>
+ <thead>
+ <tr>
+ <th><%= t('edit', :scope => 'forem.admin.categories') %></th>
+ <th><%= t('delete', :scope => 'forem.admin.categories') %></th>
+ <th><%= t('category', :scope => 'forem.admin.categories') %></th>
+
+ </tr>
+ </thead>
+ <tbody>
+ <% @category.each do |category| %>
+ <tr class="forum <%= cycle("odd", "even") %>">
+ <td><%= link_to t('edit', :scope => 'forem.admin.categories'), edit_admin_category_path(category) %></td>
+ <td><%= link_to t('delete', :scope => 'forem.admin.categories'), admin_category_path(category), :method => :delete, :confirm => t("delete_confirm", :scope => "forem.admin.categories") %></td>
+ <td>
+ <%= category.name %>
+ </td>
+ </tr>
+ <% end %>
+ </tbody>
+</table>
+
+<%= link_to t('forem.admin.forum.index'), admin_forums_path %>
+
View
3  app/views/forem/admin/categories/new.html.erb
@@ -0,0 +1,3 @@
+<h2><%= t("forem.category.new") %></h2>
+
+<%= render "form" %>
View
7 app/views/forem/admin/forums/_form.html.erb
@@ -0,0 +1,7 @@
+<%= simple_form_for [:admin, @forum] do |f| %>
+ <%= f.association :category, :include_blank => false %>
+ <%= f.input :title %>
+ <%= f.input :description, :as => :text %>
+
+ <%= f.submit %>
+<% end %>
View
3  app/views/forem/admin/forums/edit.html.erb
@@ -0,0 +1,3 @@
+<h2><%= t("forem.forum.edit", :title => @forum.title) %></h2>
+
+<%= render "form" %>
View
38 app/views/forem/admin/forums/index.html.erb
@@ -0,0 +1,38 @@
+<h2><%= t("forem.admin.forum.index") %></h2>
+
+<%= link_to t("forem.admin.forum.new_link"), new_admin_forum_path %>
+
+<table id='forums' class='forums subdued' cellspacing='0'>
+ <thead>
+ <tr>
+ <th><%= t('edit', :scope => 'forem.admin.forums') %></th>
+ <th><%= t('delete', :scope => 'forem.admin.forums') %></th>
+ <th><%= t('forum', :scope => 'forem.admin.forums') %></th>
+ <th><%= t('category', :scope => 'forem.admin.forums') %></th>
+ <th><%= t('topics', :scope => 'forem.admin.forums') %></th>
+ <th><%= t('posts', :scope => 'forem.admin.forums') %></th>
+ </tr>
+ </thead>
+ <tbody>
+ <% @forums.each do |forum| %>
+ <tr class="forum <%= cycle("odd", "even") %>">
+ <td><%= link_to t('edit', :scope => 'forem.admin.forums'), edit_admin_forum_path(forum) %></td>
+ <td><%= link_to t('delete', :scope => 'forem.admin.forums'), admin_forum_path(forum), :method => :delete, :confirm => t("delete_confirm", :scope => "forem.admin.forums") %></td>
+ <td>
+ <%= link_to forum.title, forum_path(forum) %>
+ <div class='description'><%= forum.description %></div>
+ <%= t('.last_post') %>
+ <% if last_post = forum.posts.last %>
+ <%= link_to(last_post.topic, forum_topic_path(forum, last_post.topic)) -%> by <%= last_post.user %> <%= time_ago_in_words(last_post.created_at) -%>
+ <% else %>
+ <%= t('.none') %>
+ <% end %>
+ </td>
+ <td><%= forum.category.try(:name) || "No category" %></td>
+ <td><%= forum.topics.count %></td>
+ <td><%= forum.posts.count %></td>
+ </tr>
+ <% end %>
+ </tbody>
+</table>
+
View
3  app/views/forem/admin/forums/new.html.erb
@@ -0,0 +1,3 @@
+<h2><%= t("forem.forum.new") %></h2>
+
+<%= render "form" %>
View
13 app/views/forem/admin/topics/_form.html.erb
@@ -0,0 +1,13 @@
+<%= simple_form_for [:admin, @topic] do |f| %>
+ <%= f.input :subject %>
+ <%= f.association :forum , :label => "Forum" %>
+ <%= f.label :locked %>
+ <%= f.check_box :locked %>
+ <%= f.label :pinned %>
+ <%= f.check_box :pinned %>
+ <%= f.label :hidden %>
+ <%= f.check_box :hidden %>
+
+ <br />
+ <%= f.submit %>
+<% end %>
View
3  app/views/forem/admin/topics/edit.html.erb
@@ -0,0 +1,3 @@
+<h2><%= t("forem.topic.edit", :subject => @topic.subject) %></h2>
+
+<%= render "form" %>
View
0  app/views/forem/admin/topics/index.html.erb
No changes.
View
6 app/views/forem/categories/_category.html.erb
@@ -0,0 +1,6 @@
+<% if can?(:read, category) %>
+ <div class='category' id='category_<%= category.id %>'>
+ <h2><%= link_to category.name, category %></h2>
+ <%= render "forem/forums/listing", :category => category %>
+ </div>
+<% end %>
View
2  app/views/forem/categories/show.html.erb
@@ -0,0 +1,2 @@
+<h2><%= link_to t('forem.forum.forums'), forums_path %> &raquo; <%= link_to @category, @category %></h2>
+<%= render @category %>
View
19 app/views/forem/forums/_forum.html.erb
@@ -0,0 +1,19 @@
+<% if can?(:read, forum) %>
+ <tr class="forum <%= cycle("odd", "even") %>">
+ <td>
+ <%= link_to forum.title, forum_path(forum), :class => "title" %>
+ <div class='description'><%= forum.description %></div>
+ <%= t('.last_post') -%>
+ <span class='last_post'>
+ <% if last_post = forum.last_post_for(forem_user) -%>
+ <%= link_to(last_post.topic, forum_topic_path(forum, last_post.topic)) -%> <%= t('by') %> <%= last_post.user %> <%= t('time_ago_in_words', :time => time_ago_in_words(last_post.created_at)) -%>
+ <% else %>
+ <%= t('.none') -%>
+ <% end %>
+ </span>
+ </td>
+ <td class="topics-count"><%= forum.topics.count %></td>
+ <td class="posts-count"><%= forum.posts.count %></td>
+ <td class="views-count"><%= forum.views.sum(:count) %></td>
+ </tr>
+<% end %>
View
14 app/views/forem/forums/_head.html.erb
@@ -0,0 +1,14 @@
+<div id='forum'>
+ <h2><%= link_to t('forem.forum.forums'), forums_path %> &raquo; <%= link_to forum.category, forum.category %> &raquo; <%= link_to forum.title, forum %></h2>
+ <small><%= forum.description %></small>
+ <menu id='forum_topic_links'>
+ <% unless @topic.try(:new_record?) %>
+ <% if can? :create_topic, @forum %>
+ <%= link_to t('forem.topic.links.new'), new_forum_topic_path(forum) %>
+ <% end %>
+ <% end %>
+ <% if @topic %>
+ <%= link_to t('forem.topic.links.back_to_topics'), forum_path(forum) %>
+ <% end %>
+ </menu>
+</div>
View
13 app/views/forem/forums/_listing.html.erb
@@ -0,0 +1,13 @@
+<table id='forums' class='forums subdued' cellspacing='0'>
+ <thead>
+ <tr>
+ <th class="desc-and-last-post"><%= t('.forums') %></th>
+ <th class="topics-count"><%= t('.topics') %></th>
+ <th class="posts-count"><%= t('.posts') %></th>
+ <th class="views-count"><%= t('.views') %></th>
+ </tr>
+ </thead>
+ <tbody>
+ <%= render category.forums %>
+ </tbody>
+</table>
View
12 app/views/forem/forums/index.html.erb
@@ -0,0 +1,12 @@
+<div id='forums_container'>
+ <h2><%= t('.title') %></h2>
+
+ <%= render @categories %>
+</div>
+
+<br>
+<footer id='admin_link'>
+ <% if forem_admin? %>
+ <%= link_to t("area", :scope => "forem.admin"), admin_root_path %>
+ <% end %>
+</footer>
View
24 app/views/forem/forums/show.html.erb
@@ -0,0 +1,24 @@
+<%= render :partial => 'forem/forums/head', :locals => { :forum => @forum } %>
+
+<% if @topics.num_pages > 1 %>
+ <div class='pages'>
+ <%= t('forem.common.pages') -%>: <%= forem_paginate @topics %>
+ </div>
+<% end %>
+<table class='topics subdued' cellspacing='0'>
+ <thead>
+ <tr>
+ <th class="icon"></th>
+ <th class="byline"><%= t('forem.topic.headings.topic') -%></th>
+ <th class="latest-post"><%= t('forem.topic.headings.latest') -%></th>
+ <th class="posts-count"><%= t('forem.topic.headings.posts') -%></th>
+ <th class="views-count"><%= t('forem.topic.headings.views') -%></th>
+ </tr>
+ </thead>
+ <tbody>
+ <% if @topics.empty? %>
+ <tr><td colspan='5' align='center'><%= t('forem.topic.none') %></td></tr>
+ <% end %>
+ <%= render @topics %>
+ </tbody>
+</table>
View
5 app/views/forem/posts/_form.html.erb
@@ -0,0 +1,5 @@
+<%= f.input :text %>
+
+<% if params[:reply_to_id] %>
+ <%= f.hidden_field :reply_to_id, :value => params[:reply_to_id] %>
+<% end %>
View
42 app/views/forem/posts/_post.html.erb
@@ -0,0 +1,42 @@
+<a name='post-<%= post.id %>'></a>
+<div id='post_<%= post.id %>' class='post <%= cycle('odd', 'even') -%>'>
+
+ <div class='user'>
+ <div class='username'>
+ <%= link_to_if Forem.user_profile_links, post.user, [main_app, post.user] %>
+ </div>
+ <div class='icon'><%= avatar(post.user, :size => 60) %></div>
+ </div>
+
+ <div class='contents'>
+ <a href='#post-<%= post.id %>'>
+ <time datetime="<%= post.created_at.to_s(:db) -%>"><%= "#{time_ago_in_words(post.created_at)} #{t("ago")}" %></time>
+ </a>
+ <%= forem_format(post.text) %>
+
+ <% if post.reply_to %>
+ <span class='in_reply_to'>
+ <%= link_to "#{t("forem.post.in_reply_to")} #{post.reply_to.user}", "#post-#{post.reply_to.id}" %>
+ </span>
+ <% end %>
+
+ <ul class='actions'>
+ <% if forem_user %>
+ <% if can?(:reply, @topic) %>
+ <% if @topic.can_be_replied_to? %>
+ <li><%= link_to t('reply', :scope => 'forem.topic'), new_topic_post_path(@topic, :reply_to_id => post.id) %></li>
+ <% end %>
+ <% if @topic.can_be_replied_to? %>
+ <li><%= link_to t('quote', :scope => 'forem.topic'), new_topic_post_path(@topic, :reply_to_id => post.id, :quote => true) %></li>
+ <% end %>
+ <% end %>
+ <% if post.owner_or_admin?(forem_user) %>
+ <% if can?(:edit_post, @topic.forum) %>
+ <li><%= link_to t('edit', :scope => 'forem.post'), edit_topic_post_path(@topic, post) %></li>
+ <% end %>
+ <li><%= link_to t('delete', :scope => 'forem.topic'), topic_post_path(@topic, post), :method => :delete, :confirm => t("are_you_sure") %></li>
+ <% end %>
+ <% end %>
+ </ul>
+ </div>
+</div>
View
8 app/views/forem/posts/edit.html.erb
@@ -0,0 +1,8 @@
+<%= render :partial => 'forem/forums/head', :locals => { :forum => @topic.forum } %>
+
+<h2><%= t("forem.post.edit") %></h2>
+
+<%= simple_form_for [@topic, @post] do |f| %>
+ <%= render :partial => "form", :locals => { :f => f } %>
+ <%= f.submit t("forem.post.buttons.edit") %>
+<% end %>
View
8 app/views/forem/posts/new.html.erb
@@ -0,0 +1,8 @@
+<%= render :partial => 'forem/forums/head', :locals => { :forum => @topic.forum } %>
+
+<h2><%= t("forem.post.new") %></h2>
+
+<%= simple_form_for [@topic, @post] do |f| %>
+ <%= render :partial => "form", :locals => { :f => f } %>
+ <%= f.submit t("forem.post.buttons.reply") %>
+<% end %>
View
9 app/views/forem/topics/_form.html.erb
@@ -0,0 +1,9 @@
+<%= simple_form_for [@forum, @topic] do |f| %>
+ <%= f.input :subject %>
+
+ <%= f.simple_fields_for :posts do |post| %>
+ <%= render :partial => "forem/posts/form", :locals => { :f => post }%>
+ <% end %>
+
+ <%= f.submit %>
+<% end %>
View
4 app/views/forem/topics/_head.html.erb
@@ -0,0 +1,4 @@
+<h2><%= link_to t('forem.forum.forums'), forums_path %> &raquo; <%= link_to topic.forum.title, topic.forum %> &raquo; <%= topic.subject %></h2>
+<% if forem_admin? %>
+ <%= link_to t('forem.topic.links.edit'), edit_admin_topic_path(topic) %>
+<% end %>
View
24 app/views/forem/topics/_topic.html.erb
@@ -0,0 +1,24 @@
+<tr class="topic <%= cycle('odd', 'even') %> <%= topic.locked? ? 'locked' : 'unlocked' %>">
+ <td class='icon'>
+ <% if topic.locked? %>
+ <span class='lock icon'></span>
+ <% end %>
+ <% if topic.pinned? %>
+ <span class='pin icon'></span>
+ <% end %>
+ <% if forem_user && view = topic.view_for(forem_user) %>
+ <% if topic.posts.exists?(["created_at > ?", view.updated_at]) %>
+ <span class='new_posts icon'>new</span>
+ <% end %>
+ <% end %>
+ </td>
+ <td class='byline'>
+ <div class='subject'><%= link_to topic.subject, forum_topic_path(@forum, topic) %></div>
+ <div class='started-by'><%= t "started_by" %><%= topic.posts.by_created_at.first.user %></div>
+ </td>
+ <td class='latest-post'>
+ <%= link_to_latest_post(topic.posts.by_created_at.last) -%>
+ </td>
+ <td class='posts-count'><%= topic.posts.count %></td>
+ <td class='views-count'><%= topic.views.sum(:count) %></td>
+</tr>
View
5 app/views/forem/topics/new.html.erb
@@ -0,0 +1,5 @@
+<%= render :partial => 'forem/forums/head', :locals => { :forum => @topic.forum } %>
+
+<h2><%= t("forem.topic.new") %></h2>
+
+<%= render "form" %>
View
29 app/views/forem/topics/show.html.erb
@@ -0,0 +1,29 @@
+<div id='topic' class='<%= 'un' unless @topic.locked? %>locked'>
+ <%= render :partial => 'forem/topics/head', :locals => { :topic => @topic } %>
+
+ <menu>
+ <% if @topic.can_be_replied_to? && can?(:reply, @topic) %>
+ <%= link_to t(".reply"), new_topic_post_path(@topic) %>
+ <% end %>
+ <% if @topic.user == forem_user || forem_admin? %>
+ <%= link_to t(".delete"), forum_topic_path(@forum, @topic), :method => :delete, :confirm => t("are_you_sure") %>
+ <% end %>
+ <% if forem_user %>
+ <% if !@topic.subscriber?(forem_user.id) %>
+ <%= link_to t(".subscribe"), subscribe_forum_topic_path(@topic) %>
+ <% else %>
+ <%= link_to t(".unsubscribe"), unsubscribe_forum_topic_path(@topic) %>
+ <% end %>
+ <% end %>
+ </menu>
+
+ <% if forem_admin? %>
+ <%= link_to t(".hide.#{@topic.hidden}"), toggle_hide_admin_topic_path(@topic), :method => :put %> |
+ <%= link_to t(".lock.#{@topic.locked}"), toggle_lock_admin_topic_path(@topic), :method => :put %> |
+ <%= link_to t(".pin.#{@topic.pinned}"), toggle_pin_admin_topic_path(@topic), :method => :put %>
+ <% end %>
+ <%= forem_paginate @posts %>
+ <div id='posts'>
+ <%= render :partial => "forem/posts/post", :collection => @posts %>
+ </div>
+</div>
View
8 app/views/layouts/application.html.erb
@@ -13,23 +13,23 @@
<div id="user-info">
<% if current_user %>
Welcome, <%= current_user.name.present? ? "#{current_user.name}!" : "er, what's your name again...?" %>
- <%= link_to "Sign Out", signout_path %>
+ <%= link_to "Sign Out", main_app.signout_path %>
<% else %>
<%= link_to "Sign in with Twitter", "/auth/twitter" %>
<% end %>
</div>
</div>
-
+
<div id="menu">
<ul>
<li><p>Snippets</p></li>
- <li><p>Forums</p></li>
+ <li><p><%= link_to 'Forums', forem.root_path %></p></li>
<li><p>Wiki</p></li>
<li><p>Articles</p></li>
<li><p>Users</p></li>
</ul>
</div>
-
+
<%= yield %>
</div>
</body>
View
2  config/initializers/forem.rb
@@ -0,0 +1,2 @@
+Forem.user_class = 'User'
+Forem.email_from_address = "please-change-me@example.com"
View
2  config/routes.rb
@@ -5,6 +5,8 @@
end
end
+ mount Forem::Engine, :at => "/forums"
+
match "/signout" => "sessions#destroy", :as => :signout
match "/auth/:provider/callback" => "sessions#create"
View
13 db/migrate/20120122052414_create_forem_forums.rb
@@ -0,0 +1,13 @@
+class CreateForemForums < ActiveRecord::Migration
+ def up
+ create_table :forem_forums do |t|
+ t.string :title
+ t.text :description
+ end
+
+ end
+
+ def down
+ drop_table :forem_forums
+ end
+end
View
11 db/migrate/20120122052415_create_forem_topics.rb
@@ -0,0 +1,11 @@
+class CreateForemTopics < ActiveRecord::Migration
+ def change
+ create_table :forem_topics do |t|
+ t.integer :forum_id
+ t.integer :user_id
+ t.string :subject
+
+ t.timestamps
+ end
+ end
+end
View
11 db/migrate/20120122052416_create_forem_posts.rb
@@ -0,0 +1,11 @@
+class CreateForemPosts < ActiveRecord::Migration
+ def change
+ create_table :forem_posts do |t|
+ t.integer :topic_id
+ t.text :text
+ t.integer :user_id
+
+ t.timestamps
+ end
+ end
+end
View
5 db/migrate/20120122052417_add_reply_to_to_forem_posts.rb
@@ -0,0 +1,5 @@
+class AddReplyToToForemPosts < ActiveRecord::Migration
+ def change
+ add_column :forem_posts, :reply_to_id, :integer
+ end
+end
View
5 db/migrate/20120122052418_add_locked_to_forem_topics.rb
@@ -0,0 +1,5 @@
+class AddLockedToForemTopics < ActiveRecord::Migration
+ def change
+ add_column :forem_topics, :locked, :boolean, :null => false, :default => false
+ end
+end
View
5 db/migrate/20120122052419_add_pinned_to_forem_topics.rb
@@ -0,0 +1,5 @@
+class AddPinnedToForemTopics < ActiveRecord::Migration
+ def change
+ add_column :forem_topics, :pinned, :boolean, :default => false, :nullable => false
+ end
+end
View
9 db/migrate/20120122052420_add_forem_views.rb
@@ -0,0 +1,9 @@
+class AddForemViews < ActiveRecord::Migration
+ def change
+ create_table :forem_views do |t|
+ t.integer :user_id
+ t.integer :topic_id
+ t.datetime :created_at
+ end
+ end
+end
View
6 db/migrate/20120122052421_add_updated_at_and_count_to_forem_views.rb
@@ -0,0 +1,6 @@
+class AddUpdatedAtAndCountToForemViews < ActiveRecord::Migration
+ def change
+ add_column :forem_views, :updated_at, :datetime
+ add_column :forem_views, :count, :integer, :default => 0
+ end
+end
View
5 db/migrate/20120122052422_add_hidden_to_forem_topics.rb
@@ -0,0 +1,5 @@
+class AddHiddenToForemTopics < ActiveRecord::Migration
+ def change
+ add_column :forem_topics, :hidden, :boolean, :default => false
+ end
+end
View
12 db/migrate/20120122052423_add_indexes_to_topics_posts_views.rb
@@ -0,0 +1,12 @@
+class AddIndexesToTopicsPostsViews < ActiveRecord::Migration
+ def change
+ add_index :forem_topics, :forum_id
+ add_index :forem_topics, :user_id
+ add_index :forem_posts, :topic_id
+ add_index :forem_posts, :user_id
+ add_index :forem_posts, :reply_to_id
+ add_index :forem_views, :user_id
+ add_index :forem_views, :topic_id
+ add_index :forem_views, :updated_at
+ end
+end
View
10 db/migrate/20120122052424_create_forem_categories.rb
@@ -0,0 +1,10 @@
+class CreateForemCategories < ActiveRecord::Migration
+ def change
+ create_table :forem_categories do |t|
+ t.string :name, :null => false
+ t.timestamps
+ end
+ Forem::Category.reset_column_information
+ Forem::Category.create(:name => 'General')
+ end
+end
View
9 db/migrate/20120122052425_add_category_id_to_forums.rb
@@ -0,0 +1,9 @@
+class AddCategoryIdToForums < ActiveRecord::Migration
+ def change
+ add_column :forem_forums, :category_id, :integer
+
+ if Forem::Forum.count > 0
+ Forem::Forum.update_all :category_id => Forem::Category.first.id
+ end
+ end
+end
View
8 db/migrate/20120122052426_create_forem_subscriptions.rb
@@ -0,0 +1,8 @@
+class CreateForemSubscriptions < ActiveRecord::Migration
+ def change
+ create_table :forem_subscriptions do |t|
+ t.integer :subscriber_id
+ t.integer :topic_id
+ end
+ end
+end
View
6 db/migrate/20120122052427_add_forem_admin.rb
@@ -0,0 +1,6 @@
+class AddForemAdmin < ActiveRecord::Migration
+
+ def change
+ add_column :users, :forem_admin, :boolean, :default => false
+ end
+end
View
59 db/schema.rb
@@ -11,7 +11,63 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120120191802) do
+ActiveRecord::Schema.define(:version => 20120122052427) do
+
+ create_table "forem_categories", :force => true do |t|
+ t.string "name", :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "forem_forums", :force => true do |t|
+ t.string "title"
+ t.text "description"
+ t.integer "category_id"
+ end
+
+ create_table "forem_posts", :force => true do |t|
+ t.integer "topic_id"
+ t.text "text"
+ t.integer "user_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "reply_to_id"
+ end
+
+ add_index "forem_posts", ["reply_to_id"], :name => "index_forem_posts_on_reply_to_id"
+ add_index "forem_posts", ["topic_id"], :name => "index_forem_posts_on_topic_id"
+ add_index "forem_posts", ["user_id"], :name => "index_forem_posts_on_user_id"
+
+ create_table "forem_subscriptions", :force => true do |t|
+ t.integer "subscriber_id"
+ t.integer "topic_id"
+ end
+
+ create_table "forem_topics", :force => true do |t|
+ t.integer "forum_id"
+ t.integer "user_id"
+ t.string "subject"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.boolean "locked", :default => false, :null => false
+ t.boolean "pinned", :default => false
+ t.boolean "hidden", :default => false
+ end
+
+ add_index "forem_topics", ["forum_id"], :name => "index_forem_topics_on_forum_id"
+ add_index "forem_topics", ["user_id"], :name => "index_forem_topics_on_user_id"
+
+ create_table "forem_views", :force => true do |t|
+ t.integer "user_id"
+ t.integer "topic_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "count", :default => 0
+ end
+
+ add_index "forem_views", ["topic_id"], :name => "index_forem_views_on_topic_id"
+ add_index "forem_views", ["updated_at"], :name => "index_forem_views_on_updated_at"
+ add_index "forem_views", ["user_id"], :name => "index_forem_views_on_user_id"
create_table "profiles", :force => true do |t|
t.string "name"
@@ -46,6 +102,7 @@
t.string "uid"
t.datetime "created_at"
t.datetime "updated_at"
+ t.boolean "forem_admin", :default => false
end
end
Something went wrong with that request. Please try again.