ticketee-forem 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +144 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +17 -0
- data/app/assets/images/.gitkeep +0 -0
- data/app/assets/javascripts/application.js +11 -0
- data/app/assets/javascripts/forem/posts.js +2 -0
- data/app/assets/javascripts/forem/topics.js +2 -0
- data/app/assets/stylesheets/application.css +7 -0
- data/app/assets/stylesheets/forem/posts.css +4 -0
- data/app/assets/stylesheets/forem/topics.css +4 -0
- data/app/controllers/forem/application_controller.rb +12 -0
- data/app/controllers/forem/posts_controller.rb +23 -0
- data/app/controllers/forem/topics_controller.rb +24 -0
- data/app/helpers/forem/application_helper.rb +4 -0
- data/app/helpers/forem/posts_helper.rb +4 -0
- data/app/helpers/forem/topics_helper.rb +4 -0
- data/app/models/forem/post.rb +5 -0
- data/app/models/forem/topic.rb +15 -0
- data/app/views/forem/posts/_form.html.erb +4 -0
- data/app/views/forem/posts/_post.html.erb +6 -0
- data/app/views/forem/posts/new.html.erb +5 -0
- data/app/views/forem/topics/_form.html.erb +11 -0
- data/app/views/forem/topics/index.html.erb +28 -0
- data/app/views/forem/topics/new.html.erb +2 -0
- data/app/views/forem/topics/show.html.erb +6 -0
- data/bin/autospec +16 -0
- data/bin/edit_json.rb +16 -0
- data/bin/erubis +16 -0
- data/bin/htmldiff +16 -0
- data/bin/launchy +16 -0
- data/bin/ldiff +16 -0
- data/bin/nokogiri +16 -0
- data/bin/prettify_json.rb +16 -0
- data/bin/rackup +16 -0
- data/bin/rails +16 -0
- data/bin/rake +16 -0
- data/bin/rake2thor +16 -0
- data/bin/rspec +16 -0
- data/bin/run_celerity_server.rb +16 -0
- data/bin/thor +16 -0
- data/bin/tilt +16 -0
- data/bin/tt +16 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20110607015955_create_forem_topics.rb +10 -0
- data/db/migrate/20110607021318_create_forem_posts.rb +11 -0
- data/db/migrate/20110607035012_add_posts_count_to_forem_topics.rb +5 -0
- data/lib/forem.rb +4 -0
- data/lib/forem/engine.rb +10 -0
- data/lib/forem/user_extension.rb +8 -0
- data/lib/tasks/forem_tasks.rake +4 -0
- data/script/rails +6 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/fake_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/user.rb +7 -0
- data/spec/dummy/app/views/layouts/application.html.erb +18 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +49 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +11 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +24 -0
- data/spec/dummy/config/environments/production.rb +52 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20110607020624_create_forem_topics.rb +10 -0
- data/spec/dummy/db/migrate/20110607021444_create_forem_posts.rb +11 -0
- data/spec/dummy/db/migrate/20110607035916_add_posts_count_to_forem_topics.rb +5 -0
- data/spec/dummy/db/migrate/20110607055250_create_users.rb +9 -0
- data/spec/dummy/db/schema.rb +37 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/test/fixtures/users.yml +7 -0
- data/spec/dummy/test/unit/user_test.rb +7 -0
- data/spec/integration/posts_spec.rb +63 -0
- data/spec/integration/topics_spec.rb +46 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/support/capybara.rb +8 -0
- data/spec/support/dummy_login.rb +19 -0
- data/spec/support/load_routes.rb +6 -0
- data/ticketee-forem.gemspec +16 -0
- metadata +195 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/rails/rails
|
3
|
+
revision: fa6b12aeed582b4b85e04549d4b771cc02ca813b
|
4
|
+
branch: 3-1-stable
|
5
|
+
specs:
|
6
|
+
actionmailer (3.1.0.rc3)
|
7
|
+
actionpack (= 3.1.0.rc3)
|
8
|
+
mail (~> 2.3.0)
|
9
|
+
actionpack (3.1.0.rc3)
|
10
|
+
activemodel (= 3.1.0.rc3)
|
11
|
+
activesupport (= 3.1.0.rc3)
|
12
|
+
builder (~> 3.0.0)
|
13
|
+
erubis (~> 2.7.0)
|
14
|
+
i18n (~> 0.6)
|
15
|
+
rack (~> 1.3.0)
|
16
|
+
rack-cache (~> 1.0.1)
|
17
|
+
rack-mount (~> 0.8.1)
|
18
|
+
rack-test (~> 0.6.0)
|
19
|
+
sprockets (~> 2.0.0.beta.10)
|
20
|
+
tzinfo (~> 0.3.27)
|
21
|
+
activemodel (3.1.0.rc3)
|
22
|
+
activesupport (= 3.1.0.rc3)
|
23
|
+
bcrypt-ruby (~> 2.1.4)
|
24
|
+
builder (~> 3.0.0)
|
25
|
+
i18n (~> 0.6)
|
26
|
+
activerecord (3.1.0.rc3)
|
27
|
+
activemodel (= 3.1.0.rc3)
|
28
|
+
activesupport (= 3.1.0.rc3)
|
29
|
+
arel (~> 2.1.1)
|
30
|
+
tzinfo (~> 0.3.27)
|
31
|
+
activeresource (3.1.0.rc3)
|
32
|
+
activemodel (= 3.1.0.rc3)
|
33
|
+
activesupport (= 3.1.0.rc3)
|
34
|
+
activesupport (3.1.0.rc3)
|
35
|
+
multi_json (~> 1.0)
|
36
|
+
rails (3.1.0.rc3)
|
37
|
+
actionmailer (= 3.1.0.rc3)
|
38
|
+
actionpack (= 3.1.0.rc3)
|
39
|
+
activerecord (= 3.1.0.rc3)
|
40
|
+
activeresource (= 3.1.0.rc3)
|
41
|
+
activesupport (= 3.1.0.rc3)
|
42
|
+
bundler (~> 1.0)
|
43
|
+
railties (= 3.1.0.rc3)
|
44
|
+
railties (3.1.0.rc3)
|
45
|
+
actionpack (= 3.1.0.rc3)
|
46
|
+
activesupport (= 3.1.0.rc3)
|
47
|
+
rack-ssl (~> 1.3.2)
|
48
|
+
rake (>= 0.8.7)
|
49
|
+
thor (~> 0.14.6)
|
50
|
+
|
51
|
+
PATH
|
52
|
+
remote: .
|
53
|
+
specs:
|
54
|
+
ticketee-forem (0.0.1)
|
55
|
+
|
56
|
+
GEM
|
57
|
+
remote: http://rubygems.org/
|
58
|
+
specs:
|
59
|
+
arel (2.1.1)
|
60
|
+
bcrypt-ruby (2.1.4)
|
61
|
+
builder (3.0.0)
|
62
|
+
capybara (0.4.1.2)
|
63
|
+
celerity (>= 0.7.9)
|
64
|
+
culerity (>= 0.2.4)
|
65
|
+
mime-types (>= 1.16)
|
66
|
+
nokogiri (>= 1.3.3)
|
67
|
+
rack (>= 1.0.0)
|
68
|
+
rack-test (>= 0.5.4)
|
69
|
+
selenium-webdriver (>= 0.0.27)
|
70
|
+
xpath (~> 0.1.3)
|
71
|
+
celerity (0.8.9)
|
72
|
+
childprocess (0.1.9)
|
73
|
+
ffi (~> 1.0.6)
|
74
|
+
configuration (1.2.0)
|
75
|
+
culerity (0.2.15)
|
76
|
+
diff-lcs (1.1.2)
|
77
|
+
erubis (2.7.0)
|
78
|
+
ffi (1.0.9)
|
79
|
+
hike (1.0.0)
|
80
|
+
i18n (0.6.0)
|
81
|
+
json_pure (1.5.1)
|
82
|
+
launchy (0.4.0)
|
83
|
+
configuration (>= 0.0.5)
|
84
|
+
rake (>= 0.8.1)
|
85
|
+
mail (2.3.0)
|
86
|
+
i18n (>= 0.4.0)
|
87
|
+
mime-types (~> 1.16)
|
88
|
+
treetop (~> 1.4.8)
|
89
|
+
mime-types (1.16)
|
90
|
+
multi_json (1.0.3)
|
91
|
+
nokogiri (1.4.4)
|
92
|
+
polyglot (0.3.1)
|
93
|
+
rack (1.3.0)
|
94
|
+
rack-cache (1.0.2)
|
95
|
+
rack (>= 0.4)
|
96
|
+
rack-mount (0.8.1)
|
97
|
+
rack (>= 1.0.0)
|
98
|
+
rack-ssl (1.3.2)
|
99
|
+
rack
|
100
|
+
rack-test (0.6.0)
|
101
|
+
rack (>= 1.0)
|
102
|
+
rake (0.9.2)
|
103
|
+
rspec (2.6.0)
|
104
|
+
rspec-core (~> 2.6.0)
|
105
|
+
rspec-expectations (~> 2.6.0)
|
106
|
+
rspec-mocks (~> 2.6.0)
|
107
|
+
rspec-core (2.6.4)
|
108
|
+
rspec-expectations (2.6.0)
|
109
|
+
diff-lcs (~> 1.1.2)
|
110
|
+
rspec-mocks (2.6.0)
|
111
|
+
rspec-rails (2.6.1)
|
112
|
+
actionpack (~> 3.0)
|
113
|
+
activesupport (~> 3.0)
|
114
|
+
railties (~> 3.0)
|
115
|
+
rspec (~> 2.6.0)
|
116
|
+
rubyzip (0.9.4)
|
117
|
+
selenium-webdriver (0.2.1)
|
118
|
+
childprocess (>= 0.1.7)
|
119
|
+
ffi (>= 1.0.7)
|
120
|
+
json_pure
|
121
|
+
rubyzip
|
122
|
+
sprockets (2.0.0.beta.10)
|
123
|
+
hike (~> 1.0)
|
124
|
+
rack (~> 1.0)
|
125
|
+
tilt (!= 1.3.0, ~> 1.1)
|
126
|
+
sqlite3 (1.3.3)
|
127
|
+
thor (0.14.6)
|
128
|
+
tilt (1.3.2)
|
129
|
+
treetop (1.4.9)
|
130
|
+
polyglot (>= 0.3.1)
|
131
|
+
tzinfo (0.3.27)
|
132
|
+
xpath (0.1.4)
|
133
|
+
nokogiri (~> 1.3)
|
134
|
+
|
135
|
+
PLATFORMS
|
136
|
+
ruby
|
137
|
+
|
138
|
+
DEPENDENCIES
|
139
|
+
capybara
|
140
|
+
launchy
|
141
|
+
rails!
|
142
|
+
rspec-rails (~> 2.5)
|
143
|
+
sqlite3
|
144
|
+
ticketee-forem!
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 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.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
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
|
+
|
8
|
+
Bundler::GemHelper.install_tasks
|
9
|
+
|
10
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
11
|
+
load 'rails/tasks/engine.rake'
|
12
|
+
|
13
|
+
require 'rspec/core/rake_task'
|
14
|
+
RSpec::Core::RakeTask.new(:spec)
|
15
|
+
|
16
|
+
task :default => :spec
|
17
|
+
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
<% unless options[:skip_javascript] -%>
|
8
|
+
//= require <%= options[:javascript] %>
|
9
|
+
//= require <%= options[:javascript] %>_ujs
|
10
|
+
<% end -%>
|
11
|
+
//= require_tree .
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Forem
|
2
|
+
class ApplicationController < ::ApplicationController
|
3
|
+
private
|
4
|
+
|
5
|
+
def authenticate_forem_user!
|
6
|
+
if !current_user
|
7
|
+
flash[:notice] = "You must be authenticated before you can do that."
|
8
|
+
redirect_to main_app.sign_in_path
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Forem
|
2
|
+
class PostsController < ApplicationController
|
3
|
+
before_filter :find_topic
|
4
|
+
before_filter :authenticate_forem_user!, :only => [:new, :create]
|
5
|
+
|
6
|
+
def new
|
7
|
+
@post = @topic.posts.build
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
params[:post].merge!(:user => current_user)
|
12
|
+
@post = @topic.posts.create(params[:post])
|
13
|
+
flash[:notice] = "Post has been created!"
|
14
|
+
redirect_to topic_path(@topic)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def find_topic
|
20
|
+
@topic = Forem::Topic.find(params[:topic_id])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Forem
|
2
|
+
class TopicsController < ApplicationController
|
3
|
+
before_filter :authenticate_forem_user!, :only => [:new, :create]
|
4
|
+
def index
|
5
|
+
@topics = Forem::Topic.all
|
6
|
+
end
|
7
|
+
|
8
|
+
def new
|
9
|
+
@topic = Forem::Topic.new
|
10
|
+
@topic.posts.build
|
11
|
+
end
|
12
|
+
|
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
|
+
|
20
|
+
def show
|
21
|
+
@topic = Forem::Topic.find(params[:id])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Forem
|
2
|
+
class Topic < ActiveRecord::Base
|
3
|
+
has_many :posts, :order => "created_at ASC"
|
4
|
+
has_one :last_post, :class_name => "Forem::Post",
|
5
|
+
:order => "created_at DESC"
|
6
|
+
accepts_nested_attributes_for :posts
|
7
|
+
|
8
|
+
before_save :set_post_user
|
9
|
+
|
10
|
+
private
|
11
|
+
def set_post_user
|
12
|
+
self.posts.first.user = self.user
|
13
|
+
end
|
14
|
+
end
|
15
|
+
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
|
+
|
7
|
+
<%= f.fields_for :posts do |post| %>
|
8
|
+
<%= render :partial => "forem/posts/form", :locals => { :post => post} %>
|
9
|
+
<% end %>
|
10
|
+
<%= f.submit %>
|
11
|
+
<% end %>
|
@@ -0,0 +1,28 @@
|
|
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'>
|
22
|
+
last post was <%= time_ago_in_words(topic.last_post.created_at) %> ago by <%= topic.last_post.user %>
|
23
|
+
</td>
|
24
|
+
</tr>
|
25
|
+
<% end %>
|
26
|
+
</tbody>
|
27
|
+
</table>
|
28
|
+
<% end %>
|
data/bin/autospec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'autospec' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rspec-core', 'autospec')
|