neifelheim-forem 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ = Forem
2
+
3
+ This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Forem'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec)
32
+
33
+ task :default => :spec
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,11 @@
1
+ module Forem
2
+ class ApplicationController < ::ApplicationController
3
+ private
4
+ def authenticate_forem_user!
5
+ if !current_user
6
+ flash[:notice] = "You must be authenticated before you can do that."
7
+ redirect_to main_app.sign_in_url
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,25 @@
1
+ require_dependency "forem/application_controller"
2
+
3
+ module Forem
4
+ class PostsController < ApplicationController
5
+ before_filter :authenticate_forem_user!, :only => [:new, :create]
6
+ before_filter :find_topic
7
+
8
+ def new
9
+ @post = @topic.posts.build
10
+ end
11
+
12
+ def create
13
+ params[:post].merge!(:user => current_user)
14
+ @post = @topic.posts.create(params[:post])
15
+ flash[:notice] = "Post has been created!"
16
+ redirect_to topic_path(@topic)
17
+ end
18
+
19
+ private
20
+
21
+ def find_topic
22
+ @topic = Forem::Topic.find(params[:topic_id])
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ require_dependency "forem/application_controller"
2
+
3
+ module Forem
4
+ class TopicsController < ApplicationController
5
+ before_filter :authenticate_forem_user!, :only => [:new, :create]
6
+ def index
7
+ @topics = Forem::Topic.all
8
+ end
9
+ def new
10
+ @topic = Forem::Topic.new
11
+ @topic.posts.build
12
+ end
13
+ def create
14
+ params[:topic].merge!(:user => current_user)
15
+ @topic = Forem::Topic.create(params[:topic])
16
+ flash[:notice] = "Topic has been created!"
17
+ redirect_to @topic
18
+ end
19
+ def show
20
+ @topic = Forem::Topic.find(params[:id])
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ module Forem
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Forem
2
+ module PostsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Forem
2
+ module TopicsHelper
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ module Forem
2
+ class Post < ActiveRecord::Base
3
+ attr_accessible :text, :topic_id, :user
4
+ belongs_to :topic, :counter_cache => true
5
+ belongs_to :user, :class_name => Forem::Engine.user_class.to_s
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ module Forem
2
+ class Topic < ActiveRecord::Base
3
+ before_save :set_post_user
4
+
5
+ attr_accessible :subject, :user, :posts_attributes
6
+ has_many :posts, :order => "created_at ASC"
7
+ belongs_to :user, :class_name => Forem::Engine.user_class.to_s
8
+ has_one :last_post, :class_name => "Forem::Post", :order => "created_at DESC"
9
+ accepts_nested_attributes_for :posts
10
+
11
+ private
12
+ def set_post_user
13
+ self.posts.first.user = self.user
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ <p>
2
+ <%= post.label :text %><br>
3
+ <%= post.text_area :text %>
4
+ </p>
5
+
@@ -0,0 +1,7 @@
1
+ <%= div_for(post, class: 'forem_post') do %>
2
+ <small>Written at <%= post.created_at %></small>
3
+ <small class='user'>By <%= post.user %></small>
4
+ <%= simple_format(post.text) %>
5
+ <%= link_to "Reply", new_topic_post_path(@topic) %>
6
+ <% end %>
7
+
@@ -0,0 +1,5 @@
1
+ <h2>New Post</h2>
2
+ <%= form_for [@topic, @post] do |post| %>
3
+ <%= render :partial => "form", :locals => { :post => post } %>
4
+ <%= post.submit %>
5
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <%= form_for @topic do |f| %>
2
+ <p>
3
+ <%= f.label :subject %>
4
+ <%= f.text_field :subject %>
5
+ </p>
6
+ <%= f.fields_for :posts do |post| %>
7
+ <%= render :partial => "forem/posts/form", :locals => { :post => post} %>
8
+ <% end %>
9
+ <%= f.submit %>
10
+ <% end %>
11
+
@@ -0,0 +1,27 @@
1
+ <h1>Topics</h1>
2
+ <% if current_user %>
3
+ <%= link_to "New Topic", new_topic_path %>
4
+ <% end %>
5
+ <% if @topics.empty? %>
6
+ There are currently no topics.
7
+ <% else %>
8
+ <table id='topics'>
9
+ <thead>
10
+ <tr>
11
+ <td>Subject</td>
12
+ <td>Posts count</td>
13
+ <td>Last post at</td>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ <% @topics.each do |topic| %>
18
+ <tr>
19
+ <td id='topic_subject'><%= link_to topic.subject, topic %></td>
20
+ <td id='posts_count'><%= topic.posts_count %></td>
21
+ <td id='last_post'>last post was <%= time_ago_in_words(topic.last_post.created_at) %> ago by <%= topic.last_post.user %></td>
22
+ </tr>
23
+ <% end %>
24
+ </tbody>
25
+ </table>
26
+ <% end %>
27
+
@@ -0,0 +1,3 @@
1
+ <h1>New Topic</h1>
2
+ <%= render "form" %>
3
+
@@ -0,0 +1,7 @@
1
+ <%= div_for(@topic, class: 'forem_topic') do %>
2
+ <h1><%= @topic.subject %></h1>
3
+ <div id='posts'>
4
+ <%= render :partial => "forem/posts/post", :collection => @topic.posts %>
5
+ </div>
6
+ <% end %>
7
+
@@ -0,0 +1,7 @@
1
+ Forem::Engine.routes.draw do
2
+ resources :topics do
3
+ resources :posts
4
+ end
5
+
6
+ root :to => "topics#index"
7
+ end
@@ -0,0 +1,10 @@
1
+ class CreateForemTopics < ActiveRecord::Migration
2
+ def change
3
+ create_table :forem_topics do |t|
4
+ t.text :subject
5
+ t.integer :user_id
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ class CreateForemPosts < ActiveRecord::Migration
2
+ def change
3
+ create_table :forem_posts do |t|
4
+ t.integer :topic_id
5
+ t.text :text
6
+ t.integer :user_id
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ class AddPostsCountToForemTopics < ActiveRecord::Migration
2
+ def change
3
+ add_column :forem_topics, :posts_count, :integer, default: 0
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ require "forem/engine"
2
+
3
+ module Forem
4
+ class ConfigurationNotSet < StandardError
5
+ end
6
+ end
@@ -0,0 +1,17 @@
1
+ module Forem
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Forem
4
+ config.generators.integration_tool :rspec
5
+ config.generators.test_framework :rspec
6
+
7
+ class << self
8
+ attr_accessor :user_class
9
+ end
10
+
11
+ def self.user_class
12
+ error = "Please define Forem::Engine.user_class" +
13
+ " in config/initializers/forem.rb"
14
+ @user_class || raise(ConfigurationNotSet, error)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module Forem
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :forem do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: neifelheim-forem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Manoj Mishra
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.13
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.13
30
+ - !ruby/object:Gem::Dependency
31
+ name: sqlite3
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec-rails
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: capybara
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: The best Rails 3 forum engine in the world.
79
+ email:
80
+ - b0rn2c0d3@gmail.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - app/helpers/forem/posts_helper.rb
86
+ - app/helpers/forem/topics_helper.rb
87
+ - app/helpers/forem/application_helper.rb
88
+ - app/controllers/forem/topics_controller.rb
89
+ - app/controllers/forem/application_controller.rb
90
+ - app/controllers/forem/posts_controller.rb
91
+ - app/models/forem/topic.rb
92
+ - app/models/forem/post.rb
93
+ - app/views/forem/topics/new.html.erb
94
+ - app/views/forem/topics/show.html.erb
95
+ - app/views/forem/topics/_form.html.erb
96
+ - app/views/forem/topics/index.html.erb
97
+ - app/views/forem/posts/_post.html.erb
98
+ - app/views/forem/posts/new.html.erb
99
+ - app/views/forem/posts/_form.html.erb
100
+ - app/assets/javascripts/forem/posts.js
101
+ - app/assets/javascripts/forem/topics.js
102
+ - app/assets/javascripts/forem/application.js
103
+ - app/assets/stylesheets/forem/posts.css
104
+ - app/assets/stylesheets/forem/topics.css
105
+ - app/assets/stylesheets/forem/application.css
106
+ - config/routes.rb
107
+ - db/migrate/20130623195306_create_forem_posts.rb
108
+ - db/migrate/20130623204949_add_posts_count_to_forem_topics.rb
109
+ - db/migrate/20130623193923_create_forem_topics.rb
110
+ - lib/forem.rb
111
+ - lib/forem/engine.rb
112
+ - lib/forem/version.rb
113
+ - lib/tasks/forem_tasks.rake
114
+ - MIT-LICENSE
115
+ - Rakefile
116
+ - README.rdoc
117
+ homepage: https://github.com/neifelheim/forem
118
+ licenses: []
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ segments:
130
+ - 0
131
+ hash: 3193519319419979371
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ segments:
139
+ - 0
140
+ hash: 3193519319419979371
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 1.8.25
144
+ signing_key:
145
+ specification_version: 3
146
+ summary: The best Rails 3 forum engine in the world.
147
+ test_files: []