community_engine 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +5 -3
- data/CHANGELOG +2 -0
- data/Gemfile +15 -1
- data/app/controllers/categories_controller.rb +2 -0
- data/app/controllers/category_sweeper.rb +27 -0
- data/app/controllers/comment_sweeper.rb +6 -8
- data/app/controllers/comments_controller.rb +20 -20
- data/app/controllers/page_sweeper.rb +0 -3
- data/app/controllers/pages_controller.rb +3 -3
- data/app/controllers/post_sweeper.rb +4 -7
- data/app/controllers/posts_controller.rb +53 -54
- data/app/models/category.rb +1 -1
- data/app/models/clipping.rb +2 -0
- data/app/models/invitation.rb +3 -1
- data/app/models/photo.rb +1 -1
- data/app/views/clippings/edit.html.haml +1 -1
- data/app/views/forums/_form.html.haml +1 -1
- data/app/views/photos/edit.html.haml +1 -1
- data/app/views/shared/_header.html.haml +0 -5
- data/app/views/topics/_form.html.haml +1 -1
- data/app/views/users/edit.html.haml +1 -1
- data/community_engine.gemspec +4 -4
- data/config/application_config.rb +9 -0
- data/lib/community_engine/engine.rb +6 -19
- data/lib/community_engine/version.rb +1 -1
- data/sample_files/s3.yml +3 -3
- data/test/unit/invitation_test.rb +4 -2
- data/vendor/plugins/enumerations_mixin/lib/active_record/acts/enumerated.rb +2 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjU1NTFjMTI0MzAzMmE4ZGFjNWJhZTIxOWRlMzdjOTgyOTQwMzRjMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2YyNjY5YTliNTE0N2Q1YTNmOTY1ZTcwMzcwNzRhYjg5ODJiNDY1OA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTdmZGFlZTY4NzgyZDFkYTNmZGIzZjI4ZjM1MTU2MmVjOTE4NmJlMzk2Yjhj
|
10
|
+
NDI3YWM0MzRiMzBjYmY0ZjA3ZTQ5NzgwZDZjMTEyNjE5ZTM5NWRlMzZiMDA4
|
11
|
+
MWU4OWY5N2IyM2M2OTlmODllMjU3ZTc2YzFkMGY4Njk3NmZiNzk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTgyNDJlYzYwYmY4MTMzOTY3MTM5OWI2MjgyZDUyOTk0NDc5NjBhY2VlYWVi
|
14
|
+
YTQzM2FkMjcxOWUwMDA4YjhiYmM1NGNlZmM0OTZkOGExMWQ3ZDA0N2FlODll
|
15
|
+
ZTZmNDQ5ZWE1NTUxNjQyMDdmYWMxMDQ0ZDY2NTZmOTQ4OTgwNjI=
|
data/.travis.yml
CHANGED
data/CHANGELOG
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
* swap jquery for prototype
|
6
6
|
* Upgrade to bcrybt crypto method
|
7
7
|
|
8
|
+
=2.3.1
|
9
|
+
* Remove automatic loading of omniauth middleware, in favor of letting users load it themselves as specified in the README (this was causing bugs with duplicate inits of omniauth-facebook middleware)
|
8
10
|
|
9
11
|
=2.3.0
|
10
12
|
* Upgrade omniauth to 1.1
|
data/Gemfile
CHANGED
@@ -6,4 +6,18 @@ group :test do
|
|
6
6
|
gem 'sqlite3'
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
rails_version = ENV["RAILS_VERSION"] || "default"
|
10
|
+
|
11
|
+
rails = case rails_version
|
12
|
+
when "master"
|
13
|
+
{github: "rails/rails"}
|
14
|
+
when "default"
|
15
|
+
">= 3.2.0"
|
16
|
+
else
|
17
|
+
"~> #{rails_version}"
|
18
|
+
end
|
19
|
+
|
20
|
+
gem "rails", rails
|
21
|
+
|
22
|
+
|
23
|
+
gemspec
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class CategoriesController < BaseController
|
2
2
|
before_filter :login_required, :except => [:show, :most_viewed, :rss]
|
3
3
|
before_filter :admin_required, :only => [:new, :edit, :update, :create, :destroy, :index]
|
4
|
+
|
5
|
+
cache_sweeper :category_sweeper, :only => [:create, :update, :destroy]
|
4
6
|
|
5
7
|
# GET /categories
|
6
8
|
# GET /categories.xml
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class CategorySweeper < ActionController::Caching::Sweeper
|
2
|
+
observe Category # This sweeper is going to keep an eye on the Category model
|
3
|
+
|
4
|
+
# If our sweeper detects that a Category was created call this
|
5
|
+
def after_create(category)
|
6
|
+
expire_cache_for(category)
|
7
|
+
end
|
8
|
+
|
9
|
+
# If our sweeper detects that a Category was updated call this
|
10
|
+
def after_update(category)
|
11
|
+
expire_cache_for(category)
|
12
|
+
end
|
13
|
+
|
14
|
+
# If our sweeper detects that a Category was deleted call this
|
15
|
+
def after_destroy(category)
|
16
|
+
expire_cache_for(category)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def expire_cache_for(record)
|
21
|
+
# Expire the home page
|
22
|
+
expire_action(:controller => 'base', :action => 'site_index')
|
23
|
+
|
24
|
+
# Also expire the sitemap
|
25
|
+
expire_action(:controller => 'sitemap', :action => 'index')
|
26
|
+
end
|
27
|
+
end
|
@@ -4,30 +4,28 @@ class CommentSweeper < ActionController::Caching::Sweeper
|
|
4
4
|
def after_create(comment)
|
5
5
|
expire_cache_for(comment)
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
# If our sweeper detects that a comment was updated call this
|
9
9
|
def after_update(comment)
|
10
10
|
expire_cache_for(comment)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
# If our sweeper detects that a comment was deleted call this
|
14
14
|
def after_destroy(comment)
|
15
15
|
expire_cache_for(comment)
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
private
|
19
19
|
def expire_cache_for(record)
|
20
20
|
# Expire the footer content
|
21
21
|
expire_action :controller => 'base', :action => 'footer_content'
|
22
22
|
|
23
|
-
if record.commentable_type.eql?('Post')
|
23
|
+
if record.commentable_type.eql?('Post')
|
24
24
|
expire_action :controller => 'posts', :action => 'show', :id => record.commentable.to_param , :user_id => record.commentable.user.to_param
|
25
|
-
|
25
|
+
|
26
26
|
if Post.find_recent(:limit => 16).include?(record.commentable)
|
27
|
-
# Expire the home page
|
27
|
+
# Expire the home page
|
28
28
|
expire_action :controller => 'base', :action => 'site_index'
|
29
|
-
# Expire the category pages
|
30
|
-
expire_action :controller => 'categories', :action => 'show', :id => record.commentable.category
|
31
29
|
end
|
32
30
|
end
|
33
31
|
|
@@ -12,7 +12,7 @@ class CommentsController < BaseController
|
|
12
12
|
end
|
13
13
|
|
14
14
|
cache_sweeper :comment_sweeper, :only => [:create, :destroy]
|
15
|
-
|
15
|
+
|
16
16
|
def edit
|
17
17
|
@comment = Comment.find(params[:id])
|
18
18
|
respond_to do |format|
|
@@ -22,10 +22,10 @@ class CommentsController < BaseController
|
|
22
22
|
|
23
23
|
def update
|
24
24
|
@comment = Comment.find(params[:id])
|
25
|
-
@comment.update_attributes(params[:comment])
|
25
|
+
@comment.update_attributes(params[:comment])
|
26
26
|
respond_to do |format|
|
27
27
|
format.js
|
28
|
-
end
|
28
|
+
end
|
29
29
|
end
|
30
30
|
|
31
31
|
|
@@ -34,15 +34,15 @@ class CommentsController < BaseController
|
|
34
34
|
commentable_class = commentable_type.singularize.constantize
|
35
35
|
commentable_type_humanized = commentable_type.humanize
|
36
36
|
commentable_type_tableized = commentable_type.tableize
|
37
|
-
|
37
|
+
|
38
38
|
if @commentable = commentable_class.find(params[:commentable_id])
|
39
39
|
unless logged_in? || (@commentable.owner && @commentable.owner.profile_public?)
|
40
40
|
flash.now[:error] = :private_user_profile_message.l
|
41
41
|
redirect_to login_path and return
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
@comments = @commentable.comments.recent.page(params[:page])
|
45
|
-
@title = commentable_type_humanized
|
45
|
+
@title = commentable_type_humanized
|
46
46
|
@rss_url = commentable_comments_url(commentable_type_tableized, @commentable, :format => :rss)
|
47
47
|
|
48
48
|
if @comments.any?
|
@@ -51,12 +51,12 @@ class CommentsController < BaseController
|
|
51
51
|
@title = first_comment.commentable_name
|
52
52
|
@back_url = commentable_url(first_comment)
|
53
53
|
respond_to do |format|
|
54
|
-
@rss_title = "#{configatron.community_name}: #{commentable_type_humanized} Comments - #{@title}"
|
54
|
+
@rss_title = "#{configatron.community_name}: #{commentable_type_humanized} Comments - #{@title}"
|
55
55
|
format.html
|
56
56
|
format.rss {
|
57
57
|
render_comments_rss_feed_for(@comments, @commentable, @rss_title) and return
|
58
58
|
}
|
59
|
-
end
|
59
|
+
end
|
60
60
|
else
|
61
61
|
if @commentable.is_a?(User)
|
62
62
|
@user = @commentable
|
@@ -66,19 +66,19 @@ class CommentsController < BaseController
|
|
66
66
|
@title = @commentable.respond_to?(:title) ? @commentable.title : @title
|
67
67
|
@back_url = url_for([@user, @commentable])
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
respond_to do |format|
|
71
71
|
format.html
|
72
72
|
format.rss {
|
73
|
-
@rss_title = "#{configatron.community_name}: #{commentable_type_humanized} Comments - #{@title}"
|
73
|
+
@rss_title = "#{configatron.community_name}: #{commentable_type_humanized} Comments - #{@title}"
|
74
74
|
render_comments_rss_feed_for([], @commentable, @rss_title) and return
|
75
75
|
}
|
76
|
-
end
|
77
|
-
end
|
76
|
+
end
|
77
|
+
end
|
78
78
|
else
|
79
79
|
flash[:notice] = :no_comments_found.l_with_args(:type => commentable_type_humanized)
|
80
80
|
redirect_to home_path
|
81
|
-
end
|
81
|
+
end
|
82
82
|
end
|
83
83
|
|
84
84
|
def new
|
@@ -131,7 +131,7 @@ class CommentsController < BaseController
|
|
131
131
|
}
|
132
132
|
end
|
133
133
|
end
|
134
|
-
|
134
|
+
|
135
135
|
def delete_selected
|
136
136
|
if request.post?
|
137
137
|
if params[:delete]
|
@@ -141,12 +141,12 @@ class CommentsController < BaseController
|
|
141
141
|
comment.destroy if comment.can_be_deleted_by(current_user)
|
142
142
|
}
|
143
143
|
end
|
144
|
-
flash[:notice] = :comments_deleted.l
|
144
|
+
flash[:notice] = :comments_deleted.l
|
145
145
|
redirect_to admin_comments_path
|
146
146
|
end
|
147
|
-
end
|
147
|
+
end
|
148
|
+
|
148
149
|
|
149
|
-
|
150
150
|
def unsubscribe
|
151
151
|
@comment = Comment.find(params[:id])
|
152
152
|
if @comment.token_for(params[:email]).eql?(params[:token])
|
@@ -158,11 +158,11 @@ class CommentsController < BaseController
|
|
158
158
|
|
159
159
|
|
160
160
|
private
|
161
|
-
|
161
|
+
|
162
162
|
def get_commentable_type(string)
|
163
163
|
string.camelize
|
164
164
|
end
|
165
|
-
|
165
|
+
|
166
166
|
def render_comments_rss_feed_for(comments, commentable, title)
|
167
167
|
render_rss_feed_for(comments,
|
168
168
|
{ :class => commentable.class,
|
@@ -175,5 +175,5 @@ class CommentsController < BaseController
|
|
175
175
|
}
|
176
176
|
})
|
177
177
|
end
|
178
|
-
|
178
|
+
|
179
179
|
end
|
@@ -20,9 +20,6 @@ class PageSweeper < ActionController::Caching::Sweeper
|
|
20
20
|
def expire_cache_for(record)
|
21
21
|
# Expire the home page
|
22
22
|
expire_action(:controller => 'base', :action => 'site_index')
|
23
|
-
|
24
|
-
# Expire the footer content
|
25
|
-
expire_action(:controller => 'base', :action => 'footer_content')
|
26
23
|
|
27
24
|
# Also expire the sitemap
|
28
25
|
expire_action(:controller => 'sitemap', :action => 'index')
|
@@ -8,7 +8,7 @@ class PagesController < BaseController
|
|
8
8
|
|
9
9
|
def cache_action?
|
10
10
|
!logged_in? && controller_name.eql?('pages')
|
11
|
-
end
|
11
|
+
end
|
12
12
|
|
13
13
|
before_filter :login_required, :only => [:index, :new, :edit, :update, :destroy, :create, :preview]
|
14
14
|
before_filter :require_moderator, :only => [:index, :new, :edit, :update, :destroy, :create, :preview]
|
@@ -26,7 +26,7 @@ class PagesController < BaseController
|
|
26
26
|
@page = Page.live.find(params[:id])
|
27
27
|
unless logged_in? || @page.page_public
|
28
28
|
flash[:error] = :page_not_public_warning.l
|
29
|
-
redirect_to :controller => 'sessions', :action => 'new'
|
29
|
+
redirect_to :controller => 'sessions', :action => 'new'
|
30
30
|
end
|
31
31
|
rescue
|
32
32
|
flash[:error] = :page_not_found.l
|
@@ -59,7 +59,7 @@ class PagesController < BaseController
|
|
59
59
|
end
|
60
60
|
|
61
61
|
private
|
62
|
-
|
62
|
+
|
63
63
|
def require_moderator
|
64
64
|
@page ||= Page.find(params[:id]) if params[:id]
|
65
65
|
unless admin? || moderator?
|
@@ -5,17 +5,17 @@ class PostSweeper < ActionController::Caching::Sweeper
|
|
5
5
|
def after_create(post)
|
6
6
|
expire_cache_for(post)
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
# If our sweeper detects that a Post was updated call this
|
10
10
|
def after_update(post)
|
11
11
|
expire_cache_for(post)
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
# If our sweeper detects that a Post was deleted call this
|
15
15
|
def after_destroy(post)
|
16
16
|
expire_cache_for(post)
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
private
|
20
20
|
def expire_cache_for(record)
|
21
21
|
# Expire the home page
|
@@ -23,13 +23,10 @@ class PostSweeper < ActionController::Caching::Sweeper
|
|
23
23
|
|
24
24
|
# Expire the footer content
|
25
25
|
expire_action(:controller => 'base', :action => 'footer_content')
|
26
|
-
|
26
|
+
|
27
27
|
# Also expire the sitemap
|
28
28
|
expire_action(:controller => 'sitemap', :action => 'index')
|
29
29
|
|
30
|
-
# Expire the category pages
|
31
|
-
expire_action(:controller => 'categories', :action => 'index')
|
32
|
-
|
33
30
|
# Also expire the show pages, in case we just edited a blog entry
|
34
31
|
expire_action(:controller => 'posts', :action => 'show', :id => record.to_param, :user_id => record.user.to_param)
|
35
32
|
end
|
@@ -8,17 +8,17 @@ class PostsController < BaseController
|
|
8
8
|
uses_tiny_mce do
|
9
9
|
{:only => [:show], :options => configatron.simple_mce_options}
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
cache_sweeper :post_sweeper, :only => [:create, :update, :destroy]
|
13
|
-
cache_sweeper :taggable_sweeper, :only => [:create, :update, :destroy]
|
13
|
+
cache_sweeper :taggable_sweeper, :only => [:create, :update, :destroy]
|
14
14
|
caches_action :show, :if => Proc.new{|c| !logged_in? }
|
15
|
-
|
15
|
+
|
16
16
|
before_filter :login_required, :only => [:new, :edit, :update, :destroy, :create, :manage, :preview]
|
17
17
|
before_filter :find_user, :only => [:new, :edit, :index, :show, :update_views, :manage, :preview]
|
18
18
|
before_filter :require_ownership_or_moderator, :only => [:edit, :update, :destroy, :create, :manage, :new]
|
19
19
|
|
20
|
-
skip_before_filter :verify_authenticity_token, :only => [:update_views, :send_to_friend] #called from ajax on cached pages
|
21
|
-
|
20
|
+
skip_before_filter :verify_authenticity_token, :only => [:update_views, :send_to_friend] #called from ajax on cached pages
|
21
|
+
|
22
22
|
def manage
|
23
23
|
Post.unscoped do
|
24
24
|
@search = Post.search(params[:search])
|
@@ -28,20 +28,20 @@ class PostsController < BaseController
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def index
|
31
|
-
@user = User.find(params[:user_id])
|
31
|
+
@user = User.find(params[:user_id])
|
32
32
|
@category = Category.find_by_name(params[:category_name]) if params[:category_name]
|
33
33
|
|
34
34
|
@posts = @user.posts.recent
|
35
35
|
@posts = @post.where('category_id = ?', @category.id) if @category
|
36
36
|
@posts = @posts.page(params[:page]).per(10)
|
37
|
-
|
37
|
+
|
38
38
|
@is_current_user = @user.eql?(current_user)
|
39
39
|
|
40
40
|
@popular_posts = @user.posts.order("view_count DESC").limit(10).all
|
41
|
-
|
41
|
+
|
42
42
|
@rss_title = "#{configatron.community_name}: #{@user.login}'s posts"
|
43
43
|
@rss_url = user_posts_path(@user,:format => :rss)
|
44
|
-
|
44
|
+
|
45
45
|
respond_to do |format|
|
46
46
|
format.html # index.rhtml
|
47
47
|
format.rss {
|
@@ -54,14 +54,13 @@ class PostsController < BaseController
|
|
54
54
|
}
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
58
|
-
|
57
|
+
|
59
58
|
# GET /posts/1
|
60
59
|
# GET /posts/1.xml
|
61
60
|
def show
|
62
61
|
@rss_title = "#{configatron.community_name}: #{@user.login}'s posts"
|
63
62
|
@rss_url = user_posts_path(@user,:format => :rss)
|
64
|
-
|
63
|
+
|
65
64
|
@post = Post.unscoped.find(params[:id])
|
66
65
|
|
67
66
|
@user = @post.user
|
@@ -71,31 +70,31 @@ class PostsController < BaseController
|
|
71
70
|
@comments = @post.comments.includes(:user).order('created_at DESC').limit(20)
|
72
71
|
|
73
72
|
@previous = @post.previous_post
|
74
|
-
@next = @post.next_post
|
73
|
+
@next = @post.next_post
|
75
74
|
@popular_posts = @user.posts.except(:order).order('view_count DESC').limit(10).all
|
76
75
|
@related = Post.find_related_to(@post)
|
77
|
-
@most_commented = Post.find_most_commented
|
76
|
+
@most_commented = Post.find_most_commented
|
78
77
|
end
|
79
|
-
|
78
|
+
|
80
79
|
def update_views
|
81
80
|
@post = Post.find(params[:id])
|
82
81
|
updated = update_view_count(@post)
|
83
82
|
render :text => updated ? 'updated' : 'duplicate'
|
84
83
|
end
|
85
|
-
|
84
|
+
|
86
85
|
def preview
|
87
86
|
@post = Post.unscoped.find(params[:id])
|
88
87
|
redirect_to(:controller => 'sessions', :action => 'new') and return false unless @post.user.eql?(current_user) || admin? || moderator?
|
89
88
|
end
|
90
|
-
|
89
|
+
|
91
90
|
# GET /posts/new
|
92
91
|
def new
|
93
|
-
@user = User.find(params[:user_id])
|
92
|
+
@user = User.find(params[:user_id])
|
94
93
|
@post = Post.new(params[:post])
|
95
94
|
@post.published_as = 'live'
|
96
95
|
@categories = Category.find(:all)
|
97
96
|
end
|
98
|
-
|
97
|
+
|
99
98
|
# GET /posts/1;edit
|
100
99
|
def edit
|
101
100
|
@post = Post.unscoped.find(params[:id])
|
@@ -103,20 +102,20 @@ class PostsController < BaseController
|
|
103
102
|
|
104
103
|
# POST /posts
|
105
104
|
# POST /posts.xml
|
106
|
-
def create
|
105
|
+
def create
|
107
106
|
@user = User.find(params[:user_id])
|
108
107
|
@post = Post.new(params[:post])
|
109
108
|
@post.user = @user
|
110
109
|
@post.tag_list = params[:tag_list] || ''
|
111
|
-
|
110
|
+
|
112
111
|
respond_to do |format|
|
113
112
|
if @post.save
|
114
113
|
@post.create_poll(params[:poll], params[:choices]) if params[:poll]
|
115
|
-
|
114
|
+
|
116
115
|
flash[:notice] = @post.category ? :post_created_for_category.l_with_args(:category => @post.category.name.singularize) : :your_post_was_successfully_created.l
|
117
|
-
format.html {
|
116
|
+
format.html {
|
118
117
|
if @post.is_live?
|
119
|
-
redirect_to @post.category ? category_path(@post.category) : user_post_path(@user, @post)
|
118
|
+
redirect_to @post.category ? category_path(@post.category) : user_post_path(@user, @post)
|
120
119
|
else
|
121
120
|
redirect_to manage_user_posts_path(@user)
|
122
121
|
end
|
@@ -124,51 +123,51 @@ class PostsController < BaseController
|
|
124
123
|
format.js
|
125
124
|
else
|
126
125
|
format.html { render :action => "new" }
|
127
|
-
format.js
|
126
|
+
format.js
|
128
127
|
end
|
129
128
|
end
|
130
129
|
end
|
131
|
-
|
130
|
+
|
132
131
|
# PUT /posts/1
|
133
132
|
# PUT /posts/1.xml
|
134
133
|
def update
|
135
134
|
@post = Post.unscoped.find(params[:id])
|
136
135
|
@user = @post.user
|
137
136
|
@post.tag_list = params[:tag_list] || ''
|
138
|
-
|
137
|
+
|
139
138
|
respond_to do |format|
|
140
139
|
if @post.update_attributes(params[:post])
|
141
140
|
@post.update_poll(params[:poll], params[:choices]) if params[:poll]
|
142
|
-
|
141
|
+
|
143
142
|
format.html { redirect_to user_post_path(@post.user, @post) }
|
144
143
|
else
|
145
|
-
format.html { render :action => "edit" }
|
144
|
+
format.html { render :action => "edit" }
|
146
145
|
end
|
147
146
|
end
|
148
147
|
end
|
149
|
-
|
148
|
+
|
150
149
|
# DELETE /posts/1
|
151
150
|
# DELETE /posts/1.xml
|
152
151
|
def destroy
|
153
152
|
@user = User.find(params[:user_id])
|
154
153
|
@post = Post.find(params[:id])
|
155
154
|
@post.destroy
|
156
|
-
|
155
|
+
|
157
156
|
respond_to do |format|
|
158
|
-
format.html {
|
157
|
+
format.html {
|
159
158
|
flash[:notice] = :your_post_was_deleted.l
|
160
|
-
redirect_to manage_user_posts_url(@user)
|
159
|
+
redirect_to manage_user_posts_url(@user)
|
161
160
|
}
|
162
161
|
end
|
163
162
|
end
|
164
|
-
|
163
|
+
|
165
164
|
def send_to_friend
|
166
165
|
unless params[:emails]
|
167
166
|
render :partial => 'posts/send_to_friend', :locals => {:user_id => params[:user_id], :post_id => params[:post_id]} and return
|
168
167
|
end
|
169
168
|
@post = Post.find(params[:id])
|
170
169
|
if @post.send_to(params[:emails], params[:message], (current_user || nil))
|
171
|
-
render :inline => "It worked!"
|
170
|
+
render :inline => "It worked!"
|
172
171
|
else
|
173
172
|
render :inline => "You entered invalid addresses: <ul>"+ @post.invalid_emails.collect{|email| '<li>'+email+'</li>' }.join+"</ul> Please correct these and try again.", :status => 500
|
174
173
|
end
|
@@ -179,13 +178,13 @@ class PostsController < BaseController
|
|
179
178
|
@posts = Post.find_popular({:limit => 15, :since => 3.days})
|
180
179
|
|
181
180
|
@monthly_popular_posts = Post.find_popular({:limit => 20, :since => 30.days})
|
182
|
-
|
183
|
-
@related_tags = ActsAsTaggableOn::Tag.find_by_sql("SELECT tags.id, tags.name, count(*) AS count
|
184
|
-
FROM taggings, tags
|
181
|
+
|
182
|
+
@related_tags = ActsAsTaggableOn::Tag.find_by_sql("SELECT tags.id, tags.name, count(*) AS count
|
183
|
+
FROM taggings, tags
|
185
184
|
WHERE tags.id = taggings.tag_id GROUP BY tags.id, tags.name");
|
186
185
|
|
187
186
|
@rss_title = "#{configatron.community_name} "+:popular_posts.l
|
188
|
-
@rss_url = popular_rss_url
|
187
|
+
@rss_url = popular_rss_url
|
189
188
|
respond_to do |format|
|
190
189
|
format.html # index.rhtml
|
191
190
|
format.rss {
|
@@ -195,51 +194,51 @@ class PostsController < BaseController
|
|
195
194
|
}
|
196
195
|
end
|
197
196
|
end
|
198
|
-
|
197
|
+
|
199
198
|
def recent
|
200
199
|
@posts = Post.recent.page(params[:page]).per(20)
|
201
200
|
|
202
201
|
@recent_clippings = Clipping.find_recent(:limit => 15)
|
203
202
|
@recent_photos = Photo.find_recent(:limit => 10)
|
204
|
-
|
203
|
+
|
205
204
|
@rss_title = "#{configatron.community_name} "+:recent_posts.l
|
206
205
|
@rss_url = recent_rss_url
|
207
206
|
respond_to do |format|
|
208
|
-
format.html
|
207
|
+
format.html
|
209
208
|
format.rss {
|
210
209
|
render_rss_feed_for(@posts, { :feed => {:title => @rss_title, :link => recent_url},
|
211
210
|
:item => {:title => :title, :link => Proc.new {|post| user_post_url(post.user, post)}, :description => :post, :pub_date => :published_at}
|
212
211
|
})
|
213
212
|
}
|
214
|
-
end
|
213
|
+
end
|
215
214
|
end
|
216
|
-
|
215
|
+
|
217
216
|
def featured
|
218
217
|
@posts = Post.by_featured_writers.recent.page(params[:page])
|
219
218
|
@featured_writers = User.featured
|
220
|
-
|
219
|
+
|
221
220
|
@rss_title = "#{configatron.community_name} "+:featured_posts.l
|
222
221
|
@rss_url = featured_rss_url
|
223
222
|
respond_to do |format|
|
224
|
-
format.html
|
223
|
+
format.html
|
225
224
|
format.rss {
|
226
225
|
render_rss_feed_for(@posts, { :feed => {:title => @rss_title, :link => recent_url},
|
227
226
|
:item => {:title => :title, :link => Proc.new {|post| user_post_url(post.user, post)}, :description => :post, :pub_date => :published_at}
|
228
227
|
})
|
229
228
|
}
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
233
232
|
def category_tips_update
|
234
233
|
return unless request.xhr?
|
235
234
|
@category = Category.find(params[:post_category_id] )
|
236
|
-
render :partial => "categories/tips", :locals => {:category => @category}
|
235
|
+
render :partial => "categories/tips", :locals => {:category => @category}
|
237
236
|
rescue ActiveRecord::RecordNotFound
|
238
|
-
render :partial => "categories/tips", :locals => {:category => nil}
|
237
|
+
render :partial => "categories/tips", :locals => {:category => nil}
|
239
238
|
end
|
240
|
-
|
239
|
+
|
241
240
|
private
|
242
|
-
|
241
|
+
|
243
242
|
def require_ownership_or_moderator
|
244
243
|
@user ||= User.find(params[:user_id])
|
245
244
|
@post ||= Post.unscoped.find(params[:id]) if params[:id]
|
@@ -248,5 +247,5 @@ class PostsController < BaseController
|
|
248
247
|
end
|
249
248
|
return @user
|
250
249
|
end
|
251
|
-
|
250
|
+
|
252
251
|
end
|
data/app/models/category.rb
CHANGED
data/app/models/clipping.rb
CHANGED
data/app/models/invitation.rb
CHANGED
@@ -25,7 +25,9 @@ class Invitation < ActiveRecord::Base
|
|
25
25
|
record.email_addresses = (emails - invalid_emails).join(', ')
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
|
+
attr_accessible :email_addresses, :message
|
30
|
+
|
29
31
|
def send_invite
|
30
32
|
emails = self.email_addresses.split(",").collect{|email| email.strip }.uniq
|
31
33
|
emails.each{|email|
|
data/app/models/photo.rb
CHANGED
@@ -24,7 +24,7 @@ class Photo < ActiveRecord::Base
|
|
24
24
|
#Named scopes
|
25
25
|
scope :recent, :order => "photos.created_at DESC"
|
26
26
|
scope :new_this_week, :order => "photos.created_at DESC", :conditions => ["photos.created_at > ?", 7.days.ago.iso8601]
|
27
|
-
attr_accessible :name, :description, :photo, :photo_remote_url, :crop_x, :crop_y, :crop_w, :crop_h, :user_id
|
27
|
+
attr_accessible :name, :description, :photo, :photo_remote_url, :crop_x, :crop_y, :crop_w, :crop_h, :user_id, :album_id
|
28
28
|
|
29
29
|
def display_name
|
30
30
|
(self.name && self.name.length>0) ? self.name : "#{:created_at.l.downcase}: #{I18n.l(self.created_at, :format => :published_date)}"
|
@@ -12,7 +12,7 @@
|
|
12
12
|
%label
|
13
13
|
=:tags.l
|
14
14
|
%em="(#{:optional_keywords_describing_this_forum_separated_by_commas.l})"
|
15
|
-
= text_field_tag 'tag_list', @forum.tag_list, {:autocomplete => "off", :size => 35}
|
15
|
+
= text_field_tag 'tag_list', @forum.tag_list.to_s, {:autocomplete => "off", :size => 35}
|
16
16
|
#tag_list_auto_complete.auto_complete
|
17
17
|
|
18
18
|
-content_for :end_javascript do
|
@@ -22,7 +22,7 @@
|
|
22
22
|
%label
|
23
23
|
= :tags.l
|
24
24
|
%em="(#{:optional_keywords_describing_this_photo_separated_by_commas.l})"
|
25
|
-
= text_field_tag 'tag_list', @photo.tag_list.
|
25
|
+
= text_field_tag 'tag_list', @photo.tag_list.to_s, {:autocomplete => "off", :size => 35}
|
26
26
|
#tag_list_auto_complete.auto_complete{"class"=>"auto_complete"}
|
27
27
|
-content_for :end_javascript do
|
28
28
|
= auto_complete_field 'tag_list', {:url => { :controller => "tags", :action => 'auto_complete_for_tag_name'}, :tokens => [','] }
|
@@ -1,9 +1,4 @@
|
|
1
1
|
#hd
|
2
|
-
- if !configatron.community_locale
|
3
|
-
%div
|
4
|
-
%a{:href=>url_for(:subdomain => 'ru', :only_path => false ), :title=>"#{configatron.community_locale} russian translation"}= "rus"
|
5
|
-
%a{:href=>url_for(:subdomain => 'en', :only_path =>false), :title=>"english translation" }= "eng"
|
6
|
-
|
7
2
|
%h1
|
8
3
|
%a{:href=>home_url, :title=>"#{configatron.community_name}"}= configatron.community_name
|
9
4
|
- if logged_in?
|
@@ -13,7 +13,7 @@
|
|
13
13
|
%label
|
14
14
|
= :tags.l
|
15
15
|
%em="(#{:optional_keywords_describing_this_topic_separated_by_commas.l})"
|
16
|
-
= text_field_tag 'tag_list', @topic.tag_list, {:autocomplete => "off", :size => 35}
|
16
|
+
= text_field_tag 'tag_list', @topic.tag_list.to_s, {:autocomplete => "off", :size => 35}
|
17
17
|
#tag_list_auto_complete.auto_complete
|
18
18
|
|
19
19
|
-content_for :end_javascript do
|
@@ -52,7 +52,7 @@
|
|
52
52
|
-box do
|
53
53
|
%h3= :tags.l
|
54
54
|
#user_tags
|
55
|
-
= text_field_tag 'tag_list', @user.tag_list.join
|
55
|
+
= text_field_tag 'tag_list', @user.tag_list.join.to_s, {:autocomplete => "off"}
|
56
56
|
#tag_list_auto_complete.auto_complete
|
57
57
|
-content_for :end_javascript do
|
58
58
|
= auto_complete_field 'tag_list', {:url => { :controller => "tags", :action => 'auto_complete_for_tag_name'}, :tokens => [','] }
|
data/community_engine.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.files = `git ls-files`.split("\n") rescue ''
|
26
26
|
s.test_files = `git ls-files -- {test}/*`.split("\n")
|
27
27
|
|
28
|
-
s.add_dependency(%q<rails>, ["
|
28
|
+
s.add_dependency(%q<rails>, [">= 3.2.0"])
|
29
29
|
s.add_dependency(%q<rack>, [">= 1.4.1"])
|
30
30
|
s.add_dependency(%q<authlogic>, [">= 0"])
|
31
31
|
s.add_dependency(%q<bcrypt-ruby>, [">= 0"])
|
@@ -36,12 +36,12 @@ Gem::Specification.new do |s|
|
|
36
36
|
s.add_dependency(%q<sass-rails>, ["~> 3.2.3"])
|
37
37
|
s.add_dependency(%q<ri_cal>, [">= 0"])
|
38
38
|
s.add_dependency(%q<rakismet>, [">= 0"])
|
39
|
-
s.add_dependency(%q<aws-
|
39
|
+
s.add_dependency(%q<aws-sdk>, [">= 0"])
|
40
40
|
s.add_dependency(%q<kaminari>, [">= 0"])
|
41
41
|
s.add_dependency(%q<dynamic_form>, [">= 0"])
|
42
42
|
s.add_dependency(%q<friendly_id>, ["~> 3.3"])
|
43
|
-
s.add_dependency(%q<paperclip>, ["~>
|
44
|
-
s.add_dependency(%q<cocaine>, ["0.
|
43
|
+
s.add_dependency(%q<paperclip>, ["~> 3.5.1"])
|
44
|
+
s.add_dependency(%q<cocaine>, ["0.5.1"])
|
45
45
|
s.add_dependency(%q<acts_as_commentable>, ["= 3.0.1"])
|
46
46
|
s.add_dependency(%q<recaptcha>, [">= 0"])
|
47
47
|
s.add_dependency(%q<omniauth>, ["~> 1.1.0"])
|
@@ -52,6 +52,9 @@ configuration = {
|
|
52
52
|
:missing_thumb => '/assets/icon_missing_thumb.gif',
|
53
53
|
:missing_medium => "/assets/icon_missing_medium.gif",
|
54
54
|
:paperclip_options => {
|
55
|
+
:default_url => "",
|
56
|
+
:path => "#{Rails.root}/public/system/:attachment/:id/:style/:filename",
|
57
|
+
:url => "/system/:attachment/:id/:style/:filename",
|
55
58
|
:styles => {
|
56
59
|
:thumb => {
|
57
60
|
:geometry => "100x100#",
|
@@ -71,6 +74,9 @@ configuration = {
|
|
71
74
|
:use_thumbs => true,
|
72
75
|
:dimensions => [150, 635],
|
73
76
|
:paperclip_options => {
|
77
|
+
:default_url => "",
|
78
|
+
:path => "#{Rails.root}/public/system/:attachment/:id/:style/:filename",
|
79
|
+
:url => "/system/:attachment/:id/:style/:filename",
|
74
80
|
:styles => {
|
75
81
|
:original => '465>',
|
76
82
|
:thumb => "45x45#",
|
@@ -85,6 +91,9 @@ configuration = {
|
|
85
91
|
|
86
92
|
:clipping => {
|
87
93
|
:paperclip_options => {
|
94
|
+
:default_url => "",
|
95
|
+
:path => "#{Rails.root}/public/system/:attachment/:id/:style/:filename",
|
96
|
+
:url => "/system/:attachment/:id/:style/:filename",
|
88
97
|
:styles => {
|
89
98
|
:thumb => "100x100#",
|
90
99
|
:medium => "290x320#",
|
@@ -7,35 +7,22 @@ module CommunityEngine
|
|
7
7
|
|
8
8
|
initializer engine_name do |app|
|
9
9
|
require root.join('config','application_config.rb')
|
10
|
-
require app.root.join('config','application_config.rb')
|
10
|
+
require app.root.join('config','application_config.rb')
|
11
11
|
end
|
12
|
-
|
13
|
-
initializer "#{engine_name}.initializers", :before => :load_config_initializers do
|
14
|
-
Dir["#{root}/config/initializers/**/*.rb"].each do |initializer|
|
12
|
+
|
13
|
+
initializer "#{engine_name}.initializers", :before => :load_config_initializers do
|
14
|
+
Dir["#{root}/config/initializers/**/*.rb"].each do |initializer|
|
15
15
|
load(initializer) unless File.exists?("#{root.to_s}/config/initializers/#{File.basename(initializer)}")
|
16
|
-
end
|
16
|
+
end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
initializer "#{engine_name}.rakismet_config", :before => "rakismet.setup" do |app|
|
20
20
|
if !configatron.akismet_key.nil?
|
21
21
|
app.config.rakismet.key = configatron.akismet_key
|
22
22
|
app.config.rakismet.url = configatron.app_host
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
26
|
-
initializer "#{engine_name}.load_middleware", :after => :load_config_initializers do
|
27
|
-
if !configatron.auth_providers.nil?
|
28
|
-
configatron.protect(:auth_providers)
|
29
|
-
configatron.auth_providers.to_hash.each do |name, hash|
|
30
|
-
provider = "::OmniAuth::Strategies::#{name.to_s.classify}".constantize
|
31
|
-
config.app_middleware.use provider, hash[:key], hash[:secret]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
25
|
|
38
|
-
|
39
26
|
end
|
40
27
|
end
|
41
28
|
|
data/sample_files/s3.yml
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
development:
|
2
|
-
|
2
|
+
bucket: bucket
|
3
3
|
access_key_id: 'KEY'
|
4
4
|
secret_access_key: 'SECRET_KEY'
|
5
5
|
use_persistent: true
|
6
6
|
|
7
7
|
test:
|
8
|
-
|
8
|
+
bucket: bucket
|
9
9
|
access_key_id: 'KEY'
|
10
10
|
secret_access_key: 'SECRET_KEY'
|
11
11
|
use_persistent: false
|
12
12
|
|
13
13
|
production:
|
14
|
-
|
14
|
+
bucket: bucket
|
15
15
|
access_key_id: 'KEY'
|
16
16
|
secret_access_key: 'SECRET_KEY'
|
17
17
|
use_persistent: false
|
@@ -12,14 +12,16 @@ class InvitationTest < ActiveSupport::TestCase
|
|
12
12
|
|
13
13
|
def test_send_with_names_in_emails
|
14
14
|
addresses = '"Valid Example" <valid@example.com>, valid_2@example.com'
|
15
|
-
invitation = Invitation.new(:email_addresses => addresses
|
15
|
+
invitation = Invitation.new(:email_addresses => addresses)
|
16
|
+
invitation.user = users(:quentin)
|
16
17
|
assert invitation.valid?
|
17
18
|
assert invitation.send_invite
|
18
19
|
end
|
19
20
|
|
20
21
|
def test_send_invite
|
21
22
|
addresses = "valid@example.com, valid_2@example.com"
|
22
|
-
invitation = Invitation.new(:email_addresses => addresses
|
23
|
+
invitation = Invitation.new(:email_addresses => addresses)
|
24
|
+
invitation.user = users(:quentin)
|
23
25
|
assert invitation.valid?
|
24
26
|
assert invitation.send_invite
|
25
27
|
end
|
@@ -14,6 +14,7 @@ module ActiveRecord
|
|
14
14
|
valid_keys = [:conditions, :order, :on_lookup_failure]
|
15
15
|
options.assert_valid_keys(*valid_keys)
|
16
16
|
valid_keys.each do |key|
|
17
|
+
class_attribute :acts_enumerated_on_lookup_failure
|
17
18
|
class_attribute "acts_enumerated_#{key.to_s}"
|
18
19
|
if options.has_key?( key )
|
19
20
|
self.send "acts_enumerated_#{key.to_s}=", options[key]
|
@@ -55,7 +56,7 @@ module ActiveRecord
|
|
55
56
|
else
|
56
57
|
raise TypeError, "#{self.name}[]: argument should be a String, Symbol or Fixnum but got a: #{arg.class.name}"
|
57
58
|
end
|
58
|
-
self.send(
|
59
|
+
self.send(:acts_enumerated_on_lookup_failure) || self.send(:enforce_strict_literals, arg)
|
59
60
|
end
|
60
61
|
|
61
62
|
def lookup_id(arg)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: community_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno Bornsztein
|
@@ -14,14 +14,14 @@ dependencies:
|
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -165,7 +165,7 @@ dependencies:
|
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
|
-
name: aws-
|
168
|
+
name: aws-sdk
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
171
|
- - ! '>='
|
@@ -226,28 +226,28 @@ dependencies:
|
|
226
226
|
requirements:
|
227
227
|
- - ~>
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version:
|
229
|
+
version: 3.5.1
|
230
230
|
type: :runtime
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
234
|
- - ~>
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
version:
|
236
|
+
version: 3.5.1
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: cocaine
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
240
240
|
requirements:
|
241
241
|
- - '='
|
242
242
|
- !ruby/object:Gem::Version
|
243
|
-
version: 0.
|
243
|
+
version: 0.5.1
|
244
244
|
type: :runtime
|
245
245
|
prerelease: false
|
246
246
|
version_requirements: !ruby/object:Gem::Requirement
|
247
247
|
requirements:
|
248
248
|
- - '='
|
249
249
|
- !ruby/object:Gem::Version
|
250
|
-
version: 0.
|
250
|
+
version: 0.5.1
|
251
251
|
- !ruby/object:Gem::Dependency
|
252
252
|
name: acts_as_commentable
|
253
253
|
requirement: !ruby/object:Gem::Requirement
|
@@ -526,6 +526,7 @@ files:
|
|
526
526
|
- app/controllers/authorizations_controller.rb
|
527
527
|
- app/controllers/base_controller.rb
|
528
528
|
- app/controllers/categories_controller.rb
|
529
|
+
- app/controllers/category_sweeper.rb
|
529
530
|
- app/controllers/clippings_controller.rb
|
530
531
|
- app/controllers/comment_sweeper.rb
|
531
532
|
- app/controllers/comments_controller.rb
|