Skip to content

Commit

Permalink
moving to 1.9.2, making backup of old rails 2 files
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex committed Mar 13, 2011
1 parent 059e915 commit d1f351a
Show file tree
Hide file tree
Showing 29 changed files with 2,082 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .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
49 changes: 49 additions & 0 deletions 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
4 changes: 2 additions & 2 deletions 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
Expand Down
98 changes: 98 additions & 0 deletions 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
40 changes: 40 additions & 0 deletions 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

43 changes: 43 additions & 0 deletions 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 =~ /<label/
%|<div class="fieldWithErrors">#{html_tag} <span class="error">#{[instance.error_message].join(', ')}</span></div>|.html_safe
else
html_tag
end
end

19 changes: 19 additions & 0 deletions config/environments/development.rb.rails2
@@ -0,0 +1,19 @@
# Settings specified here will take precedence over those in config/environment.rb

# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false

# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true

# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false

# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false

config.gem "rails-footnotes"
28 changes: 28 additions & 0 deletions config/environments/production.rb.rails2
@@ -0,0 +1,28 @@
# Settings specified here will take precedence over those in config/environment.rb

# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true

# Full error reports are disabled and caching is turned on
config.action_controller.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.action_view.cache_template_loading = true

# See everything in the log (default is :info)
# config.log_level = :debug

# Use a different logger for distributed setups
# config.logger = SyslogLogger.new

# Use a different cache store in production
config.cache_store = :mem_cache_store, 'localhost:11211'

# Enable serving of images, stylesheets, and javascripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"

# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false

# Enable threaded mode
# config.threadsafe!
24 changes: 24 additions & 0 deletions config/routes.rb.rails2
@@ -0,0 +1,24 @@
ActionController::Routing::Routes.draw do |map|
map.error '/error', :controller => "welcome", :action => "error"

map.root :controller => "welcome"
map.resources :users, :collection => { :follow => :post }
map.resources :tweets, :collection => {:my => :get, :refresh => :post, :by_hashtag => :post}
map.resources :categories, :as => :categories, :member => {:create_on_twitter => :post}
map.resources :configurations
map.resources :subscriptions
map.resources :tags, :only => [:index, :show], :collection => { :by_period => :post }
map.resource :session, :collection => {:callback => :get}
map.resource :poll

map.namespace :admin do |admin|
admin.root :controller => 'welcome'
admin.resources :polls
end

map.login "/login", :controller => "sessions", :action => "create"
map.logout "/logout", :controller => "sessions", :action => "destroy"
map.settings "/settings", :controller => "settings", :action => "index"
map.deactivate "/deactivate", :controller => "users", :action => "deactivate"
map.about '/about', :controller => 'about', :action => 'index'
end
2 changes: 2 additions & 0 deletions doc/README_FOR_APP.rails2
@@ -0,0 +1,2 @@
Use this README file to introduce your application and point to useful places in the API for learning more.
Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
19 changes: 19 additions & 0 deletions o-rdoc/rackup
@@ -0,0 +1,19 @@
#!/home/vortex/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'rack' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0"

if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end

gem 'rack', version
load Gem.bin_path('rack', 'rackup', version)
19 changes: 19 additions & 0 deletions o-rdoc/rails
@@ -0,0 +1,19 @@
#!/home/vortex/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'rails' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0"

if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end

gem 'rails', version
load Gem.bin_path('rails', 'rails', version)
20 changes: 20 additions & 0 deletions vendor/plugins/rails_upgrade/MIT-LICENSE
@@ -0,0 +1,20 @@
Copyright (c) 2010 Jeremy McAnally

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 comments on commit d1f351a

Please sign in to comment.