railties 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js +59 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js +75 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushBash.js +59 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js +65 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js +100 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js +97 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushCss.js +91 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js +55 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js +41 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js +52 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js +67 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js +52 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushJava.js +57 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js +58 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js +72 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js +88 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js +33 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js +74 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushPython.js +64 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js +55 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushSass.js +94 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushScala.js +51 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushSql.js +66 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushVb.js +56 -0
- data/guides/assets/javascripts/syntaxhighlighter/shBrushXml.js +69 -0
- data/guides/assets/javascripts/syntaxhighlighter/shCore.js +17 -0
- data/guides/assets/stylesheets/main.css +6 -13
- data/guides/assets/stylesheets/syntaxhighlighter/shCore.css +226 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreDefault.css +328 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreDjango.css +331 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreEclipse.css +339 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreEmacs.css +324 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css +328 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreMDUltra.css +324 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreMidnight.css +324 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreRDark.css +324 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeDefault.css +117 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeDjango.css +120 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeEclipse.css +128 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeEmacs.css +113 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css +117 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeMDUltra.css +113 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeMidnight.css +113 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeRDark.css +113 -0
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeRailsGuides.css +116 -0
- data/guides/rails_guides/generator.rb +21 -3
- data/guides/source/3_0_release_notes.textile +3 -7
- data/guides/source/action_controller_overview.textile +8 -1
- data/guides/source/action_mailer_basics.textile +1 -1
- data/guides/source/action_view_overview.textile +1 -1
- data/guides/source/active_record_querying.textile +44 -50
- data/guides/source/active_record_validations_callbacks.textile +3 -3
- data/guides/source/caching_with_rails.textile +1 -1
- data/guides/source/configuring.textile +3 -3
- data/guides/source/debugging_rails_applications.textile +6 -4
- data/guides/source/form_helpers.textile +21 -15
- data/guides/source/getting_started.textile +2 -12
- data/guides/source/i18n.textile +6 -0
- data/guides/source/index.html.erb +10 -2
- data/guides/source/layout.html.erb +13 -5
- data/guides/source/layouts_and_rendering.textile +2 -2
- data/guides/source/migrations.textile +1 -1
- data/guides/source/performance_testing.textile +6 -6
- data/guides/source/plugins.textile +9 -9
- data/guides/source/routing.textile +45 -25
- data/guides/source/ruby_on_rails_guides_guidelines.textile +77 -0
- data/lib/rails/application/configuration.rb +2 -0
- data/lib/rails/application/finisher.rb +7 -0
- data/lib/rails/code_statistics.rb +1 -1
- data/lib/rails/commands/console.rb +1 -1
- data/lib/rails/commands/runner.rb +2 -2
- data/lib/rails/engine/configuration.rb +6 -0
- data/lib/rails/generators/generated_attribute.rb +1 -0
- data/lib/rails/generators/rails/app/app_generator.rb +7 -4
- data/lib/rails/generators/rails/app/templates/Gemfile +2 -3
- data/lib/rails/generators/rails/app/templates/README +1 -1
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +1 -1
- data/lib/rails/generators/resource_helpers.rb +1 -1
- data/lib/rails/plugin.rb +1 -1
- data/lib/rails/railtie.rb +1 -1
- data/lib/rails/railtie/configuration.rb +4 -3
- data/lib/rails/ruby_version_check.rb +1 -2
- data/lib/rails/tasks/misc.rake +1 -1
- data/lib/rails/version.rb +2 -2
- metadata +70 -15
- data/guides/assets/javascripts/code_highlighter.js +0 -188
- data/guides/assets/javascripts/highlighters.js +0 -90
- data/guides/assets/stylesheets/syntax.css +0 -31
@@ -14,8 +14,7 @@ elsif RUBY_VERSION > '1.9' and RUBY_VERSION < '1.9.2'
|
|
14
14
|
$stderr.puts <<-end_message
|
15
15
|
|
16
16
|
Rails 3 doesn't officially support Ruby 1.9.1 since recent stable
|
17
|
-
releases have segfaulted the test suite. Please upgrade to Ruby 1.9.2
|
18
|
-
before Rails 3 is released!
|
17
|
+
releases have segfaulted the test suite. Please upgrade to Ruby 1.9.2.
|
19
18
|
|
20
19
|
You're running
|
21
20
|
#{RUBY_DESCRIPTION}
|
data/lib/rails/tasks/misc.rake
CHANGED
@@ -7,7 +7,7 @@ task :rails_env do
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
desc 'Generate a
|
10
|
+
desc 'Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie sessions).'
|
11
11
|
task :secret do
|
12
12
|
require 'active_support/secure_random'
|
13
13
|
puts ActiveSupport::SecureRandom.hex(64)
|
data/lib/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railties
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 3
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 3
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 3.0.
|
9
|
+
- 2
|
10
|
+
version: 3.0.2
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- David Heinemeier Hansson
|
@@ -14,63 +15,71 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-11-15 00:00:00 -06:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: rake
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 49
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
- 8
|
30
|
-
-
|
31
|
-
version: 0.8.
|
33
|
+
- 7
|
34
|
+
version: 0.8.7
|
32
35
|
type: :runtime
|
33
36
|
version_requirements: *id001
|
34
37
|
- !ruby/object:Gem::Dependency
|
35
38
|
name: thor
|
36
39
|
prerelease: false
|
37
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
38
42
|
requirements:
|
39
43
|
- - ~>
|
40
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 47
|
41
46
|
segments:
|
42
47
|
- 0
|
43
48
|
- 14
|
44
|
-
-
|
45
|
-
version: 0.14.
|
49
|
+
- 4
|
50
|
+
version: 0.14.4
|
46
51
|
type: :runtime
|
47
52
|
version_requirements: *id002
|
48
53
|
- !ruby/object:Gem::Dependency
|
49
54
|
name: activesupport
|
50
55
|
prerelease: false
|
51
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
52
58
|
requirements:
|
53
59
|
- - "="
|
54
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
55
62
|
segments:
|
56
63
|
- 3
|
57
64
|
- 0
|
58
|
-
-
|
59
|
-
version: 3.0.
|
65
|
+
- 2
|
66
|
+
version: 3.0.2
|
60
67
|
type: :runtime
|
61
68
|
version_requirements: *id003
|
62
69
|
- !ruby/object:Gem::Dependency
|
63
70
|
name: actionpack
|
64
71
|
prerelease: false
|
65
72
|
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
66
74
|
requirements:
|
67
75
|
- - "="
|
68
76
|
- !ruby/object:Gem::Version
|
77
|
+
hash: 3
|
69
78
|
segments:
|
70
79
|
- 3
|
71
80
|
- 0
|
72
|
-
-
|
73
|
-
version: 3.0.
|
81
|
+
- 2
|
82
|
+
version: 3.0.2
|
74
83
|
type: :runtime
|
75
84
|
version_requirements: *id004
|
76
85
|
description: "Rails internals: application bootup, plugins, generators, and rake tasks."
|
@@ -152,14 +161,55 @@ files:
|
|
152
161
|
- guides/assets/images/tab_yellow.gif
|
153
162
|
- guides/assets/images/tab_yellow.png
|
154
163
|
- guides/assets/images/validation_error_messages.png
|
155
|
-
- guides/assets/javascripts/code_highlighter.js
|
156
164
|
- guides/assets/javascripts/guides.js
|
157
|
-
- guides/assets/javascripts/
|
165
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js
|
166
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js
|
167
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushBash.js
|
168
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js
|
169
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js
|
170
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js
|
171
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushCss.js
|
172
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js
|
173
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js
|
174
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js
|
175
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js
|
176
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushJava.js
|
177
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js
|
178
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js
|
179
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js
|
180
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js
|
181
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js
|
182
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js
|
183
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushPython.js
|
184
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js
|
185
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushSass.js
|
186
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushScala.js
|
187
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushSql.js
|
188
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushVb.js
|
189
|
+
- guides/assets/javascripts/syntaxhighlighter/shBrushXml.js
|
190
|
+
- guides/assets/javascripts/syntaxhighlighter/shCore.js
|
158
191
|
- guides/assets/stylesheets/main.css
|
159
192
|
- guides/assets/stylesheets/print.css
|
160
193
|
- guides/assets/stylesheets/reset.css
|
161
194
|
- guides/assets/stylesheets/style.css
|
162
|
-
- guides/assets/stylesheets/
|
195
|
+
- guides/assets/stylesheets/syntaxhighlighter/shCore.css
|
196
|
+
- guides/assets/stylesheets/syntaxhighlighter/shCoreDefault.css
|
197
|
+
- guides/assets/stylesheets/syntaxhighlighter/shCoreDjango.css
|
198
|
+
- guides/assets/stylesheets/syntaxhighlighter/shCoreEclipse.css
|
199
|
+
- guides/assets/stylesheets/syntaxhighlighter/shCoreEmacs.css
|
200
|
+
- guides/assets/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css
|
201
|
+
- guides/assets/stylesheets/syntaxhighlighter/shCoreMDUltra.css
|
202
|
+
- guides/assets/stylesheets/syntaxhighlighter/shCoreMidnight.css
|
203
|
+
- guides/assets/stylesheets/syntaxhighlighter/shCoreRDark.css
|
204
|
+
- guides/assets/stylesheets/syntaxhighlighter/shThemeDefault.css
|
205
|
+
- guides/assets/stylesheets/syntaxhighlighter/shThemeDjango.css
|
206
|
+
- guides/assets/stylesheets/syntaxhighlighter/shThemeEclipse.css
|
207
|
+
- guides/assets/stylesheets/syntaxhighlighter/shThemeEmacs.css
|
208
|
+
- guides/assets/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css
|
209
|
+
- guides/assets/stylesheets/syntaxhighlighter/shThemeMDUltra.css
|
210
|
+
- guides/assets/stylesheets/syntaxhighlighter/shThemeMidnight.css
|
211
|
+
- guides/assets/stylesheets/syntaxhighlighter/shThemeRailsGuides.css
|
212
|
+
- guides/assets/stylesheets/syntaxhighlighter/shThemeRDark.css
|
163
213
|
- guides/rails_guides/generator.rb
|
164
214
|
- guides/rails_guides/helpers.rb
|
165
215
|
- guides/rails_guides/indexer.rb
|
@@ -201,6 +251,7 @@ files:
|
|
201
251
|
- guides/source/rails_application_templates.textile
|
202
252
|
- guides/source/rails_on_rack.textile
|
203
253
|
- guides/source/routing.textile
|
254
|
+
- guides/source/ruby_on_rails_guides_guidelines.textile
|
204
255
|
- guides/source/security.textile
|
205
256
|
- guides/source/testing.textile
|
206
257
|
- guides/w3c_validator.rb
|
@@ -417,25 +468,29 @@ rdoc_options:
|
|
417
468
|
require_paths:
|
418
469
|
- lib
|
419
470
|
required_ruby_version: !ruby/object:Gem::Requirement
|
471
|
+
none: false
|
420
472
|
requirements:
|
421
473
|
- - ">="
|
422
474
|
- !ruby/object:Gem::Version
|
475
|
+
hash: 57
|
423
476
|
segments:
|
424
477
|
- 1
|
425
478
|
- 8
|
426
479
|
- 7
|
427
480
|
version: 1.8.7
|
428
481
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
482
|
+
none: false
|
429
483
|
requirements:
|
430
484
|
- - ">="
|
431
485
|
- !ruby/object:Gem::Version
|
486
|
+
hash: 3
|
432
487
|
segments:
|
433
488
|
- 0
|
434
489
|
version: "0"
|
435
490
|
requirements: []
|
436
491
|
|
437
492
|
rubyforge_project: rails
|
438
|
-
rubygems_version: 1.3.
|
493
|
+
rubygems_version: 1.3.7
|
439
494
|
signing_key:
|
440
495
|
specification_version: 3
|
441
496
|
summary: Tools for creating, working with, and running Rails applications.
|
@@ -1,188 +0,0 @@
|
|
1
|
-
/* Unobtrustive Code Highlighter By Dan Webb 11/2005
|
2
|
-
Version: 0.4
|
3
|
-
|
4
|
-
Usage:
|
5
|
-
Add a script tag for this script and any stylesets you need to use
|
6
|
-
to the page in question, add correct class names to CODE elements,
|
7
|
-
define CSS styles for elements. That's it!
|
8
|
-
|
9
|
-
Known to work on:
|
10
|
-
IE 5.5+ PC
|
11
|
-
Firefox/Mozilla PC/Mac
|
12
|
-
Opera 7.23 + PC
|
13
|
-
Safari 2
|
14
|
-
|
15
|
-
Known to degrade gracefully on:
|
16
|
-
IE5.0 PC
|
17
|
-
|
18
|
-
Note: IE5.0 fails due to the use of lookahead in some stylesets. To avoid script errors
|
19
|
-
in older browsers use expressions that use lookahead in string format when defining stylesets.
|
20
|
-
|
21
|
-
This script is inspired by star-light by entirely cunning Dean Edwards
|
22
|
-
http://dean.edwards.name/star-light/.
|
23
|
-
*/
|
24
|
-
|
25
|
-
// replace callback support for safari.
|
26
|
-
if ("a".replace(/a/, function() {return "b"}) != "b") (function(){
|
27
|
-
var default_replace = String.prototype.replace;
|
28
|
-
String.prototype.replace = function(search,replace){
|
29
|
-
// replace is not function
|
30
|
-
if(typeof replace != "function"){
|
31
|
-
return default_replace.apply(this,arguments)
|
32
|
-
}
|
33
|
-
var str = "" + this;
|
34
|
-
var callback = replace;
|
35
|
-
// search string is not RegExp
|
36
|
-
if(!(search instanceof RegExp)){
|
37
|
-
var idx = str.indexOf(search);
|
38
|
-
return (
|
39
|
-
idx == -1 ? str :
|
40
|
-
default_replace.apply(str,[search,callback(search, idx, str)])
|
41
|
-
)
|
42
|
-
}
|
43
|
-
var reg = search;
|
44
|
-
var result = [];
|
45
|
-
var lastidx = reg.lastIndex;
|
46
|
-
var re;
|
47
|
-
while((re = reg.exec(str)) != null){
|
48
|
-
var idx = re.index;
|
49
|
-
var args = re.concat(idx, str);
|
50
|
-
result.push(
|
51
|
-
str.slice(lastidx,idx),
|
52
|
-
callback.apply(null,args).toString()
|
53
|
-
);
|
54
|
-
if(!reg.global){
|
55
|
-
lastidx += RegExp.lastMatch.length;
|
56
|
-
break
|
57
|
-
}else{
|
58
|
-
lastidx = reg.lastIndex;
|
59
|
-
}
|
60
|
-
}
|
61
|
-
result.push(str.slice(lastidx));
|
62
|
-
return result.join("")
|
63
|
-
}
|
64
|
-
})();
|
65
|
-
|
66
|
-
var CodeHighlighter = { styleSets : new Array };
|
67
|
-
|
68
|
-
CodeHighlighter.addStyle = function(name, rules) {
|
69
|
-
// using push test to disallow older browsers from adding styleSets
|
70
|
-
if ([].push) this.styleSets.push({
|
71
|
-
name : name,
|
72
|
-
rules : rules,
|
73
|
-
ignoreCase : arguments[2] || false
|
74
|
-
})
|
75
|
-
|
76
|
-
function setEvent() {
|
77
|
-
// set highlighter to run on load (use LowPro if present)
|
78
|
-
if (typeof Event != 'undefined' && typeof Event.onReady == 'function')
|
79
|
-
return Event.onReady(CodeHighlighter.init.bind(CodeHighlighter));
|
80
|
-
|
81
|
-
var old = window.onload;
|
82
|
-
|
83
|
-
if (typeof window.onload != 'function') {
|
84
|
-
window.onload = function() { CodeHighlighter.init() };
|
85
|
-
} else {
|
86
|
-
window.onload = function() {
|
87
|
-
old();
|
88
|
-
CodeHighlighter.init();
|
89
|
-
}
|
90
|
-
}
|
91
|
-
}
|
92
|
-
|
93
|
-
// only set the event when the first style is added
|
94
|
-
if (this.styleSets.length==1) setEvent();
|
95
|
-
}
|
96
|
-
|
97
|
-
CodeHighlighter.init = function() {
|
98
|
-
if (!document.getElementsByTagName) return;
|
99
|
-
if ("a".replace(/a/, function() {return "b"}) != "b") return; // throw out Safari versions that don't support replace function
|
100
|
-
// throw out older browsers
|
101
|
-
|
102
|
-
var codeEls = document.getElementsByTagName("CODE");
|
103
|
-
// collect array of all pre elements
|
104
|
-
codeEls.filter = function(f) {
|
105
|
-
var a = new Array;
|
106
|
-
for (var i = 0; i < this.length; i++) if (f(this[i])) a[a.length] = this[i];
|
107
|
-
return a;
|
108
|
-
}
|
109
|
-
|
110
|
-
var rules = new Array;
|
111
|
-
rules.toString = function() {
|
112
|
-
// joins regexes into one big parallel regex
|
113
|
-
var exps = new Array;
|
114
|
-
for (var i = 0; i < this.length; i++) exps.push(this[i].exp);
|
115
|
-
return exps.join("|");
|
116
|
-
}
|
117
|
-
|
118
|
-
function addRule(className, rule) {
|
119
|
-
// add a replace rule
|
120
|
-
var exp = (typeof rule.exp != "string")?String(rule.exp).substr(1, String(rule.exp).length-2):rule.exp;
|
121
|
-
// converts regex rules to strings and chops of the slashes
|
122
|
-
rules.push({
|
123
|
-
className : className,
|
124
|
-
exp : "(" + exp + ")",
|
125
|
-
length : (exp.match(/(^|[^\\])\([^?]/g) || "").length + 1, // number of subexps in rule
|
126
|
-
replacement : rule.replacement || null
|
127
|
-
});
|
128
|
-
}
|
129
|
-
|
130
|
-
function parse(text, ignoreCase) {
|
131
|
-
// main text parsing and replacement
|
132
|
-
return text.replace(new RegExp(rules, (ignoreCase)?"gi":"g"), function() {
|
133
|
-
var i = 0, j = 1, rule;
|
134
|
-
while (rule = rules[i++]) {
|
135
|
-
if (arguments[j]) {
|
136
|
-
// if no custom replacement defined do the simple replacement
|
137
|
-
if (!rule.replacement) return "<span class=\"" + rule.className + "\">" + arguments[0] + "</span>";
|
138
|
-
else {
|
139
|
-
// replace $0 with the className then do normal replaces
|
140
|
-
var str = rule.replacement.replace("$0", rule.className);
|
141
|
-
for (var k = 1; k <= rule.length - 1; k++) str = str.replace("$" + k, arguments[j + k]);
|
142
|
-
return str;
|
143
|
-
}
|
144
|
-
} else j+= rule.length;
|
145
|
-
}
|
146
|
-
});
|
147
|
-
}
|
148
|
-
|
149
|
-
function highlightCode(styleSet) {
|
150
|
-
// clear rules array
|
151
|
-
var parsed, clsRx = new RegExp("(\\s|^)" + styleSet.name + "(\\s|$)");
|
152
|
-
rules.length = 0;
|
153
|
-
|
154
|
-
// get stylable elements by filtering out all code elements without the correct className
|
155
|
-
var stylableEls = codeEls.filter(function(item) { return clsRx.test(item.className) });
|
156
|
-
|
157
|
-
// add style rules to parser
|
158
|
-
for (var className in styleSet.rules) addRule(className, styleSet.rules[className]);
|
159
|
-
|
160
|
-
|
161
|
-
// replace for all elements
|
162
|
-
for (var i = 0; i < stylableEls.length; i++) {
|
163
|
-
// EVIL hack to fix IE whitespace badness if it's inside a <pre>
|
164
|
-
if (/MSIE/.test(navigator.appVersion) && stylableEls[i].parentNode.nodeName == 'PRE') {
|
165
|
-
stylableEls[i] = stylableEls[i].parentNode;
|
166
|
-
|
167
|
-
parsed = stylableEls[i].innerHTML.replace(/(<code[^>]*>)([^<]*)<\/code>/i, function() {
|
168
|
-
return arguments[1] + parse(arguments[2], styleSet.ignoreCase) + "</code>"
|
169
|
-
});
|
170
|
-
parsed = parsed.replace(/\n( *)/g, function() {
|
171
|
-
var spaces = "";
|
172
|
-
for (var i = 0; i < arguments[1].length; i++) spaces+= " ";
|
173
|
-
return "\n" + spaces;
|
174
|
-
});
|
175
|
-
parsed = parsed.replace(/\t/g, " ");
|
176
|
-
parsed = parsed.replace(/\n(<\/\w+>)?/g, "<br />$1").replace(/<br \/>[\n\r\s]*<br \/>/g, "<p><br></p>");
|
177
|
-
|
178
|
-
} else parsed = parse(stylableEls[i].innerHTML, styleSet.ignoreCase);
|
179
|
-
|
180
|
-
stylableEls[i].innerHTML = parsed;
|
181
|
-
}
|
182
|
-
}
|
183
|
-
|
184
|
-
// run highlighter on all stylesets
|
185
|
-
for (var i=0; i < this.styleSets.length; i++) {
|
186
|
-
highlightCode(this.styleSets[i]);
|
187
|
-
}
|
188
|
-
}
|
@@ -1,90 +0,0 @@
|
|
1
|
-
CodeHighlighter.addStyle("css", {
|
2
|
-
comment : {
|
3
|
-
exp : /\/\*[^*]*\*+([^\/][^*]*\*+)*\//
|
4
|
-
},
|
5
|
-
keywords : {
|
6
|
-
exp : /@\w[\w\s]*/
|
7
|
-
},
|
8
|
-
selectors : {
|
9
|
-
exp : "([\\w-:\\[.#][^{};>]*)(?={)"
|
10
|
-
},
|
11
|
-
properties : {
|
12
|
-
exp : "([\\w-]+)(?=\\s*:)"
|
13
|
-
},
|
14
|
-
units : {
|
15
|
-
exp : /([0-9])(em|en|px|%|pt)\b/,
|
16
|
-
replacement : "$1<span class=\"$0\">$2</span>"
|
17
|
-
},
|
18
|
-
urls : {
|
19
|
-
exp : /url\([^\)]*\)/
|
20
|
-
}
|
21
|
-
});
|
22
|
-
|
23
|
-
CodeHighlighter.addStyle("ruby",{
|
24
|
-
comment : {
|
25
|
-
exp : /#[^\n]+/
|
26
|
-
},
|
27
|
-
brackets : {
|
28
|
-
exp : /\(|\)/
|
29
|
-
},
|
30
|
-
string : {
|
31
|
-
exp : /'[^']*'|"[^"]*"/
|
32
|
-
},
|
33
|
-
keywords : {
|
34
|
-
exp : /\b(do|end|self|class|def|if|module|yield|then|else|for|until|unless|while|elsif|case|when|break|retry|redo|rescue|require|raise)\b/
|
35
|
-
},
|
36
|
-
/* Added by Shelly Fisher (shelly@agileevolved.com) */
|
37
|
-
symbol : {
|
38
|
-
exp : /([^:])(:[A-Za-z0-9_!?]+)/
|
39
|
-
},
|
40
|
-
ivar : {
|
41
|
-
exp : /\@[A-Za-z0-9_!?]+/
|
42
|
-
}
|
43
|
-
});
|
44
|
-
|
45
|
-
CodeHighlighter.addStyle("html", {
|
46
|
-
comment : {
|
47
|
-
exp: /<!\s*(--([^-]|[\r\n]|-[^-])*--\s*)>/
|
48
|
-
},
|
49
|
-
tag : {
|
50
|
-
exp: /(<\/?)([a-zA-Z1-9]+\s?)/,
|
51
|
-
replacement: "$1<span class=\"$0\">$2</span>"
|
52
|
-
},
|
53
|
-
string : {
|
54
|
-
exp : /'[^']*'|"[^"]*"/
|
55
|
-
},
|
56
|
-
attribute : {
|
57
|
-
exp: /\b([a-zA-Z-:]+)(=)/,
|
58
|
-
replacement: "<span class=\"$0\">$1</span>$2"
|
59
|
-
},
|
60
|
-
doctype : {
|
61
|
-
exp: /<!DOCTYPE([^&]|&[^g]|&g[^t])*>/
|
62
|
-
}
|
63
|
-
});
|
64
|
-
|
65
|
-
CodeHighlighter.addStyle("javascript",{
|
66
|
-
comment : {
|
67
|
-
exp : /(\/\/[^\n]*(\n|$))|(\/\*[^*]*\*+([^\/][^*]*\*+)*\/)/
|
68
|
-
},
|
69
|
-
brackets : {
|
70
|
-
exp : /\(|\)/
|
71
|
-
},
|
72
|
-
string : {
|
73
|
-
exp : /'[^']*'|"[^"]*"/
|
74
|
-
},
|
75
|
-
keywords : {
|
76
|
-
exp : /\b(arguments|break|case|continue|default|delete|do|else|false|for|function|if|in|instanceof|new|null|return|switch|this|true|typeof|var|void|while|with)\b/
|
77
|
-
},
|
78
|
-
global : {
|
79
|
-
exp : /\b(toString|valueOf|window|element|prototype|constructor|document|escape|unescape|parseInt|parseFloat|setTimeout|clearTimeout|setInterval|clearInterval|NaN|isNaN|Infinity)\b/
|
80
|
-
}
|
81
|
-
});
|
82
|
-
|
83
|
-
CodeHighlighter.addStyle("yaml", {
|
84
|
-
keyword : {
|
85
|
-
exp : /\/\*[^*]*\*+([^\/][^*]*\*+)*\//
|
86
|
-
},
|
87
|
-
value : {
|
88
|
-
exp : /@\w[\w\s]*/
|
89
|
-
},
|
90
|
-
});
|