mongoid-forums 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +35 -0
- data/app/assets/javascripts/mongoid_forums/admin/base.js +2 -0
- data/app/assets/javascripts/mongoid_forums/admin/categories.js +2 -0
- data/app/assets/javascripts/mongoid_forums/admin/forums.js +2 -0
- data/app/assets/javascripts/mongoid_forums/application.js +13 -0
- data/app/assets/javascripts/mongoid_forums/forums.js +2 -0
- data/app/assets/javascripts/mongoid_forums/posts.js +2 -0
- data/app/assets/javascripts/mongoid_forums/topics.js +2 -0
- data/app/assets/stylesheets/mongoid_forums/admin/base.css +4 -0
- data/app/assets/stylesheets/mongoid_forums/admin/categories.css +4 -0
- data/app/assets/stylesheets/mongoid_forums/admin/forums.css +4 -0
- data/app/assets/stylesheets/mongoid_forums/application.css +15 -0
- data/app/assets/stylesheets/mongoid_forums/forums.css +4 -0
- data/app/assets/stylesheets/mongoid_forums/posts.css +4 -0
- data/app/assets/stylesheets/mongoid_forums/topics.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/mongoid_forums/admin/base_controller.rb +11 -0
- data/app/controllers/mongoid_forums/admin/categories_controller.rb +36 -0
- data/app/controllers/mongoid_forums/admin/forums_controller.rb +36 -0
- data/app/controllers/mongoid_forums/application_controller.rb +45 -0
- data/app/controllers/mongoid_forums/forums_controller.rb +57 -0
- data/app/controllers/mongoid_forums/posts_controller.rb +75 -0
- data/app/controllers/mongoid_forums/redirect_controller.rb +33 -0
- data/app/controllers/mongoid_forums/topics_controller.rb +84 -0
- data/app/helpers/mongoid_forums/admin/base_helper.rb +4 -0
- data/app/helpers/mongoid_forums/admin/categories_helper.rb +4 -0
- data/app/helpers/mongoid_forums/admin/forums_helper.rb +4 -0
- data/app/helpers/mongoid_forums/application_helper.rb +20 -0
- data/app/helpers/mongoid_forums/formatting_helper.rb +28 -0
- data/app/helpers/mongoid_forums/forums_helper.rb +15 -0
- data/app/helpers/mongoid_forums/posts_helper.rb +4 -0
- data/app/helpers/mongoid_forums/topics_helper.rb +4 -0
- data/app/models/mongoid_forums/alert.rb +80 -0
- data/app/models/mongoid_forums/category.rb +13 -0
- data/app/models/mongoid_forums/concerns/subscribable.rb +76 -0
- data/app/models/mongoid_forums/concerns/viewable.rb +60 -0
- data/app/models/mongoid_forums/forum.rb +42 -0
- data/app/models/mongoid_forums/permission.rb +95 -0
- data/app/models/mongoid_forums/post.rb +37 -0
- data/app/models/mongoid_forums/rank.rb +9 -0
- data/app/models/mongoid_forums/subscription.rb +66 -0
- data/app/models/mongoid_forums/topic.rb +45 -0
- data/app/models/mongoid_forums/view.rb +30 -0
- data/app/views/layouts/mongoid_forums/application.haml +21 -0
- data/app/views/mongoid_forums/admin/base/index.haml +4 -0
- data/app/views/mongoid_forums/admin/categories/edit.html.erb +2 -0
- data/app/views/mongoid_forums/admin/categories/new.haml +3 -0
- data/app/views/mongoid_forums/admin/forums/edit.html.erb +2 -0
- data/app/views/mongoid_forums/admin/forums/new.haml +4 -0
- data/app/views/mongoid_forums/forums/index.haml +43 -0
- data/app/views/mongoid_forums/forums/new.haml +15 -0
- data/app/views/mongoid_forums/forums/show.haml +43 -0
- data/app/views/mongoid_forums/posts/_form.haml +4 -0
- data/app/views/mongoid_forums/posts/_post.haml +20 -0
- data/app/views/mongoid_forums/posts/_quoted.haml +9 -0
- data/app/views/mongoid_forums/posts/edit.haml +17 -0
- data/app/views/mongoid_forums/posts/new.haml +17 -0
- data/app/views/mongoid_forums/topics/_topic.haml +2 -0
- data/app/views/mongoid_forums/topics/my_posts.haml +6 -0
- data/app/views/mongoid_forums/topics/my_subscriptions.haml +5 -0
- data/app/views/mongoid_forums/topics/my_topics.haml +6 -0
- data/app/views/mongoid_forums/topics/show.haml +12 -0
- data/config/routes.rb +40 -0
- data/lib/generators/mongoid_forums/install/templates/initializer.rb +5 -0
- data/lib/generators/mongoid_forums/install_generator.rb +101 -0
- data/lib/generators/mongoid_forums/views_generator.rb +27 -0
- data/lib/mongoid_forums/engine.rb +15 -0
- data/lib/mongoid_forums/sanitizer.rb +10 -0
- data/lib/mongoid_forums/version.rb +3 -0
- data/lib/mongoid_forums.rb +40 -0
- data/lib/tasks/mongoid_forums_tasks.rake +4 -0
- data/test/controllers/mongoid_forums/admin/base_controller_test.rb +11 -0
- data/test/controllers/mongoid_forums/admin/categories_controller_test.rb +31 -0
- data/test/controllers/mongoid_forums/admin/forums_controller_test.rb +31 -0
- data/test/controllers/mongoid_forums/forums_controller_test.rb +16 -0
- data/test/controllers/mongoid_forums/posts_controller_test.rb +36 -0
- data/test/controllers/mongoid_forums/topics_controller_test.rb +36 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/javascripts/welcome.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/assets/stylesheets/welcome.css +4 -0
- data/test/dummy/app/controllers/application_controller.rb +11 -0
- data/test/dummy/app/controllers/welcome_controller.rb +4 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/welcome_helper.rb +2 -0
- data/test/dummy/app/models/concerns/zero_oid_fix.rb +10 -0
- data/test/dummy/app/models/user.rb +43 -0
- data/test/dummy/app/views/layouts/application.haml +13 -0
- data/test/dummy/app/views/partials/_nav.haml +6 -0
- data/test/dummy/app/views/welcome/index.html.erb +2 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +29 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +76 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/devise.rb +259 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/kaminari_config.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/mongoid_forums.rb +5 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/simple_form.rb +166 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
- data/test/dummy/config/locales/devise.en.yml +60 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/locales/simple_form.en.yml +31 -0
- data/test/dummy/config/mongoid.yml +69 -0
- data/test/dummy/config/routes.rb +8 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/lib/templates/erb/scaffold/_form.html.erb +13 -0
- data/test/dummy/log/development.log +152624 -0
- data/test/dummy/log/test.log +51 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/test/controllers/welcome_controller_test.rb +9 -0
- data/test/dummy/test/fixtures/users.yml +11 -0
- data/test/dummy/test/models/user_test.rb +7 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0405ebcb982faa24d5a9bbe01ba43bf8 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/04b994ecf135576af395f1d87108f0e1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0532538bff94834533de08d16379c66f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/063d0c765cb2fe0a6fa3995059d65fcc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0a395daf2ed2bad0174008f223997c21 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0a4181c6e19406e1c40781394b0f7496 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0f520169da88dbfbdd5b5f40cb5acc80 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1b516e1e4f37dd27b32d035c2c825de7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1d1293f6abfd57a3035ab25a567fe43e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/25a167c7563d6fe8ec6b13ec1ac09274 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/268f4f56598234185d91373d61899b3f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/26ce0653a8cb3da5990ace16181dbd63 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2dedb8177c20286c4259c1d58c5646cc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2fda08fb2ff79ca1dd653c3b688c1651 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/30d0258c36708f3d7911d6ba2303aaad +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/311da47a66243f663a4557a7e9997796 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/37b103f4623089af1456b90830fe941c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/37f7e269b2ddbd05160232e59bf0288f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/408e554cb00cbb09ae89a1e7ac45ea4f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/41f10e590485de7db44ca61e32c135ea +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/45e716730a5c02112d5817e1b8faa1a0 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4acd6b11130459cfdf814caad7638e95 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/60f651a96095c10f531bd7bf9a14beb5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6b12ee5284cadf70954a584a88b6c529 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6be29bb8e609ed29aaa3a6d4a04a9ae0 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6cef1e9aec64b514669e261e511dc792 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/76dc342539f7133a15b70b919f77425a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/873adae1bf2f532256c8ffe71a557df5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8d7f8b5066922abfdf12e8cf0a7f2f0e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/948b1a4ef7d3401c10fc537c40b56a1e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/99d8deee7a422780b297ca618f4062c8 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9d4262e6cd4898fd1df7f51b2d3e5c92 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9e611bdf180a46600cc5019392a1b561 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ab4dfca9c17bc07c2fce0127b5d9669f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/af01a98a48fa1ebf1d65f0429ba2bb28 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/bc0c996f7ce50479170183c13af2d29d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/beeaeba29291235e532fb452d94795b3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cc040cf4f4539a12745d02867976f5ba +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ce30207f8949b0e3a822f6094bd31dcc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d675d8a6b14078d1fc331870b4992050 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/daba24276ab6f3be739a0385f977df1c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/df5f9fbb250c939b0513aa2a35b4855b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e22980ed174c68b2505214836a40e271 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e2c4f946939f2d7d0b42d86383755cae +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e6a87270f3b0e8a73bcec17322694b61 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e95bb3887fb84a7d966c0fc7c4e087fd +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/eaa7a7fe023d19cd34c33a47e6b303f3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f91f775cd15edae9264ec0c23937c58b +0 -0
- data/test/fixtures/mongoid_forums/categories.yml +11 -0
- data/test/fixtures/mongoid_forums/forums.yml +11 -0
- data/test/fixtures/mongoid_forums/posts.yml +11 -0
- data/test/fixtures/mongoid_forums/ranks.yml +11 -0
- data/test/fixtures/mongoid_forums/topics.yml +11 -0
- data/test/integration/navigation_test.rb +9 -0
- data/test/models/mongoid_forums/category_test.rb +9 -0
- data/test/models/mongoid_forums/forum_test.rb +9 -0
- data/test/models/mongoid_forums/post_test.rb +9 -0
- data/test/models/mongoid_forums/rank_test.rb +9 -0
- data/test/models/mongoid_forums/topic_test.rb +9 -0
- data/test/mongoid_forums_test.rb +7 -0
- data/test/test_helper.rb +17 -0
- metadata +491 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
%h3
|
|
2
|
+
New Topic in
|
|
3
|
+
= @forum.category.name
|
|
4
|
+
Category
|
|
5
|
+
|
|
6
|
+
= simple_form_for @topic, :url => forum_create_path do |f|
|
|
7
|
+
= f.label :name
|
|
8
|
+
= f.text_field :name
|
|
9
|
+
%br
|
|
10
|
+
%br
|
|
11
|
+
= f.label :post
|
|
12
|
+
= f.simple_fields_for :posts do |post|
|
|
13
|
+
= render :partial => "mongoid_forums/posts/form", :locals => { :f => post }
|
|
14
|
+
%br
|
|
15
|
+
= f.submit "Create Topic", :class => "btn", :disable_with => "Creating..."
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
%h1 Viewing Forum "#{@forum.name}"
|
|
2
|
+
= link_to "Add a topic", forum_path(@forum) + '/new'
|
|
3
|
+
%br
|
|
4
|
+
%br
|
|
5
|
+
%h2 Topics:
|
|
6
|
+
%table{:border => "1"}
|
|
7
|
+
%tr
|
|
8
|
+
%th
|
|
9
|
+
Name
|
|
10
|
+
%th
|
|
11
|
+
Creator
|
|
12
|
+
%th
|
|
13
|
+
Last post
|
|
14
|
+
%th
|
|
15
|
+
Unread posts
|
|
16
|
+
%th
|
|
17
|
+
Posts
|
|
18
|
+
%th
|
|
19
|
+
Views
|
|
20
|
+
|
|
21
|
+
- @topics.each do |topic|
|
|
22
|
+
- if allow? "mongoid_forums/topics", :show, topic
|
|
23
|
+
%tr
|
|
24
|
+
%td
|
|
25
|
+
- if topic.locked
|
|
26
|
+
🔒
|
|
27
|
+
- if topic.hidden
|
|
28
|
+
⚠
|
|
29
|
+
= link_to topic.name, topic
|
|
30
|
+
%td
|
|
31
|
+
= topic.user.forum_display_name
|
|
32
|
+
= time_ago_in_words( topic.created_at )
|
|
33
|
+
ago
|
|
34
|
+
%td
|
|
35
|
+
= topic.posts.last.user.forum_display_name
|
|
36
|
+
= time_ago_in_words( topic.posts.last.created_at )
|
|
37
|
+
ago
|
|
38
|
+
%td
|
|
39
|
+
= topic.unread_post_count(mongoid_forums_user)
|
|
40
|
+
%td
|
|
41
|
+
= topic.posts.count
|
|
42
|
+
%td
|
|
43
|
+
= topic.views_count ? topic.views_count : "None"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
= post.user.forum_display_name
|
|
2
|
+
- if post.reply_to_id
|
|
3
|
+
replied to
|
|
4
|
+
= MongoidForums::Post.find(post.reply_to_id).user.forum_display_name
|
|
5
|
+
- else
|
|
6
|
+
created
|
|
7
|
+
= time_ago_in_words(post.created_at)
|
|
8
|
+
ago
|
|
9
|
+
|
|
10
|
+
= link_to 'Quote', new_topic_post_path(post.topic_id, :reply_to_id => post.id)
|
|
11
|
+
- if allow? "mongoid_forums/posts", :edit, post
|
|
12
|
+
= link_to "Edit", edit_topic_post_path(post.topic_id, post)
|
|
13
|
+
|
|
14
|
+
%br
|
|
15
|
+
- if post.reply_to_id
|
|
16
|
+
= render :partial => 'mongoid_forums/posts/quoted', :locals => {:post => post}
|
|
17
|
+
%br
|
|
18
|
+
= mongoid_forums_format(post.text)
|
|
19
|
+
%br
|
|
20
|
+
%hr
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
%h1 Edit Post
|
|
2
|
+
- if @current_resource[:reply_to_id]
|
|
3
|
+
- replying_to = MongoidForums::Post.find(@current_resource[:reply_to_id])
|
|
4
|
+
This post is a reply to
|
|
5
|
+
= replying_to.user.forum_display_name
|
|
6
|
+
%br
|
|
7
|
+
>
|
|
8
|
+
= replying_to.text
|
|
9
|
+
%br
|
|
10
|
+
%br
|
|
11
|
+
|
|
12
|
+
= form_for ([@current_resource.topic, @current_resource]) do |f|
|
|
13
|
+
= f.label :text
|
|
14
|
+
%br
|
|
15
|
+
= render :partial => "form", :locals => { :f => f }
|
|
16
|
+
%br
|
|
17
|
+
= f.submit "Update post", :class => "btn", :disable_with => "Updating..."
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
%h1 New Post
|
|
2
|
+
- if params[:reply_to_id]
|
|
3
|
+
- replying_to = MongoidForums::Post.find(params[:reply_to_id])
|
|
4
|
+
Replying to
|
|
5
|
+
= replying_to.user.forum_display_name
|
|
6
|
+
%br
|
|
7
|
+
>
|
|
8
|
+
= replying_to.text
|
|
9
|
+
%br
|
|
10
|
+
%br
|
|
11
|
+
|
|
12
|
+
= form_for ([@topic, @post]) do |f|
|
|
13
|
+
= f.label :text
|
|
14
|
+
%br
|
|
15
|
+
= render :partial => "form", :locals => { :f => f }
|
|
16
|
+
%br
|
|
17
|
+
= f.submit "Create Reply", :class => "btn", :disable_with => "Creating..."
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
%h1 Viewing Topic "#{@topic.name}"
|
|
2
|
+
= link_to "Reply to topic", new_topic_post_path(@topic)
|
|
3
|
+
- if allow? "mongoid_forums/topics", :edit, @topic
|
|
4
|
+
= link_to "Edit topic", edit_topic_post_path(@topic, @topic.posts.first.id)
|
|
5
|
+
- if mongoid_forums_user && @topic.subscriber?(mongoid_forums_user.id)
|
|
6
|
+
= link_to "Unsubscribe", unsubscribe_topic_path(@topic)
|
|
7
|
+
-elsif mongoid_forums_user
|
|
8
|
+
= link_to "Subscribe", subscribe_topic_path(@topic)
|
|
9
|
+
%br
|
|
10
|
+
= paginate @posts
|
|
11
|
+
%br
|
|
12
|
+
= render @posts
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
MongoidForums::Engine.routes.draw do
|
|
2
|
+
|
|
3
|
+
namespace :admin do
|
|
4
|
+
root :to => 'base#index'
|
|
5
|
+
resources :forums
|
|
6
|
+
resources :categories
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
root :to => "forums#index"
|
|
10
|
+
|
|
11
|
+
# REDIRECT OLD ROUTES
|
|
12
|
+
get '/forums/:forum_id/', :to => "redirect#forum"
|
|
13
|
+
get '/forums/:forum_id/topics/:topic_id', :to => "redirect#topic"
|
|
14
|
+
get '/posts/:post_id', :to => "redirect#posts"
|
|
15
|
+
get '/subscriptions', :to => "redirect#subscriptions"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# ME ROUTES
|
|
19
|
+
get 'my_subscriptions', :to => "topics#my_subscriptions"
|
|
20
|
+
get 'my_topics', :to => "topics#my_topics"
|
|
21
|
+
get 'my_posts', :to => "topics#my_posts"
|
|
22
|
+
|
|
23
|
+
# this moves the creation of topics into /forum_id/new
|
|
24
|
+
resources :forums, :path => "/" do
|
|
25
|
+
get 'new'
|
|
26
|
+
post 'create'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
resources :topics, :path => "/topics" do
|
|
30
|
+
resources :posts
|
|
31
|
+
member do
|
|
32
|
+
get :subscribe
|
|
33
|
+
get :unsubscribe
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
resources :categories
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
MongoidForums.user_class = "<%= user_class %>"
|
|
2
|
+
MongoidForums.email_from_address = "please-change-me@example.com"
|
|
3
|
+
# If you do not want to use gravatar for avatars then specify the method to use here:
|
|
4
|
+
# MongoidForums.avatar_user_method = :custom_avatar_url
|
|
5
|
+
MongoidForums.per_page = <%= MongoidForums.per_page.inspect %>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Thanks to radar/forem
|
|
2
|
+
# The code used to inspire this generator!
|
|
3
|
+
require 'rails/generators'
|
|
4
|
+
module MongoidForums
|
|
5
|
+
module Generators
|
|
6
|
+
class InstallGenerator < Rails::Generators::Base
|
|
7
|
+
class_option "user-class", :type => :string
|
|
8
|
+
class_option "current-user-helper", :type => :string
|
|
9
|
+
|
|
10
|
+
source_root File.expand_path("../install/templates", __FILE__)
|
|
11
|
+
desc "Used to install MongoidForums"
|
|
12
|
+
|
|
13
|
+
def determine_user_class
|
|
14
|
+
# Is there a cleaner way to do this?
|
|
15
|
+
if options["user-class"]
|
|
16
|
+
puts "Class of item passed as argument #{options["user-class"].class}"
|
|
17
|
+
@user_class = options["user-class"]
|
|
18
|
+
else
|
|
19
|
+
@user_class = ask("What is your user class called? [User]")
|
|
20
|
+
puts "Class of item passed from prompt #{@user_class.class}"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
if @user_class.blank?
|
|
24
|
+
@user_class = 'User'
|
|
25
|
+
puts "Class of item set when blank #{@user_class.class}"
|
|
26
|
+
else
|
|
27
|
+
@user_class = @user_class
|
|
28
|
+
puts "Class of item set when passed #{@user_class.class}"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def determine_current_user_helper
|
|
34
|
+
if options["current-user-helper"]
|
|
35
|
+
current_user_helper = options["current-user-helper"]
|
|
36
|
+
else
|
|
37
|
+
current_user_helper = ask("What is the current_user helper called in your app? [current_user]")
|
|
38
|
+
end
|
|
39
|
+
current_user_helper = :current_user if current_user_helper.blank?
|
|
40
|
+
puts "Defining mongoid_forums_user method inside ApplicationController..."
|
|
41
|
+
|
|
42
|
+
mongoid_forums_user_method = %Q{
|
|
43
|
+
def mongoid_forums_user
|
|
44
|
+
#{current_user_helper}
|
|
45
|
+
end
|
|
46
|
+
helper_method :mongoid_forums_user
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
inject_into_file("#{Rails.root}/app/controllers/application_controller.rb",
|
|
50
|
+
mongoid_forums_user_method,
|
|
51
|
+
:after => "ActionController::Base\n")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def add_mongoid_forums_initializer
|
|
55
|
+
path = "#{Rails.root}/config/initializers/mongoid_forums.rb"
|
|
56
|
+
if File.exists?(path)
|
|
57
|
+
puts "Skipping config/initializers/mongoid_forums.rb creation, as file already exists!"
|
|
58
|
+
else
|
|
59
|
+
puts "Adding mongoid_forums initializer (config/initializers/mongoid_forums.rb)..."
|
|
60
|
+
template "initializer.rb", path
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def mount_engine
|
|
65
|
+
puts "Mounting MongoidForums::Engine at \"/forums\" in config/routes.rb..."
|
|
66
|
+
insert_into_file("#{Rails.root}/config/routes.rb", :after => /routes.draw.do\n/) do
|
|
67
|
+
%Q{ mount MongoidForums::Engine, :at => "/forums"\n}
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def finished
|
|
72
|
+
output = "\n\n" + ("*" * 53)
|
|
73
|
+
output += %Q{\nDone! MongoidForums has been successfully installed. Yaaaaay!
|
|
74
|
+
Here's what happened:\n\n}
|
|
75
|
+
|
|
76
|
+
output += step("A new file was created at config/initializers/mongoid_forums.rb
|
|
77
|
+
This is where you put MongoidForums's configuration settings.\n")
|
|
78
|
+
output += step("The engine was mounted in your config/routes.rb file using this line:
|
|
79
|
+
mount MongoidForums::Engine, :at => \"/forums\"
|
|
80
|
+
If you want to change where the forums are located, just change the \"/forums\" path at the end of this line to whatever you want.")
|
|
81
|
+
output += %Q{\nAnd finally:
|
|
82
|
+
#{step("We told you that MongoidForums has been successfully installed and walked you through the steps.")}}
|
|
83
|
+
output += "Thanks for using MongoidForums!"
|
|
84
|
+
puts output
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
private
|
|
88
|
+
|
|
89
|
+
def step(words)
|
|
90
|
+
@step ||= 0
|
|
91
|
+
@step += 1
|
|
92
|
+
"#{@step}) #{words}\n"
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def user_class
|
|
96
|
+
@user_class
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Thanks to plataformatec/devise
|
|
2
|
+
# The code used to inspire this generator!
|
|
3
|
+
require 'rails/generators'
|
|
4
|
+
module MongoidForums
|
|
5
|
+
module Generators
|
|
6
|
+
class ViewsGenerator < Rails::Generators::Base #:nodoc:
|
|
7
|
+
source_root File.expand_path("../../../../app/views/mongoid_forums", __FILE__)
|
|
8
|
+
desc "Used to copy Mongoid Forum's views to your application's views."
|
|
9
|
+
|
|
10
|
+
def copy_views
|
|
11
|
+
view_directory :admin
|
|
12
|
+
#view_directory :categories
|
|
13
|
+
view_directory :forums
|
|
14
|
+
#view_directory :moderation
|
|
15
|
+
view_directory :posts
|
|
16
|
+
#view_directory :subscription_mailer
|
|
17
|
+
view_directory :topics
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
protected
|
|
21
|
+
|
|
22
|
+
def view_directory(name)
|
|
23
|
+
directory name.to_s, "app/views/mongoid_forums/#{name}"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require "mongoid"
|
|
2
|
+
require 'devise'
|
|
3
|
+
require 'simple_form'
|
|
4
|
+
|
|
5
|
+
require 'kaminari'
|
|
6
|
+
|
|
7
|
+
module MongoidForums
|
|
8
|
+
class Engine < ::Rails::Engine
|
|
9
|
+
isolate_namespace MongoidForums
|
|
10
|
+
|
|
11
|
+
config.to_prepare do
|
|
12
|
+
MongoidForums.decorate_user_class! if MongoidForums.user_class
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require "mongoid_forums/engine"
|
|
2
|
+
require 'mongoid_forums/sanitizer'
|
|
3
|
+
require 'sanitize'
|
|
4
|
+
|
|
5
|
+
module MongoidForums
|
|
6
|
+
mattr_accessor :per_page, :user_class, :formatter, :email_from_address
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
def per_page
|
|
10
|
+
@@per_page || 20
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def decorate_user_class!
|
|
14
|
+
MongoidForums.user_class.class_eval do
|
|
15
|
+
|
|
16
|
+
has_many :mongoid_forums_posts, :class_name => "MongoidForums::Post", :foreign_key => "user_id"
|
|
17
|
+
has_many :mongoid_forums_topics, :class_name => "MongoidForums::Topic", :foreign_key => "user_id"
|
|
18
|
+
|
|
19
|
+
# Using +to_s+ by default for backwards compatibility
|
|
20
|
+
def forum_display_name
|
|
21
|
+
to_s
|
|
22
|
+
end unless method_defined? :forum_display_name
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def user_class
|
|
28
|
+
if @@user_class.is_a?(Class)
|
|
29
|
+
raise "You can't set MongoidForums.user_class to be a class. Please use a string instead.\n\n " +
|
|
30
|
+
"See https://github.com/radar/mongoid_forums/issues/88 for more information."
|
|
31
|
+
elsif @@user_class.is_a?(String)
|
|
32
|
+
begin
|
|
33
|
+
Object.const_get(@@user_class)
|
|
34
|
+
rescue NameError
|
|
35
|
+
@@user_class.constantize
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module MongoidForums
|
|
4
|
+
class Admin::CategoriesControllerTest < ActionController::TestCase
|
|
5
|
+
test "should get new" do
|
|
6
|
+
get :new
|
|
7
|
+
assert_response :success
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
test "should get create" do
|
|
11
|
+
get :create
|
|
12
|
+
assert_response :success
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test "should get edit" do
|
|
16
|
+
get :edit
|
|
17
|
+
assert_response :success
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
test "should get update" do
|
|
21
|
+
get :update
|
|
22
|
+
assert_response :success
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
test "should get destroy" do
|
|
26
|
+
get :destroy
|
|
27
|
+
assert_response :success
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module MongoidForums
|
|
4
|
+
class Admin::ForumsControllerTest < ActionController::TestCase
|
|
5
|
+
test "should get new" do
|
|
6
|
+
get :new
|
|
7
|
+
assert_response :success
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
test "should get create" do
|
|
11
|
+
get :create
|
|
12
|
+
assert_response :success
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test "should get edit" do
|
|
16
|
+
get :edit
|
|
17
|
+
assert_response :success
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
test "should get update" do
|
|
21
|
+
get :update
|
|
22
|
+
assert_response :success
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
test "should get destroy" do
|
|
26
|
+
get :destroy
|
|
27
|
+
assert_response :success
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module MongoidForums
|
|
4
|
+
class ForumsControllerTest < ActionController::TestCase
|
|
5
|
+
test "should get index" do
|
|
6
|
+
get :index
|
|
7
|
+
assert_response :success
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
test "should get show" do
|
|
11
|
+
get :show
|
|
12
|
+
assert_response :success
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module MongoidForums
|
|
4
|
+
class PostsControllerTest < ActionController::TestCase
|
|
5
|
+
test "should get new" do
|
|
6
|
+
get :new
|
|
7
|
+
assert_response :success
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
test "should get create" do
|
|
11
|
+
get :create
|
|
12
|
+
assert_response :success
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test "should get show" do
|
|
16
|
+
get :show
|
|
17
|
+
assert_response :success
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
test "should get edit" do
|
|
21
|
+
get :edit
|
|
22
|
+
assert_response :success
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
test "should get update" do
|
|
26
|
+
get :update
|
|
27
|
+
assert_response :success
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
test "should get destroy" do
|
|
31
|
+
get :destroy
|
|
32
|
+
assert_response :success
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module MongoidForums
|
|
4
|
+
class TopicsControllerTest < ActionController::TestCase
|
|
5
|
+
test "should get show" do
|
|
6
|
+
get :show
|
|
7
|
+
assert_response :success
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
test "should get new" do
|
|
11
|
+
get :new
|
|
12
|
+
assert_response :success
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test "should get create" do
|
|
16
|
+
get :create
|
|
17
|
+
assert_response :success
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
test "should get update" do
|
|
21
|
+
get :update
|
|
22
|
+
assert_response :success
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
test "should get edit" do
|
|
26
|
+
get :edit
|
|
27
|
+
assert_response :success
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
test "should get destroy" do
|
|
31
|
+
get :destroy
|
|
32
|
+
assert_response :success
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
== README
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
|
4
|
+
application up and running.
|
|
5
|
+
|
|
6
|
+
Things you may want to cover:
|
|
7
|
+
|
|
8
|
+
* Ruby version
|
|
9
|
+
|
|
10
|
+
* System dependencies
|
|
11
|
+
|
|
12
|
+
* Configuration
|
|
13
|
+
|
|
14
|
+
* Database creation
|
|
15
|
+
|
|
16
|
+
* Database initialization
|
|
17
|
+
|
|
18
|
+
* How to run the test suite
|
|
19
|
+
|
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
|
21
|
+
|
|
22
|
+
* Deployment instructions
|
|
23
|
+
|
|
24
|
+
* ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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 any plugin's vendor/assets/javascripts directory 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
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
@@ -0,0 +1,15 @@
|
|
|
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 any plugin's vendor/assets/stylesheets directory 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 bottom of the
|
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
|
11
|
+
* file per style scope.
|
|
12
|
+
*
|
|
13
|
+
*= require_tree .
|
|
14
|
+
*= require_self
|
|
15
|
+
*/
|