update to rails 2.2.2

This commit is contained in:
Eugene Korbut 2009-01-08 05:55:58 +10:00
parent 51b79e7298
commit 789f813b42
24 changed files with 6178 additions and 2698 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
log
config/database.yml
.*.sw?

View file

@ -5,8 +5,6 @@ class ApplicationController < ActionController::Base
before_filter :user_login_filter
before_filter :add_scripts
model :customer
protected
def secure_user?() true end
def secure_cust?() false end
@ -21,7 +19,7 @@ class ApplicationController < ActionController::Base
def user_login_filter
if (secure_user? or secure_cust? )and logged_user.nil?
@session["return_to"] = @request.request_uri
session["return_to"] = request.request_uri
redirect_to :controller=>"/login", :action => "index"
return false
end
@ -30,24 +28,24 @@ class ApplicationController < ActionController::Base
alias login_required user_login_filter
def logged_user # returns customer id
@session['user']
session['user']
end
def logged_customer
@session['user']
session['user']
end
def localize
# We will use instance vars for the locale so we can make use of them in
# the templates.
@charset = 'utf-8'
@headers['Content-Type'] = "text/html; charset=#{@charset}"
headers['Content-Type'] = "text/html; charset=#{@charset}"
# Here is a very simplified approach to extract the prefered language
# from the request. If all fails, just use 'en_EN' as the default.
temp = if @request.env['HTTP_ACCEPT_LANGUAGE'].nil?
temp = if request.env['HTTP_ACCEPT_LANGUAGE'].nil?
[]
else
@request.env['HTTP_ACCEPT_LANGUAGE'].split(',').first.split('-') rescue []
request.env['HTTP_ACCEPT_LANGUAGE'].split(',').first.split('-') rescue []
end
language = temp.slice(0)
dialect = temp.slice(1)

View file

@ -1,8 +1,6 @@
require 'ezcrypto'
class LoginController < ApplicationController
model :customer
def index
if not(logged_user.nil?)
redirect_to :controller =>"webmail", :action=>"index"
@ -12,17 +10,17 @@ class LoginController < ApplicationController
end
def authenticate
if user = auth(@params['login_user']["email"], @params['login_user']["password"])
@session["user"] = user.id
if user = auth(params['login_user']["email"], params['login_user']["password"])
session["user"] = user.id
if CDF::CONFIG[:crypt_session_pass]
@session["wmp"] = EzCrypto::Key.encrypt_with_password(CDF::CONFIG[:encryption_password], CDF::CONFIG[:encryption_salt], @params['login_user']["password"])
session["wmp"] = EzCrypto::Key.encrypt_with_password(CDF::CONFIG[:encryption_password], CDF::CONFIG[:encryption_salt], params['login_user']["password"])
else
# dont use crypt
@session["wmp"] = @params['login_user']["password"]
session["wmp"] = params['login_user']["password"]
end
if @session["return_to"]
redirect_to_path(@session["return_to"])
@session["return_to"] = nil
if session["return_to"]
redirect_to_path(session["return_to"])
session["return_to"] = nil
else
redirect_to :action=>"index"
end

View file

@ -8,12 +8,12 @@
<link rel="stylesheet" href="/stylesheets/mailr.css" type="text/css" media="screen" />
</head>
<body>
<div id="login" <%= 'class="login_error"' if @flash['error'] %>>
<div id="login" <%= 'class="login_error"' if flash['error'] %>>
<h1>Mailr</h1>
<% if @flash['error'] %>
<div id="SystemError"><%= @flash['error'] %></div>
<% elsif @flash['status'] %>
<div id="SystemStatus"><%= @flash['status'] %></div>
<% if flash['error'] %>
<div id="SystemError"><%= flash['error'] %></div>
<% elsif flash['status'] %>
<div id="SystemStatus"><%= flash['status'] %></div>
<% end %>
<form action="<%=url_for(:controller => 'login', :action => 'authenticate')%>" method="post">
<table class="form_layout">

View file

@ -5,7 +5,7 @@ require 'mail2screen'
require 'ezcrypto'
class Webmail::WebmailController < ApplicationController
uses_component_template_root
# uses_component_template_root
# Administrative functions
before_filter :login_required
@ -18,7 +18,7 @@ class Webmail::WebmailController < ApplicationController
after_filter :close_imap_session
model :filter, :expression, :mail_pref, :customer
# model :filter, :expression, :mail_pref, :customer
BOOL_ON = "on"

View file

@ -1,17 +1,109 @@
unless defined?(RAILS_ROOT)
root_path = File.join(File.dirname(__FILE__), '..')
unless RUBY_PLATFORM =~ /mswin32/
require 'pathname'
root_path = Pathname.new(root_path).cleanpath.to_s
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
defined? Rails::Initializer
end
def pick_boot
(vendor_rails? ? VendorBoot : GemBoot).new
end
def vendor_rails?
File.exist?("#{RAILS_ROOT}/vendor/rails")
end
def preinitialize
load(preinitializer_path) if File.exist?(preinitializer_path)
end
def preinitializer_path
"#{RAILS_ROOT}/config/preinitializer.rb"
end
end
class Boot
def run
load_initializer
Rails::Initializer.run(:set_load_path)
end
end
class VendorBoot < Boot
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
end
end
class GemBoot < Boot
def load_initializer
self.class.load_rubygems
load_rails_gem
require 'initializer'
end
def load_rails_gem
if version = self.class.gem_version
gem 'rails', version
else
gem 'rails'
end
rescue Gem::LoadError => load_error
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
exit 1
end
class << self
def rubygems_version
Gem::RubyGemsVersion rescue nil
end
def gem_version
if defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION
elsif ENV.include?('RAILS_GEM_VERSION')
ENV['RAILS_GEM_VERSION']
else
parse_gem_version(read_environment_rb)
end
end
def load_rubygems
require 'rubygems'
min_version = '1.3.1'
unless rubygems_version >= min_version
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
exit 1
end
rescue LoadError
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
exit 1
end
def parse_gem_version(text)
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
end
private
def read_environment_rb
File.read("#{RAILS_ROOT}/config/environment.rb")
end
end
end
RAILS_ROOT = root_path
end
if File.directory?("#{RAILS_ROOT}/vendor/rails")
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
else
require 'rubygems'
require 'initializer'
end
Rails::Initializer.run(:set_load_path)
# All that for this:
Rails.boot!

View file

@ -20,7 +20,7 @@ Rails::Initializer.run do |config|
# Use the database for sessions instead of the file system
# (create the session table with 'rake create_sessions_table')
config.action_controller.session_store = :active_record_store
#config.action_controller.session_store = :active_record_store
# Enable page/fragment caching by setting a file-based store
# (remember to create the caching directory and make it readable to the application)
@ -37,6 +37,7 @@ Rails::Initializer.run do |config|
# config.active_record.schema_format = :ruby
# See Rails::Configuration for more options
config.action_controller.session = { :session_key => "_mailr_session", :secret => "123456789012345678901234567890" }
end
# Add new inflection rules using the following format

View file

@ -6,9 +6,6 @@ config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Enable the breakpoint server that script/breakpointer connects to
config.breakpoint_server = true
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false

View file

@ -0,0 +1,65 @@
class Init < ActiveRecord::Migration
def self.up
create_table :customers do |t|
t.string :fname, :lname, :email
t.integer :customer_id
t.timestamps
end
create_table :filters do |t|
t.string :name, :destination_folder
t.integer :customer_id, :order_num
t.timestamps
end
create_table :expressions do |t|
t.string :field_name, :operator, :expr_value
t.integer :filter_id
t.boolean :case_sensitive
t.timestamps
end
create_table :mail_prefs do |t|
t.string :mail_type
t.integer :wm_rows, :customer_id
t.boolean :check_external_mail
t.timestamps
end
create_table :contacts do |t|
t.string :fname, :lname, :email, :hphone, :wphone, :mobile, :fax
t.text :notes
t.integer :customer_id
t.timestamps
end
create_table :contact_groups do |t|
t.string :name
t.integer :customer_id
t.timestamps
end
create_table :contact_contact_groups do |t|
t.integer :contact_id, :contact_group_id
t.timestamps
end
create_table :imap_messages do |t|
t.string :folder_name, :username, :msg_id, :from, :from_flat, :to, :to_flat, :subject, :content_type
t.integer :uid, :size
t.boolean :unread
t.datetime :date
end
end
def self.down
drop_table :imap_messages
drop_table :contact_contact_groups
drop_table :contact_groups
drop_table :contacts
drop_table :mail_prefs
drop_table :expressions
drop_table :filters
drop_table :customers
end
end

95
db/schema.rb Normal file
View file

@ -0,0 +1,95 @@
# This file is auto-generated from the current state of the database. Instead of editing this file,
# please use the migrations feature of Active Record to incrementally modify your database, and
# then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your database schema. If you need
# to create the application database on another system, you should be using db:schema:load, not running
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20090107193228) do
create_table "contact_contact_groups", :force => true do |t|
t.integer "contact_id"
t.integer "contact_group_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "contact_groups", :force => true do |t|
t.string "name"
t.integer "customer_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "contacts", :force => true do |t|
t.string "fname"
t.string "lname"
t.string "email"
t.string "hphone"
t.string "wphone"
t.string "mobile"
t.string "fax"
t.text "notes"
t.integer "customer_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "customers", :force => true do |t|
t.string "fname"
t.string "lname"
t.string "email"
t.integer "customer_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "expressions", :force => true do |t|
t.string "field_name"
t.string "operator"
t.string "expr_value"
t.integer "filter_id"
t.boolean "case_sensitive"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "filters", :force => true do |t|
t.string "name"
t.string "destination_folder"
t.integer "customer_id"
t.integer "order_num"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "imap_messages", :force => true do |t|
t.string "folder_name"
t.string "username"
t.string "msg_id"
t.string "from"
t.string "from_flat"
t.string "to"
t.string "to_flat"
t.string "subject"
t.string "content_type"
t.integer "uid"
t.integer "size"
t.boolean "unread"
t.datetime "date"
end
create_table "mail_prefs", :force => true do |t|
t.string "mail_type"
t.integer "wm_rows"
t.integer "customer_id"
t.boolean "check_external_mail"
t.datetime "created_at"
t.datetime "updated_at"
end
end

View file

@ -1,10 +0,0 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
require "dispatcher"
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
Dispatcher.dispatch

View file

@ -1,24 +0,0 @@
#!/usr/bin/env ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
# and the GC period is nil (turned off). A reasonable number of requests
# could range from 10-100 depending on the memory footprint of your app.
#
# Example:
# # Default log path, normal GC behavior.
# RailsFCGIHandler.process!
#
# # Default log path, 50 requests between GC.
# RailsFCGIHandler.process! nil, 50
#
# # Custom log path, normal GC behavior.
# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
#
require File.dirname(__FILE__) + "/../config/environment"
require 'fcgi_handler'
RailsFCGIHandler.process!

View file

@ -1,10 +0,0 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
require "dispatcher"
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
Dispatcher.dispatch

View file

@ -1,78 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Rails: Welcome on board</title>
<style>
body { background-color: #fff; color: #333; }
body, p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 12px;
line-height: 18px;
}
li {
margin-bottom: 7px;
}
pre {
background-color: #eee;
padding: 10px;
font-size: 11px;
}
a { color: #000; }
a:visited { color: #666; }
a:hover { color: #fff; background-color:#000; }
</style>
</head>
<body>
<h1>Congratulations, you've put Ruby on Rails!</h1>
<p><b>Before you move on</b>, verify that the following conditions have been met:</p>
<ol>
<li>The log and public directories must be writable to the web server (<code>chmod -R 775 log</code> and <code>chmod -R 775 public</code>).
<li>
The shebang line in the public/dispatch* files must reference your Ruby installation. <br/>
You might need to change it to <code>#!/usr/bin/env ruby</code> or point directly at the installation.
</li>
<li>
Rails on Apache needs to have the cgi handler and mod_rewrite enabled. <br/>
Somewhere in your httpd.conf, you should have:<br/>
<code>AddHandler cgi-script .cgi</code><br/>
<code>LoadModule rewrite_module libexec/httpd/mod_rewrite.so</code><br/>
<code>AddModule mod_rewrite.c</code>
</li>
</ol>
<p>Take the following steps to get started:</p>
<ol>
<li>Create empty development and test databases for your application.<br/>
<small>Recommendation: Use *_development and *_test names, such as basecamp_development and basecamp_test</small><br/>
<small>Warning: Don't point your test database at your development database, it'll destroy the latter on test runs!</small>
<li>Edit config/database.yml with your database settings.
<li>Create controllers and models using the generator in <code>script/generate</code> <br/>
<small>Help: Run the generator with no arguments for documentation</small>
<li>See all the tests run by running <code>rake</code>.
<li>Develop your Rails application!
<li>Setup Apache with <a href="http://www.fastcgi.com">FastCGI</a> (and <a href="http://raa.ruby-lang.org/list.rhtml?name=fcgi">Ruby bindings</a>), if you need better performance
<li>Remove the dispatches you don't use (so if you're on FastCGI, delete/move dispatch.rb, dispatch.cgi and gateway.cgi)</li>
</ol>
<p>
Trying to setup a default page for Rails using Routes? You'll have to delete this file (public/index.html) to get under way. Then define a new route in <tt>config/routes.rb</tt> of the form:
<pre> map.connect '', :controller => 'wiki/page', :action => 'show', :title => 'Welcome'</pre>
</p>
<p>
Having problems getting up and running? First try debugging it yourself by looking at the log files. <br/>
Then try the friendly Rails community <a href="http://www.rubyonrails.org">on the web</a> or <a href="http://www.rubyonrails.org/show/IRC">on IRC</a>
(<a href="irc://irc.freenode.net/#rubyonrails">FreeNode#rubyonrails</a>).
</p>
</body>
</html>

View file

@ -0,0 +1,2 @@
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

4
script/about Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about'

3
script/dbconsole Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/dbconsole'

3
script/performance/request Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/request'

3
script/plugin Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'

3
script/process/inspector Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'