rails 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rails might be problematic. Click here for more details.

@@ -77,9 +77,12 @@ Element.getInlineOpacity = function(element){
77
77
  }
78
78
 
79
79
  Element.childrenWithClassName = function(element, className, findFirst) {
80
- return [$A($(element).getElementsByTagName('*'))[findFirst ? 'detect' : 'select']( function(c) {
81
- return c.className ? Element.hasClassName(c, className) : false;
82
- })].flatten();
80
+ var classNameRegExp = new RegExp("(^|\\s)" + className + "(\\s|$)");
81
+ var results = $A($(element).getElementsByTagName('*'))[findFirst ? 'detect' : 'select']( function(c) {
82
+ return (c.className && c.className.match(classNameRegExp));
83
+ });
84
+ if(!results) results = [];
85
+ return results;
83
86
  }
84
87
 
85
88
  Element.forceRerendering = function(element) {
@@ -91,11 +94,6 @@ Element.forceRerendering = function(element) {
91
94
  } catch(e) { }
92
95
  };
93
96
 
94
- ['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom',
95
- 'collectTextNodes','collectTextNodesIgnoreClass','childrenWithClassName'].each(
96
- function(f) { Element.Methods[f] = Element[f]; }
97
- );
98
-
99
97
  /*--------------------------------------------------------------------------*/
100
98
 
101
99
  Array.prototype.call = function() {
@@ -943,11 +941,18 @@ Effect.Fold = function(element) {
943
941
  effect.element.setStyle(oldStyle);
944
942
  } });
945
943
  }}, arguments[1] || {}));
946
- }
944
+ };
945
+
946
+ ['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom',
947
+ 'collectTextNodes','collectTextNodesIgnoreClass','childrenWithClassName'].each(
948
+ function(f) { Element.Methods[f] = Element[f]; }
949
+ );
947
950
 
948
951
  Element.Methods.visualEffect = function(element, effect, options) {
949
952
  s = effect.gsub(/_/, '-').camelize();
950
953
  effect_class = s.charAt(0).toUpperCase() + s.substring(1);
951
954
  new Effect[effect_class](element, options);
952
955
  return $(element);
953
- };
956
+ };
957
+
958
+ Element.addMethods();
@@ -1,4 +1,4 @@
1
- /* Prototype JavaScript framework, version 1.5.0_pre1
1
+ /* Prototype JavaScript framework, version 1.5.0_rc0
2
2
  * (c) 2005 Sam Stephenson <sam@conio.net>
3
3
  *
4
4
  * Prototype is freely distributable under the terms of an MIT-style license.
@@ -7,7 +7,7 @@
7
7
  /*--------------------------------------------------------------------------*/
8
8
 
9
9
  var Prototype = {
10
- Version: '1.5.0_pre1',
10
+ Version: '1.5.0_rc0',
11
11
  ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
12
12
 
13
13
  emptyFunction: function() {},
@@ -25,7 +25,7 @@ var Class = {
25
25
  var Abstract = new Object();
26
26
 
27
27
  Object.extend = function(destination, source) {
28
- for (property in source) {
28
+ for (var property in source) {
29
29
  destination[property] = source[property];
30
30
  }
31
31
  return destination;
@@ -176,7 +176,7 @@ Object.extend(String.prototype, {
176
176
  },
177
177
 
178
178
  evalScripts: function() {
179
- return this.extractScripts().map(eval);
179
+ return this.extractScripts().map(function(script) { return eval(script) });
180
180
  },
181
181
 
182
182
  escapeHTML: function() {
@@ -355,7 +355,7 @@ var Enumerable = {
355
355
  var result;
356
356
  this.each(function(value, index) {
357
357
  value = (iterator || Prototype.K)(value, index);
358
- if (value >= (result || value))
358
+ if (result == undefined || value >= result)
359
359
  result = value;
360
360
  });
361
361
  return result;
@@ -365,7 +365,7 @@ var Enumerable = {
365
365
  var result;
366
366
  this.each(function(value, index) {
367
367
  value = (iterator || Prototype.K)(value, index);
368
- if (value <= (result || value))
368
+ if (result == undefined || value < result)
369
369
  result = value;
370
370
  });
371
371
  return result;
@@ -447,7 +447,8 @@ var $A = Array.from = function(iterable) {
447
447
 
448
448
  Object.extend(Array.prototype, Enumerable);
449
449
 
450
- Array.prototype._reverse = Array.prototype.reverse;
450
+ if (!Array.prototype._reverse)
451
+ Array.prototype._reverse = Array.prototype.reverse;
451
452
 
452
453
  Object.extend(Array.prototype, {
453
454
  _each: function(iterator) {
@@ -476,7 +477,7 @@ Object.extend(Array.prototype, {
476
477
 
477
478
  flatten: function() {
478
479
  return this.inject([], function(array, value) {
479
- return array.concat(value.constructor == Array ?
480
+ return array.concat(value && value.constructor == Array ?
480
481
  value.flatten() : [value]);
481
482
  });
482
483
  },
@@ -498,21 +499,13 @@ Object.extend(Array.prototype, {
498
499
  return (inline !== false ? this : this.toArray())._reverse();
499
500
  },
500
501
 
501
- shift: function() {
502
- var result = this[0];
503
- for (var i = 0; i < this.length - 1; i++)
504
- this[i] = this[i + 1];
505
- this.length--;
506
- return result;
507
- },
508
-
509
502
  inspect: function() {
510
503
  return '[' + this.map(Object.inspect).join(', ') + ']';
511
504
  }
512
505
  });
513
506
  var Hash = {
514
507
  _each: function(iterator) {
515
- for (key in this) {
508
+ for (var key in this) {
516
509
  var value = this[key];
517
510
  if (typeof value == 'function') continue;
518
511
 
@@ -590,9 +583,9 @@ var $R = function(start, end, exclusive) {
590
583
  var Ajax = {
591
584
  getTransport: function() {
592
585
  return Try.these(
586
+ function() {return new XMLHttpRequest()},
593
587
  function() {return new ActiveXObject('Msxml2.XMLHTTP')},
594
- function() {return new ActiveXObject('Microsoft.XMLHTTP')},
595
- function() {return new XMLHttpRequest()}
588
+ function() {return new ActiveXObject('Microsoft.XMLHTTP')}
596
589
  ) || false;
597
590
  },
598
591
 
@@ -644,6 +637,7 @@ Ajax.Base.prototype = {
644
637
  this.options = {
645
638
  method: 'post',
646
639
  asynchronous: true,
640
+ contentType: 'application/x-www-form-urlencoded',
647
641
  parameters: ''
648
642
  }
649
643
  Object.extend(this.options, options || {});
@@ -707,8 +701,7 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
707
701
  'Accept', 'text/javascript, text/html, application/xml, text/xml, */*'];
708
702
 
709
703
  if (this.options.method == 'post') {
710
- requestHeaders.push('Content-type',
711
- 'application/x-www-form-urlencoded');
704
+ requestHeaders.push('Content-type', this.options.contentType);
712
705
 
713
706
  /* Force "Connection: close" for Mozilla browsers to work around
714
707
  * a bug where XMLHttpReqeuest sends an incorrect Content-length
@@ -739,7 +732,7 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
739
732
 
740
733
  evalJSON: function() {
741
734
  try {
742
- return eval(this.header('X-JSON'));
735
+ return eval('(' + this.header('X-JSON') + ')');
743
736
  } catch (e) {}
744
737
  },
745
738
 
@@ -900,13 +893,14 @@ if (!window.Element)
900
893
 
901
894
  Element.extend = function(element) {
902
895
  if (!element) return;
896
+ if (_nativeExtensions) return element;
903
897
 
904
898
  if (!element._extended && element.tagName && element != window) {
905
- var methods = Element.Methods;
899
+ var methods = Element.Methods, cache = Element.extend.cache;
906
900
  for (property in methods) {
907
901
  var value = methods[property];
908
902
  if (typeof value == 'function')
909
- element[property] = value.bind(null, element);
903
+ element[property] = cache.findOrStore(value);
910
904
  }
911
905
  }
912
906
 
@@ -914,6 +908,14 @@ Element.extend = function(element) {
914
908
  return element;
915
909
  }
916
910
 
911
+ Element.extend.cache = {
912
+ findOrStore: function(value) {
913
+ return this[value] = this[value] || function() {
914
+ return value.apply(null, [this].concat($A(arguments)));
915
+ }
916
+ }
917
+ }
918
+
917
919
  Element.Methods = {
918
920
  visible: function(element) {
919
921
  return $(element).style.display != 'none';
@@ -1035,7 +1037,7 @@ Element.Methods = {
1035
1037
 
1036
1038
  setStyle: function(element, style) {
1037
1039
  element = $(element);
1038
- for (name in style)
1040
+ for (var name in style)
1039
1041
  element.style[name.camelize()] = style[name];
1040
1042
  },
1041
1043
 
@@ -1105,6 +1107,29 @@ Element.Methods = {
1105
1107
 
1106
1108
  Object.extend(Element, Element.Methods);
1107
1109
 
1110
+ var _nativeExtensions = false;
1111
+
1112
+ if(!HTMLElement && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) {
1113
+ var HTMLElement = {}
1114
+ HTMLElement.prototype = document.createElement('div').__proto__;
1115
+ }
1116
+
1117
+ Element.addMethods = function(methods) {
1118
+ Object.extend(Element.Methods, methods || {});
1119
+
1120
+ if(typeof HTMLElement != 'undefined') {
1121
+ var methods = Element.Methods, cache = Element.extend.cache;
1122
+ for (property in methods) {
1123
+ var value = methods[property];
1124
+ if (typeof value == 'function')
1125
+ HTMLElement.prototype[property] = cache.findOrStore(value);
1126
+ }
1127
+ _nativeExtensions = true;
1128
+ }
1129
+ }
1130
+
1131
+ Element.addMethods();
1132
+
1108
1133
  var Toggle = new Object();
1109
1134
  Toggle.display = Element.toggle;
1110
1135
 
@@ -1123,7 +1148,8 @@ Abstract.Insertion.prototype = {
1123
1148
  try {
1124
1149
  this.element.insertAdjacentHTML(this.adjacency, this.content);
1125
1150
  } catch (e) {
1126
- if (this.element.tagName.toLowerCase() == 'tbody') {
1151
+ var tagName = this.element.tagName.toLowerCase();
1152
+ if (tagName == 'tbody' || tagName == 'tr') {
1127
1153
  this.insertContent(this.contentFromAnonymousTable());
1128
1154
  } else {
1129
1155
  throw e;
@@ -1396,7 +1422,7 @@ var Form = {
1396
1422
  form = $(form);
1397
1423
  var elements = new Array();
1398
1424
 
1399
- for (tagName in Form.Element.Serializers) {
1425
+ for (var tagName in Form.Element.Serializers) {
1400
1426
  var tagElements = form.getElementsByTagName(tagName);
1401
1427
  for (var j = 0; j < tagElements.length; j++)
1402
1428
  elements.push(tagElements[j]);
@@ -1518,23 +1544,17 @@ Form.Element.Serializers = {
1518
1544
  var value = '', opt, index = element.selectedIndex;
1519
1545
  if (index >= 0) {
1520
1546
  opt = element.options[index];
1521
- value = opt.value;
1522
- if (!value && !('value' in opt))
1523
- value = opt.text;
1547
+ value = opt.value || opt.text;
1524
1548
  }
1525
1549
  return [element.name, value];
1526
1550
  },
1527
1551
 
1528
1552
  selectMany: function(element) {
1529
- var value = new Array();
1553
+ var value = [];
1530
1554
  for (var i = 0; i < element.length; i++) {
1531
1555
  var opt = element.options[i];
1532
- if (opt.selected) {
1533
- var optValue = opt.value;
1534
- if (!optValue && !('value' in opt))
1535
- optValue = opt.text;
1536
- value.push(optValue);
1537
- }
1556
+ if (opt.selected)
1557
+ value.push(opt.value || opt.text);
1538
1558
  }
1539
1559
  return [element.name, value];
1540
1560
  }
@@ -1751,7 +1771,8 @@ Object.extend(Event, {
1751
1771
  });
1752
1772
 
1753
1773
  /* prevent memory leaks in IE */
1754
- Event.observe(window, 'unload', Event.unloadCache, false);
1774
+ if (navigator.appVersion.match(/\bMSIE\b/))
1775
+ Event.observe(window, 'unload', Event.unloadCache, false);
1755
1776
  var Position = {
1756
1777
  // set to true if needed, warning: firefox performance problems
1757
1778
  // NOT neeeded for page scrolling, only if draggable contained in
@@ -22,4 +22,4 @@ if options[:sandbox]
22
22
  else
23
23
  puts "Loading #{ENV['RAILS_ENV']} environment."
24
24
  end
25
- exec "#{options[:irb]} #{libs} --prompt-mode simple"
25
+ exec "#{options[:irb]} #{libs} --simple-prompt"
@@ -31,7 +31,7 @@
31
31
  # look like subversion repositories with plugins:
32
32
  # http://wiki.rubyonrails.org/rails/pages/Plugins
33
33
  #
34
- # * Unless you specify that you want to use svn, script/plugin uses plain ole
34
+ # * Unless you specify that you want to use svn, script/plugin uses plain old
35
35
  # HTTP for downloads. The following bullets are true if you specify
36
36
  # that you want to use svn.
37
37
  #
@@ -107,7 +107,7 @@ class RailsEnvironment
107
107
 
108
108
  def use_checkout?
109
109
  # this is a bit of a guess. we assume that if the rails environment
110
- # is under subversion than they probably want the plugin checked out
110
+ # is under subversion then they probably want the plugin checked out
111
111
  # instead of exported. This can be overridden on the command line
112
112
  File.directory?("#{root}/.svn")
113
113
  end
@@ -161,6 +161,7 @@ class Plugin
161
161
 
162
162
  def install(method=nil, options = {})
163
163
  method ||= rails_env.best_install_method?
164
+ method = :export if method == :http and @uri =~ /svn:\/\/*/
164
165
 
165
166
  uninstall if installed? and options[:force]
166
167
 
@@ -655,7 +656,7 @@ module Commands
655
656
  puts "Scraping #{uri}" if $verbose
656
657
  dupes = []
657
658
  content = open(uri).each do |line|
658
- if line =~ /<a[^>]*href=['"]([^'"]*)['"]/
659
+ if line =~ /<a[^>]*href=['"]([^'"]*)['"]/ or line =~ /(svn:\/\/[^<|\n]*)/
659
660
  uri = $1
660
661
  if uri =~ /\/plugins\// and uri !~ /\/browser\//
661
662
  uri = extract_repository_uri(uri)
@@ -813,9 +814,13 @@ class RecursiveHTTPFetcher
813
814
 
814
815
  def ls
815
816
  @urls_to_fetch.collect do |url|
816
- open(url) do |stream|
817
- links("", stream.read)
818
- end rescue nil
817
+ if url =~ /^svn:\/\/.*/
818
+ `svn ls #{url}`.split("\n").map {|entry| "/#{entry}"} rescue nil
819
+ else
820
+ open(url) do |stream|
821
+ links("", stream.read)
822
+ end rescue nil
823
+ end
819
824
  end.flatten
820
825
  end
821
826
 
@@ -1,6 +1,17 @@
1
1
  require 'optparse'
2
2
  require 'socket'
3
3
 
4
+ def daemonize #:nodoc:
5
+ exit if fork # Parent exits, child continues.
6
+ Process.setsid # Become session leader.
7
+ exit if fork # Zap session leader. See [1].
8
+ Dir.chdir "/" # Release old working directory.
9
+ File.umask 0000 # Ensure sensible umask. Adjust as needed.
10
+ STDIN.reopen "/dev/null" # Free file descriptors and
11
+ STDOUT.reopen "/dev/null", "a" # point them somewhere sensible.
12
+ STDERR.reopen STDOUT # STDOUT/ERR should better go to a logfile.
13
+ end
14
+
4
15
  def spawn(port)
5
16
  print "Checking if something is already running on port #{port}..."
6
17
  begin
@@ -54,12 +65,12 @@ ARGV.options do |opts|
54
65
 
55
66
  opts.on(" Options:")
56
67
 
57
- opts.on("-p", "--port=number", Integer, "Starting port number (default: #{OPTIONS[:port]})") { |OPTIONS[:port]| }
58
- opts.on("-i", "--instances=number", Integer, "Number of instances (default: #{OPTIONS[:instances]})") { |OPTIONS[:instances]| }
59
- opts.on("-r", "--repeat=seconds", Integer, "Repeat spawn attempts every n seconds (default: off)") { |OPTIONS[:repeat]| }
60
- opts.on("-e", "--environment=name", String, "test|development|production (default: #{OPTIONS[:environment]})") { |OPTIONS[:environment]| }
61
- opts.on("-s", "--spawner=path", String, "default: #{OPTIONS[:spawner]}") { |OPTIONS[:spawner]| }
62
- opts.on("-d", "--dispatcher=path", String, "default: #{OPTIONS[:dispatcher]}") { |dispatcher| OPTIONS[:dispatcher] = File.expand_path(dispatcher) }
68
+ opts.on("-p", "--port=number", Integer, "Starting port number (default: #{OPTIONS[:port]})") { |OPTIONS[:port]| }
69
+ opts.on("-i", "--instances=number", Integer, "Number of instances (default: #{OPTIONS[:instances]})") { |OPTIONS[:instances]| }
70
+ opts.on("-r", "--repeat=seconds", Integer, "Repeat spawn attempts every n seconds (default: off)") { |OPTIONS[:repeat]| }
71
+ opts.on("-e", "--environment=name", String, "test|development|production (default: #{OPTIONS[:environment]})") { |OPTIONS[:environment]| }
72
+ opts.on("-s", "--spawner=path", String, "default: #{OPTIONS[:spawner]}") { |OPTIONS[:spawner]| }
73
+ opts.on("-d", "--dispatcher=path", String, "default: #{OPTIONS[:dispatcher]}") { |dispatcher| OPTIONS[:dispatcher] = File.expand_path(dispatcher) }
63
74
 
64
75
  opts.separator ""
65
76
 
@@ -71,10 +82,12 @@ end
71
82
  ENV["RAILS_ENV"] = OPTIONS[:environment]
72
83
 
73
84
  if OPTIONS[:repeat]
85
+ daemonize
86
+ trap("TERM") { exit }
87
+
74
88
  loop do
75
89
  spawn_all
76
- puts "Sleeping for #{OPTIONS[:repeat]} seconds"
77
- sleep OPTIONS[:repeat]
90
+ sleep(OPTIONS[:repeat])
78
91
  end
79
92
  else
80
93
  spawn_all
@@ -90,8 +90,26 @@ class Dispatcher
90
90
  rescue Object
91
91
  begin
92
92
  output.write "Status: #{status}\r\n"
93
- output.write "Content-Type: text/plain\r\n\r\n"
94
- output.write exception.to_s + "\r\n" + exception.backtrace.join("\r\n") if exception
93
+
94
+ if exception
95
+ message = exception.to_s + "\r\n" + exception.backtrace.join("\r\n")
96
+ error_path = File.join(RAILS_ROOT, 'public', '500.html')
97
+
98
+ if defined?(RAILS_DEFAULT_LOGGER) && !RAILS_DEFAULT_LOGGER.nil?
99
+ RAILS_DEFAULT_LOGGER.fatal(message)
100
+
101
+ output.write "Content-Type: text/html\r\n\r\n"
102
+
103
+ if File.exists?(error_path)
104
+ output.write(IO.read(error_path))
105
+ else
106
+ output.write("<html><body><h1>Application error (Rails)</h1></body></html>")
107
+ end
108
+ else
109
+ output.write "Content-Type: text/plain\r\n\r\n"
110
+ output.write(message)
111
+ end
112
+ end
95
113
  rescue Object
96
114
  end
97
115
  end
@@ -2,7 +2,7 @@ module Rails
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 1
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -6,7 +6,7 @@ class AppGenerator < Rails::Generator::Base
6
6
 
7
7
  DATABASES = %w( mysql oracle postgresql sqlite2 sqlite3 )
8
8
 
9
- default_options :db => "mysql", :shebang => DEFAULT_SHEBANG
9
+ default_options :db => "mysql", :shebang => DEFAULT_SHEBANG, :freeze => false
10
10
  mandatory_options :source => "#{File.dirname(__FILE__)}/../../../../.."
11
11
 
12
12
  def initialize(runtime_args, runtime_options = {})
@@ -17,7 +17,8 @@ class AppGenerator < Rails::Generator::Base
17
17
  end
18
18
 
19
19
  def manifest
20
- script_options = { :chmod => 0755 }
20
+ # Use /usr/bin/env if no special shebang was specified
21
+ script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
21
22
  dispatcher_options = { :chmod => 0755, :shebang => options[:shebang] }
22
23
 
23
24
  record do |m|
@@ -43,8 +44,8 @@ class AppGenerator < Rails::Generator::Base
43
44
  m.template "configs/apache.conf", "public/.htaccess"
44
45
 
45
46
  # Environments
46
- m.file "environments/boot.rb", "config/boot.rb"
47
- m.file "environments/environment.rb", "config/environment.rb"
47
+ m.file "environments/boot.rb", "config/boot.rb"
48
+ m.template "environments/environment.rb", "config/environment.rb", :assigns => { :freeze => options[:freeze] }
48
49
  m.file "environments/production.rb", "config/environments/production.rb"
49
50
  m.file "environments/development.rb", "config/environments/development.rb"
50
51
  m.file "environments/test.rb", "config/environments/test.rb"
@@ -93,13 +94,17 @@ class AppGenerator < Rails::Generator::Base
93
94
  def add_options!(opt)
94
95
  opt.separator ''
95
96
  opt.separator 'Options:'
96
- opt.on("-r", "--ruby", String,
97
- "Path to the Ruby binary of your choice.",
97
+ opt.on("-r", "--ruby=path", String,
98
+ "Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).",
98
99
  "Default: #{DEFAULT_SHEBANG}") { |options[:shebang]| }
99
100
 
100
101
  opt.on("-d", "--database=name", String,
101
102
  "Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite2/sqlite3).",
102
103
  "Default: mysql") { |options[:db]| }
104
+
105
+ opt.on("-f", "--freeze",
106
+ "Freeze Rails in vendor/rails from the gems generating the skeleton",
107
+ "Default: false") { |options[:freeze]| }
103
108
  end
104
109
 
105
110
  def mysql_socket_location