community_engine 3.0.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +4 -1
- data/.travis.yml +5 -2
- data/CHANGELOG.markdown +270 -0
- data/Gemfile +3 -0
- data/README.markdown +20 -21
- data/Rakefile +8 -6
- data/TODO.markdown +3 -0
- data/UPGRADING.markdown +46 -36
- data/app/assets/javascripts/active_admin.js.coffee +19 -0
- data/app/assets/javascripts/ckeditor/configs/ads.js.coffee +175 -0
- data/app/assets/javascripts/ckeditor/configs/comments.js.coffee +2 -0
- data/app/assets/javascripts/ckeditor/configs/posts.js.coffee +248 -0
- data/app/assets/javascripts/ckeditor/rte/rte.ads.js.coffee +7 -0
- data/app/assets/javascripts/ckeditor/rte/rte.comments.js.coffee +8 -0
- data/app/assets/javascripts/ckeditor/rte/rte.js.coffee +20 -0
- data/app/assets/javascripts/ckeditor/rte/rte.posts.js.coffee +14 -0
- data/app/assets/javascripts/community_engine.js +114 -123
- data/{vendor → app}/assets/javascripts/jcrop/jquery.Jcrop.js +0 -0
- data/{vendor → app}/assets/javascripts/jcrop/jquery.color.js +0 -0
- data/{vendor → app}/assets/javascripts/tag-it/tag-it.js +0 -0
- data/app/assets/stylesheets/active_admin.css.scss +27 -0
- data/{vendor → app}/assets/stylesheets/jcrop/Jcrop.gif +0 -0
- data/{vendor → app}/assets/stylesheets/jcrop/jquery.Jcrop.min.css +0 -0
- data/{vendor → app}/assets/stylesheets/tag-it/tag-it.css +0 -0
- data/{vendor → app}/assets/stylesheets/tag-it/tagit.ui-zendesk.css +0 -0
- data/app/controllers/activities_controller.rb +4 -4
- data/app/controllers/albums_controller.rb +13 -18
- data/app/controllers/authorizations_controller.rb +1 -1
- data/app/controllers/base_controller.rb +9 -32
- data/app/controllers/categories_controller.rb +1 -78
- data/app/controllers/clippings_controller.rb +3 -7
- data/app/controllers/comments_controller.rb +4 -24
- data/app/controllers/events_controller.rb +3 -12
- data/app/controllers/favorites_controller.rb +2 -2
- data/app/controllers/forums_controller.rb +5 -9
- data/app/controllers/invitations_controller.rb +1 -1
- data/app/controllers/messages_controller.rb +4 -8
- data/app/controllers/moderators_controller.rb +1 -1
- data/app/controllers/monitorships_controller.rb +1 -1
- data/app/controllers/pages_controller.rb +0 -62
- data/app/controllers/password_resets_controller.rb +2 -2
- data/app/controllers/photo_manager_controller.rb +3 -3
- data/app/controllers/photos_controller.rb +43 -14
- data/app/controllers/posts_controller.rb +7 -14
- data/app/controllers/rsvps_controller.rb +3 -3
- data/app/controllers/sb_posts_controller.rb +20 -20
- data/app/controllers/sessions_controller.rb +1 -1
- data/app/controllers/tags_controller.rb +4 -52
- data/app/controllers/topics_controller.rb +15 -10
- data/app/controllers/users_controller.rb +9 -16
- data/app/controllers/votes_controller.rb +2 -2
- data/app/helpers/base_helper.rb +4 -14
- data/app/models/acts_as_taggable_on/tag.rb +9 -41
- data/app/models/clipping.rb +1 -1
- data/app/models/forum.rb +2 -2
- data/app/models/photo.rb +1 -1
- data/app/models/post.rb +1 -1
- data/app/models/sb_post.rb +19 -15
- data/app/models/topic.rb +10 -10
- data/app/models/user.rb +1 -1
- data/app/policies/active_admin/page_policy.rb +11 -0
- data/app/policies/application_policy.rb +59 -0
- data/app/policies/post_policy.rb +13 -0
- data/app/policies/sb_post_policy.rb +15 -0
- data/app/policies/topic_policy.rb +23 -0
- data/app/views/ckeditor/pictures/index.html.haml +15 -0
- data/app/views/ckeditor/shared/_asset.html.haml +9 -0
- data/app/views/ckeditor/shared/_asset_tmpl.html.erb +14 -0
- data/app/views/comments/approve.js.haml +1 -1
- data/app/views/comments/create.js.erb +1 -1
- data/app/views/comments/edit.js.erb +2 -1
- data/app/views/events/_subscribe.html.haml +1 -1
- data/app/views/forums/show.html.haml +8 -4
- data/app/views/posts/show.html.haml +4 -0
- data/app/views/sb_posts/_edit_script.js.erb +2 -3
- data/app/views/sb_posts/_reply_script.js.erb +2 -4
- data/app/views/sb_posts/_sb_post.html.haml +7 -6
- data/app/views/sb_posts/create.js.erb +4 -4
- data/app/views/sb_posts/edit.js.erb +2 -1
- data/app/views/sessions/_menu_item.html.haml +4 -4
- data/app/views/shared/_end_javascript.html.haml +1 -2
- data/app/views/shared/_login_sidebar.html.haml +2 -2
- data/app/views/tags/show.html.haml +3 -3
- data/app/views/topics/show.html.haml +1 -1
- data/app/views/users/_profile_user_info_sidebar.html.haml +2 -2
- data/app/views/users/destroy.js.erb +3 -0
- data/app/views/users/new.html.haml +1 -1
- data/app/views/users/show.html.haml +1 -1
- data/app/views/users/signup_completed.html.haml +1 -1
- data/community_engine.gemspec +14 -11
- data/config/initializers/active_admin.rb +239 -0
- data/config/initializers/ckeditor.rb +8 -0
- data/config/initializers/ransack_bootstrap_fix.rb +25 -0
- data/config/locales/de-DE.yml +1 -0
- data/config/locales/en.yml +3 -0
- data/config/routes.rb +14 -19
- data/config/spring.rb +1 -0
- data/db/migrate/083_create_active_admin_comments.rb +19 -0
- data/lib/community_engine.rb +7 -3
- data/lib/community_engine/admin/ads.rb +3 -0
- data/lib/community_engine/admin/categories.rb +20 -0
- data/lib/community_engine/admin/comments.rb +4 -0
- data/lib/community_engine/admin/dashboard.rb +38 -0
- data/lib/community_engine/admin/events.rb +3 -0
- data/lib/community_engine/admin/forums.rb +3 -0
- data/lib/community_engine/admin/homepage_features.rb +25 -0
- data/lib/community_engine/admin/metro_areas.rb +4 -0
- data/lib/community_engine/admin/pages.rb +26 -0
- data/lib/community_engine/admin/posts.rb +92 -0
- data/lib/community_engine/admin/tags.rb +21 -0
- data/lib/community_engine/admin/users.rb +54 -0
- data/lib/community_engine/authenticated_system.rb +5 -20
- data/lib/community_engine/engine.rb +5 -0
- data/lib/community_engine/version.rb +1 -1
- data/lib/resource_feeder/atom.rb +2 -0
- data/lib/resource_feeder/rss.rb +2 -0
- data/lib/white_list.rb +6 -11
- data/test/fixtures/events.yml +10 -0
- data/test/fixtures/tags.yml +6 -5
- data/test/functional/activities_controller_test.rb +19 -19
- data/test/functional/admin/posts_controller_test.rb +16 -0
- data/test/functional/admin_controller_test.rb +82 -82
- data/test/functional/categories_controller_test.rb +0 -39
- data/test/functional/comments_controller_test.rb +14 -7
- data/test/functional/favorites_controller_test.rb +15 -16
- data/test/functional/pages_controller_test.rb +0 -71
- data/test/functional/posts_controller_test.rb +21 -2
- data/test/functional/sb_posts_controller_test.rb +3 -3
- data/test/functional/sessions_controller_test.rb +2 -2
- data/test/functional/tags_controller_test.rb +9 -20
- data/test/functional/users_controller_test.rb +0 -8
- data/test/functional/votes_controller_test.rb +1 -1
- data/test/testapp/config/spring.rb +1 -0
- data/test/testapp/db/schema.rb +16 -1
- data/test/unit/event_test.rb +1 -1
- metadata +204 -170
- data/CHANGELOG +0 -144
- data/app/controllers/admin_controller.rb +0 -80
- data/app/controllers/ads_controller.rb +0 -90
- data/app/controllers/homepage_features_controller.rb +0 -74
- data/app/controllers/metro_areas_controller.rb +0 -74
- data/app/controllers/statistics_controller.rb +0 -35
- data/app/views/admin/comments.html.haml +0 -53
- data/app/views/admin/events.html.haml +0 -26
- data/app/views/admin/messages.html.haml +0 -3
- data/app/views/admin/update.js.erb +0 -1
- data/app/views/admin/users.html.haml +0 -57
- data/app/views/ads/_form.html.haml +0 -21
- data/app/views/ads/edit.html.haml +0 -7
- data/app/views/ads/index.html.haml +0 -29
- data/app/views/ads/new.html.haml +0 -6
- data/app/views/ads/show.html.haml +0 -19
- data/app/views/categories/_form.html.haml +0 -8
- data/app/views/categories/edit.html.haml +0 -4
- data/app/views/categories/index.html.haml +0 -20
- data/app/views/categories/new.html.haml +0 -4
- data/app/views/homepage_features/_form.html.haml +0 -6
- data/app/views/homepage_features/edit.html.haml +0 -6
- data/app/views/homepage_features/index.html.haml +0 -24
- data/app/views/homepage_features/new.html.haml +0 -2
- data/app/views/homepage_features/show.html.haml +0 -27
- data/app/views/metro_areas/_form.html.haml +0 -6
- data/app/views/metro_areas/edit.html.haml +0 -8
- data/app/views/metro_areas/index.html.haml +0 -21
- data/app/views/metro_areas/new.html.haml +0 -6
- data/app/views/metro_areas/show.html.haml +0 -14
- data/app/views/pages/_form.html.haml +0 -18
- data/app/views/pages/edit.html.haml +0 -4
- data/app/views/pages/index.html.haml +0 -34
- data/app/views/pages/new.html.haml +0 -7
- data/app/views/shared/_admin_nav.html.haml +0 -17
- data/app/views/shared/_load_tinymce.js.erb +0 -15
- data/app/views/statistics/activities.xml.builder +0 -33
- data/app/views/statistics/index.html.haml +0 -48
- data/app/views/tags/edit.html.haml +0 -12
- data/app/views/tags/manage.html.haml +0 -30
- data/app/views/users/update.js.erb +0 -1
- data/test/functional/ads_controller_test.rb +0 -51
- data/test/functional/homepage_features_controller_test.rb +0 -69
- data/test/functional/metro_areas_controller_test.rb +0 -63
- data/test/functional/statistics_controller_test.rb +0 -18
- data/test/unit/acts_as_taggable_on/tag_test.rb +0 -22
- data/vendor/converted2.3plugins_to_lib_leftovers/acts_as_publishable/README +0 -3
- data/vendor/converted2.3plugins_to_lib_leftovers/acts_as_publishable/Rakefile +0 -22
- data/vendor/converted2.3plugins_to_lib_leftovers/acts_as_publishable/generators/publishing/publishing_generator.rb +0 -34
- data/vendor/converted2.3plugins_to_lib_leftovers/acts_as_publishable/generators/publishing/templates/migration.rb +0 -13
- data/vendor/converted2.3plugins_to_lib_leftovers/acts_as_publishable/install.rb +0 -3
- data/vendor/converted2.3plugins_to_lib_leftovers/acts_as_publishable/test/acts_as_publishable_test.rb +0 -8
- data/vendor/converted2.3plugins_to_lib_leftovers/acts_as_publishable/uninstall.rb +0 -1
- data/vendor/converted2.3plugins_to_lib_leftovers/resource_feeder/README +0 -4
- data/vendor/converted2.3plugins_to_lib_leftovers/resource_feeder/Rakefile +0 -22
- data/vendor/converted2.3plugins_to_lib_leftovers/resource_feeder/test/atom_feed_test.rb +0 -85
- data/vendor/converted2.3plugins_to_lib_leftovers/resource_feeder/test/rss_feed_test.rb +0 -61
- data/vendor/converted2.3plugins_to_lib_leftovers/resource_feeder/test/test_helper.rb +0 -60
- data/vendor/converted2.3plugins_to_lib_leftovers/white_list/README +0 -35
- data/vendor/converted2.3plugins_to_lib_leftovers/white_list/Rakefile +0 -22
- data/vendor/converted2.3plugins_to_lib_leftovers/white_list/test/white_list_test.rb +0 -120
@@ -1,5 +1,5 @@
|
|
1
1
|
class AuthorizationsController < BaseController
|
2
|
-
|
2
|
+
before_action :login_required, :only => [:destroy]
|
3
3
|
|
4
4
|
def create
|
5
5
|
omniauth = request.env['omniauth.auth'] #this is where you get all the data from your provider through omniauth
|
@@ -3,19 +3,21 @@ require 'open-uri'
|
|
3
3
|
require 'pp'
|
4
4
|
|
5
5
|
class BaseController < ApplicationController
|
6
|
-
|
7
6
|
include AuthenticatedSystem
|
7
|
+
include Pundit
|
8
8
|
include LocalizedApplication
|
9
9
|
include BaseHelper
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
around_action :set_locale
|
12
|
+
skip_before_action :verify_authenticity_token, :only => :footer_content
|
13
|
+
before_action :initialize_header_tabs
|
14
|
+
|
15
|
+
before_action :store_location, :except => :footer_content
|
16
16
|
|
17
17
|
caches_action :site_index, :footer_content, :if => Proc.new{|c| c.cache_action? }
|
18
18
|
|
19
|
+
rescue_from Pundit::NotAuthorizedError, with: :access_denied
|
20
|
+
|
19
21
|
def cache_action?
|
20
22
|
!logged_in? && controller_name.eql?('base') && params[:format].blank?
|
21
23
|
end
|
@@ -60,28 +62,8 @@ class BaseController < ApplicationController
|
|
60
62
|
def advertise
|
61
63
|
end
|
62
64
|
|
63
|
-
protected
|
64
|
-
def self.uses_tiny_mce(options = {}, &block)
|
65
|
-
if block_given?
|
66
|
-
options = block.call
|
67
|
-
end
|
68
|
-
|
69
|
-
new_configuration = TinyMCE::Rails.configuration.merge(options.delete(:options)).options
|
70
|
-
new_configuration.stringify_keys!
|
71
|
-
|
72
|
-
# Set instance vars in the current class
|
73
|
-
p = Proc.new do |c|
|
74
|
-
configuration = c.instance_variable_get(:@tiny_mce_configuration) || {}
|
75
|
-
|
76
|
-
c.instance_variable_set(:@tiny_mce_configuration, configuration.merge(new_configuration))
|
77
|
-
c.instance_variable_set(:@uses_tiny_mce, true)
|
78
|
-
end
|
79
|
-
|
80
|
-
before_filter p, options
|
81
|
-
end
|
82
|
-
|
83
|
-
|
84
65
|
private
|
66
|
+
|
85
67
|
def admin_required
|
86
68
|
current_user && current_user.admin? ? true : access_denied
|
87
69
|
end
|
@@ -147,10 +129,5 @@ class BaseController < ApplicationController
|
|
147
129
|
# Usage: @header_tabs << {:name => "My tab", :url => my_tab_path, :section => 'my_tab_section' }
|
148
130
|
@header_tabs = []
|
149
131
|
end
|
150
|
-
def initialize_admin_tabs
|
151
|
-
# This hook allows plugins or host apps to easily add tabs to the admin nav by adding to the @admin_nav_links array
|
152
|
-
# Usage: @admin_nav_links << {:name => "My link", :url => my_link_path, }
|
153
|
-
@admin_nav_links = []
|
154
|
-
end
|
155
132
|
|
156
133
|
end
|
@@ -1,19 +1,6 @@
|
|
1
1
|
class CategoriesController < BaseController
|
2
|
-
|
3
|
-
before_filter :admin_required, :only => [:new, :edit, :update, :create, :destroy, :index]
|
2
|
+
before_action :login_required, :except => [:show, :most_viewed, :rss]
|
4
3
|
|
5
|
-
cache_sweeper :category_sweeper, :only => [:create, :update, :destroy]
|
6
|
-
|
7
|
-
# GET /categories
|
8
|
-
# GET /categories.xml
|
9
|
-
def index
|
10
|
-
@categories = Category.all
|
11
|
-
|
12
|
-
respond_to do |format|
|
13
|
-
format.html # index.rhtml
|
14
|
-
format.xml { render :xml => @categories.to_xml }
|
15
|
-
end
|
16
|
-
end
|
17
4
|
|
18
5
|
# GET /categories/1
|
19
6
|
# GET /categories/1.xml
|
@@ -44,64 +31,6 @@ class CategoriesController < BaseController
|
|
44
31
|
end
|
45
32
|
end
|
46
33
|
|
47
|
-
# GET /categories/new
|
48
|
-
def new
|
49
|
-
@category = Category.new
|
50
|
-
end
|
51
|
-
|
52
|
-
# GET /categories/1;edit
|
53
|
-
def edit
|
54
|
-
@category = Category.find(params[:id])
|
55
|
-
end
|
56
|
-
|
57
|
-
# POST /categories
|
58
|
-
# POST /categories.xml
|
59
|
-
def create
|
60
|
-
@category = Category.new(category_params)
|
61
|
-
|
62
|
-
respond_to do |format|
|
63
|
-
if @category.save
|
64
|
-
flash[:notice] = :category_was_successfully_created.l
|
65
|
-
|
66
|
-
format.html { redirect_to category_url(@category) }
|
67
|
-
format.xml do
|
68
|
-
headers["Location"] = category_url(@category)
|
69
|
-
render :nothing => true, :status => "201 Created"
|
70
|
-
end
|
71
|
-
else
|
72
|
-
format.html { render :action => "new" }
|
73
|
-
format.xml { render :xml => @category.errors.to_xml }
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
# patch /categories/1
|
79
|
-
# patch /categories/1.xml
|
80
|
-
def update
|
81
|
-
@category = Category.find(params[:id])
|
82
|
-
|
83
|
-
respond_to do |format|
|
84
|
-
if @category.update_attributes(category_params)
|
85
|
-
format.html { redirect_to category_url(@category) }
|
86
|
-
format.xml { render :nothing => true }
|
87
|
-
else
|
88
|
-
format.html { render :action => "edit" }
|
89
|
-
format.xml { render :xml => @category.errors.to_xml }
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# DELETE /categories/1
|
95
|
-
# DELETE /categories/1.xml
|
96
|
-
def destroy
|
97
|
-
@category = Category.find(params[:id])
|
98
|
-
@category.destroy
|
99
|
-
|
100
|
-
respond_to do |format|
|
101
|
-
format.html { redirect_to categories_url }
|
102
|
-
format.xml { render :nothing => true }
|
103
|
-
end
|
104
|
-
end
|
105
34
|
|
106
35
|
def show_tips
|
107
36
|
@category = Category.find(params[:id] )
|
@@ -111,10 +40,4 @@ class CategoriesController < BaseController
|
|
111
40
|
end
|
112
41
|
|
113
42
|
|
114
|
-
private
|
115
|
-
|
116
|
-
def category_params
|
117
|
-
params[:category].permit(:name, :tips, :new_post_text, :nav_text)
|
118
|
-
end
|
119
|
-
|
120
43
|
end
|
@@ -1,11 +1,7 @@
|
|
1
1
|
class ClippingsController < BaseController
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
uses_tiny_mce do
|
7
|
-
{:only => [:show,:new_clipping], :options => configatron.default_mce_options}
|
8
|
-
end
|
2
|
+
before_action :login_required, :only => [:new, :edit, :update, :create, :destroy, :new_clipping]
|
3
|
+
before_action :find_user, :only => [:new, :edit, :index, :show]
|
4
|
+
before_action :require_current_user, :only => [:new, :edit, :update, :destroy]
|
9
5
|
|
10
6
|
cache_sweeper :taggable_sweeper, :only => [:create, :update, :destroy]
|
11
7
|
|
@@ -1,14 +1,10 @@
|
|
1
1
|
class CommentsController < BaseController
|
2
|
-
|
3
|
-
|
2
|
+
before_action :login_required, :except => [:index, :unsubscribe]
|
3
|
+
before_action :admin_or_moderator_required, :only => [:delete_selected, :edit, :update, :approve, :disapprove]
|
4
4
|
|
5
5
|
if configatron.allow_anonymous_commenting
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
uses_tiny_mce do
|
11
|
-
{:only => [:index, :edit, :update], :options => configatron.simple_mce_options}
|
6
|
+
skip_before_action :verify_authenticity_token, :only => [:create] #because the auth token might be cached anyway
|
7
|
+
skip_before_action :login_required, :only => [:create]
|
12
8
|
end
|
13
9
|
|
14
10
|
cache_sweeper :comment_sweeper, :only => [:create, :destroy]
|
@@ -141,22 +137,6 @@ class CommentsController < BaseController
|
|
141
137
|
end
|
142
138
|
end
|
143
139
|
|
144
|
-
def delete_selected
|
145
|
-
if request.delete?
|
146
|
-
if params[:delete]
|
147
|
-
params[:delete].each { |id|
|
148
|
-
comment = Comment.find(id)
|
149
|
-
comment.spam! if params[:spam] && configatron.has_key?(:akismet_key)
|
150
|
-
comment.destroy if comment.can_be_deleted_by(current_user)
|
151
|
-
}
|
152
|
-
end
|
153
|
-
flash[:notice] = :comments_deleted.l
|
154
|
-
else
|
155
|
-
flash[:error] = :comments_not_deleted.l
|
156
|
-
end
|
157
|
-
redirect_to admin_comments_path
|
158
|
-
end
|
159
|
-
|
160
140
|
|
161
141
|
def unsubscribe
|
162
142
|
@comment = Comment.find(params[:id])
|
@@ -4,16 +4,7 @@ class EventsController < BaseController
|
|
4
4
|
caches_page :ical
|
5
5
|
cache_sweeper :event_sweeper, :only => [:create, :update, :destroy]
|
6
6
|
|
7
|
-
|
8
|
-
uses_tiny_mce do
|
9
|
-
{:only => [:new, :edit, :create, :update, :clone ], :options => configatron.default_mce_options}
|
10
|
-
end
|
11
|
-
|
12
|
-
uses_tiny_mce do
|
13
|
-
{:only => [:show], :options => configatron.simple_mce_options}
|
14
|
-
end
|
15
|
-
|
16
|
-
before_filter :admin_required, :except => [:index, :show, :ical]
|
7
|
+
before_action :admin_required, :except => [:index, :show, :ical]
|
17
8
|
|
18
9
|
def ical
|
19
10
|
@calendar = RiCal.Calendar
|
@@ -25,7 +16,7 @@ class EventsController < BaseController
|
|
25
16
|
event.dtend = ce_event.end_time
|
26
17
|
event.summary = ce_event.name + (ce_event.metro_area.blank? ? '' : " (#{ce_event.metro_area})")
|
27
18
|
coder = HTMLEntities.new
|
28
|
-
event.description = (ce_event.description.blank? ? '' : coder.decode(
|
19
|
+
event.description = (ce_event.description.blank? ? '' : coder.decode(view_context.strip_tags(ce_event.description).to_s) + "\n\n") + event_url(ce_event)
|
29
20
|
event.location = ce_event.location unless ce_event.location.blank?
|
30
21
|
end
|
31
22
|
@calendar.add_subcomponent rical_event
|
@@ -146,7 +137,7 @@ class EventsController < BaseController
|
|
146
137
|
elsif object.is_a? User
|
147
138
|
states = object.country.states if object.country
|
148
139
|
if object.state
|
149
|
-
metro_areas = object.state.metro_areas
|
140
|
+
metro_areas = object.state.metro_areas.order("name")
|
150
141
|
else
|
151
142
|
metro_areas = object.country.metro_areas.order("name")
|
152
143
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class FavoritesController < BaseController
|
2
|
-
|
3
|
-
|
2
|
+
before_action :login_required, :only => [:destroy]
|
3
|
+
before_action :find_user, :only => [:show, :index]
|
4
4
|
|
5
5
|
cache_sweeper :favorite_sweeper, :only => [:create, :destroy]
|
6
6
|
|
@@ -1,10 +1,6 @@
|
|
1
1
|
class ForumsController < BaseController
|
2
2
|
before_action :admin_required, :except => [:index, :show]
|
3
3
|
|
4
|
-
uses_tiny_mce do
|
5
|
-
{:options => configatron.default_mce_options}
|
6
|
-
end
|
7
|
-
|
8
4
|
def index
|
9
5
|
@forums = Forum.order("position")
|
10
6
|
respond_to do |format|
|
@@ -22,7 +18,7 @@ class ForumsController < BaseController
|
|
22
18
|
|
23
19
|
@topics = @forum.topics.includes(:replied_by_user).order('sticky DESC, replied_at DESC').page(params[:page]).per(20)
|
24
20
|
end
|
25
|
-
|
21
|
+
|
26
22
|
format.xml do
|
27
23
|
render :xml => @forum
|
28
24
|
end
|
@@ -32,7 +28,7 @@ class ForumsController < BaseController
|
|
32
28
|
def new
|
33
29
|
@forum = Forum.new
|
34
30
|
end
|
35
|
-
|
31
|
+
|
36
32
|
def create
|
37
33
|
@forum = Forum.new(forum_params)
|
38
34
|
@forum.tag_list = params[:tag_list] || ''
|
@@ -56,7 +52,7 @@ class ForumsController < BaseController
|
|
56
52
|
format.xml { head 200 }
|
57
53
|
end
|
58
54
|
end
|
59
|
-
|
55
|
+
|
60
56
|
def destroy
|
61
57
|
@forum = Forum.find(params[:id])
|
62
58
|
@forum.destroy
|
@@ -65,11 +61,11 @@ class ForumsController < BaseController
|
|
65
61
|
format.xml { head 200 }
|
66
62
|
end
|
67
63
|
end
|
68
|
-
|
64
|
+
|
69
65
|
private
|
70
66
|
|
71
67
|
def forum_params
|
72
68
|
params[:forum].permit(:name, :position, :description)
|
73
69
|
end
|
74
|
-
|
70
|
+
|
75
71
|
end
|
@@ -1,13 +1,9 @@
|
|
1
1
|
class MessagesController < BaseController
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
before_action :find_user
|
3
|
+
before_action :login_required
|
4
|
+
before_action :require_ownership_or_moderator, :except => [:auto_complete_for_username]
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
uses_tiny_mce do
|
9
|
-
{:options => configatron.default_mce_options}
|
10
|
-
end
|
6
|
+
skip_before_action :verify_authenticity_token, :only => [:auto_complete_for_username]
|
11
7
|
|
12
8
|
def auto_complete_for_username
|
13
9
|
@usernames = User.active.where.not(login: @user.login).pluck(:login)
|
@@ -1,27 +1,11 @@
|
|
1
1
|
class PagesController < BaseController
|
2
|
-
uses_tiny_mce do
|
3
|
-
{:only => [:new, :edit, :update, :create ], :options => configatron.default_mce_options}
|
4
|
-
end
|
5
2
|
|
6
|
-
cache_sweeper :page_sweeper, :only => [:create, :update, :destroy]
|
7
3
|
caches_action :show, :if => Proc.new{|c| c.cache_action? }
|
8
4
|
|
9
5
|
def cache_action?
|
10
6
|
!logged_in? && controller_name.eql?('pages')
|
11
7
|
end
|
12
8
|
|
13
|
-
before_filter :login_required, :only => [:index, :new, :edit, :update, :destroy, :create, :preview]
|
14
|
-
before_filter :require_moderator, :only => [:index, :new, :edit, :update, :destroy, :create, :preview]
|
15
|
-
|
16
|
-
def index
|
17
|
-
@pages = Page.unscoped.order('created_at DESC').page(params[:page])
|
18
|
-
end
|
19
|
-
|
20
|
-
def preview
|
21
|
-
@page = Page.unscoped.find(params[:id])
|
22
|
-
render :action => :show
|
23
|
-
end
|
24
|
-
|
25
9
|
def show
|
26
10
|
@page = Page.live.find(params[:id])
|
27
11
|
unless logged_in? || @page.page_public
|
@@ -32,51 +16,5 @@ class PagesController < BaseController
|
|
32
16
|
flash[:error] = :page_not_found.l
|
33
17
|
redirect_to home_path
|
34
18
|
end
|
35
|
-
|
36
|
-
def new
|
37
|
-
@page = Page.new
|
38
|
-
end
|
39
|
-
|
40
|
-
def edit
|
41
|
-
@page = Page.unscoped.find(params[:id])
|
42
|
-
end
|
43
|
-
|
44
|
-
def create
|
45
|
-
@page = Page.new(page_params)
|
46
|
-
if @page.save
|
47
|
-
flash[:notice] = :page_was_successfully_created.l
|
48
|
-
redirect_to admin_pages_path
|
49
|
-
else
|
50
|
-
render :action => :new
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def update
|
55
|
-
if @page.update_attributes(page_params)
|
56
|
-
flash[:notice] = :page_was_successfully_updated.l
|
57
|
-
redirect_to admin_pages_path
|
58
|
-
else
|
59
|
-
render :action => :edit
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def destroy
|
64
|
-
@page.destroy
|
65
|
-
flash[:notice] = :page_was_successfully_deleted.l
|
66
|
-
redirect_to admin_pages_path
|
67
|
-
end
|
68
|
-
|
69
|
-
private
|
70
|
-
|
71
|
-
def require_moderator
|
72
|
-
@page ||= Page.unscoped.find(params[:id]) if params[:id]
|
73
|
-
unless admin? || moderator?
|
74
|
-
redirect_to :controller => 'sessions', :action => 'new' and return false
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def page_params
|
79
|
-
params.require(:page).permit(:title, :body, :published_as, :page_public)
|
80
|
-
end
|
81
19
|
|
82
20
|
end
|