https://svn.lrde.epita.fr/svn/ranch/trunk
Index: ChangeLog
from Nicolas Despr�s <nicolas.despres(a)gmail.com>
Update to Rails 0.14.3.
* web/ranch/test/test_helper.rb,
* web/ranch/script/about:,
* web/ranch/script/plugin:,
* web/ranch/config/database.yml:,
* web/ranch/config/boot.rb:,
* web/ranch/config/environment.rb:,
* web/ranch/config/environments/test.rb:,
* web/ranch/README:,
* web/ranch/public/javascripts/prototype.js:,
* web/ranch/public/javascripts/effects.js:,
* web/ranch/public/javascripts/dragdrop.js:,
* web/ranch/public/javascripts/controls.js: Update.
README | 69 +++++----------------
config/boot.rb | 2
config/database.yml | 68 ++++++++++++++++++++-
config/environment.rb | 4 -
config/environments/test.rb | 6 -
public/javascripts/controls.js | 23 +++++--
public/javascripts/dragdrop.js | 9 +-
public/javascripts/effects.js | 127 ++--------------------------------------
public/javascripts/prototype.js | 24 ++++---
script/about | 3
script/plugin | 3
test/test_helper.rb | 19 +++++
12 files changed, 153 insertions(+), 204 deletions(-)
Index: web/ranch/test/test_helper.rb
--- web/ranch/test/test_helper.rb (revision 7)
+++ web/ranch/test/test_helper.rb (working copy)
@@ -3,10 +3,25 @@
require 'test_help'
class Test::Unit::TestCase
- # Turn off transactional fixtures if you're working with MyISAM tables in MySQL
+ # Transactional fixtures accelerate your tests by wrapping each test method
+ # in a transaction that's rolled back on completion. This ensures that the
+ # test database remains unchanged so your fixtures don't have to be reloaded
+ # between every test method. Fewer database queries means faster tests.
+ #
+ # Read Mike Clark's excellent walkthrough at
+ #
http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
+ #
+ # Every Active Record database supports transactions except MyISAM tables
+ # in MySQL. Turn off transactional fixtures in this case; however, if you
+ # don't care one way or the other, switching from MyISAM to InnoDB tables
+ # is recommended.
self.use_transactional_fixtures = true
- # Instantiated fixtures are slow, but give you @david where you otherwise would need
people(:david)
+ # Instantiated fixtures are slow, but give you @david where otherwise you
+ # would need people(:david). If you don't want to migrate your existing
+ # test cases which use the @david style and don't mind the speed hit (each
+ # instantiated fixtures translates to a database query per test method),
+ # then set this back to true.
self.use_instantiated_fixtures = false
# Add more helper methods to be used by all tests here...
Index: web/ranch/script/about
--- web/ranch/script/about (revision 0)
+++ web/ranch/script/about (revision 0)
@@ -0,0 +1,3 @@
+#!/usr/bin/ruby1.8
+require File.dirname(__FILE__) + '/../config/boot'
+require 'commands/about'
\ No newline at end of file
Property changes on: web/ranch/script/about
___________________________________________________________________
Name: svn:executable
+ *
Index: web/ranch/script/plugin
--- web/ranch/script/plugin (revision 0)
+++ web/ranch/script/plugin (revision 0)
@@ -0,0 +1,3 @@
+#!/usr/bin/ruby1.8
+require File.dirname(__FILE__) + '/../config/boot'
+require 'commands/plugin'
\ No newline at end of file
Property changes on: web/ranch/script/plugin
___________________________________________________________________
Name: svn:executable
+ *
Index: web/ranch/config/database.yml
--- web/ranch/config/database.yml (revision 7)
+++ web/ranch/config/database.yml (working copy)
@@ -1,9 +1,21 @@
+# MySQL (default setup). Versions 4.1 and 5.0 are recommended.
+#
+# Get the fast C bindings:
+# gem install mysql
+# (on OS X: gem install mysql -- --include=/usr/local/lib)
+# 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: ranch_development
- socket: /path/to/your/mysql.sock
username: root
password:
+ socket: /var/run/mysqld/mysqld.sock
+
+ # Connect on a TCP socket. If omitted, the adapter will connect on the
+ # domain socket given by socket instead.
+ #host: localhost
+ #port: 3306
# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
@@ -11,13 +23,63 @@
test:
adapter: mysql
database: ranch_test
- socket: /path/to/your/mysql.sock
username: root
password:
+ socket: /var/run/mysqld/mysqld.sock
production:
adapter: mysql
database: ranch_production
- socket: /path/to/your/mysql.sock
username: root
password:
+ socket: /var/run/mysqld/mysqld.sock
+
+
+# PostgreSQL versions 7.4 - 8.1
+#
+# Get the C bindings:
+# gem install postgres
+# or use the pure-Ruby bindings on Windows:
+# gem install postgres-pr
+postgresql_example:
+ adapter: postgresql
+ database: ranch_development
+ username: ranch
+ password:
+
+ # Connect on a TCP socket. Omitted by default since the client uses a
+ # domain socket that doesn't need configuration.
+ #host: remote-database
+ #port: 5432
+
+ # Schema search path. The server defaults to $user,public
+ #schema_search_path: myapp,sharedapp,public
+
+ # Character set encoding. The server defaults to sql_ascii.
+ #encoding: UTF8
+
+ # Minimum log levels, in increasing order:
+ # debug5, debug4, debug3, debug2, debug1,
+ # info, notice, warning, error, log, fatal, or panic
+ # The server defaults to notice.
+ #min_messages: warning
+
+
+# SQLite version 2.x
+# gem install sqlite-ruby
+sqlite_example:
+ adapter: sqlite
+ database: db/development.sqlite2
+
+
+# SQLite version 3.x
+# gem install sqlite3-ruby
+sqlite3_example:
+ adapter: sqlite3
+ database: db/development.sqlite3
+
+
+# In-memory SQLite 3 database. Useful for tests.
+sqlite3_in_memory_example:
+ adapter: sqlite3
+ database: ":memory:"
\ No newline at end of file
Index: web/ranch/config/boot.rb
--- web/ranch/config/boot.rb (revision 7)
+++ web/ranch/config/boot.rb (working copy)
@@ -2,7 +2,7 @@
root_path = File.join(File.dirname(__FILE__), '..')
unless RUBY_PLATFORM =~ /mswin32/
require 'pathname'
- root_path = Pathname.new(root_path).cleanpath.to_s
+ root_path = Pathname.new(root_path).cleanpath(true).to_s
end
RAILS_ROOT = root_path
end
Index: web/ranch/config/environment.rb
--- web/ranch/config/environment.rb (revision 7)
+++ web/ranch/config/environment.rb (working copy)
@@ -2,7 +2,7 @@
# Uncomment below to force Rails into production mode
# (Use only when you can't set environment variables through your web/app server)
-# ENV['RAILS_ENV'] = 'production'
+# ENV['RAILS_ENV'] ||= 'production'
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
@@ -12,7 +12,7 @@
# config.frameworks -= [ :action_web_service, :action_mailer ]
# Add additional load paths for your own custom dirs
- # config.load_paths += %W( #{RAILS_ROOT}/app/services )
+ # config.load_paths += %W( #{RAILS_ROOT}/extras )
# Force all environments to use the same logger level
# (by default production uses :info, the others :debug)
Index: web/ranch/config/environments/test.rb
--- web/ranch/config/environments/test.rb (revision 7)
+++ web/ranch/config/environments/test.rb (working copy)
@@ -15,9 +15,3 @@
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
-
-# Overwrite the default settings for fixtures in tests. See Fixtures
-# for more details about these settings.
-# config.transactional_fixtures = true
-# config.instantiated_fixtures = false
-# config.pre_loaded_fixtures = false
\ No newline at end of file
Index: web/ranch/README
--- web/ranch/README (revision 7)
+++ web/ranch/README (working copy)
@@ -1,22 +1,22 @@
== Welcome to Rails
-Rails is a web-application and persistance framework that includes everything
+Rails is a web-application and persistence framework that includes everything
needed to create database-backed web-applications according to the
Model-View-Control pattern of separation. This pattern splits the view (also
called the presentation) into "dumb" templates that are primarily responsible
-for inserting pre-build data in between HTML tags. The model contains the
+for inserting pre-built data in between HTML tags. The model contains the
"smart" domain objects (such as Account, Product, Person, Post) that holds all
the business logic and knows how to persist themselves to a database. The
controller handles the incoming requests (such as Save New Account, Update
Product, Show Post) by manipulating the model and directing data to the view.
-In Rails, the model is handled by what's called a object-relational mapping
+In Rails, the model is handled by what's called an object-relational mapping
layer entitled Active Record. This layer allows you to present the data from
database rows as objects and embellish these data objects with business logic
methods. You can read more about Active Record in
link:files/vendor/rails/activerecord/README.html.
-The controller and view is handled by the Action Pack, which handles both
+The controller and view are handled by the Action Pack, which handles both
layers by its two parts: Action View and Action Controller. These two layers
are bundled in a single package due to their heavy interdependence. This is
unlike the relationship between the Active Record and Action Pack that is much
@@ -25,21 +25,10 @@
link:files/vendor/rails/actionpack/README.html.
-== Requirements
-
-* Database and driver (MySQL, PostgreSQL, or SQLite)
-* Rake[http://rake.rubyforge.org] for running tests and the generating documentation
-
-== Optionals
-
-* Apache 1.3.x or 2.x or lighttpd 1.3.11+ (or any FastCGI-capable webserver with a
- mod_rewrite-like module)
-* FastCGI (or mod_ruby) for better performance on Apache
-
== Getting started
-1. Run the WEBrick servlet: <tt>ruby script/server</tt>
- (run with --help for options)
+1. Run the WEBrick servlet: <tt>ruby script/server</tt> (run with --help for
options)
+ ...or if you have lighttpd installed: <tt>ruby script/lighttpd</tt>
(it's faster)
2. Go to
http://localhost:3000/ and get "Congratulations, you've put Ruby on
Rails!"
3. Follow the guidelines on the "Congratulations, you've put Ruby on
Rails!" screen
@@ -60,36 +49,9 @@
</VirtualHost>
NOTE: Be sure that CGIs can be executed in that directory as well. So ExecCGI
-should be on and ".cgi" should respond. All requests from 127.0.0.1 goes
+should be on and ".cgi" should respond. All requests from 127.0.0.1 go
through CGI, so no Apache restart is necessary for changes. All other requests
-goes through FCGI (or mod_ruby) that requires restart to show changes.
-
-
-== Example for lighttpd conf (with FastCGI)
-
- server.port = 8080
- server.bind = "127.0.0.1"
- # server.event-handler = "freebsd-kqueue" # needed on OS X
-
- server.modules = ( "mod_rewrite", "mod_fastcgi" )
-
- url.rewrite = ( "^/$" => "index.html", "^([^.]+)$"
=> "$1.html" )
- server.error-handler-404 = "/dispatch.fcgi"
-
- server.document-root = "/path/application/public"
- server.errorlog = "/path/application/log/server.log"
-
- fastcgi.server = ( ".fcgi" =>
- ( "localhost" =>
- (
- "min-procs" => 1,
- "max-procs" => 5,
- "socket" => "/tmp/application.fcgi.socket",
- "bin-path" => "/path/application/public/dispatch.fcgi",
- "bin-environment" => ( "RAILS_ENV" =>
"development" )
- )
- )
- )
+go through FCGI (or mod_ruby), which requires a restart to show changes.
== Debugging Rails
@@ -139,7 +101,7 @@
You can interact with the domain model by starting the console through script/console.
Here you'll have all parts of the application configured, just like it is when the
application is running. You can inspect domain models, change values, and save to the
-database. Start the script without arguments will launch it in the development
environment.
+database. Starting the script without arguments will launch it in the development
environment.
Passing an argument will specify a different environment, like <tt>console
production</tt>.
@@ -155,11 +117,11 @@
app/models
Holds models that should be named like post.rb.
- Most models will descent from ActiveRecord::Base.
+ Most models will descend from ActiveRecord::Base.
app/views
Holds the template files for the view that should be named like
- weblog/index.rhtml for the WeblogController#index action. All views uses eRuby
+ weblog/index.rhtml for the WeblogController#index action. All views use eRuby
syntax. This directory can also be used to keep stylesheets, images, and so on
that can be symlinked to public.
@@ -170,14 +132,14 @@
Configuration files for the Rails environment, the routing map, the database, and other
dependencies.
components
- Self-contained mini-applications that can bundle controllers, models, and views
together.
+ Self-contained mini-applications that can bundle together controllers, models, and
views.
lib
Application specific libraries. Basically, any kind of custom code that doesn't
- belong controllers, models, or helpers. This directory is in the load path.
+ belong under controllers, models, or helpers. This directory is in the load path.
public
- The directory available for the web server. Contains sub-directories for images,
stylesheets,
+ The directory available for the web server. Contains subdirectories for images,
stylesheets,
and javascripts. Also contains the dispatchers and the default HTML files.
script
@@ -187,4 +149,5 @@
Unit and functional tests along with fixtures.
vendor
- External libraries that the application depend on. This directory is in the load path.
+ External libraries that the application depends on. Also includes the plugins
subdirectory.
+ This directory is in the load path.
Index: web/ranch/public/javascripts/prototype.js
--- web/ranch/public/javascripts/prototype.js (revision 7)
+++ web/ranch/public/javascripts/prototype.js (working copy)
@@ -1,4 +1,4 @@
-/* Prototype JavaScript framework, version 1.4.0_rc0
+/* Prototype JavaScript framework, version 1.4.0_rc2
* (c) 2005 Sam Stephenson <sam(a)conio.net>
*
* THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
@@ -11,7 +11,7 @@
/*--------------------------------------------------------------------------*/
var Prototype = {
- Version: '1.4.0_rc0',
+ Version: '1.4.0_rc2',
emptyFunction: function() {},
K: function(x) {return x}
@@ -607,8 +607,8 @@
try {
this.url = url;
- if (this.options.method == 'get')
- this.url += '?' + parameters;
+ if (this.options.method == 'get' && parameters.length > 0)
+ this.url += (this.url.match(/\?/) ? '&' : '?') + parameters;
Ajax.Responders.dispatch('onCreate', this, this.transport);
@@ -626,6 +626,8 @@
this.transport.send(this.options.method == 'post' ? body : null);
} catch (e) {
+ (this.options.onException || Prototype.emptyFunction)(this, e);
+ Ajax.Responders.dispatch('onException', this, e);
}
},
@@ -783,9 +785,9 @@
}
});
document.getElementsByClassName = function(className, parentElement) {
- var children = (document.body || $(parentElement)).getElementsByTagName('*');
+ var children = ($(parentElement) || document.body).getElementsByTagName('*');
return $A(children).inject([], function(elements, child) {
- if (Element.hasClassName(child, className))
+ if (child.className.match(new RegExp("(^|\\s)" + className +
"(\\s|$)")))
elements.push(child);
return elements;
});
@@ -1129,7 +1131,7 @@
},
getElements: function(form) {
- var form = $(form);
+ form = $(form);
var elements = new Array();
for (tagName in Form.Element.Serializers) {
@@ -1141,7 +1143,7 @@
},
getInputs: function(form, typeName, name) {
- var form = $(form);
+ form = $(form);
var inputs = form.getElementsByTagName('input');
if (!typeName && !name)
@@ -1177,7 +1179,7 @@
},
focusFirstElement: function(form) {
- var form = $(form);
+ form = $(form);
var elements = Form.getElements(form);
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
@@ -1195,7 +1197,7 @@
Form.Element = {
serialize: function(element) {
- var element = $(element);
+ element = $(element);
var method = element.tagName.toLowerCase();
var parameter = Form.Element.Serializers[method](element);
@@ -1205,7 +1207,7 @@
},
getValue: function(element) {
- var element = $(element);
+ element = $(element);
var method = element.tagName.toLowerCase();
var parameter = Form.Element.Serializers[method](element);
Index: web/ranch/public/javascripts/effects.js
--- web/ranch/public/javascripts/effects.js (revision 7)
+++ web/ranch/public/javascripts/effects.js (working copy)
@@ -6,121 +6,6 @@
//
// See scriptaculous.js for full license.
-Object.debug = function(obj) {
- var info = [];
-
- if(typeof obj in ["string","number"]) {
- return obj;
- } else {
- for(property in obj)
- if(typeof obj[property]!="function")
- info.push(property + ' => ' +
- (typeof obj[property] == "string" ?
- '"' + obj[property] + '"' :
- obj[property]));
- }
-
- return ("'" + obj + "' #" + typeof obj +
- ": {" + info.join(", ") + "}");
-}
-
-
-/*--------------------------------------------------------------------------*/
-
-var Builder = {
- NODEMAP: {
- AREA: 'map',
- CAPTION: 'table',
- COL: 'table',
- COLGROUP: 'table',
- LEGEND: 'fieldset',
- OPTGROUP: 'select',
- OPTION: 'select',
- PARAM: 'object',
- TBODY: 'table',
- TD: 'table',
- TFOOT: 'table',
- TH: 'table',
- THEAD: 'table',
- TR: 'table'
- },
- // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken,
- // due to a Firefox bug
- node: function(elementName) {
- elementName = elementName.toUpperCase();
-
- // try innerHTML approach
- var parentTag = this.NODEMAP[elementName] || 'div';
- var parentElement = document.createElement(parentTag);
- parentElement.innerHTML = "<" + elementName + "></" +
elementName + ">";
- var element = parentElement.firstChild || null;
-
- // see if browser added wrapping tags
- if(element && (element.tagName != elementName))
- element = element.getElementsByTagName(elementName)[0];
-
- // fallback to createElement approach
- if(!element) element = document.createElement(elementName);
-
- // abort if nothing could be created
- if(!element) return;
-
- // attributes (or text)
- if(arguments[1])
- if(this._isStringOrNumber(arguments[1]) ||
- (arguments[1] instanceof Array)) {
- this._children(element, arguments[1]);
- } else {
- var attrs = this._attributes(arguments[1]);
- if(attrs.length) {
- parentElement.innerHTML = "<" +elementName + " " +
- attrs + "></" + elementName + ">";
- element = parentElement.firstChild || null;
- // workaround firefox 1.0.X bug
- if(!element) {
- element = document.createElement(elementName);
- for(attr in arguments[1])
- element[attr == 'class' ? 'className' : attr] =
arguments[1][attr];
- }
- if(element.tagName != elementName)
- element = parentElement.getElementsByTagName(elementName)[0];
- }
- }
-
- // text, or array of children
- if(arguments[2])
- this._children(element, arguments[2]);
-
- return element;
- },
- _text: function(text) {
- return document.createTextNode(text);
- },
- _attributes: function(attributes) {
- var attrs = [];
- for(attribute in attributes)
- attrs.push((attribute=='className' ? 'class' : attribute) +
- '="' + attributes[attribute].toString().escapeHTML() +
'"');
- return attrs.join(" ");
- },
- _children: function(element, children) {
- if(typeof children=='object') { // array can hold nodes and text
- children.flatten().each( function(e) {
- if(typeof e=='object')
- element.appendChild(e)
- else
- if(Builder._isStringOrNumber(e))
- element.appendChild(Builder._text(e));
- });
- } else
- if(Builder._isStringOrNumber(children))
- element.appendChild(Builder._text(children));
- },
- _isStringOrNumber: function(param) {
- return(typeof param=='string' || typeof param=='number');
- }
-}
-
/* ------------- element ext -------------- */
// converts rgb() and #xxx to #xxxxxx format,
@@ -371,6 +256,9 @@
Effect.Queue = {
effects: [],
+ _each: function(iterator) {
+ this.effects._each(iterator);
+ },
interval: null,
add: function(effect) {
var timestamp = new Date().getTime();
@@ -407,6 +295,7 @@
this.effects.invoke('loop', timePos);
}
}
+Object.extend(Effect.Queue, Enumerable);
Effect.Base = function() {};
Effect.Base.prototype = {
@@ -632,6 +521,8 @@
this.start(options);
},
setup: function() {
+ // Prevent executing on elements not in the layout flow
+ if(this.element.style.display=='none') { this.cancel(); return; }
// Disable background image during the effect
this.oldBgImage = this.element.style.backgroundImage;
this.element.style.backgroundImage = "none";
@@ -862,7 +753,7 @@
},
afterUpdateInternal: function(effect) {
effect.element.firstChild.style.bottom =
- (effect.originalHeight - effect.element.clientHeight) + 'px'; },
+ (effect.dims[0] - effect.element.clientHeight) + 'px'; },
afterFinishInternal: function(effect) {
Element.undoClipping(effect.element);
Element.undoPositioned(effect.element.firstChild);
@@ -889,7 +780,7 @@
},
afterUpdateInternal: function(effect) {
effect.element.firstChild.style.bottom =
- (effect.originalHeight - effect.element.clientHeight) + 'px'; },
+ (effect.dims[0] - effect.element.clientHeight) + 'px'; },
afterFinishInternal: function(effect) {
Element.hide(effect.element);
Element.undoClipping(effect.element);
@@ -987,7 +878,7 @@
els.top = oldTop;
els.left = oldLeft;
els.height = oldHeight;
- els.width = originalWidth;
+ els.width = originalWidth + 'px';
Element.setInlineOpacity(el, oldOpacity);
}
}, options)
Index: web/ranch/public/javascripts/dragdrop.js
--- web/ranch/public/javascripts/dragdrop.js (revision 7)
+++ web/ranch/public/javascripts/dragdrop.js (working copy)
@@ -280,7 +280,7 @@
style.position = "relative";
if(this.options.zindex) {
- this.options.originalZ =
parseInt(Element.getStyle(this.element,'z-index') || 0);
+ this.originalZ = parseInt(Element.getStyle(this.element,'z-index') ||
0);
style.zIndex = this.options.zindex;
}
@@ -355,8 +355,8 @@
hoverclass: null,
ghosting: false,
format: null,
- onChange: function() {},
- onUpdate: function() {}
+ onChange: Prototype.emptyFunction,
+ onUpdate: Prototype.emptyFunction
}, arguments[1] || {});
// clear any old sortable with same element
@@ -472,7 +472,10 @@
onEmptyHover: function(element, dropon) {
if(element.parentNode!=dropon) {
+ var oldParentNode = element.parentNode;
dropon.appendChild(element);
+ Sortable.options(oldParentNode).onChange(element);
+ Sortable.options(dropon).onChange(element);
}
},
Index: web/ranch/public/javascripts/controls.js
--- web/ranch/public/javascripts/controls.js (revision 7)
+++ web/ranch/public/javascripts/controls.js (working copy)
@@ -184,7 +184,10 @@
this.show();
this.active = true;
}
- } else this.hide();
+ } else {
+ this.active = false;
+ this.hide();
+ }
},
markPrevious: function() {
@@ -425,6 +428,15 @@
//
// see documentation on
http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor
+// Use this if you notice weird scrolling problems on some browsers,
+// the DOM might be a bit confused when this gets called so do this
+// waits 1 ms (with setTimeout) until it does the activation
+Field.scrollFreeActivate = function(field) {
+ setTimeout(function() {
+ Field.activate(field);
+ }, 1);
+}
+
Ajax.InPlaceEditor = Class.create();
Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99";
Ajax.InPlaceEditor.prototype = {
@@ -490,7 +502,7 @@
Event.observe(this.options.externalControl, 'mouseout',
this.mouseoutListener);
}
},
- enterEditMode: function() {
+ enterEditMode: function(evt) {
if (this.saving) return;
if (this.editing) return;
this.editing = true;
@@ -501,11 +513,12 @@
Element.hide(this.element);
this.createForm();
this.element.parentNode.insertBefore(this.form, this.element);
- Field.focus(this.editField);
+ Field.scrollFreeActivate(this.editField);
// stop the event to avoid a page refresh in Safari
- if (arguments.length > 1) {
- Event.stop(arguments[0]);
+ if (evt) {
+ Event.stop(evt);
}
+ return false;
},
createForm: function() {
this.form = document.createElement("form");