community_engine 2.3.1 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.travis.yml +2 -2
- data/CHANGELOG +1 -0
- data/Gemfile +2 -0
- data/README.markdown +101 -57
- data/about.yml +1 -1
- data/app/controllers/authorizations_controller.rb +2 -1
- data/app/controllers/base_controller.rb +31 -43
- data/app/controllers/comments_controller.rb +11 -5
- data/app/controllers/messages_controller.rb +1 -1
- data/app/controllers/password_resets_controller.rb +4 -4
- data/app/controllers/sessions_controller.rb +3 -4
- data/app/helpers/base_helper.rb +47 -43
- data/app/models/album.rb +3 -3
- data/app/models/authorization.rb +14 -14
- data/app/models/clipping.rb +13 -13
- data/app/models/clipping_image.rb +4 -4
- data/app/models/comment.rb +18 -10
- data/app/models/event.rb +12 -12
- data/app/models/homepage_feature.rb +4 -4
- data/app/models/message.rb +2 -2
- data/app/models/metro_area.rb +1 -1
- data/app/models/photo.rb +4 -4
- data/app/models/poll.rb +1 -1
- data/app/models/post.rb +48 -48
- data/app/models/sb_post.rb +1 -1
- data/app/models/topic.rb +2 -2
- data/app/models/user.rb +3 -2
- data/app/views/admin/comments.html.haml +11 -8
- data/app/views/admin/users.html.haml +6 -4
- data/app/views/comments/_comment.html.haml +3 -0
- data/app/views/comments/approve.js.haml +1 -0
- data/app/views/layouts/application.html.haml +16 -16
- data/app/views/messages/_sent.html.haml +2 -2
- data/app/views/users/_search_options.html.haml +2 -2
- data/app/views/users/new.html.haml +4 -4
- data/community_engine.gemspec +4 -3
- data/config/locales/en.yml +10 -4
- data/config/routes.rb +35 -34
- data/db/migrate/090_add_comment_role.rb +15 -0
- data/lib/community_engine/authenticated_system.rb +11 -11
- data/lib/community_engine/engines_extensions.rb +14 -2
- data/lib/community_engine/version.rb +1 -1
- data/lib/tasks/community_engine_tasks.rake +3 -72
- data/test/functional/authorizations_controller_test.rb +60 -0
- data/test/functional/comments_controller_test.rb +44 -67
- data/test/functional/password_reset_controller_test.rb +14 -6
- data/test/functional/sessions_controller_test.rb +3 -3
- data/test/functional/topics_controller_test.rb +2 -2
- data/test/test_helper.rb +1 -8
- data/test/testapp/config/application.rb +4 -0
- data/test/testapp/db/schema.rb +4 -3
- data/test/unit/comment_test.rb +85 -28
- metadata +53 -49
- data/lib/community_engine/rails_asset_extensions.rb +0 -131
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
NTdmZGFlZTY4NzgyZDFkYTNmZGIzZjI4ZjM1MTU2MmVjOTE4NmJlMzk2Yjhj
|
10
|
-
NDI3YWM0MzRiMzBjYmY0ZjA3ZTQ5NzgwZDZjMTEyNjE5ZTM5NWRlMzZiMDA4
|
11
|
-
MWU4OWY5N2IyM2M2OTlmODllMjU3ZTc2YzFkMGY4Njk3NmZiNzk=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MTgyNDJlYzYwYmY4MTMzOTY3MTM5OWI2MjgyZDUyOTk0NDc5NjBhY2VlYWVi
|
14
|
-
YTQzM2FkMjcxOWUwMDA4YjhiYmM1NGNlZmM0OTZkOGExMWQ3ZDA0N2FlODll
|
15
|
-
ZTZmNDQ5ZWE1NTUxNjQyMDdmYWMxMDQ0ZDY2NTZmOTQ4OTgwNjI=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b9de87bef90a83355c574952e438ec062645ae69
|
4
|
+
data.tar.gz: 8d5b30da07b1907ddf84009ef4f23b8babb1ce27
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 39d7289ca53c143fe0add0222ecabb3b3c474375f1b39e436fd022e32795261117ecb6b9b2adafdf5005fef927260a9fd70641f12306199c775e1a0f6e2b13f2
|
7
|
+
data.tar.gz: f5448eb0f8fa19a45098cf884fc82075c6ac19de9e7704c677ea0b58ab1d4a2ed72b219a5f6e51e35d105c3f1f8f6af7b8a13ae6b30415963cccd45cf9e75e18
|
data/.travis.yml
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
bundler_args: --binstubs
|
2
2
|
|
3
3
|
rvm:
|
4
|
-
- 1.9.
|
4
|
+
- 1.9.3
|
5
5
|
- 2.0.0
|
6
6
|
env:
|
7
7
|
- "RAILS_ENV='test' RAILS_VERSION=3.2.0"
|
8
|
-
- "RAILS_ENV='test' RAILS_VERSION=3.2.
|
8
|
+
- "RAILS_ENV='test' RAILS_VERSION=3.2.19"
|
9
9
|
|
10
10
|
script: "bundle exec rake db:drop db:create db:migrate test"
|
data/CHANGELOG
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
=2.3.1
|
9
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)
|
10
|
+
* Add spam comment moderation (comments identified as spam as held in 'pending status')
|
10
11
|
|
11
12
|
=2.3.0
|
12
13
|
* Upgrade omniauth to 1.1
|
data/Gemfile
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
gem 'omniauth-facebook'
|
4
|
+
gem 'acts_as_commentable', :git => 'https://github.com/jackdempsey/acts_as_commentable'
|
4
5
|
|
5
6
|
group :test do
|
6
7
|
gem 'sqlite3'
|
8
|
+
gem 'mocha', :require => false
|
7
9
|
end
|
8
10
|
|
9
11
|
rails_version = ENV["RAILS_VERSION"] || "default"
|
data/README.markdown
CHANGED
@@ -1,69 +1,84 @@
|
|
1
|
-
|
1
|
+
CommunityEngine
|
2
|
+
===============
|
2
3
|
|
3
|
-
|
4
|
+
[![Build Status](https://travis-ci.org/bborn/communityengine.svg?branch=master)](https://travis-ci.org/bborn/communityengine)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/community_engine.svg)](https://badge.fury.io/rb/community_engine)
|
4
6
|
|
5
7
|
Information at: [http://www.communityengine.org](http://www.communityengine.org)
|
6
8
|
|
7
|
-
Requirements
|
9
|
+
**Requirements:**
|
8
10
|
|
9
11
|
- RAILS VERSION 3.2.8
|
10
12
|
|
13
|
+
For Rails 2.x use the [rails2.x branch](https://github.com/bborn/communityengine/tree/rails2.x)
|
14
|
+
|
15
|
+
For Rails 4.x use the [rails4 branch](https://github.com/bborn/communityengine/tree/rails4)
|
16
|
+
|
11
17
|
Getting CommunityEngine Running
|
12
18
|
--------------------------------
|
13
19
|
|
14
20
|
1. Copy the following into your `Gemfile`:
|
15
21
|
|
16
|
-
|
17
|
-
|
18
|
-
|
22
|
+
```ruby
|
23
|
+
gem 'community_engine'
|
24
|
+
```
|
19
25
|
|
20
26
|
2. Add a file called `application_config.rb` to your `config` directory. In it put (at least):
|
21
27
|
|
22
|
-
|
23
|
-
|
28
|
+
```ruby
|
29
|
+
configatron.community_name = "Your Application Name"
|
30
|
+
# See CE's application_config.rb to see all the other configuration options available
|
31
|
+
```
|
24
32
|
|
25
33
|
3. From your app's root directory run:
|
26
34
|
|
27
|
-
|
28
|
-
|
29
|
-
|
35
|
+
```
|
36
|
+
$ bundle install --binstubs
|
37
|
+
$ bin/rake community_engine:install:migrations
|
38
|
+
$ bin/rake db:migrate
|
39
|
+
```
|
30
40
|
|
31
41
|
4. Mount CommunityEngine in your `config/routes.rb` file:
|
32
42
|
|
33
|
-
|
43
|
+
```ruby
|
44
|
+
mount CommunityEngine::Engine => "/"
|
45
|
+
```
|
34
46
|
|
35
47
|
5. Delete the default `views/layouts/application.html.erb` that Rails created for you. Delete `public/index.html` if you haven't already.
|
36
48
|
|
37
49
|
6. Start your server!
|
38
50
|
|
39
|
-
|
51
|
+
```
|
52
|
+
$ bin/rails server
|
53
|
+
```
|
40
54
|
|
41
55
|
Optional Configuration
|
42
|
-
|
56
|
+
----------------------
|
43
57
|
|
44
|
-
To override the default configuration, create an `application_config.rb` file in `Rails.root/config
|
58
|
+
To override the default configuration, create an `application_config.rb` file in `Rails.root/config`.
|
45
59
|
|
46
|
-
The application configuration defined in this file overrides the one defined in the [CommunityEngine gem](https://github.com/bborn/communityengine/blob/
|
60
|
+
The application configuration defined in this file overrides the one defined in the [CommunityEngine gem](https://github.com/bborn/communityengine/blob/master/config/application_config.rb).
|
47
61
|
|
48
62
|
This is where you can change commonly used configuration variables, like `configatron.community_name`, etc.
|
49
63
|
|
50
64
|
|
51
|
-
OmniAuth Configuration
|
52
|
-
|
65
|
+
OmniAuth Configuration
|
66
|
+
----------------------
|
53
67
|
|
54
|
-
You can allow users to sign up and log in using their accounts from other social networks (like Facbeook, Twitter, LinkedIn, etc.). To do so, just add an initializer in your app's `config/initializers` directory called `omniauth.rb
|
55
|
-
|
56
|
-
Rails.application.config.middleware.use OmniAuth::Builder do
|
57
|
-
provider :twitter, 'CONSUMER_KEY', 'CONSUMER_SECRET'
|
58
|
-
provider :facebook, 'APP_ID', 'APP_SECRET'
|
59
|
-
provider :linked_in, 'CONSUMER_KEY', 'CONSUMER_SECRET'
|
60
|
-
end
|
68
|
+
You can allow users to sign up and log in using their accounts from other social networks (like Facbeook, Twitter, LinkedIn, etc.). To do so, just add an initializer in your app's `config/initializers` directory called `omniauth.rb` and add the following lines:
|
61
69
|
|
62
|
-
|
70
|
+
```ruby
|
71
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
72
|
+
provider :twitter, configatron.auth_providers.twitter.key, configatron.auth_providers.twitter.secret
|
73
|
+
provider :facebook, configatron.auth_providers.facebook.key, configatron.auth_providers.facebook.secret, {:provider_ignores_state => true}
|
74
|
+
end
|
75
|
+
```
|
63
76
|
|
64
|
-
|
77
|
+
You must also add the corresponding provider gem, for example to use facebook login you will need to add the following to your gemfile:
|
65
78
|
|
66
|
-
|
79
|
+
```ruby
|
80
|
+
gem 'omniauth-facebook'
|
81
|
+
```
|
67
82
|
|
68
83
|
See the [OmniAuth Github repository](https://github.com/intridea/omniauth) for more information and configuration options.
|
69
84
|
|
@@ -75,7 +90,7 @@ By default CommunityEngine uses the filesystem to store photos.
|
|
75
90
|
|
76
91
|
To use Amazon S3 as the backend for your file uploads,you'll need to add a file called `s3.yml` to the application's root config directory (examples are in `/community_engine/sample_files`).
|
77
92
|
|
78
|
-
You'll need to change your configuration in your `application_config.rb` to tell CommunityEngine to use s3 as the photo backend. For more, see the Paperclip documentation on S3 storage for uploads: https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/storage/s3.rb
|
93
|
+
You'll need to change your configuration in your `application_config.rb` to tell CommunityEngine to use s3 as the photo backend. For more, see the Paperclip documentation on S3 storage for uploads: https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/storage/s3.rb.
|
79
94
|
|
80
95
|
Finally, you'll need an S3 account for S3 photo uploading.
|
81
96
|
|
@@ -84,7 +99,7 @@ Finally, you'll need an S3 account for S3 photo uploading.
|
|
84
99
|
Roles
|
85
100
|
------
|
86
101
|
|
87
|
-
CommunityEngine Users have a Role (by default, it's admin, moderator, or member)
|
102
|
+
CommunityEngine Users have a Role (by default, it's admin, moderator, or member).
|
88
103
|
|
89
104
|
Once logged in as an admin, you'll be able to toggle other users between moderator and member (just go to their profile page and look on the sidebar.)
|
90
105
|
|
@@ -92,7 +107,9 @@ Admins and moderators can edit and delete other users posts.
|
|
92
107
|
|
93
108
|
There is a rake task to make an existing user into an admin:
|
94
109
|
|
95
|
-
|
110
|
+
```
|
111
|
+
$ rake community_engine:make_admin email=user@foo.com
|
112
|
+
```
|
96
113
|
|
97
114
|
(Pass in the e-mail of the user you'd like to make an admin)
|
98
115
|
|
@@ -105,11 +122,15 @@ Localization is done via Rails native I18n API. We've added some extensions to S
|
|
105
122
|
|
106
123
|
For complex strings with substitutions, Symbols respond to the `.l` method with a hash passed as an argument, for example:
|
107
124
|
|
108
|
-
|
125
|
+
```ruby
|
126
|
+
:welcome.l :name => current_user.name
|
127
|
+
```
|
109
128
|
|
110
129
|
And in your language file you'd have:
|
111
130
|
|
112
|
-
|
131
|
+
```yaml
|
132
|
+
welcome: "Welcome %{name}"
|
133
|
+
```
|
113
134
|
|
114
135
|
To customize the language, or add a new language create a new yaml file in `Rails.root/config/locales`. The name of the file should be `LANG-LOCALE.yml` (`e.g. en-US.yml` or `es-PR`). The language only file (`es.yml`) will support all locales.
|
115
136
|
|
@@ -121,17 +142,38 @@ Spam sucks. Most likely, you'll need to implement some custom solution to contro
|
|
121
142
|
|
122
143
|
ReCaptcha: to allow non-logged-in commenting and use [ReCaptcha](http://recaptcha.net/) to ensure robots aren't submitting comments to your site, just add the following lines to your `application_config.rb`:
|
123
144
|
|
124
|
-
|
125
|
-
|
126
|
-
|
145
|
+
```ruby
|
146
|
+
:allow_anonymous_commenting => true,
|
147
|
+
:recaptcha_pub_key => YOUR_PUBLIC_KEY,
|
148
|
+
:recaptcha_priv_key => YOUR_PRIVATE_KEY
|
149
|
+
```
|
127
150
|
|
128
151
|
You can also require ReCaptcha on signup (to prevent automated signups) by adding this in your `application_config.rb` (you'll still need to add your ReCaptcha keys):
|
129
152
|
|
130
|
-
|
153
|
+
```ruby
|
154
|
+
:require_captcha_on_signup => true
|
155
|
+
```
|
131
156
|
|
132
157
|
Akismet: Unfortunately, bots aren't the only ones submitting spam; humans do it too. [Akismet](http://akismet.com/) is a great collaborative spam filter from the makers of Wordpress, and you can use it to check for spam comments by adding one line to your `application_config.rb`:
|
133
158
|
|
134
|
-
|
159
|
+
```ruby
|
160
|
+
:akismet_key => YOUR_KEY
|
161
|
+
```
|
162
|
+
|
163
|
+
|
164
|
+
Ads
|
165
|
+
------------
|
166
|
+
|
167
|
+
Ads are snippets of HTML that will be inserted into your templates. You have to declare where they show up in your view. For example, if you wanted a sidebar ad slot, add ```Ad.display()``` in your application template (or wherever your sidebar is):
|
168
|
+
|
169
|
+
```haml
|
170
|
+
#sidebar
|
171
|
+
%h1 This is the sidebar
|
172
|
+
|
173
|
+
=Ad.display(:sidebar, logged_in?)
|
174
|
+
```
|
175
|
+
|
176
|
+
Then on the admin dashboard, create an ad and use "sidebar" as the location to target it to the :sidebar slot. You can create multiple ads for the same slot and they'll rotate according to their weight.
|
135
177
|
|
136
178
|
|
137
179
|
Integrating with Your Application & Overriding CE
|
@@ -139,39 +181,41 @@ Integrating with Your Application & Overriding CE
|
|
139
181
|
|
140
182
|
To make a controller from your application use CE's layout and inherit CE's helper methods, make it inherit from `BaseController`. For example:
|
141
183
|
|
142
|
-
|
184
|
+
```ruby
|
185
|
+
class RecipesController < BaseController
|
143
186
|
|
144
|
-
|
187
|
+
before_filter :login_required
|
145
188
|
|
146
|
-
|
147
|
-
|
148
|
-
|
189
|
+
uses_tiny_mce do
|
190
|
+
{:only => [:show], :options => configatron.default_mce_options}
|
191
|
+
end
|
149
192
|
|
150
|
-
|
193
|
+
end
|
194
|
+
```
|
151
195
|
|
152
196
|
To override or modify a controller, helper, or model from CE, you can use the `require_from_ce` helper method. For example, to override a method in CE's `User` model, create `app/models/user.rb`:
|
153
197
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
#add a new association
|
158
|
-
has_many :recipes
|
198
|
+
```ruby
|
199
|
+
class User < ActiveRecord::Base
|
200
|
+
require_from_ce('models/user')
|
159
201
|
|
160
|
-
|
161
|
-
|
162
|
-
login.capitalize
|
163
|
-
end
|
202
|
+
#add a new association
|
203
|
+
has_many :recipes
|
164
204
|
|
165
|
-
|
205
|
+
#override an existing method
|
206
|
+
def display_name
|
207
|
+
login.capitalize
|
208
|
+
end
|
166
209
|
|
210
|
+
end
|
211
|
+
```
|
167
212
|
|
168
213
|
|
169
214
|
|
170
|
-
Other
|
215
|
+
Other Notes
|
171
216
|
-----------
|
172
217
|
|
173
|
-
Any views you create in your app directory will override those in CommunityEngine
|
174
|
-
For example, you could create `Rails.root/app/views/layouts/application.html.haml` and have that include your own stylesheets, etc.
|
218
|
+
Any views you create in your app directory will override those in CommunityEngine. For example, you could create `Rails.root/app/views/layouts/application.html.haml` and have that include your own stylesheets, etc.
|
175
219
|
|
176
220
|
|
177
221
|
Contributors - Thanks! :)
|
data/about.yml
CHANGED
@@ -4,4 +4,4 @@ homepage: http://www.missingmethod.com
|
|
4
4
|
summary: A social networking engine
|
5
5
|
description: Adds basic social networking capabilities to your existing application, including users, blogs, photos, clippings, favorites, and more.
|
6
6
|
license: MIT
|
7
|
-
version: 2.
|
7
|
+
version: 2.3.2
|
@@ -11,7 +11,8 @@ class AuthorizationsController < BaseController
|
|
11
11
|
flash[:notice] = t('authorizations.create.success_existing_user', :provider => provider_name)
|
12
12
|
elsif @auth.valid?
|
13
13
|
flash[:notice] = t('authorizations.create.success_message', :provider => provider_name)
|
14
|
-
UserSession.create(@auth.user, true)
|
14
|
+
user_session = UserSession.create(@auth.user, true)
|
15
|
+
self.current_user = user_session.user
|
15
16
|
end
|
16
17
|
|
17
18
|
if logged_in?
|
@@ -6,9 +6,10 @@ class BaseController < ApplicationController
|
|
6
6
|
|
7
7
|
include AuthenticatedSystem
|
8
8
|
include LocalizedApplication
|
9
|
-
|
9
|
+
include BaseHelper
|
10
|
+
|
11
|
+
around_filter :set_locale
|
10
12
|
skip_before_filter :verify_authenticity_token, :only => :footer_content
|
11
|
-
helper_method :commentable_url
|
12
13
|
before_filter :initialize_header_tabs
|
13
14
|
before_filter :initialize_admin_tabs
|
14
15
|
before_filter :store_location, :except => :footer_content
|
@@ -16,13 +17,13 @@ class BaseController < ApplicationController
|
|
16
17
|
caches_action :site_index, :footer_content, :if => Proc.new{|c| c.cache_action? }
|
17
18
|
|
18
19
|
def cache_action?
|
19
|
-
!logged_in? && controller_name.eql?('base') && params[:format].blank?
|
20
|
-
end
|
21
|
-
|
20
|
+
!logged_in? && controller_name.eql?('base') && params[:format].blank?
|
21
|
+
end
|
22
|
+
|
22
23
|
def rss_site_index
|
23
24
|
redirect_to :controller => 'base', :action => 'site_index', :format => 'rss'
|
24
25
|
end
|
25
|
-
|
26
|
+
|
26
27
|
def plaxo
|
27
28
|
render :layout => false
|
28
29
|
end
|
@@ -42,23 +43,23 @@ class BaseController < ApplicationController
|
|
42
43
|
:pub_date => :published_at}
|
43
44
|
})
|
44
45
|
end
|
45
|
-
end
|
46
|
+
end
|
46
47
|
end
|
47
|
-
|
48
|
+
|
48
49
|
def footer_content
|
49
|
-
get_recent_footer_content
|
50
|
-
render :partial => 'shared/footer_content' and return
|
50
|
+
get_recent_footer_content
|
51
|
+
render :partial => 'shared/footer_content' and return
|
51
52
|
end
|
52
|
-
|
53
|
+
|
53
54
|
def homepage_features
|
54
55
|
@homepage_features = HomepageFeature.find_features
|
55
56
|
@homepage_features.shift
|
56
57
|
render :partial => 'homepage_feature', :collection => @homepage_features and return
|
57
58
|
end
|
58
|
-
|
59
|
+
|
59
60
|
def advertise
|
60
61
|
end
|
61
|
-
|
62
|
+
|
62
63
|
def css_help
|
63
64
|
end
|
64
65
|
|
@@ -67,9 +68,9 @@ class BaseController < ApplicationController
|
|
67
68
|
if block_given?
|
68
69
|
options = block.call
|
69
70
|
end
|
70
|
-
|
71
|
+
|
71
72
|
new_configuration = TinyMCE::Rails.configuration.merge(options.delete(:options)).options
|
72
|
-
|
73
|
+
|
73
74
|
# Set instance vars in the current class
|
74
75
|
p = Proc.new do |c|
|
75
76
|
configuration = c.instance_variable_get(:@tiny_mce_configuration) || {}
|
@@ -80,23 +81,23 @@ class BaseController < ApplicationController
|
|
80
81
|
|
81
82
|
before_filter p, options
|
82
83
|
end
|
83
|
-
|
84
|
-
|
84
|
+
|
85
|
+
|
85
86
|
private
|
86
87
|
def admin_required
|
87
88
|
current_user && current_user.admin? ? true : access_denied
|
88
89
|
end
|
89
|
-
|
90
|
+
|
90
91
|
def admin_or_moderator_required
|
91
92
|
current_user && (current_user.admin? || current_user.moderator?) ? true : access_denied
|
92
93
|
end
|
93
|
-
|
94
|
+
|
94
95
|
def find_user
|
95
96
|
if @user = User.active.find(params[:user_id] || params[:id])
|
96
97
|
@is_current_user = (@user && @user.eql?(current_user))
|
97
98
|
unless logged_in? || @user.profile_public?
|
98
99
|
flash[:error] = :private_user_profile_message.l
|
99
|
-
access_denied
|
100
|
+
access_denied
|
100
101
|
else
|
101
102
|
return @user
|
102
103
|
end
|
@@ -105,7 +106,7 @@ class BaseController < ApplicationController
|
|
105
106
|
access_denied
|
106
107
|
end
|
107
108
|
end
|
108
|
-
|
109
|
+
|
109
110
|
def require_current_user
|
110
111
|
@user ||= User.find(params[:user_id] || params[:id] )
|
111
112
|
unless admin? || (@user && (@user.eql?(current_user)))
|
@@ -117,7 +118,7 @@ class BaseController < ApplicationController
|
|
117
118
|
def popular_tags(limit = 20, type = nil)
|
118
119
|
ActsAsTaggableOn::Tag.popular(limit, type)
|
119
120
|
end
|
120
|
-
|
121
|
+
|
121
122
|
|
122
123
|
def get_recent_footer_content
|
123
124
|
@recent_clippings = Clipping.find_recent(:limit => 10)
|
@@ -125,47 +126,34 @@ class BaseController < ApplicationController
|
|
125
126
|
@recent_comments = Comment.find_recent(:limit => 13)
|
126
127
|
@popular_tags = popular_tags(30)
|
127
128
|
@recent_activity = User.recent_activity(:size => 15, :current => 1)
|
128
|
-
|
129
|
+
|
129
130
|
end
|
130
131
|
|
131
132
|
def get_additional_homepage_data
|
132
133
|
@sidebar_right = true
|
133
134
|
@homepage_features = HomepageFeature.find_features
|
134
135
|
@homepage_features_data = @homepage_features.collect {|f| [f.id, f.image.url(:large) ] }
|
135
|
-
|
136
|
+
|
136
137
|
@active_users = User.find_by_activity({:limit => 5, :require_avatar => false})
|
137
138
|
@featured_writers = User.find_featured
|
138
139
|
|
139
140
|
@featured_posts = Post.find_featured
|
140
|
-
|
141
|
+
|
141
142
|
@topics = Topic.find(:all, :limit => 5, :order => "replied_at DESC")
|
142
143
|
|
143
|
-
@popular_posts = Post.find_popular({:limit => 10})
|
144
|
+
@popular_posts = Post.find_popular({:limit => 10})
|
144
145
|
@popular_polls = Poll.find_popular(:limit => 8)
|
145
146
|
end
|
146
147
|
|
147
|
-
|
148
|
-
def commentable_url(comment)
|
149
|
-
if comment.recipient && comment.commentable
|
150
|
-
if comment.commentable_type != "User"
|
151
|
-
polymorphic_url([comment.recipient, comment.commentable])+"#comment_#{comment.id}"
|
152
|
-
elsif comment
|
153
|
-
user_url(comment.recipient)+"#comment_#{comment.id}"
|
154
|
-
end
|
155
|
-
elsif comment.commentable
|
156
|
-
polymorphic_url(comment.commentable)+"#comment_#{comment.id}"
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
148
|
def initialize_header_tabs
|
161
149
|
# This hook allows plugins or host apps to easily add tabs to the header by adding to the @header_tabs array
|
162
150
|
# Usage: @header_tabs << {:name => "My tab", :url => my_tab_path, :section => 'my_tab_section' }
|
163
|
-
@header_tabs = []
|
164
|
-
end
|
151
|
+
@header_tabs = []
|
152
|
+
end
|
165
153
|
def initialize_admin_tabs
|
166
154
|
# This hook allows plugins or host apps to easily add tabs to the admin nav by adding to the @admin_nav_links array
|
167
155
|
# Usage: @admin_nav_links << {:name => "My link", :url => my_link_path, }
|
168
|
-
@admin_nav_links = []
|
169
|
-
end
|
156
|
+
@admin_nav_links = []
|
157
|
+
end
|
170
158
|
|
171
159
|
end
|