diff --git a/app/views/deployments/_lock_info.html.erb b/app/views/deployments/_lock_info.html.erb
index ad66c8bb5..ce7cf7558 100644
--- a/app/views/deployments/_lock_info.html.erb
+++ b/app/views/deployments/_lock_info.html.erb
@@ -3,7 +3,7 @@
<% if stage.locking_deployment %>
- This stage is being deployed by <%= link_to h(stage.locking_deployment.user.login), user_path(stage.locking_deployment.user) %> who executed <%=link_to h(stage.locking_deployment.task), project_stage_deployment_path(current_project, current_stage, stage.locking_deployment) %> at <%=h stage.locking_deployment.created_at.to_s(:log) %>
+ This stage is being deployed by <%= link_to stage.locking_deployment.user.login, user_path(stage.locking_deployment.user) %> who executed <%=link_to stage.locking_deployment.task, project_stage_deployment_path(current_project, current_stage, stage.locking_deployment) %> at <%= stage.locking_deployment.created_at.to_s(:log) %>
Override locking and deploy anyhow?
diff --git a/app/views/deployments/_status.html.erb b/app/views/deployments/_status.html.erb
index ddbb59977..37a64c933 100644
--- a/app/views/deployments/_status.html.erb
+++ b/app/views/deployments/_status.html.erb
@@ -3,14 +3,14 @@
<% if current_user.admin? || current_user == @user %>
@@ -52,11 +52,9 @@
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
<%= link_to "Manage users", users_path, :style => "float:right", :class => "arrow_link" %>
<%= link_to "Users", users_path %> >
User <%= link_to @user.login, user_path(@user) %>
- <% end %>
<% end %>
<% content_for(:page_title) do %>
diff --git a/config.ru b/config.ru
new file mode 100644
index 000000000..6166449b9
--- /dev/null
+++ b/config.ru
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run Www::Application
diff --git a/config/application.rb b/config/application.rb
new file mode 100644
index 000000000..8429fd41b
--- /dev/null
+++ b/config/application.rb
@@ -0,0 +1,92 @@
+require File.expand_path('../boot', __FILE__)
+
+# load Webistrano configuration
+require File.expand_path('../webistrano_config', __FILE__)
+
+# moved fro preinitializer
+# is this necessary
+begin
+ require "rubygems"
+ require "bundler"
+rescue LoadError
+ raise "Could not load the bundler gem. Install it with `gem install bundler`."
+end
+
+if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
+ raise RuntimeError, "Your bundler version is too old for Rails 2.3." +
+ "Run `gem install bundler` to upgrade."
+end
+
+begin
+ # Set up load paths for all bundled gems
+ ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
+ Bundler.setup
+rescue Bundler::GemNotFound
+ raise RuntimeError, "Bundler couldn't find some gems." +
+ "Did you run `bundle install`?"
+end
+####
+
+require 'rails/all'
+
+# If you have a Gemfile, require the gems listed there, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(:default, Rails.env) if defined?(Bundler)
+
+module Www
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Custom directories with classes and modules you want to be autoloadable.
+ # config.autoload_paths += %W(#{config.root}/extras)
+ config.autoload_paths << "#{Rails.root}/lib"
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named.
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+ #config.plugins = [ :browser_filters, :exception_notification, :multiple_select, :query_trace,
+ # :restful_authentication, :rubycas_client, :version_fu ]
+ config.plugins = [ :browser_filters, :version_fu, :rails_upgrade]
+
+ # Activate observers that should always be running.
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # 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. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+ config.time_zone = 'UTC'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
+
+ # JavaScript files you want as :defaults (application.js is always included).
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
+
+ # Configure the default encoding used in templates for Ruby 1.9.
+ config.encoding = "utf-8"
+
+ # Configure sensitive parameters which will be filtered from the log file.
+ config.filter_parameters += [:password]
+
+ config.action_dispatch.session = {
+ :key => '_webistrano_session',
+ :secret => WebistranoConfig[:session_secret]
+ }
+
+ end
+end
+
+require 'open4'
+require 'capistrano/cli'
+require 'syntax/convertors/html'
+
+# from environment.rb needed?
+# delete cached stylesheet on boot in order to delete stale versions
+#File.delete("#{Rails.root.to_s}/public/stylesheets/application.css") if File.exists?("#{Rails.root.to_s}/public/stylesheets/application.css")
+
+# set default time_zone to UTC
+#ENV['TZ'] = 'UTC'
+#Time.zone = 'UTC'
diff --git a/config/boot.rb b/config/boot.rb
index 753f212e1..4489e5868 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -1,123 +1,6 @@
-# Don't change this file!
-# Configure your app in config/environment.rb and config/environments/*.rb
+require 'rubygems'
-RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
+# Set up gems listed in the Gemfile.
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
-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 if defined? Gem::RubyGemsVersion
- 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.1.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
-end
-
-class Rails::Boot
- def run
- load_initializer
-
- Rails::Initializer.class_eval do
- def load_gems
- @bundler_loaded ||= Bundler.require :default, Rails.env
- end
- end
-
- Rails::Initializer.run(:set_load_path)
- end
-end
-
-# All that for this:
-Rails.boot!
+require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
diff --git a/config/database.yml.sample b/config/database.yml.sample
index b00ae505e..9378af0c0 100644
--- a/config/database.yml.sample
+++ b/config/database.yml.sample
@@ -1,36 +1,39 @@
-# MySQL (default setup). Versions 4.1 and 5.0 are recommended.
+# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
-# gem install mysql
-# On MacOS X:
-# gem install mysql -- --include=/usr/local/lib
-# On Windows:
-# gem install mysql
-# Choose the win32 build.
-# Install MySQL and put its /bin directory on your path.
+# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
- adapter: mysql
- database: webistrano_development
- username: root
- password:
- socket: /tmp/mysql.sock
+ adapter: mysql2
+ encoding: utf8
+ reconnect: false
+ database: webistrano_dev
+ pool: 5
+ username: webistrano
+ password: master
+ socket: /var/run/mysqld/mysqld.sock
-# Warning: The database defined as 'test' will be erased and
-# re-generated from your development database when you run 'rake'.
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
- adapter: mysql
+ adapter: mysql2
+ encoding: utf8
+ reconnect: false
database: webistrano_test
- username: root
- password:
- socket: /tmp/mysql.sock
+ pool: 5
+ username: webistrano
+ password: master
+ socket: /var/run/mysqld/mysqld.sock
production:
- adapter: mysql
- database: webistrano_production
- username: root
- password:
- socket: /tmp/mysql.sock
+ adapter: mysql2
+ encoding: utf8
+ reconnect: false
+ database: webistrano_prod
+ pool: 5
+ username: webistrano
+ password: master
+ socket: /var/run/mysqld/mysqld.sock
diff --git a/config/environment.rb b/config/environment.rb
index 5f95832a0..ab06d2105 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -1,49 +1,4 @@
-# Be sure to restart your server when you modify this file
-
-# Uncomment below to force Rails into production mode when
-# you don't control web/app server and can't set it the proper way
-# ENV['RAILS_ENV'] ||= 'production'
-
-# Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.3.11' unless defined? RAILS_GEM_VERSION
-
-# Bootstrap the Rails environment, frameworks, and default configuration
-require File.join(File.dirname(__FILE__), 'boot')
-
-# load Webistrano configuration
-require "#{RAILS_ROOT}/config/webistrano_config"
-
-Rails::Initializer.run do |config|
-
- # Your secret key for verifying cookie session data integrity.
- # If you change this key, all old sessions will become invalid!
- # Make sure the secret is at least 30 characters and all random,
- # no regular words or you'll be exposed to dictionary attacks.
- config.action_controller.session = {
- :key => '_webistrano_session',
- :secret => WebistranoConfig[:session_secret]
- }
-
- # Make Active Record use UTC-base instead of local time
- config.time_zone = 'UTC'
-
- config.gem 'net-ssh', :version => '2.0.15', :lib => 'net/ssh'
- config.gem 'net-scp', :version => '1.0.2', :lib => 'net/scp'
- config.gem 'net-sftp', :version => '2.0.2', :lib => 'net/sftp'
- config.gem 'net-ssh-gateway', :version => '1.0.1', :lib => 'net/ssh/gateway'
- config.gem 'capistrano', :version => '2.5.9'
- config.gem 'highline', :version => '1.5.1'
- config.gem 'open4', :version => '0.9.3'
- config.gem 'syntax', :version => '1.0.0'
-end
-
-require 'open4'
-require 'capistrano/cli'
-require 'syntax/convertors/html'
-
-# delete cached stylesheet on boot in order to delete stale versions
-File.delete("#{RAILS_ROOT}/public/stylesheets/application.css") if File.exists?("#{RAILS_ROOT}/public/stylesheets/application.css")
-
-# set default time_zone to UTC
-ENV['TZ'] = 'UTC'
-Time.zone = 'UTC'
\ No newline at end of file
+# Load the rails application
+require File.expand_path('../application', __FILE__)
+# Initialize the rails application
+Www::Application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
index d81d692ba..64f183ae8 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -1,17 +1,31 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Www::Application.configure do
+ # Settings specified here will take precedence over those in config/application.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
+ # 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
+ # 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_controller.perform_caching = false
-config.action_view.debug_rjs = true
+ # Show full error reports and disable caching
+ config.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
+ # Don't care if the mailer can't send
+ config.action_mailer.raise_delivery_errors = false
+
+ # Print deprecation notices to the Rails logger
+ config.active_support.deprecation = :log
+
+ # Only use best-standards-support built into browsers
+ config.action_dispatch.best_standards_support = :builtin
+
+# config.middleware.use ExceptionNotifier,
+# :email_prefix => "[Whatever] ",
+# :sender_address => %{"notifier" },
+# :exception_recipients => %w{exceptions@example.com}
+
+end
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 0b2132c3f..0740633d6 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -1,21 +1,49 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Www::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
-# The production environment is meant for finished, "live" apps.
-# Code is not reloaded between requests
-config.cache_classes = true
+ # The production environment is meant for finished, "live" apps.
+ # Code is not reloaded between requests
+ config.cache_classes = true
-# Use a different logger for distributed setups
-# config.logger = SyslogLogger.new
+ # Full error reports are disabled and caching is turned on
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = 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
+ # Specifies the header that your server uses for sending files
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
-# Enable serving of images, stylesheets, and javascripts from an asset server
-# config.action_controller.asset_host = "http://assets.example.com"
+ # For nginx:
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
-# Disable delivery errors, bad email addresses will be ignored
-# config.action_mailer.raise_delivery_errors = false
+ # If you have no front-end server that supports something like X-Sendfile,
+ # just comment this out and Rails will serve the files
-# long only errors
-config.log_level = :error
+ # See everything in the log (default is :info)
+ config.log_level = :error
+
+ # Use a different logger for distributed setups
+ # config.logger = SyslogLogger.new
+
+ # Use a different cache store in production
+ # config.cache_store = :mem_cache_store
+
+ # Disable Rails's static asset server
+ # In production, Apache or nginx will already do this
+ config.serve_static_assets = false
+
+ # 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!
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation can not be found)
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners
+ config.active_support.deprecation = :notify
+end
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 01d00198f..ca842fff4 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -1,25 +1,35 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Www::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
-# The test environment is used exclusively to run your application's
-# test suite. You never need to work with it otherwise. Remember that
-# your test database is "scratch space" for the test suite and is wiped
-# and recreated between test runs. Don't rely on the data there!
-config.cache_classes = true
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
-# Log error messages when you accidentally call methods on nil.
-config.whiny_nils = true
+ # 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_controller.perform_caching = false
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
-# Disable request forgery protection in test environment
-config.action_controller.allow_forgery_protection = false
+ # Raise exceptions instead of rendering exception templates
+ config.action_dispatch.show_exceptions = false
-# Tell ActionMailer not to deliver emails to the real world.
-# The :test delivery method accumulates sent emails in the
-# ActionMailer::Base.deliveries array.
-config.action_mailer.delivery_method = :test
+ # Disable request forgery protection in test environment
+ config.action_controller.allow_forgery_protection = false
-require 'test/unit'
-config.gem 'mocha', :version => '0.9.8'
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ # config.active_record.schema_format = :sql
+
+ # Print deprecation notices to the stderr
+ config.active_support.deprecation = :stderr
+end
diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb
new file mode 100644
index 000000000..59385cdf3
--- /dev/null
+++ b/config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
diff --git a/config/initializers/capistrano_namespace_rake_fix.rb b/config/initializers/capistrano_namespace_rake_fix.rb
deleted file mode 100644
index 5f72b1599..000000000
--- a/config/initializers/capistrano_namespace_rake_fix.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-# see http://groups.google.com/group/capistrano/browse_thread/thread/b5e11c0ebf37a8be
-Capistrano::Configuration::Namespaces::Namespace.class_eval { undef :symlink }
\ No newline at end of file
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
index 09158b865..9e8b0131f 100644
--- a/config/initializers/inflections.rb
+++ b/config/initializers/inflections.rb
@@ -1,8 +1,8 @@
# Be sure to restart your server when you modify this file.
-# Add new inflection rules using the following format
+# Add new inflection rules using the following format
# (all these examples are active by default):
-# Inflector.inflections do |inflect|
+# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb
new file mode 100644
index 000000000..c78f63ba2
--- /dev/null
+++ b/config/initializers/secret_token.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+Www::Application.config.secret_token = 'f729b177755bce74cd7b099f2dc7bb9c2e8f56046611a907be294bbdd5cf96fdc0b2a976eb9d74e93203b69c7aa1ff303a2d8591d40643323348470e653a31b4'
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb
new file mode 100644
index 000000000..92b77e0e4
--- /dev/null
+++ b/config/initializers/session_store.rb
@@ -0,0 +1,15 @@
+# Be sure to restart your server when you modify this file.
+
+Www::Application.config.session_store :cookie_store, :key => '_www_session'
+
+# Use the database for sessions instead of the cookie-based default,
+# which shouldn't be used to store highly confidential information
+# (create the session table with "rails generate session_migration")
+# Www::Application.config.session_store :active_record_store
+
+
+# from environment.rb
+#config.action_controller.session = {
+# :key => '_webistrano_session',
+# :secret => WebistranoConfig[:session_secret]
+#}
diff --git a/config/initializers/time_formatting.rb b/config/initializers/time_formatting.rb
index e98153a3d..8625077f6 100644
--- a/config/initializers/time_formatting.rb
+++ b/config/initializers/time_formatting.rb
@@ -1,2 +1,2 @@
-ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update(:log => '%Y-%m-%d %H:%M')
-ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update(:date_with_day => '%Y-%m-%d')
\ No newline at end of file
+Time::DATE_FORMATS.update(:log => '%Y-%m-%d %H:%M')
+Time::DATE_FORMATS.update(:date_with_day => '%Y-%m-%d')
diff --git a/config/initializers/webistrano_configuration.rb b/config/initializers/webistrano_configuration.rb
index 4c21b9a4e..d3bce0ea9 100644
--- a/config/initializers/webistrano_configuration.rb
+++ b/config/initializers/webistrano_configuration.rb
@@ -1,14 +1,11 @@
if WebistranoConfig[:authentication_method] == :cas
- cas_options = YAML::load_file(RAILS_ROOT+'/config/cas.yml')
- CASClient::Frameworks::Rails::Filter.configure(cas_options[RAILS_ENV])
+ cas_options = YAML::load_file(Rails.root.to_s+'/config/cas.yml')
+ CASClient::Frameworks::Rails::Filter.configure(cas_options[Rails.env])
end
-WEBISTRANO_VERSION = '1.5'
+WEBISTRANO_VERSION = '1.5 - JS 1.0'
ActionMailer::Base.delivery_method = WebistranoConfig[:smtp_delivery_method]
ActionMailer::Base.smtp_settings = WebistranoConfig[:smtp_settings]
-Notification.webistrano_sender_address = WebistranoConfig[:webistrano_sender_address]
-
-ExceptionNotification::Notifier.exception_recipients = WebistranoConfig[:exception_recipients]
-ExceptionNotification::Notifier.sender_address = WebistranoConfig[:exception_sender_address]
+Notification.webistrano_sender_address = WebistranoConfig[:webistrano_sender_address]
\ No newline at end of file
diff --git a/config/locales/en.yml b/config/locales/en.yml
new file mode 100644
index 000000000..a747bfa69
--- /dev/null
+++ b/config/locales/en.yml
@@ -0,0 +1,5 @@
+# Sample localization file for English. Add more files in this directory for other locales.
+# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+
+en:
+ hello: "Hello world"
diff --git a/config/preinitializer.rb b/config/preinitializer.rb
deleted file mode 100644
index 85399f7c1..000000000
--- a/config/preinitializer.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-begin
- require "rubygems"
- require "bundler"
-rescue LoadError
- raise "Could not load the bundler gem. Install it with `gem install bundler`."
-end
-
-if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
- raise RuntimeError, "Your bundler version is too old for Rails 2.3." +
- "Run `gem install bundler` to upgrade."
-end
-
-begin
- # Set up load paths for all bundled gems
- ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
- Bundler.setup
-rescue Bundler::GemNotFound
- raise RuntimeError, "Bundler couldn't find some gems." +
- "Did you run `bundle install`?"
-end
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index db6ce4658..0874ac307 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,45 +1,64 @@
-ActionController::Routing::Routes.draw do |map|
- # The priority is based upon order of creation: first created -> highest priority.
+Www::Application.routes.draw do
- # Sample of regular route:
- # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
- # Keep in mind you can assign values other than :controller and :action
+ resources :auth_sources
+ resources :auth_sources_ldap
- # Sample of named route:
- # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
- # This route can be invoked with purchase_url(:id => product.id)
+ match '/' => 'projects#dashboard', :as => :home
+ match ':controller/service.wsdl' => '#wsdl'
- # You can have the root of your site routed by hooking up ''
- # -- just remember to delete public/index.html.
- map.home '', :controller => "projects", :action => 'dashboard'
+ resources :hosts
+ resources :recipes do
+ collection do
+ get :preview
+ end
+ end
- # Allow downloading Web Service WSDL as a file with an extension
- # instead of a file named 'wsdl'
- map.connect ':controller/service.wsdl', :action => 'wsdl'
-
- map.resources :hosts
- map.resources :recipes, :collection => {:preview => :get}
- map.resources :projects, :member => {:dashboard => :get} do |projects|
- projects.resources :project_configurations
-
- projects.resources :stages, :member => {:capfile => :get, :recipes => :any, :tasks => :get} do |stages|
- stages.resources :stage_configurations
- stages.resources :roles
- stages.resources :deployments, :collection => {:latest => :get}, :member => {:cancel => :post}
+ resources :projects do
+ member do
+ get :dashboard
+ end
+
+ resources :project_configurations
+ resources :stages do
+ match :recipes, :on => :member
+ member do
+ get :capfile
+ get :tasks
+ end
+
+ resources :stage_configurations
+ resources :roles
+ resources :deployments do
+ collection do
+ get :latest
+ end
+
+ member do
+ post :cancel
+ end
+ end
+ end
+ end
+
+ resources :users do
+
+ member do
+ get :deployments
+ post :enable
+ end
+ end
+
+ resources :sessions do
+ collection do
+ get :version
end
end
- # RESTful auth
- map.resources :users,:member => {:deployments => :get, :enable => :post}
- map.resources :sessions, :collection => {:version => :get}
- map.signup '/signup', :controller => 'users', :action => 'new'
- map.login '/login', :controller => 'sessions', :action => 'new'
- map.logout '/logout', :controller => 'sessions', :action => 'destroy'
-
- # stylesheet
- map.stylesheet '/stylesheets/application.css', :controller => 'stylesheets', :action => 'application'
- # Install the default route as the lowest priority.
- map.connect ':controller/:action/:id.:format'
- map.connect ':controller/:action/:id'
-end
+
+ match '/signup' => 'users#new', :as => :signup
+ match '/login' => 'sessions#new', :as => :login
+ match '/logout' => 'sessions#destroy', :as => :logout
+ match '/stylesheets/application.css' => 'stylesheets#application', :as => :stylesheet
+ match '/:controller(/:action(/:id))'
+end
\ No newline at end of file
diff --git a/db/migrate/20101109184848_add_auth_source_id_to_users.rb b/db/migrate/20101109184848_add_auth_source_id_to_users.rb
new file mode 100644
index 000000000..49fef78a5
--- /dev/null
+++ b/db/migrate/20101109184848_add_auth_source_id_to_users.rb
@@ -0,0 +1,9 @@
+class AddAuthSourceIdToUsers < ActiveRecord::Migration
+ def self.up
+ add_column :users, :auth_source_id, :integer
+ end
+
+ def self.down
+ remove_column :users, :auth_source_id
+ end
+end
diff --git a/db/migrate/20101109185024_create_auth_sources.rb b/db/migrate/20101109185024_create_auth_sources.rb
new file mode 100644
index 000000000..9cc20a949
--- /dev/null
+++ b/db/migrate/20101109185024_create_auth_sources.rb
@@ -0,0 +1,24 @@
+class CreateAuthSources < ActiveRecord::Migration
+ def self.up
+ create_table "auth_sources", :force => true do |t|
+ t.column "type", :string, :limit => 30, :default => "", :null => false
+ t.column "name", :string, :limit => 60, :default => "", :null => false
+ t.column "host", :string, :limit => 60
+ t.column "port", :integer
+ t.column "account", :string, :limit => nil
+ t.column "account_password", :string, :limit => 60
+ t.column "base_dn", :string, :limit => 255
+ t.column "attr_login", :string, :limit => 30
+ t.column "attr_firstname", :string, :limit => 30
+ t.column "attr_lastname", :string, :limit => 30
+ t.column "attr_mail", :string, :limit => 30
+ t.column "onthefly_register", :boolean, :default => false, :null => false
+ t.column 'tls', :boolean, :default => false, :null => false
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :auth_sources
+ end
+end
diff --git a/db/migrate/20101110193943_add_can_manage_fields_to_users.rb b/db/migrate/20101110193943_add_can_manage_fields_to_users.rb
new file mode 100644
index 000000000..34189fe2d
--- /dev/null
+++ b/db/migrate/20101110193943_add_can_manage_fields_to_users.rb
@@ -0,0 +1,17 @@
+class AddCanManageFieldsToUsers < ActiveRecord::Migration
+ def self.up
+ add_column :users, :manage_hosts, :boolean, :default => false
+ add_column :users, :manage_recipes, :boolean, :default => false
+ add_column :users, :manage_users, :boolean, :default => false
+ add_column :users, :manage_stages, :boolean, :default => false
+ add_column :users, :manage_projects, :boolean, :default => false
+ end
+
+ def self.down
+ remove_column :users, :manage_hosts
+ remove_column :users, :manage_recipes
+ remove_column :users, :manage_users
+ remove_column :users, :manage_stages
+ remove_column :users, :manage_projects
+ end
+end
diff --git a/db/migrate/20101110200852_create_user_project_links.rb b/db/migrate/20101110200852_create_user_project_links.rb
new file mode 100644
index 000000000..2925cd94e
--- /dev/null
+++ b/db/migrate/20101110200852_create_user_project_links.rb
@@ -0,0 +1,14 @@
+class CreateUserProjectLinks < ActiveRecord::Migration
+ def self.up
+ create_table :user_project_links do |t|
+ t.integer :user_id
+ t.integer :project_id
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :user_project_links
+ end
+end
diff --git a/db/migrate/20101201002226_add_archived_flag_to_projects.rb b/db/migrate/20101201002226_add_archived_flag_to_projects.rb
new file mode 100644
index 000000000..5a7a2d782
--- /dev/null
+++ b/db/migrate/20101201002226_add_archived_flag_to_projects.rb
@@ -0,0 +1,9 @@
+class AddArchivedFlagToProjects < ActiveRecord::Migration
+ def self.up
+ add_column :projects, :archived, :boolean, :default => false
+ end
+
+ def self.down
+ remove_column :projects, :archived
+ end
+end
\ No newline at end of file
diff --git a/db/migrate/017_add_default_user.rb b/db/migrate/20131220141503_add_default_user.rb
similarity index 91%
rename from db/migrate/017_add_default_user.rb
rename to db/migrate/20131220141503_add_default_user.rb
index 25a89099b..22720a6d1 100644
--- a/db/migrate/017_add_default_user.rb
+++ b/db/migrate/20131220141503_add_default_user.rb
@@ -1,4 +1,4 @@
-require "#{RAILS_ROOT}/app/models/user"
+require "#{Rails.root.to_s}/app/models/user"
class AddDefaultUser < ActiveRecord::Migration
def self.up
diff --git a/db/schema.rb b/db/schema.rb
index 8ba3d7003..2808641e6 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1,16 +1,36 @@
-# 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.
+# encoding: UTF-8
+# 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
+# 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 => 20110512144542) do
+ create_table "auth_sources", :force => true do |t|
+ t.string "type", :limit => 30, :default => "", :null => false
+ t.string "name", :limit => 60, :default => "", :null => false
+ t.string "host", :limit => 60
+ t.integer "port"
+ t.string "account"
+ t.string "account_password", :limit => 60
+ t.string "base_dn"
+ t.string "attr_login", :limit => 30
+ t.string "attr_firstname", :limit => 30
+ t.string "attr_lastname", :limit => 30
+ t.string "attr_mail", :limit => 30
+ t.boolean "onthefly_register", :default => false, :null => false
+ t.boolean "tls", :default => false, :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
create_table "configuration_parameters", :force => true do |t|
t.string "name"
t.string "value"
@@ -60,6 +80,7 @@
t.string "template"
t.datetime "created_at"
t.datetime "updated_at"
+ t.boolean "archived", :default => false
end
create_table "recipe_versions", :force => true do |t|
@@ -116,6 +137,13 @@
add_index "stages", ["project_id"], :name => "index_stages_on_project_id"
+ create_table "user_project_links", :force => true do |t|
+ t.integer "user_id"
+ t.integer "project_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
create_table "users", :force => true do |t|
t.string "login"
t.string "email"
@@ -128,6 +156,12 @@
t.integer "admin", :default => 0
t.string "time_zone", :default => "UTC"
t.datetime "disabled"
+ t.integer "auth_source_id"
+ t.boolean "manage_hosts", :default => false
+ t.boolean "manage_recipes", :default => false
+ t.boolean "manage_users", :default => false
+ t.boolean "manage_stages", :default => false
+ t.boolean "manage_projects", :default => false
end
add_index "users", ["disabled"], :name => "index_users_on_disabled"
diff --git a/db/seeds.rb b/db/seeds.rb
new file mode 100644
index 000000000..664d8c74c
--- /dev/null
+++ b/db/seeds.rb
@@ -0,0 +1,7 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+#
+# Examples:
+#
+# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
+# Mayor.create(:name => 'Daley', :city => cities.first)
diff --git a/doc/README_FOR_APP b/doc/README_FOR_APP
index ac6c14912..fe41f5cc2 100644
--- a/doc/README_FOR_APP
+++ b/doc/README_FOR_APP
@@ -1,2 +1,2 @@
Use this README file to introduce your application and point to useful places in the API for learning more.
-Run "rake appdoc" to generate API documentation for your models and controllers.
\ No newline at end of file
+Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
diff --git a/doc/passenger.rst b/doc/passenger.rst
new file mode 100644
index 000000000..d3456bc0d
--- /dev/null
+++ b/doc/passenger.rst
@@ -0,0 +1,26 @@
+Install and server through passenger with apache
+
+- enable libapache2-mod-passenger (aptitude install libapache2-mod-passenger)
+- enable rewrite (a2enmod rewrite)
+
+/etc/apache2/sites-available/webistrano
+
+ ServerName server.example.com
+ DocumentRoot /path/to/rails/app/public
+
+ # set passenger root for ubuntu installations
+ PassengerRoot /usr/lib/phusion_passenger
+
+ # path to ruby executable
+ PassengerRuby /home/vagrant/.rvm/rubies/ruby-1.8.7-p374/bin/ruby
+
+ # endpoint
+ RailsBaseURI /
+
+ # rails environment to load
+ RailsEnv development
+
+
+- enable site (a2ensite webistrano)
+- restart apache (/etc/init.d apache2 restart)
+
diff --git a/vendor/gems/open4-0.9.3/open4-0.9.3.gem b/lib/tasks/.gitkeep
similarity index 100%
rename from vendor/gems/open4-0.9.3/open4-0.9.3.gem
rename to lib/tasks/.gitkeep
diff --git a/lib/webistrano/deployer.rb b/lib/webistrano/deployer.rb
index 327ef6945..bb9e28f17 100644
--- a/lib/webistrano/deployer.rb
+++ b/lib/webistrano/deployer.rb
@@ -22,7 +22,7 @@ def initialize(deployment)
@deployment = deployment
- if(@deployment.task && !@deployment.new_record?)
+ if(@deployment.send(:task) && !@deployment.new_record?)
# a read deployment
@logger = Webistrano::Logger.new(deployment)
@logger.level = Webistrano::Logger::TRACE
@@ -63,8 +63,12 @@ def execute!
set_webistrano_logger(config)
set_up_config(config)
-
- exchange_real_revision(config) unless (config.fetch(:scm).to_s == 'git') # git cannot do a local query by default
+
+ # git and mercurial cannot do a local query by default
+ unless %w(git mercurial).include? config.fetch(:scm).to_s
+ exchange_real_revision(config)
+ end
+
save_revision(config)
save_pid
diff --git a/public/404.html b/public/404.html
index eff660b90..9a48320a5 100644
--- a/public/404.html
+++ b/public/404.html
@@ -1,23 +1,19 @@
-
-
-
-
+
+
-
The page you were looking for doesn't exist (404)
-
+
@@ -27,4 +23,4 @@
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
-
\ No newline at end of file
+
diff --git a/public/422.html b/public/422.html
index b54e4a3ca..83660ab18 100644
--- a/public/422.html
+++ b/public/422.html
@@ -1,23 +1,19 @@
-
-
-
-
+
+
-
The change you wanted was rejected (422)
-
+
@@ -27,4 +23,4 @@
The change you wanted was rejected.
Maybe you tried to change something you didn't have access to.
-
\ No newline at end of file
+
diff --git a/public/500.html b/public/500.html
index f0aee0e9f..b80307fc1 100644
--- a/public/500.html
+++ b/public/500.html
@@ -1,23 +1,19 @@
-
-
-
-
+
+
-
- We're sorry, but something went wrong
-
+ We're sorry, but something went wrong (500)
+
@@ -27,4 +23,4 @@
We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it shortly.
-
\ No newline at end of file
+
diff --git a/public/dispatch.cgi b/public/dispatch.cgi
index a76782ae0..9b5ae760f 100755
--- a/public/dispatch.cgi
+++ b/public/dispatch.cgi
@@ -1,4 +1,4 @@
-#!/opt/local/bin/ruby
+#!/usr/local/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
diff --git a/public/dispatch.fcgi b/public/dispatch.fcgi
index a5267664e..65188f380 100755
--- a/public/dispatch.fcgi
+++ b/public/dispatch.fcgi
@@ -1,4 +1,4 @@
-#!/opt/local/bin/ruby
+#!/usr/local/bin/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)
diff --git a/public/dispatch.rb b/public/dispatch.rb
index a76782ae0..4e7790d9a 100755
--- a/public/dispatch.rb
+++ b/public/dispatch.rb
@@ -1,6 +1,6 @@
-#!/opt/local/bin/ruby
+#!/usr/local/bin/ruby
-require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
+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
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 2ee02d19e..b801ae15a 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -1,49 +1,49 @@
// open a new window
function loadWindow(url) {
- popupWin = window.open(url, 'new_window', 'scrollbars=no,status=no,toolbar=no,location=no,directories=no,menubar=no,width=960, height=700, top=50, left=50, resizable=1, scrollbars=yes');
- popupWin.focus();
+ popupWin = window.open(url, 'new_window', 'scrollbars=no,status=no,toolbar=no,location=no,directories=no,menubar=no,width=960, height=700, top=50, left=50, resizable=1, scrollbars=yes');
+ popupWin.focus();
}
/* Create Menu Links */
function open_menu(dom_id){
- // arrow images
- $(dom_id + "_arrow_right").hide();
- $(dom_id + "_arrow_down").show();
-
- // stages
- $(dom_id + "_stages").show();
+ // arrow images
+ $(dom_id + "_arrow_right").hide();
+ $(dom_id + "_arrow_down").show();
+
+ // stages
+ $(dom_id + "_stages").show();
}
function close_menu(dom_id){
- // arrow images
- $(dom_id + "_arrow_right").show();
- $(dom_id + "_arrow_down").hide();
-
- // stages
- $(dom_id + "_stages").hide();
+ // arrow images
+ $(dom_id + "_arrow_right").show();
+ $(dom_id + "_arrow_down").hide();
+
+ // stages
+ $(dom_id + "_stages").hide();
}
function open_menu_box(dom_id){
- // arrow images
- $(dom_id + "_arrow_right").hide();
- $(dom_id + "_arrow_down").show();
-
- // show box body
- $(dom_id + "_open_content").show();
-
- // hide closed info
- $(dom_id + "_closed_content").hide();
+ // arrow images
+ $(dom_id + "_arrow_right").hide();
+ $(dom_id + "_arrow_down").show();
+
+ // show box body
+ $(dom_id + "_open_content").show();
+
+ // hide closed info
+ $(dom_id + "_closed_content").hide();
}
function close_menu_box(dom_id){
- // arrow images
- $(dom_id + "_arrow_right").show();
- $(dom_id + "_arrow_down").hide();
-
- // show box body
- $(dom_id + "_open_content").hide();
-
- // hide closed info
- $(dom_id + "_closed_content").show();
-}
\ No newline at end of file
+ // arrow images
+ $(dom_id + "_arrow_right").show();
+ $(dom_id + "_arrow_down").hide();
+
+ // show box body
+ $(dom_id + "_open_content").hide();
+
+ // hide closed info
+ $(dom_id + "_closed_content").show();
+}
diff --git a/public/javascripts/controls.js b/public/javascripts/controls.js
index 5aaf0bb2b..7392fb664 100644
--- a/public/javascripts/controls.js
+++ b/public/javascripts/controls.js
@@ -1,22 +1,24 @@
-// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-// (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
-// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com)
+// script.aculo.us controls.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
+
+// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// (c) 2005-2009 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
+// (c) 2005-2009 Jon Tirsen (http://www.tirsen.com)
// Contributors:
// Richard Livsey
// Rahul Bhargava
// Rob Wills
-//
+//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
-// Autocompleter.Base handles all the autocompletion functionality
+// Autocompleter.Base handles all the autocompletion functionality
// that's independent of the data source for autocompletion. This
// includes drawing the autocompletion menu, observing keyboard
// and mouse events, and similar.
//
-// Specific autocompleters need to provide, at the very least,
+// Specific autocompleters need to provide, at the very least,
// a getUpdatedChoices function that will be invoked every time
-// the text inside the monitored textbox changes. This method
+// the text inside the monitored textbox changes. This method
// should get the text for which to provide autocompletion by
// invoking this.getToken(), NOT by directly accessing
// this.element.value. This is to allow incremental tokenized
@@ -30,23 +32,23 @@
// will incrementally autocomplete with a comma as the token.
// Additionally, ',' in the above example can be replaced with
// a token array, e.g. { tokens: [',', '\n'] } which
-// enables autocompletion on multiple tokens. This is most
-// useful when one of the tokens is \n (a newline), as it
+// enables autocompletion on multiple tokens. This is most
+// useful when one of the tokens is \n (a newline), as it
// allows smart autocompletion after linebreaks.
if(typeof Effect == 'undefined')
throw("controls.js requires including script.aculo.us' effects.js library");
-var Autocompleter = { }
+var Autocompleter = { };
Autocompleter.Base = Class.create({
baseInitialize: function(element, update, options) {
- element = $(element)
- this.element = element;
- this.update = $(update);
- this.hasFocus = false;
- this.changed = false;
- this.active = false;
- this.index = 0;
+ element = $(element);
+ this.element = element;
+ this.update = $(update);
+ this.hasFocus = false;
+ this.changed = false;
+ this.active = false;
+ this.index = 0;
this.entryCount = 0;
this.oldElementValue = this.element.value;
@@ -59,28 +61,28 @@ Autocompleter.Base = Class.create({
this.options.tokens = this.options.tokens || [];
this.options.frequency = this.options.frequency || 0.4;
this.options.minChars = this.options.minChars || 1;
- this.options.onShow = this.options.onShow ||
- function(element, update){
+ this.options.onShow = this.options.onShow ||
+ function(element, update){
if(!update.style.position || update.style.position=='absolute') {
update.style.position = 'absolute';
Position.clone(element, update, {
- setHeight: false,
+ setHeight: false,
offsetTop: element.offsetHeight
});
}
Effect.Appear(update,{duration:0.15});
};
- this.options.onHide = this.options.onHide ||
+ this.options.onHide = this.options.onHide ||
function(element, update){ new Effect.Fade(update,{duration:0.15}) };
- if(typeof(this.options.tokens) == 'string')
+ if(typeof(this.options.tokens) == 'string')
this.options.tokens = new Array(this.options.tokens);
// Force carriage returns as token delimiters anyway
if (!this.options.tokens.include('\n'))
this.options.tokens.push('\n');
this.observer = null;
-
+
this.element.setAttribute('autocomplete','off');
Element.hide(this.update);
@@ -91,10 +93,10 @@ Autocompleter.Base = Class.create({
show: function() {
if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
- if(!this.iefix &&
+ if(!this.iefix &&
(Prototype.Browser.IE) &&
(Element.getStyle(this.update, 'position')=='absolute')) {
- new Insertion.After(this.update,
+ new Insertion.After(this.update,
'');
@@ -102,7 +104,7 @@ Autocompleter.Base = Class.create({
}
if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
},
-
+
fixIEOverlapping: function() {
Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
this.iefix.style.zIndex = 1;
@@ -150,15 +152,15 @@ Autocompleter.Base = Class.create({
Event.stop(event);
return;
}
- else
- if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
+ else
+ if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
(Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;
this.changed = true;
this.hasFocus = true;
if(this.observer) clearTimeout(this.observer);
- this.observer =
+ this.observer =
setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
},
@@ -170,35 +172,35 @@ Autocompleter.Base = Class.create({
onHover: function(event) {
var element = Event.findElement(event, 'LI');
- if(this.index != element.autocompleteIndex)
+ if(this.index != element.autocompleteIndex)
{
this.index = element.autocompleteIndex;
this.render();
}
Event.stop(event);
},
-
+
onClick: function(event) {
var element = Event.findElement(event, 'LI');
this.index = element.autocompleteIndex;
this.selectEntry();
this.hide();
},
-
+
onBlur: function(event) {
// needed to make click events working
setTimeout(this.hide.bind(this), 250);
this.hasFocus = false;
- this.active = false;
- },
-
+ this.active = false;
+ },
+
render: function() {
if(this.entryCount > 0) {
for (var i = 0; i < this.entryCount; i++)
- this.index==i ?
- Element.addClassName(this.getEntry(i),"selected") :
+ this.index==i ?
+ Element.addClassName(this.getEntry(i),"selected") :
Element.removeClassName(this.getEntry(i),"selected");
- if(this.hasFocus) {
+ if(this.hasFocus) {
this.show();
this.active = true;
}
@@ -207,27 +209,27 @@ Autocompleter.Base = Class.create({
this.hide();
}
},
-
+
markPrevious: function() {
- if(this.index > 0) this.index--
+ if(this.index > 0) this.index--;
else this.index = this.entryCount-1;
this.getEntry(this.index).scrollIntoView(true);
},
-
+
markNext: function() {
- if(this.index < this.entryCount-1) this.index++
+ if(this.index < this.entryCount-1) this.index++;
else this.index = 0;
this.getEntry(this.index).scrollIntoView(false);
},
-
+
getEntry: function(index) {
return this.update.firstChild.childNodes[index];
},
-
+
getCurrentEntry: function() {
return this.getEntry(this.index);
},
-
+
selectEntry: function() {
this.active = false;
this.updateElement(this.getCurrentEntry());
@@ -244,7 +246,7 @@ Autocompleter.Base = Class.create({
if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
} else
value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
-
+
var bounds = this.getTokenBounds();
if (bounds[0] != -1) {
var newValue = this.element.value.substr(0, bounds[0]);
@@ -257,7 +259,7 @@ Autocompleter.Base = Class.create({
}
this.oldElementValue = this.element.value;
this.element.focus();
-
+
if (this.options.afterUpdateElement)
this.options.afterUpdateElement(this.element, selectedElement);
},
@@ -269,20 +271,20 @@ Autocompleter.Base = Class.create({
Element.cleanWhitespace(this.update.down());
if(this.update.firstChild && this.update.down().childNodes) {
- this.entryCount =
+ this.entryCount =
this.update.down().childNodes.length;
for (var i = 0; i < this.entryCount; i++) {
var entry = this.getEntry(i);
entry.autocompleteIndex = i;
this.addObservers(entry);
}
- } else {
+ } else {
this.entryCount = 0;
}
this.stopIndicator();
this.index = 0;
-
+
if(this.entryCount==1 && this.options.autoSelect) {
this.selectEntry();
this.hide();
@@ -298,7 +300,7 @@ Autocompleter.Base = Class.create({
},
onObserverEvent: function() {
- this.changed = false;
+ this.changed = false;
this.tokenBounds = null;
if(this.getToken().length>=this.options.minChars) {
this.getUpdatedChoices();
@@ -351,16 +353,16 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
getUpdatedChoices: function() {
this.startIndicator();
-
- var entry = encodeURIComponent(this.options.paramName) + '=' +
+
+ var entry = encodeURIComponent(this.options.paramName) + '=' +
encodeURIComponent(this.getToken());
this.options.parameters = this.options.callback ?
this.options.callback(this.element, entry) : entry;
- if(this.options.defaultParams)
+ if(this.options.defaultParams)
this.options.parameters += '&' + this.options.defaultParams;
-
+
new Ajax.Request(this.url, this.options);
},
@@ -382,7 +384,7 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
// - choices - How many autocompletion choices to offer
//
// - partialSearch - If false, the autocompleter will match entered
-// text only at the beginning of strings in the
+// text only at the beginning of strings in the
// autocomplete array. Defaults to true, which will
// match text at the beginning of any *word* in the
// strings in the autocomplete array. If you want to
@@ -399,7 +401,7 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
// - ignoreCase - Whether to ignore case when autocompleting.
// Defaults to true.
//
-// It's possible to pass in a custom function as the 'selector'
+// It's possible to pass in a custom function as the 'selector'
// option, if you prefer to write your own autocompletion logic.
// In that case, the other options above will not apply unless
// you support them.
@@ -427,20 +429,20 @@ Autocompleter.Local = Class.create(Autocompleter.Base, {
var entry = instance.getToken();
var count = 0;
- for (var i = 0; i < instance.options.array.length &&
- ret.length < instance.options.choices ; i++) {
+ for (var i = 0; i < instance.options.array.length &&
+ ret.length < instance.options.choices ; i++) {
var elem = instance.options.array[i];
- var foundPos = instance.options.ignoreCase ?
- elem.toLowerCase().indexOf(entry.toLowerCase()) :
+ var foundPos = instance.options.ignoreCase ?
+ elem.toLowerCase().indexOf(entry.toLowerCase()) :
elem.indexOf(entry);
while (foundPos != -1) {
- if (foundPos == 0 && elem.length != entry.length) {
- ret.push("