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,6 +1,6 @@
|
|
1
1
|
class PasswordResetsController < BaseController
|
2
|
-
|
3
|
-
|
2
|
+
before_action :require_no_user
|
3
|
+
before_action :load_user_using_perishable_token, :only => [ :edit, :update ]
|
4
4
|
|
5
5
|
def new
|
6
6
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
class PhotoManagerController < BaseController
|
2
2
|
include Viewable
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
before_action :login_required
|
4
|
+
before_action :find_user
|
5
|
+
before_action :require_current_user
|
6
6
|
|
7
7
|
def index
|
8
8
|
@albums = current_user.albums.order('id DESC').page(params[:page_albums])
|
@@ -2,15 +2,11 @@ require 'pp'
|
|
2
2
|
|
3
3
|
class PhotosController < BaseController
|
4
4
|
include Viewable
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
before_action :login_required, :only => [:new, :edit, :update, :destroy, :create, :swfupload]
|
6
|
+
before_action :find_user, :only => [:new, :edit, :index, :show]
|
7
|
+
before_action :require_current_user, :only => [:new, :edit, :update, :destroy]
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
uses_tiny_mce do
|
12
|
-
{:only => [:show], :options => configatron.simple_mce_options}
|
13
|
-
end
|
9
|
+
skip_before_action :verify_authenticity_token, :only => [:create]
|
14
10
|
|
15
11
|
cache_sweeper :taggable_sweeper, :only => [:create, :update, :destroy]
|
16
12
|
|
@@ -51,18 +47,51 @@ class PhotosController < BaseController
|
|
51
47
|
def manage_photos
|
52
48
|
if logged_in?
|
53
49
|
@user = current_user
|
54
|
-
@
|
55
|
-
if params[:tag_name]
|
56
|
-
@photos = @photos.where('tags.name = ?', params[:tag_name])
|
57
|
-
end
|
58
|
-
@selected = params[:photo_id]
|
59
|
-
@photos = @photos.page(params[:page]).per(10)
|
50
|
+
@pictures = current_user.photos.recent.includes(:tags).page(params[:page]).per(10)
|
60
51
|
end
|
61
52
|
respond_to do |format|
|
53
|
+
format.html {
|
54
|
+
render :template => 'ckeditor/pictures/index', :layout => 'ckeditor/application'
|
55
|
+
}
|
62
56
|
format.js
|
63
57
|
end
|
64
58
|
end
|
65
59
|
|
60
|
+
def create_photos
|
61
|
+
@photo = current_user.photos.new
|
62
|
+
file = params[:qqfile] ||params[:upload]
|
63
|
+
@photo.photo = Ckeditor::Http.normalize_param(file, request)
|
64
|
+
callback = ckeditor_before_create_asset(@photo)
|
65
|
+
|
66
|
+
if callback && @photo.save
|
67
|
+
hash = {
|
68
|
+
:id => @photo.id,
|
69
|
+
:type => 'ckeditor::picture',
|
70
|
+
:url_content => @photo.photo.url,
|
71
|
+
:url_thumb => @photo.photo.url(:thumb),
|
72
|
+
:filename => @photo.photo_file_name,
|
73
|
+
:format_created_at => @photo.created_at,
|
74
|
+
:size => @photo.photo_file_size
|
75
|
+
}
|
76
|
+
|
77
|
+
body = params[:CKEditor].blank? ? hash.to_json : %Q"<script type='text/javascript'>
|
78
|
+
window.parent.CKEDITOR.tools.callFunction(#{params[:CKEditorFuncNum]}, '#{config.relative_url_root}#{Ckeditor::Utils.escape_single_quotes(@photo.photo.url)}');
|
79
|
+
</script>"
|
80
|
+
|
81
|
+
render :text => body
|
82
|
+
|
83
|
+
else
|
84
|
+
if params[:CKEditor].blank?
|
85
|
+
render :nothing => true, :format => :json
|
86
|
+
else
|
87
|
+
render :text => %Q"<script type='text/javascript'>
|
88
|
+
window.parent.CKEDITOR.tools.callFunction(#{params[:CKEditorFuncNum]}, null, '#{Ckeditor::Utils.escape_single_quotes(@photo.errors.full_messages.first)}');
|
89
|
+
</script>"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
66
95
|
# GET /photos/1
|
67
96
|
# GET /photos/1.xml
|
68
97
|
def show
|
@@ -1,23 +1,15 @@
|
|
1
1
|
class PostsController < BaseController
|
2
2
|
include Viewable
|
3
3
|
|
4
|
-
uses_tiny_mce do
|
5
|
-
{:only => [:new, :edit, :update, :create ], :options => configatron.default_mce_options}
|
6
|
-
end
|
7
|
-
|
8
|
-
uses_tiny_mce do
|
9
|
-
{:only => [:show], :options => configatron.simple_mce_options}
|
10
|
-
end
|
11
|
-
|
12
4
|
cache_sweeper :post_sweeper, :only => [:create, :update, :destroy]
|
13
5
|
cache_sweeper :taggable_sweeper, :only => [:create, :update, :destroy]
|
14
6
|
caches_action :show, :if => Proc.new{|c| !logged_in? }
|
15
7
|
|
16
|
-
|
17
|
-
|
18
|
-
|
8
|
+
before_action :login_required, :only => [:new, :edit, :update, :destroy, :create, :manage, :preview]
|
9
|
+
before_action :find_user, :only => [:new, :edit, :index, :show, :update_views, :manage, :preview]
|
10
|
+
before_action :require_ownership_or_moderator, :only => [:edit, :update, :destroy, :create, :manage, :new]
|
19
11
|
|
20
|
-
|
12
|
+
skip_before_action :verify_authenticity_token, :only => [:update_views, :send_to_friend] #called from ajax on cached pages
|
21
13
|
|
22
14
|
def manage
|
23
15
|
Post.unscoped do
|
@@ -58,11 +50,12 @@ class PostsController < BaseController
|
|
58
50
|
# GET /posts/1
|
59
51
|
# GET /posts/1.xml
|
60
52
|
def show
|
53
|
+
@post = Post.unscoped.find(params[:id])
|
54
|
+
redirect_to user_posts_path(@user), :alert => :post_not_published_yet.l and return false unless @post.is_live? || @post.user.eql?(current_user) || admin? || moderator?
|
55
|
+
|
61
56
|
@rss_title = "#{configatron.community_name}: #{@user.login}'s posts"
|
62
57
|
@rss_url = user_posts_path(@user,:format => :rss)
|
63
58
|
|
64
|
-
@post = Post.unscoped.find(params[:id])
|
65
|
-
|
66
59
|
@user = @post.user
|
67
60
|
@is_current_user = @user.eql?(current_user)
|
68
61
|
@comment = Comment.new
|
@@ -1,8 +1,8 @@
|
|
1
1
|
class RsvpsController < BaseController
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
before_action :login_required, :only => [:new, :edit, :update, :destroy, :create]
|
4
|
+
before_action :find_event
|
5
|
+
before_action :require_ownership_or_moderator, :only => [:edit, :update, :destroy]
|
6
6
|
|
7
7
|
def find_event
|
8
8
|
@event = Event.find(params[:event_id])
|
@@ -1,20 +1,17 @@
|
|
1
1
|
class SbPostsController < BaseController
|
2
|
-
|
3
|
-
|
2
|
+
before_action :find_post, :except => [:index, :monitored, :search, :new, :create]
|
3
|
+
before_action :login_required, :except => [:index, :search, :show, :monitored, :create]
|
4
4
|
|
5
|
-
|
5
|
+
before_action :only => [:create] do |controller|
|
6
6
|
login_required unless configatron.allow_anonymous_forum_posting
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
skip_before_action :verify_authenticity_token, :only => [:create] #remove for the create action
|
10
|
+
before_action do |controller|
|
11
11
|
#add it back unless anonymous posting is allowed
|
12
12
|
verify_authenticity_token if controller.action_name.eql?('create') && !configatron.allow_anonymous_forum_posting
|
13
13
|
end
|
14
14
|
|
15
|
-
uses_tiny_mce do
|
16
|
-
{:only => [:edit, :update], :options => configatron.default_mce_options}
|
17
|
-
end
|
18
15
|
|
19
16
|
|
20
17
|
def index
|
@@ -92,6 +89,8 @@ class SbPostsController < BaseController
|
|
92
89
|
end
|
93
90
|
|
94
91
|
def edit
|
92
|
+
authorize @post
|
93
|
+
|
95
94
|
respond_to do |format|
|
96
95
|
format.html
|
97
96
|
format.js
|
@@ -99,10 +98,13 @@ class SbPostsController < BaseController
|
|
99
98
|
end
|
100
99
|
|
101
100
|
def update
|
102
|
-
@post
|
103
|
-
|
104
|
-
|
105
|
-
|
101
|
+
authorize @post
|
102
|
+
@post.update_attributes(sb_post_params)
|
103
|
+
|
104
|
+
unless @post.valid?
|
105
|
+
flash[:bad_reply] = :an_error_occurred.l
|
106
|
+
end
|
107
|
+
|
106
108
|
respond_to do |format|
|
107
109
|
format.html do
|
108
110
|
redirect_to forum_topic_path(:forum_id => params[:forum_id], :id => params[:topic_id], :anchor => @post.dom_id, :page => params[:page] || '1')
|
@@ -110,9 +112,12 @@ class SbPostsController < BaseController
|
|
110
112
|
format.js
|
111
113
|
format.xml { head 200 }
|
112
114
|
end
|
115
|
+
|
113
116
|
end
|
114
117
|
|
115
118
|
def destroy
|
119
|
+
authorize @post
|
120
|
+
|
116
121
|
@post.destroy
|
117
122
|
flash[:notice] = :sb_post_was_deleted.l_with_args(:title => CGI::escapeHTML(@post.topic.title))
|
118
123
|
# check for posts_count == 1 because its cached and counting the currently deleted post
|
@@ -127,16 +132,11 @@ class SbPostsController < BaseController
|
|
127
132
|
end
|
128
133
|
|
129
134
|
protected
|
130
|
-
#overide in your app
|
131
|
-
def authorized?
|
132
|
-
%w(create new).include?(action_name) || @post.editable_by?(current_user)
|
133
|
-
end
|
134
|
-
|
135
135
|
def find_post
|
136
136
|
@post = SbPost.find_by_id_and_topic_id_and_forum_id(params[:id].to_i, params[:topic_id].to_i, params[:forum_id].to_i) || raise(ActiveRecord::RecordNotFound)
|
137
137
|
end
|
138
138
|
|
139
|
-
|
140
|
-
|
141
|
-
|
139
|
+
def sb_post_params
|
140
|
+
params[:sb_post].permit(:body, :author_email, :author_ip, :author_name, :author_url)
|
141
|
+
end
|
142
142
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# This controller handles the login/logout function of the site.
|
2
2
|
class SessionsController < BaseController
|
3
3
|
|
4
|
-
|
4
|
+
skip_before_action :store_location, :only => [:new, :create]
|
5
5
|
|
6
6
|
def index
|
7
7
|
redirect_to :action => "new"
|
@@ -1,7 +1,5 @@
|
|
1
1
|
class TagsController < BaseController
|
2
|
-
|
3
|
-
before_filter :admin_required, :only => [:manage, :edit, :update, :destroy]
|
4
|
-
skip_before_filter :verify_authenticity_token, :only => [:auto_complete_for_tag_name]
|
2
|
+
skip_before_action :verify_authenticity_token, :only => [:auto_complete_for_tag_name]
|
5
3
|
|
6
4
|
caches_action :show, :cache_path => Proc.new { |controller| controller.send(:tag_url, controller.params[:id]) }, :if => Proc.new{|c| c.cache_action? }
|
7
5
|
def cache_action?
|
@@ -16,60 +14,14 @@ class TagsController < BaseController
|
|
16
14
|
end
|
17
15
|
|
18
16
|
def index
|
19
|
-
@tags = popular_tags(100)
|
20
|
-
|
21
|
-
@user_tags = popular_tags(75, 'User').to_a
|
22
|
-
|
23
|
-
@post_tags = popular_tags(75, 'Post').to_a
|
24
|
-
|
25
|
-
@photo_tags = popular_tags(75, 'Photo').to_a
|
26
|
-
|
27
|
-
@clipping_tags = popular_tags(75, 'Clipping').to_a
|
28
|
-
end
|
29
|
-
|
30
|
-
def manage
|
31
|
-
@search = ActsAsTaggableOn::Tag.search(params[:q])
|
32
|
-
@tags = @search.result
|
33
|
-
@tags = @tags.order('name ASC').distinct.page(params[:page]).per(100)
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
def edit
|
38
|
-
@tag = ActsAsTaggableOn::Tag.find_by_name(URI::decode(params[:id]))
|
39
|
-
end
|
40
|
-
|
41
|
-
def update
|
42
|
-
@tag = ActsAsTaggableOn::Tag.find_by_name(URI::decode(params[:id]))
|
43
|
-
|
44
|
-
respond_to do |format|
|
45
|
-
if @tag.update_attributes(params[:tag])
|
46
|
-
flash[:notice] = :tag_was_successfully_updated.l
|
47
|
-
format.html { redirect_to admin_tags_url }
|
48
|
-
format.xml { render :nothing => true }
|
49
|
-
else
|
50
|
-
format.html { render :action => "edit" }
|
51
|
-
format.xml { render :xml => @tag.errors.to_xml }
|
52
|
-
end
|
53
|
-
end
|
17
|
+
@tags = popular_tags(100)
|
54
18
|
end
|
55
19
|
|
56
|
-
def destroy
|
57
|
-
@tag = ActsAsTaggableOn::Tag.find_by_name(URI::decode(params[:id]))
|
58
|
-
@tag.destroy
|
59
|
-
|
60
|
-
respond_to do |format|
|
61
|
-
format.html {
|
62
|
-
flash[:notice] = :tag_was_successfully_deleted.l
|
63
|
-
redirect_to admin_tags_url
|
64
|
-
}
|
65
|
-
format.xml { render :nothing => true }
|
66
|
-
end
|
67
|
-
end
|
68
20
|
|
69
21
|
def show
|
70
|
-
tag_array = ActsAsTaggableOn::
|
22
|
+
tag_array = ActsAsTaggableOn::DefaultParser.new( URI::decode(params[:id]) ).parse
|
71
23
|
|
72
|
-
@tags = ActsAsTaggableOn::Tag.where('name IN (?)', tag_array)
|
24
|
+
@tags = ActsAsTaggableOn::Tag.where('name IN (?)', tag_array )
|
73
25
|
if @tags.nil? || @tags.empty?
|
74
26
|
flash[:notice] = :tag_does_not_exists.l_with_args(:tag => tag_array)
|
75
27
|
redirect_to :action => :index and return
|
@@ -1,10 +1,8 @@
|
|
1
1
|
class TopicsController < BaseController
|
2
|
-
|
3
|
-
|
2
|
+
before_action :find_forum_and_topic, :except => :index
|
3
|
+
before_action :login_required, :except => [:index, :show]
|
4
|
+
after_action :verify_authorized, :except => [:index, :show]
|
4
5
|
|
5
|
-
uses_tiny_mce do
|
6
|
-
{:only => [:show, :new, :create, :update], :options => configatron.default_mce_options}
|
7
|
-
end
|
8
6
|
|
9
7
|
def index
|
10
8
|
@forum = Forum.find(params[:forum_id])
|
@@ -20,6 +18,7 @@ class TopicsController < BaseController
|
|
20
18
|
def new
|
21
19
|
@topic = Topic.new
|
22
20
|
@topic.sb_posts.build
|
21
|
+
authorize @topic
|
23
22
|
end
|
24
23
|
|
25
24
|
def show
|
@@ -49,6 +48,8 @@ class TopicsController < BaseController
|
|
49
48
|
|
50
49
|
def create
|
51
50
|
@topic = @forum.topics.new(topic_params)
|
51
|
+
authorize @topic
|
52
|
+
|
52
53
|
assign_protected
|
53
54
|
|
54
55
|
@post = @topic.sb_posts.first
|
@@ -76,8 +77,14 @@ class TopicsController < BaseController
|
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
80
|
+
def edit
|
81
|
+
authorize @topic
|
82
|
+
end
|
83
|
+
|
79
84
|
def update
|
80
85
|
assign_protected
|
86
|
+
|
87
|
+
authorize @topic
|
81
88
|
@topic.tag_list = params[:tag_list] || ''
|
82
89
|
@topic.update_attributes!(topic_params)
|
83
90
|
respond_to do |format|
|
@@ -87,6 +94,8 @@ class TopicsController < BaseController
|
|
87
94
|
end
|
88
95
|
|
89
96
|
def destroy
|
97
|
+
authorize @topic
|
98
|
+
|
90
99
|
@topic.destroy
|
91
100
|
flash[:notice] = :topic_deleted.l_with_args(:topic => CGI::escapeHTML(@topic.title))
|
92
101
|
respond_to do |format|
|
@@ -114,12 +123,8 @@ class TopicsController < BaseController
|
|
114
123
|
@topic = @forum.topics.find(params[:id]) if params[:id]
|
115
124
|
end
|
116
125
|
|
117
|
-
#overide in your app
|
118
|
-
def authorized?
|
119
|
-
%w(new create).include?(action_name) || @topic.editable_by?(current_user)
|
120
|
-
end
|
121
126
|
|
122
127
|
def topic_params
|
123
|
-
params[:topic].permit(:title, :sticky, :locked, {:sb_posts_attributes => [:body]}, :forum_id)
|
128
|
+
params[:topic].permit(:tag_list, :title, :sticky, :locked, {:sb_posts_attributes => [:body]}, :forum_id)
|
124
129
|
end
|
125
130
|
end
|
@@ -2,27 +2,18 @@ class UsersController < BaseController
|
|
2
2
|
include Viewable
|
3
3
|
cache_sweeper :taggable_sweeper, :only => [:activate, :update, :destroy]
|
4
4
|
|
5
|
-
|
6
|
-
{:only => [:new, :create, :update, :edit, :welcome_about], :options => configatron.default_mce_options}
|
7
|
-
end
|
8
|
-
|
9
|
-
uses_tiny_mce do
|
10
|
-
{:only => [:show], :options => configatron.simple_mce_options}
|
11
|
-
end
|
12
|
-
|
13
|
-
# Filters
|
14
|
-
before_filter :login_required, :only => [:edit, :edit_account, :update, :welcome_photo, :welcome_about,
|
5
|
+
before_action :login_required, :only => [:edit, :edit_account, :update, :welcome_photo, :welcome_about,
|
15
6
|
:welcome_invite, :return_admin, :assume, :featured,
|
16
7
|
:toggle_featured, :edit_pro_details, :update_pro_details, :dashboard, :deactivate,
|
17
8
|
:crop_profile_photo, :upload_profile_photo]
|
18
|
-
|
9
|
+
before_action :find_user, :only => [:edit, :edit_pro_details, :show, :update, :statistics, :deactivate,
|
19
10
|
:crop_profile_photo, :upload_profile_photo ]
|
20
|
-
|
11
|
+
before_action :require_current_user, :only => [:edit, :update, :update_account,
|
21
12
|
:edit_pro_details, :update_pro_details,
|
22
13
|
:welcome_photo, :welcome_about, :welcome_invite, :deactivate,
|
23
14
|
:crop_profile_photo, :upload_profile_photo]
|
24
|
-
|
25
|
-
|
15
|
+
before_action :admin_required, :only => [:assume, :destroy, :featured, :toggle_featured, :toggle_moderator]
|
16
|
+
before_action :admin_or_current_user_required, :only => [:statistics]
|
26
17
|
|
27
18
|
def activate
|
28
19
|
redirect_to signup_path and return if params[:id].blank?
|
@@ -140,18 +131,20 @@ class UsersController < BaseController
|
|
140
131
|
end
|
141
132
|
|
142
133
|
def destroy
|
134
|
+
@user = User.find(params[:id])
|
143
135
|
unless @user.admin? || @user.featured_writer?
|
136
|
+
@user.spam! if params[:spam] && configatron.has_key?(:akismet_key)
|
144
137
|
@user.destroy
|
145
138
|
flash[:notice] = :the_user_was_deleted.l
|
146
139
|
else
|
147
140
|
flash[:error] = :you_cant_delete_that_user.l
|
148
141
|
end
|
149
142
|
respond_to do |format|
|
143
|
+
format.html { redirect_to users_url }
|
150
144
|
format.js {
|
151
145
|
render :inline => flash[:error], :status => 500 if flash[:error]
|
152
|
-
render
|
146
|
+
render if flash[:notice]
|
153
147
|
}
|
154
|
-
format.html { redirect_to users_url }
|
155
148
|
end
|
156
149
|
end
|
157
150
|
|