community_engine 2.1.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OTUxNzQzYzY5OGRjZDgzZjRiNDIxNmMyNDg1NmUxNTFiN2NkOGFlNg==
5
+ data.tar.gz: !binary |-
6
+ NGE1ODk0ODU2MjhmNmNiZWVkMWI2NGU5MDdhMzNlMDY2ZDJiZDIxOA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ M2M0MTBmMWIyMGIxZDAxMGMwMDVhMWYwZGVlZDVjZTE3YmYzMGZhNDIxNjdh
10
+ M2RjYTFiODk4OTY2NzJiZjFiZWY3ZDg1Yzc4NzBmMjljOGZhN2MwMGE2Mzc1
11
+ MTNhMzcxZGJjYmQ4ZTBlN2E3ZGZmY2M1OGRjY2UwYzk1YmY2ZmY=
12
+ data.tar.gz: !binary |-
13
+ MGQ3YTNmYmUwMjJhYTc3OWE3OTRmMjM5YWVkNTJiYjI5YzA2OGIzYTAyNjQ1
14
+ ZWQxOTFjYzkzOTg2Y2ZjZmU5NjJlNDM1ZWI1MjgyZjRjNGI4ZWJmYTQ1NDRh
15
+ ZTYzYmZlMjhiMzVkZmUyYTQzYTNkMzg2NmM1NzhjMzdlMDdiMzc=
@@ -2,8 +2,7 @@ bundler_args: --binstubs
2
2
 
3
3
  rvm:
4
4
  - 1.9.2
5
-
5
+ - 2.0.0
6
6
  env: "RAILS_ENV='test' "
7
7
 
8
8
  script: "bundle exec rake db:drop db:create db:migrate test"
9
-
data/CHANGELOG CHANGED
@@ -3,9 +3,12 @@
3
3
  * fix photo uploading from welcome_photo page
4
4
  * add back searching to users index
5
5
  * swap jquery for prototype
6
+ * Upgrade to bcrybt crypto method
6
7
 
7
8
 
8
- * Upgrade to bcrybt crypto method
9
+ =2.3.0
10
+ * Upgrade omniauth to 1.1
11
+
9
12
 
10
13
  =2.0.0.beta4
11
14
  * Replace white_list plugin with Sanitize gem (white_list.rb initizlizer format has changed)
@@ -97,4 +100,4 @@
97
100
  = 0.10.7
98
101
 
99
102
  * Updating CE to be compatible with Rails 2.1.2
100
- * Lots of il8n refactoring, mainly using symbol tokens instead of string for localization in views.
103
+ * Lots of il8n refactoring, mainly using symbol tokens instead of string for localization in views.
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
+ gem 'omniauth-facebook'
4
+
3
5
  group :test do
4
6
  gem 'sqlite3'
5
7
  end
@@ -59,6 +59,12 @@ You can allow users to sign up and log in using their accounts from other social
59
59
  provider :linked_in, 'CONSUMER_KEY', 'CONSUMER_SECRET'
60
60
  end
61
61
 
62
+ You must also add the corresponding provider gem, for example to use facebook login you will need to add
63
+
64
+ gem 'omniauth-facebook'
65
+
66
+ to your gemfile
67
+
62
68
  See the [OmniAuth Github repository](https://github.com/intridea/omniauth) for more information and configuration options.
63
69
 
64
70
 
@@ -44,7 +44,7 @@ Make sure you have the following in your `environment.rb`:
44
44
  config.gem 'authlogic'
45
45
  config.gem 'icalendar'
46
46
  config.gem 'calendar_date_select'
47
-
47
+
48
48
  Run `rake db:migrate`
49
49
  That's it!
50
50
 
@@ -53,7 +53,7 @@ That's it!
53
53
  Upgrading v1.0.2
54
54
  ================
55
55
 
56
- Beginning with CE v.1.0.2, we have started using the Desert gem instead of the Engines plugin. Desert does many of the things the Engines plugin did, but also allows model code mixing. Also, in light of Engine's inclusion into Rails core, it appeared many of the features CE loves about Engines (plugin migrations, asset helpers, code mixing) were going to be dropped.
56
+ Beginning with CE v.1.0.2, we have started using the Desert gem instead of the Engines plugin. Desert does many of the things the Engines plugin did, but also allows model code mixing. Also, in light of Engine's inclusion into Rails core, it appeared many of the features CE loves about Engines (plugin migrations, asset helpers, code mixing) were going to be dropped.
57
57
 
58
58
  Upgrading an Engines-based CE app to use the new Desert-based CE is easy:
59
59
 
@@ -66,7 +66,7 @@ Upgrading an Engines-based CE app to use the new Desert-based CE is easy:
66
66
  Run git rm --cached vendor/plugins/engines (no trailing slash).
67
67
  Run rm -rf vendor/plugins/engines
68
68
  Commit your changes
69
-
69
+
70
70
 
71
71
  2. run `rake:rails:update` (coming from anything < Rails 2.3)
72
72
 
@@ -82,12 +82,12 @@ If you have old migrations from the Engines-based CE, you may experience some pr
82
82
 
83
83
  Here's a regex that might help you in doing that:
84
84
 
85
- Find:
85
+ Find:
86
86
 
87
87
  (Engines|Rails)\.plugins\[\"community_engine\"\]\.migrate\(([0-9]+)\)
88
-
89
- Replace:
90
88
 
91
- migrate_plugin(:community_engine, $2)
89
+ Replace:
90
+
91
+ migrate_plugin(:community_engine, $2)
92
92
 
93
- Also, you need to run `rake community_engine:db:migrate:upgrade_desert_plugin_migrations` before you migrate any _new_ CE migrations, to ensure your plugin migrations are listed in the correct table. Please note that you'll have to do this (carefully, and with backups) in production as well. Please post any questions to the CE Google Group.
93
+ Also, you need to run `rake community_engine:db:migrate:upgrade_desert_plugin_migrations` before you migrate any _new_ CE migrations, to ensure your plugin migrations are listed in the correct table. Please note that you'll have to do this (carefully, and with backups) in production as well. Please post any questions to the CE Google Group.
@@ -45,8 +45,8 @@ class MessagesController < BaseController
45
45
  @message.valid?
46
46
  render :action => :new and return
47
47
  else
48
- @message = Message.new(params[:message])
49
- @message.recipient = User.find_by_login(params[:message][:to].strip)
48
+ @message = Message.new(params[:message])
49
+ @message.recipient= User.where('lower(login) = ?', params[:message][:to].strip.downcase).first
50
50
  @message.sender = @user
51
51
  unless @message.valid?
52
52
  render :action => :new and return
@@ -7,7 +7,7 @@ class TopicsController < BaseController
7
7
  end
8
8
 
9
9
  def index
10
- @forum = Forum.find(params[:forum_id])
10
+ @forum = Forum.find(params[:forum_id])
11
11
  respond_to do |format|
12
12
  format.html { redirect_to forum_path(params[:forum_id]) }
13
13
  format.xml do
@@ -21,7 +21,7 @@ class TopicsController < BaseController
21
21
  @topic = Topic.new(params[:topic])
22
22
  @topic.sb_posts.build
23
23
  end
24
-
24
+
25
25
  def show
26
26
  respond_to do |format|
27
27
  format.html do
@@ -42,40 +42,40 @@ class TopicsController < BaseController
42
42
  end
43
43
  format.rss do
44
44
  @posts = @topic.sb_posts.recent.limit(25)
45
- render :action => 'show.xml.builder', :layout => false
45
+ render :action => 'show', :layout => false, :formats => [:xml]
46
46
  end
47
47
  end
48
48
  end
49
-
49
+
50
50
  def create
51
51
  @topic = @forum.topics.new(params[:topic])
52
52
  assign_protected
53
-
53
+
54
54
  @post = @topic.sb_posts.first
55
55
  if (!@post.nil?)
56
56
  @post.user = current_user
57
57
  end
58
-
58
+
59
59
  @topic.tag_list = params[:tag_list] || ''
60
60
 
61
61
  if !@topic.save
62
62
  respond_to do |format|
63
- format.html {
63
+ format.html {
64
64
  render :action => 'new' and return
65
65
  }
66
66
  end
67
67
  else
68
68
  respond_to do |format|
69
- format.html {
70
- redirect_to forum_topic_path(@forum, @topic)
69
+ format.html {
70
+ redirect_to forum_topic_path(@forum, @topic)
71
71
  }
72
- format.xml {
73
- head :created, :location => forum_topic_url(:forum_id => @forum, :id => @topic, :format => :xml)
72
+ format.xml {
73
+ head :created, :location => forum_topic_url(:forum_id => @forum, :id => @topic, :format => :xml)
74
74
  }
75
75
  end
76
76
  end
77
77
  end
78
-
78
+
79
79
  def update
80
80
  assign_protected
81
81
  @topic.tag_list = params[:tag_list] || ''
@@ -85,30 +85,30 @@ class TopicsController < BaseController
85
85
  format.xml { head 200 }
86
86
  end
87
87
  end
88
-
88
+
89
89
  def destroy
90
90
  @topic.destroy
91
- flash[:notice] = :topic_deleted.l_with_args(:topic => CGI::escapeHTML(@topic.title))
91
+ flash[:notice] = :topic_deleted.l_with_args(:topic => CGI::escapeHTML(@topic.title))
92
92
  respond_to do |format|
93
93
  format.html { redirect_to forum_path(@forum) }
94
94
  format.xml { head 200 }
95
95
  end
96
96
  end
97
-
98
- protected
97
+
98
+ protected
99
99
  def assign_protected
100
100
  @topic.sticky = @topic.locked = 0
101
101
  @topic.forum_id = @forum.id
102
102
  @topic.user = current_user if @topic.new_record?
103
-
103
+
104
104
  # admins and moderators can sticky and lock topics
105
105
  return unless admin? or current_user.moderator_of?(@topic.forum)
106
- @topic.sticky, @topic.locked = params[:topic][:sticky], params[:topic][:locked]
106
+ @topic.sticky, @topic.locked = params[:topic][:sticky], params[:topic][:locked]
107
107
  # only admins can move
108
108
  return unless admin?
109
109
  @topic.forum_id = params[:topic][:forum_id] if params[:topic][:forum_id]
110
110
  end
111
-
111
+
112
112
  def find_forum_and_topic
113
113
  @forum = Forum.find(params[:forum_id])
114
114
  @topic = @forum.topics.find(params[:id]) if params[:id]
@@ -4,33 +4,36 @@ class Ad < ActiveRecord::Base
4
4
 
5
5
  validates_presence_of :html
6
6
  validates_inclusion_of :audience, :in => AUDIENCES
7
- validates_inclusion_of :frequency, :in => FREQUENCIES
8
-
7
+ validates_inclusion_of :frequency, :in => FREQUENCIES
8
+
9
+ attr_accessible :html, :name, :frequency, :audience, :published, :time_constrained, :start_date, :end_date, :location
10
+
11
+
9
12
  def self.display(location, logged_in = false)
10
13
  return nil if location.blank?
11
- ads = find(:all,
12
- :conditions => ["location = ?
13
- AND published = ?
14
+ ads = find(:all,
15
+ :conditions => ["location = ?
16
+ AND published = ?
14
17
  AND (time_constrained = ? OR (start_date > ? AND end_date < ?))
15
- AND (audience IN (?) )",
18
+ AND (audience IN (?) )",
16
19
  location.to_s, true, false, Time.now, Time.now, audiences_for(logged_in) ])
17
-
20
+
18
21
  ad = random_weighted(ads.map{|a| [a, a.frequency] })
19
22
  ad ? ad.html.html_safe : ''
20
23
  end
21
-
24
+
22
25
  def self.audiences_for(logged_in)
23
26
  ["all", "logged_#{logged_in ? 'in' : 'out'}"]
24
27
  end
25
-
28
+
26
29
  def self.frequencies_for_select
27
30
  FREQUENCIES.map{|f| [f, f.to_s]}
28
31
  end
29
-
32
+
30
33
  def self.audiences_for_select
31
34
  AUDIENCES.map{|a| [a, a.to_s]}
32
- end
33
-
35
+ end
36
+
34
37
  def self.random_weighted(items)
35
38
  total = 0
36
39
  pick = nil
@@ -38,6 +41,6 @@ class Ad < ActiveRecord::Base
38
41
  pick = item if rand(total += weight) < weight
39
42
  end
40
43
  pick
41
- end
44
+ end
42
45
 
43
- end
46
+ end
@@ -47,10 +47,10 @@ class Authorization < ActiveRecord::Base
47
47
  def assign_account_info(auth_hash)
48
48
  self.uid = auth_hash['uid']
49
49
  self.provider = auth_hash['provider']
50
- self.nickname = auth_hash['user_info']['nickname']
51
- self.email = auth_hash['user_info']['email']
52
- self.picture_url = auth_hash['user_info']['image']
53
- self.name = auth_hash['user_info']['name']
50
+ self.nickname = auth_hash['info']['nickname']
51
+ self.email = auth_hash['info']['email']
52
+ self.picture_url = auth_hash['info']['image']
53
+ self.name = auth_hash['info']['name']
54
54
  if auth_hash['credentials']
55
55
  self.access_token = auth_hash['credentials']['token']
56
56
  self.access_token_secret = auth_hash['credentials']['secret']
@@ -3,7 +3,7 @@ class MetroArea < ActiveRecord::Base
3
3
  belongs_to :state
4
4
  belongs_to :country
5
5
 
6
- attr_accessible :name, :state, :country_id
6
+ attr_accessible :name, :state, :country_id, :state_id
7
7
 
8
8
  #validates_presence_of :state, :if => Proc.new { |user| user.country.eql?(Country.get(:us)) }
9
9
  validates_presence_of :country_id
@@ -1,7 +1,9 @@
1
1
  class Page < ActiveRecord::Base
2
2
  acts_as_publishable :live, :draft, :members_only, :public
3
3
  validates_presence_of :title, :body
4
-
4
+
5
+ attr_accessible :title, :body, :published_as, :page_public
6
+
5
7
  def to_param
6
8
  id.to_s << "-" << (title ? title.parameterize : '')
7
9
  end
@@ -1,28 +1,30 @@
1
1
  class Photo < ActiveRecord::Base
2
+ include UrlUpload
3
+
2
4
  acts_as_commentable
3
5
  belongs_to :album
4
-
6
+
5
7
  has_attached_file :photo, configatron.photo.paperclip_options.to_hash
6
- validates_attachment_presence :photo
8
+ validates_attachment_presence :photo, :unless => Proc.new{|record| record.photo_remote_url }
7
9
  validates_attachment_content_type :photo, :content_type => configatron.photo.validation_options.content_type
8
10
  validates_attachment_size :photo, :less_than => configatron.photo.validation_options.max_size.to_i.megabytes
9
11
 
10
- attr_accessor :crop_x, :crop_y, :crop_w, :crop_h
12
+ attr_accessor :crop_x, :crop_y, :crop_w, :crop_h, :photo_remote_url
11
13
  after_update :reprocess_photo, :if => :cropping?
12
-
14
+
13
15
  acts_as_taggable
14
16
 
15
17
  acts_as_activity :user, :if => Proc.new{|record| record.album_id.nil?}
16
-
18
+
17
19
  validates_presence_of :user
18
-
20
+
19
21
  belongs_to :user
20
22
  has_one :user_as_avatar, :class_name => "User", :foreign_key => "avatar_id", :inverse_of => :avatar
21
-
23
+
22
24
  #Named scopes
23
25
  scope :recent, :order => "photos.created_at DESC"
24
26
  scope :new_this_week, :order => "photos.created_at DESC", :conditions => ["photos.created_at > ?", 7.days.ago.iso8601]
25
- attr_accessible :name, :description, :photo, :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
26
28
 
27
29
  def display_name
28
30
  (self.name && self.name.length>0) ? self.name : "#{:created_at.l.downcase}: #{I18n.l(self.created_at, :format => :published_date)}"
@@ -56,10 +58,10 @@ class Photo < ActiveRecord::Base
56
58
  def self.find_recent(options = {:limit => 3})
57
59
  self.new_this_week.find(:all, :limit => options[:limit])
58
60
  end
59
-
61
+
60
62
  def self.find_related_to(photo, options = {})
61
- options.reverse_merge!({:limit => 8,
62
- :order => 'created_at DESC',
63
+ options.reverse_merge!({:limit => 8,
64
+ :order => 'created_at DESC',
63
65
  :conditions => ['photos.id != ?', photo.id]
64
66
  })
65
67
  limit(options[:limit]).order(options[:order]).where(options[:conditions]).tagged_with(photo.tags.collect{|t| t.name }, :any => true)
@@ -74,6 +76,11 @@ class Photo < ActiveRecord::Base
74
76
  @geometry[style] ||= Paperclip::Geometry.from_file(photo.path(style))
75
77
  end
76
78
 
79
+ def photo_remote_url=(url_value)
80
+ data = self.data_from_url(url_value)
81
+ self.photo = data
82
+ end
83
+
77
84
  private
78
85
 
79
86
  def reprocess_photo
@@ -49,8 +49,8 @@ class User < ActiveRecord::Base
49
49
 
50
50
  #validation
51
51
  validates_presence_of :metro_area, :if => Proc.new { |user| user.state }
52
- validates_uniqueness_of :login
53
- validates_exclusion_of :login, :in => configatron.reserved_logins
52
+ validates_uniqueness_of :login, :if => :requires_unique_login?
53
+ validates_exclusion_of :login, :in => Proc.new{ configatron.reserved_logins }
54
54
 
55
55
  validate :valid_birthday, :if => :requires_valid_birthday?
56
56
  validate :check_spam
@@ -255,7 +255,7 @@ class User < ActiveRecord::Base
255
255
  end
256
256
 
257
257
  def avatar_photo_url(size = :original)
258
- if avatar
258
+ if avatar_id
259
259
  avatar.photo.url(size)
260
260
  elsif facebook?
261
261
  facebook_authorization.picture_url
@@ -478,6 +478,10 @@ class User < ActiveRecord::Base
478
478
  !omniauthed?
479
479
  end
480
480
 
481
+ def requires_unique_login?
482
+ true
483
+ end
484
+
481
485
  def omniauthed?
482
486
  authorizing_from_omniauth || authorizations.any?
483
487
  end
@@ -25,10 +25,10 @@
25
25
  = link_to page.title, edit_admin_page_path(page)
26
26
  = link_to("(#{:preview.l})", preview_admin_page_path(page), :target => '_blank') unless page.is_live?
27
27
  %td
28
- -if page.is_public?
29
- = t(:yes)
28
+ -if page.page_public?
29
+ = t(:yes_status)
30
30
  -else
31
- = t(:no)
31
+ = t(:no_status)
32
32
  %td= page.is_live? ? link_to(:published.l, pages_path(page)) : :draft.l
33
33
 
34
34
  =paginate @pages
@@ -7,12 +7,12 @@
7
7
 
8
8
  #yui-main
9
9
  .yui-b
10
- -box do
10
+ -box do
11
11
  %h3=:editing_post.l
12
12
 
13
13
  = error_messages_for :post
14
14
  = form_for(:post, :url => user_post_path(@user, @post), :html => { :method => :put, :class =>'MainForm' }) do |f|
15
- %label
15
+ %label
16
16
  =:title.l
17
17
  %em= '('+:required.l+')'
18
18
  = f.text_field :title
@@ -27,19 +27,19 @@
27
27
  %label
28
28
  =:tags.l
29
29
  %em="(#{:optional_keywords_describing_this_post_separated_by_commas.l})"
30
- = text_field_tag 'tag_list', @post.tag_list, {:autocomplete => "off", :size => 35}
30
+ = text_field_tag 'tag_list', @post.tag_list.to_s, {:autocomplete => "off", :size => 35}
31
31
  #tag_list_auto_complete.auto_complete
32
32
  -content_for :end_javascript do
33
33
  = auto_complete_field 'tag_list', {:url => { :controller => "tags", :action => 'auto_complete_for_tag_name'}, :tokens => [','] }
34
-
34
+
35
35
  %label=:save_post_as.l
36
36
  = f.select(:published_as, [[:published.l, 'live'], [:draft.l, 'draft']])
37
-
37
+
38
38
  %label
39
- = f.check_box :send_comment_notifications
40
- =:send_comment_notifications.l
39
+ = f.check_box :send_comment_notifications
40
+ =:send_comment_notifications.l
41
+
41
42
 
42
-
43
43
  %p
44
44
  = submit_tag :update.l
45
45
  = :or.l