Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

Commit

Permalink
rails3 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bborn committed Feb 4, 2011
1 parent b6a02e8 commit bd5f7ff
Show file tree
Hide file tree
Showing 162 changed files with 1,401 additions and 1,987 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@
* remove all the theming stuff
* asset paths https://github.com/rails/rails/commit/a132229d7b4382d9ffe8847fa58f469cb8f2ecfc#L5L149
* take out ez where
* fix initializers/rakismet, recaptcha etc.
* take out vendors/offerings crap
* go back and fix: Rails 3 Fix comments
* searchlogic broken with rails 3 gem 'searchlogic', :git => git://github.com/railsdog/searchlogic.git
* copy new migrations from main app back into ce
* don't allow show_localization_keys_for_debugging
* remote_form_for is gone
* remove stylesheet customization
* rework users index to use searchlogic/metaseach or something
* use aato instead of aatos
* authlogic has problems: not sure it's recording last_login magic columns, investigate
* finding transparently by login is broken


GOTCHAS:
* edge rails needs edge rack? and edge arel

=1.2.1
* Anonymous forum replies
Expand Down
25 changes: 13 additions & 12 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
source "http://rubygems.org"

gem 'rails', '3.1.0.beta', :git => 'git://github.com/rails/rails.git'
gem 'configatron'
gem 'hpricot'
gem 'rmagick'
gem 'htmlentities'
gem 'haml'
gem 'calendar_date_select'
gem 'ri_cal'
gem 'authlogic'
gem 'searchlogic'
gem 'rakismet'
gem 'aws-s3'
# gem 'rails', '3.1.0.beta', :git => 'git://github.com/rails/rails.git'
# gem 'rails'
# gem 'configatron'
# gem 'hpricot'
# gem 'rmagick'
# gem 'htmlentities'
# gem 'haml'
# gem 'calendar_date_select'
# gem 'ri_cal'
# gem 'authlogic'
# gem 'searchlogic'
# gem 'rakismet'
# gem 'aws-s3'
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ The language only file (`es.yml`) will support all locales.

To wrap all localized strings in a `<span>` that shows their localization key, put this in your `environment.rb`:

configatron.show_localization_keys_for_debugging = true if RAILS_ENV.eql?('development')
configatron.show_localization_keys_for_debugging = true if Rails.env.eql?('development')

Note, this will affect the look and feel of buttons. You can highlight what is localized by using the `span.localized` style (look in `screen.css`)

Expand Down
7 changes: 6 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ begin
gem.version = '1.9.9'

gem.add_dependency 'rails', '3.1.0.beta'
gem.add_dependency 'rack', '1.2.1'
gem.add_dependency 'configatron'
gem.add_dependency 'hpricot'
gem.add_dependency 'rmagick'
Expand All @@ -40,9 +41,13 @@ begin
gem.add_dependency 'calendar_date_select'
gem.add_dependency 'ri_cal'
gem.add_dependency 'authlogic'
gem.add_dependency 'searchlogic'

gem.add_dependency 'rd_searchlogic', '3.0.1'
gem.add_dependency 'rakismet'
gem.add_dependency 'aws-s3'
gem.add_dependency "will_paginate", "~> 3.0.pre2"
gem.add_dependency "dynamic_form"


# other fields that would normally go in your gemspec
# like authors, email and has_rdoc can also be included here
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def comment_link
end

def full_comment_link
"#{application_url}#{comment_link}"
"#{home_url}#{comment_link}"
end

def comment_rss_link
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/forums_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class ForumsController < BaseController
before_filter :find_or_initialize_forum
helper :application

uses_tiny_mce do
uses_tiny_mce do
configatron.default_mce_options
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/friendships_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def create

respond_to do |format|
if @friendship.save && reverse_friendship.save
UserNotifier.deliver_friendship_request(@friendship) if @friendship.friend.notify_friend_requests?
UserNotifier.friendship_request(@friendship) if @friendship.friend.notify_friend_requests?
format.html {
flash[:notice] = :friendship_requested.l_with_args(:friend => @friendship.friend.login)
redirect_to accepted_user_friendships_path(@user)
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ def new
end

def create

@user_session = UserSession.new(:login => params[:login], :password => params[:password], :remember_me => params[:remember_me])

if @user_session.save
if @user_session.save!


current_user = @user_session.record #if current_user has been called before this, it will ne nil, so we have to make to reset it

Expand Down
15 changes: 5 additions & 10 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require "RMagick"

class UsersController < BaseController
include Viewable
Expand Down Expand Up @@ -56,14 +55,10 @@ def deactivate
redirect_to login_path
end

def index
cond, @search, @metro_areas, @states = User.paginated_users_conditions_with_search(params)
def index
@users = User.active.paginate(:page => params[:page]) #Rails 3 fix no search!

@users = User.recent.find(:all,
:conditions => cond.to_sql,
:include => [:tags],
:page => {:current => params[:page], :size => 20}
)
@metro_areas, @states = User.find_country_and_state_from_search_params(params)

@tags = User.tag_counts :limit => 10

Expand Down Expand Up @@ -316,7 +311,7 @@ def forgot_username
return unless request.post?

if @user = User.active.find_by_email(params[:email])
UserNotifier.deliver_forgot_username(@user)
UserNotifier.forgot_username(@user)
redirect_to login_url
flash[:info] = :your_username_was_emailed_to_you.l
else
Expand All @@ -335,7 +330,7 @@ def resend_activation

if @user && !@user.active?
flash[:notice] = :activation_email_resent_message.l
UserNotifier.deliver_signup_notification(@user)
UserNotifier.signup_notification(@user)
redirect_to login_path and return
else
flash[:notice] = :activation_email_not_sent_message.l
Expand Down
115 changes: 55 additions & 60 deletions app/helpers/base_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'md5'

# Methods added to this helper will be available to all templates in the application.
module BaseHelper
Expand All @@ -12,7 +11,7 @@ def commentable_url(comment)
end

def forum_page?
%w(forums topics sb_posts).include?(@controller.controller_name)
%w(forums topics sb_posts).include?(controller.controller_name)
end

def is_current_user_and_featured?(u)
Expand Down Expand Up @@ -109,74 +108,76 @@ def excerpt_with_jump(text, end_string = ' ...')
end

def page_title
divider = " | ".html_safe

app_base = configatron.community_name
tagline = " | #{configatron.community_tagline}"

tagline = " #{divider} #{configatron.community_tagline}"
title = app_base
case @controller.controller_name

case controller.controller_name
when 'base'
title += tagline
when 'pages'
if @page and @page.title
title = @page.title + ' &raquo; ' + app_base + tagline
end
title += tagline
when 'pages'
if @page and @page.title
title = @page.title + divider + app_base + tagline
end
when 'posts'
if @post and @post.title
title = @post.title + ' &raquo; ' + app_base + tagline
title += (@post.tags.empty? ? '' : " &laquo; "+:keywords.l+": " + @post.tags[0...4].join(', ') )
title = @post.title + divider + app_base + tagline
title += (@post.tags.empty? ? '' : "#{divider}#{:keywords.l}: " + @post.tags[0...4].join(', ') )
@canonical_url = user_post_url(@post.user, @post)
end
when 'users'
if @user && !@user.new_record? && @user.login
title = @user.login
title += ', ' + :expert_in.l + ' ' + @user.offerings.collect{|o| o.skill.name }.join(', ') if @user.vendor? and !@user.offerings.empty?
title += ' &raquo; ' + app_base + tagline
title += ", #{:expert_in.l} #{@user.offerings.collect{|o| o.skill.name }.join(', ')}" if @user.vendor? and !@user.offerings.empty?
title += divider + app_base + tagline
@canonical_url = user_url(@user)
else
title = :showing_users.l+' &raquo; ' + app_base + tagline
title = :showing_users.l+divider + app_base + tagline
end
when 'photos'
if @user and @user.login
title = :users_photos.l(:user => @user.login)+' &raquo; ' + app_base + tagline
title = :users_photos.l(:user => @user.login) + divider + app_base + tagline
end
when 'clippings'
if @user and @user.login
title = :user_clippings.l(:user => @user.login) + ' &raquo; ' + app_base + tagline
title = :user_clippings.l(:user => @user.login) + divider + app_base + tagline
end
when 'tags'
case @controller.action_name
case controller.action_name
when 'show'
if params[:type]
title = I18n.translate('all_' + params[:type].downcase.pluralize + '_tagged', :tag_name => @tags.map(&:name).join(', '))
else
title = :posts_photos_and_bookmarks.l(:name => @tags.map(&:name).join(', '))
end
title += ' (' + :related_tags.l + ': ' + @related_tags.join(', ') + ')' if @related_tags
title += ' | ' + app_base
title += " (#{:related_tags.l}: #{@related_tags.join(', ')})" if @related_tags
title += divider + app_base
@canonical_url = tag_url(URI.escape(@tags_raw, /[\/.?#]/)) if @tags_raw
else
title = 'Showing tags &raquo; ' + app_base + tagline
title = "Showing tags #{divider} #{app_base} #{tagline}"
end
when 'categories'
if @category and @category.name
title = :posts_photos_and_bookmarks.l(:name => @category.name) + ' &raquo; ' + app_base + tagline
title = :posts_photos_and_bookmarks.l(:name => @category.name) + divider + app_base + tagline
else
title = :showing_categories.l + ' &raquo; ' + app_base + tagline
title = :showing_categories.l + divider + app_base + tagline
end
when 'skills'
if @skill and @skill.name
title = :find_an_expert_in.l + ' ' + @skill.name + ' &raquo; ' + app_base + tagline
title = :find_an_expert_in.l + ' ' + @skill.name + divider + app_base + tagline
else
title = :find_experts.l + ' &raquo; ' + app_base + tagline
title = :find_experts.l + divider + app_base + tagline
end
when 'sessions'
title = :login.l + ' &raquo; ' + app_base + tagline
title = :login.l + divider + app_base + tagline
end

if @page_title
title = @page_title + ' &raquo; ' + app_base + tagline
title = @page_title + divider + app_base + tagline
elsif title == app_base
title = :showing.l + ' ' + @controller.controller_name + ' &raquo; ' + app_base + tagline
title = :showing.l + ' ' + controller.controller_name + divider + app_base + tagline
end

title
Expand All @@ -194,14 +195,15 @@ def add_friend_link(user = nil)
html += "<span style='display:none;' class='spinner'>"
html += image_tag 'spinner.gif', :plugin => "community_engine"
html += :requesting_friendship.l+" ...</span></span>"
html
html.html_safe
end

def topnav_tab(name, options)
classes = [options.delete(:class)]
classes << 'current' if options[:section] && (options.delete(:section).to_a.include?(@section))

"<li class='#{classes.join(' ')}'>" + link_to( "<span>"+name+"</span>", options.delete(:url), options) + "</li>"
string = "<li class='#{classes.join(' ')}'>" + link_to( content_tag(:span, name), options.delete(:url), options) + "</li>"
string.html_safe
end

# def format_post_totals(posts)
Expand All @@ -212,7 +214,7 @@ def more_comments_links(commentable)
html = link_to "&raquo; " + :all_comments.l, comments_url(commentable.class.to_s.underscore, commentable.to_param)
html += "<br />"
html += link_to "&raquo; " + :comments_rss.l, comments_url(commentable.class.to_s.underscore, commentable.to_param, :format => :rss)
html
html.html_safe
end

def more_user_comments_links(user = @user)
Expand Down Expand Up @@ -244,40 +246,34 @@ def feature_enabled?(feature)
end

def show_footer_content?
return true if (
current_page?(:controller => 'base', :action => 'site_index') ||
current_page?(:controller => 'posts', :action => 'show') ||
current_page?(:controller => 'categories', :action => 'show') ||
current_page?(:controller => 'users', :action => 'show')
)

return false
return true #you can override this in your app
end

def clippings_link
"javascript:(function() {d=document, w=window, e=w.getSelection, k=d.getSelection, x=d.selection, s=(e?e():(k)?k():(x?x.createRange().text:0)), e=encodeURIComponent, document.location='#{application_url}new_clipping?uri='+e(document.location)+'&title='+e(document.title)+'&selection='+e(s);} )();"
"javascript:(function() {d=document, w=window, e=w.getSelection, k=d.getSelection, x=d.selection, s=(e?e():(k)?k():(x?x.createRange().text:0)), e=encodeURIComponent, document.location='#{home_url}new_clipping?uri='+e(document.location)+'&title='+e(document.title)+'&selection='+e(s);} )();"
end

def paginating_links(paginator, options = {}, html_options = {})
if paginator.page_count > 1
name = options[:name] || PaginatingFind::Helpers::DEFAULT_OPTIONS[:name]

our_params = (options[:params] || params).clone

our_params.delete("authenticity_token")
our_params.delete("commit")

links = paginating_links_each(paginator, options) do |n|
our_params[name] = n
link_to(n, our_params, html_options.merge(:class => (paginator.page.eql?(n) ? 'active' : '')))
end
end

if options[:show_info].eql?(false)
(links || '')
else
content_tag(:div, pagination_info_for(paginator), :class => 'pagination_info') + (links || '')
end
will_paginate paginator
# if paginator.page_count > 1
# name = options[:name] || PaginatingFind::Helpers::DEFAULT_OPTIONS[:name]
#
# our_params = (options[:params] || params).clone
#
# our_params.delete("authenticity_token")
# our_params.delete("commit")
#
# links = paginating_links_each(paginator, options) do |n|
# our_params[name] = n
# link_to(n, our_params, html_options.merge(:class => (paginator.page.eql?(n) ? 'active' : '')))
# end
# end
#
# if options[:show_info].eql?(false)
# (links || '')
# else
# content_tag(:div, pagination_info_for(paginator), :class => 'pagination_info') + (links || '')
# end
end

def pagination_info_for(paginator, options = {})
Expand Down Expand Up @@ -366,6 +362,5 @@ def profile_completeness(user)
def possesive(user)
user.gender ? (user.male? ? :his.l : :her.l) : :their.l
end


end
6 changes: 1 addition & 5 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@ module UsersHelper
def friends?(user, friend)
Friendship.friends?(user, friend)
end

def random_greeting(user)
"#{:greetings.l.sort_by{rand}.first} #{user.login}!"
end


end
Loading

0 comments on commit bd5f7ff

Please sign in to comment.