From d1f351afa7443f37a9635bdfb9de188e04d6c33b Mon Sep 17 00:00:00 2001 From: Peco Danajlovski Date: Sun, 13 Mar 2011 17:32:10 +0100 Subject: [PATCH] moving to 1.9.2, making backup of old rails 2 files --- .gitignore.rails2 | 16 + .../application_controller.rb.rails2 | 49 ++ app/controllers/polls_controller.rb | 4 +- app/helpers/application_helper.rb.rails2 | 98 ++++ config/database.yml.rails2 | 40 ++ config/environment.rb.rails2 | 43 ++ config/environments/development.rb.rails2 | 19 + config/environments/production.rb.rails2 | 28 ++ config/routes.rb.rails2 | 24 + doc/README_FOR_APP.rails2 | 2 + o-rdoc/rackup | 19 + o-rdoc/rails | 19 + vendor/plugins/rails_upgrade/MIT-LICENSE | 20 + vendor/plugins/rails_upgrade/README | 20 + vendor/plugins/rails_upgrade/Rakefile | 22 + vendor/plugins/rails_upgrade/init.rb | 2 + vendor/plugins/rails_upgrade/install.rb | 38 ++ .../rails_upgrade/lib/application_checker.rb | 472 ++++++++++++++++++ .../rails_upgrade/lib/gemfile_generator.rb | 95 ++++ .../lib/new_configuration_generator.rb | 51 ++ .../rails_upgrade/lib/rails_upgrade.rb | 0 .../rails_upgrade/lib/routes_upgrader.rb | 349 +++++++++++++ .../lib/tasks/rails_upgrade_tasks.rake | 78 +++ .../test/application_checker_test.rb | 293 +++++++++++ .../test/gemfile_generator_test.rb | 72 +++ .../test/new_configuration_generator_test.rb | 63 +++ .../test/routes_upgrader_test.rb | 142 ++++++ .../plugins/rails_upgrade/test/test_helper.rb | 5 + vendor/plugins/rails_upgrade/uninstall.rb | 1 + 29 files changed, 2082 insertions(+), 2 deletions(-) create mode 100644 .gitignore.rails2 create mode 100644 app/controllers/application_controller.rb.rails2 create mode 100644 app/helpers/application_helper.rb.rails2 create mode 100644 config/database.yml.rails2 create mode 100644 config/environment.rb.rails2 create mode 100644 config/environments/development.rb.rails2 create mode 100644 config/environments/production.rb.rails2 create mode 100644 config/routes.rb.rails2 create mode 100644 doc/README_FOR_APP.rails2 create mode 100755 o-rdoc/rackup create mode 100755 o-rdoc/rails create mode 100644 vendor/plugins/rails_upgrade/MIT-LICENSE create mode 100644 vendor/plugins/rails_upgrade/README create mode 100644 vendor/plugins/rails_upgrade/Rakefile create mode 100644 vendor/plugins/rails_upgrade/init.rb create mode 100644 vendor/plugins/rails_upgrade/install.rb create mode 100644 vendor/plugins/rails_upgrade/lib/application_checker.rb create mode 100644 vendor/plugins/rails_upgrade/lib/gemfile_generator.rb create mode 100644 vendor/plugins/rails_upgrade/lib/new_configuration_generator.rb create mode 100644 vendor/plugins/rails_upgrade/lib/rails_upgrade.rb create mode 100644 vendor/plugins/rails_upgrade/lib/routes_upgrader.rb create mode 100644 vendor/plugins/rails_upgrade/lib/tasks/rails_upgrade_tasks.rake create mode 100644 vendor/plugins/rails_upgrade/test/application_checker_test.rb create mode 100644 vendor/plugins/rails_upgrade/test/gemfile_generator_test.rb create mode 100644 vendor/plugins/rails_upgrade/test/new_configuration_generator_test.rb create mode 100644 vendor/plugins/rails_upgrade/test/routes_upgrader_test.rb create mode 100644 vendor/plugins/rails_upgrade/test/test_helper.rb create mode 100644 vendor/plugins/rails_upgrade/uninstall.rb diff --git a/.gitignore.rails2 b/.gitignore.rails2 new file mode 100644 index 0000000..933701f --- /dev/null +++ b/.gitignore.rails2 @@ -0,0 +1,16 @@ +.DS_Store +log/*.log +tmp/**/* +config/database.yml +config/twitter.yml +config/initializers/site_keys.rb +db/*.sqlite3 +*~ +*.swp +*.swo +.project +db/schema.rb +.idea +.sass-cache +mkmf.log +.rvmrc diff --git a/app/controllers/application_controller.rb.rails2 b/app/controllers/application_controller.rb.rails2 new file mode 100644 index 0000000..c2e231c --- /dev/null +++ b/app/controllers/application_controller.rb.rails2 @@ -0,0 +1,49 @@ +# Filters added to this controller apply to all controllers in the application. +# Likewise, all the methods added will be available for all controllers. + +class ApplicationController < ActionController::Base + include Twitter::AuthenticationHelpers + + helper :all # include all helpers, all the time + protect_from_forgery # See ActionController::RequestForgeryProtection for details + + # Filters + before_filter :load_configuration + + # Scrub sensitive parameters from your log + filter_parameter_logging :password + + def require_admin + if !current_user || !current_user.is_admin? + flash[:notice] = "You must be admin to access requested page" + redirect_to root_url + return false + end + end + + private + + def get_filtered_tweets + @filtered_tweets = Tweet.find(:all, :conditions => ["text like ?", "%#{@configuration.try(:today_topic)}%"], :order => 'original_tweet_id DESC', :limit => G140[:tweets_per_hashtag], :include => :user) + end + + def get_trending_tags + unless session[:trending_from].nil? + from_when = session[:trending_from] + else + from_when = G140[:default_trending_filter] + end + + unless from_when == 0 + @trending_tags = Tag.trending_from(from_when.day.ago) + else + @trending_tags = Tag.trending_tags + end + + end + + def load_configuration + @configuration = Configuration.first + end + +end diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 83c0c08..ce5e88e 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -1,7 +1,7 @@ class PollsController < ApplicationController before_filter :authenticate, :only => :create - before_filter :get_filtered_tweets, :only => :show - before_filter :get_trending_tags, :only => [:index, :show] + before_filter :get_filtered_tweets, :only => [:show, :create] + before_filter :get_trending_tags, :only => [:index, :show, :create] def show @poll = Poll.published.first diff --git a/app/helpers/application_helper.rb.rails2 b/app/helpers/application_helper.rb.rails2 new file mode 100644 index 0000000..a66ed10 --- /dev/null +++ b/app/helpers/application_helper.rb.rails2 @@ -0,0 +1,98 @@ +# Methods added to this helper will be available to all templates in the application. +module ApplicationHelper + + include WillPaginate::ViewHelpers + + def will_paginate_with_i18n(collection, options = {}) + will_paginate_without_i18n(collection, options.merge(:previous_label => I18n.t('pagination.previous'), :next_label => I18n.t('pagination.next'))) + end + alias_method_chain :will_paginate, :i18n + + def twitter_path screen_name + "http://twitter.com/#{screen_name}" + end + + def tweet_url(tweet) + "http://twitter.com/#{tweet.user.screen_name}/status/#{tweet.original_tweet_id}" + end + + # Turns all hashtags into clickable links. If a block is given, each url + # is yielded and the result is used as the link text. + def auto_link_hashtags(text) + return '' if text.blank? + + result = text + tags = text.gsub(/ ?#(\w+)/) + tags.each do |entry| + stripped_entry = entry.strip.gsub(/#|@/, "") + tag = Tag.find_by_name(stripped_entry) + + unless tag.nil? + link = link_to '#' + tag.name, tag + result = result.gsub(entry.strip, link) + end + end + + return result + end + + def auto_link_screen_names(text) + return '' if text.blank? + + result = text + screen_names = text.gsub(/ ?@(\w+)/) + screen_names.each do |entry| + stripped_entry = entry.strip.gsub(/#|@/, "") + + unless entry.nil? + link = link_to '@' + stripped_entry, "http://twitter.com/#{stripped_entry}", :target => '_blank' + result = result.gsub(entry.strip, link) + end + end + + return result + end + + def auto_link_resources(text) + auto_link_screen_names(auto_link_hashtags(text)) + end + + def is_trending_filter_selected(days_count) + saved_count = session[:trending_from] + if saved_count == days_count + return "selected" + else + return "" + end + end + + +# def auto_link_urls(text, html_options = {}) +# link_attributes = html_options.stringify_keys +# text.gsub(AUTO_LINK_RE) do +# href = $& +# punctuation = '' +# left, right = $`, $' +# # detect already linked URLs and URLs in the middle of a tag +# if left =~ /<[^>]+$/ && right =~ /^[^>]*>/ +# # do not change string; URL is already linked +# href +# else +# # don't include trailing punctuation character as part of the URL +# if href.sub!(/[^\w\/-]$/, '') and punctuation = $& and opening = BRACKETS[punctuation] +# if href.scan(opening).size > href.scan(punctuation).size +# href << punctuation +# punctuation = '' +# end +# end +# +# link_text = block_given?? yield(href) : href +# href = 'http://' + href unless href =~ %r{^[a-z]+://}i +# +# content_tag(:a, h(link_text), link_attributes.merge('href' => href)) + punctuation +# end +# end +# end + + +end diff --git a/config/database.yml.rails2 b/config/database.yml.rails2 new file mode 100644 index 0000000..aeac15e --- /dev/null +++ b/config/database.yml.rails2 @@ -0,0 +1,40 @@ +# MySQL. Versions 4.1 and 5.0 are recommended. +# +# Install the MySQL driver: +# gem install mysql +# On Mac OS X: +# sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql +# On Mac OS X Leopard: +# sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config +# This sets the ARCHFLAGS environment variable to your native architecture +# On Windows: +# gem install mysql +# Choose the win32 build. +# Install MySQL and put its /bin directory on your path. +# +# And be sure to use new-style password hashing: +# http://dev.mysql.com/doc/refman/5.0/en/old-client.html +defaults: &defaults + adapter: mysql + encoding: utf8 + username: root + password: testroot + host: localhost + +development: + database: 140mk_dev + <<: *defaults +test: &TEST + database: 140mk_test + <<: *defaults +production: + database: 140mk_live + <<: *defaults + +cucumber: &CUCUMBER + <<: *TEST +culerity_development: + <<: *CUCUMBER +culerity_continuousintegration: + <<: *CUCUMBER + diff --git a/config/environment.rb.rails2 b/config/environment.rb.rails2 new file mode 100644 index 0000000..105337e --- /dev/null +++ b/config/environment.rb.rails2 @@ -0,0 +1,43 @@ +# Be sure to restart your server when you modify this file + +# Specifies gem version of Rails to use when vendor/rails is not present +RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION + +# Bootstrap the Rails environment, frameworks, and default configuration +require File.join(File.dirname(__FILE__), 'boot') + +Rails::Initializer.run do |config| + # Specify gems that this application depends on and have them installed with rake gems:install + # config.gem 'twitter', :version => '0.7.11' + config.gem 'twitter', :version => '0.9.12' + config.gem 'will_paginate', :version => '~> 2.3.11', :source => 'http://gemcutter.org' + config.gem 'compass' + config.gem 'compass-960-plugin', :lib => false + config.gem 'compass-colors' + config.gem 'fancy-buttons' + config.gem 'simple-navigation', :lib => 'simple_navigation' + config.gem 'jrails' + config.gem 'formtastic', :version => '0.9.8' + config.gem 'jintastic', :version => '1.1.0' + config.gem 'responders', :version => "= 0.4.2" + config.gem 'inherited_resources', :version => '= 1.0.2' + config.gem 'cyrillizer' + config.gem 'newrelic_rpm' + config.gem 'web-app-theme', :version => '0.5.3', :lib => 'web_app_theme' + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. + config.time_zone = 'UTC' + + # Default locale + config.i18n.default_locale = :mk +end + +ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| + if html_tag =~ /