railties 3.0.0.beta2 → 3.0.0.beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +6 -2
- data/guides/{images → assets/images}/belongs_to.png +0 -0
- data/guides/{images → assets/images}/book_icon.gif +0 -0
- data/guides/{images → assets/images}/bullet.gif +0 -0
- data/guides/{images → assets/images}/challenge.png +0 -0
- data/guides/{images → assets/images}/chapters_icon.gif +0 -0
- data/guides/{images → assets/images}/check_bullet.gif +0 -0
- data/guides/{images → assets/images}/credits_pic_blank.gif +0 -0
- data/guides/{images → assets/images}/csrf.png +0 -0
- data/guides/{images → assets/images}/customized_error_messages.png +0 -0
- data/guides/{images → assets/images}/edge_badge.png +0 -0
- data/guides/{images → assets/images}/error_messages.png +0 -0
- data/guides/{images → assets/images}/feature_tile.gif +0 -0
- data/guides/{images → assets/images}/footer_tile.gif +0 -0
- data/guides/{images → assets/images}/fxn.png +0 -0
- data/guides/{images → assets/images}/grey_bullet.gif +0 -0
- data/guides/{images → assets/images}/habtm.png +0 -0
- data/guides/{images → assets/images}/has_many.png +0 -0
- data/guides/{images → assets/images}/has_many_through.png +0 -0
- data/guides/{images → assets/images}/has_one.png +0 -0
- data/guides/{images → assets/images}/has_one_through.png +0 -0
- data/guides/{images → assets/images}/header_backdrop.png +0 -0
- data/guides/{images → assets/images}/header_tile.gif +0 -0
- data/guides/{images → assets/images}/i18n/demo_localized_pirate.png +0 -0
- data/guides/{images → assets/images}/i18n/demo_translated_en.png +0 -0
- data/guides/{images → assets/images}/i18n/demo_translated_pirate.png +0 -0
- data/guides/{images → assets/images}/i18n/demo_translation_missing.png +0 -0
- data/guides/{images → assets/images}/i18n/demo_untranslated.png +0 -0
- data/guides/{images → assets/images}/icons/README +0 -0
- data/guides/{images → assets/images}/icons/callouts/1.png +0 -0
- data/guides/{images → assets/images}/icons/callouts/10.png +0 -0
- data/guides/{images → assets/images}/icons/callouts/11.png +0 -0
- data/guides/{images → assets/images}/icons/callouts/12.png +0 -0
- data/guides/{images → assets/images}/icons/callouts/13.png +0 -0
- data/guides/{images → assets/images}/icons/callouts/14.png +0 -0
- data/guides/{images → assets/images}/icons/callouts/15.png +0 -0
- data/guides/{images → assets/images}/icons/callouts/2.png +0 -0
- data/guides/{images → assets/images}/icons/callouts/3.png +0 -0
- data/guides/{images → assets/images}/icons/callouts/4.png +0 -0
- data/guides/{images → assets/images}/icons/callouts/5.png +0 -0
- data/guides/{images → assets/images}/icons/callouts/6.png +0 -0
- data/guides/{images → assets/images}/icons/callouts/7.png +0 -0
- data/guides/{images → assets/images}/icons/callouts/8.png +0 -0
- data/guides/{images → assets/images}/icons/callouts/9.png +0 -0
- data/guides/{images → assets/images}/icons/caution.png +0 -0
- data/guides/{images → assets/images}/icons/example.png +0 -0
- data/guides/{images → assets/images}/icons/home.png +0 -0
- data/guides/{images → assets/images}/icons/important.png +0 -0
- data/guides/{images → assets/images}/icons/next.png +0 -0
- data/guides/{images → assets/images}/icons/note.png +0 -0
- data/guides/{images → assets/images}/icons/prev.png +0 -0
- data/guides/{images → assets/images}/icons/tip.png +0 -0
- data/guides/{images → assets/images}/icons/up.png +0 -0
- data/guides/{images → assets/images}/icons/warning.png +0 -0
- data/guides/assets/images/jaimeiniesta.jpg +0 -0
- data/guides/{images → assets/images}/nav_arrow.gif +0 -0
- data/guides/{images → assets/images}/polymorphic.png +0 -0
- data/guides/{images → assets/images}/posts_index.png +0 -0
- data/guides/{images → assets/images}/rails_guides_logo.gif +0 -0
- data/guides/{images → assets/images}/rails_logo_remix.gif +0 -0
- data/guides/{images → assets/images}/rails_welcome.png +0 -0
- data/guides/{images → assets/images}/session_fixation.png +0 -0
- data/guides/{images → assets/images}/tab_grey.gif +0 -0
- data/guides/{images → assets/images}/tab_info.gif +0 -0
- data/guides/{images → assets/images}/tab_note.gif +0 -0
- data/guides/{images → assets/images}/tab_red.gif +0 -0
- data/guides/{images → assets/images}/tab_yellow.gif +0 -0
- data/guides/{images → assets/images}/tab_yellow.png +0 -0
- data/guides/{images → assets/images}/validation_error_messages.png +0 -0
- data/guides/{files → assets}/javascripts/code_highlighter.js +0 -0
- data/guides/{files → assets}/javascripts/guides.js +0 -0
- data/guides/{files → assets}/javascripts/highlighters.js +0 -0
- data/guides/{files → assets}/stylesheets/main.css +26 -15
- data/guides/{files → assets}/stylesheets/print.css +0 -0
- data/guides/{files → assets}/stylesheets/reset.css +0 -0
- data/guides/{files → assets}/stylesheets/style.css +0 -0
- data/guides/{files → assets}/stylesheets/syntax.css +0 -0
- data/guides/rails_guides/generator.rb +79 -29
- data/guides/rails_guides/helpers.rb +2 -2
- data/guides/rails_guides/indexer.rb +24 -11
- data/guides/source/2_2_release_notes.textile +1 -1
- data/guides/source/3_0_release_notes.textile +27 -1
- data/guides/source/action_controller_overview.textile +7 -7
- data/guides/source/action_view_overview.textile +15 -15
- data/guides/source/active_record_querying.textile +4 -3
- data/guides/source/active_support_core_extensions.textile +6 -6
- data/guides/source/activerecord_validations_callbacks.textile +1 -1
- data/guides/source/association_basics.textile +83 -82
- data/guides/source/command_line.textile +16 -12
- data/guides/source/configuring.textile +1 -1
- data/guides/source/contribute.textile +1 -1
- data/guides/source/contributing_to_rails.textile +3 -4
- data/guides/source/credits.html.erb +64 -0
- data/guides/source/debugging_rails_applications.textile +2 -1
- data/guides/source/form_helpers.textile +15 -13
- data/guides/source/getting_started.textile +9 -8
- data/guides/source/index.html.erb +154 -0
- data/guides/source/initialization.textile +4138 -0
- data/guides/source/layout.html.erb +15 -7
- data/guides/source/layouts_and_rendering.textile +6 -5
- data/guides/source/nested_model_forms.textile +3 -3
- data/guides/source/performance_testing.textile +4 -4
- data/guides/source/plugins.textile +15 -14
- data/guides/source/rails_on_rack.textile +1 -1
- data/guides/source/routing.textile +379 -490
- data/guides/source/security.textile +5 -5
- data/guides/source/testing.textile +3 -2
- data/lib/rails.rb +7 -2
- data/lib/rails/application.rb +9 -2
- data/lib/rails/application/configuration.rb +19 -10
- data/lib/rails/application/finisher.rb +4 -0
- data/lib/rails/backtrace_cleaner.rb +1 -1
- data/{bin/rails → lib/rails/cli.rb} +0 -0
- data/lib/rails/commands/runner.rb +1 -1
- data/lib/rails/configuration.rb +12 -0
- data/lib/rails/engine.rb +6 -10
- data/lib/rails/engine/configuration.rb +2 -3
- data/lib/rails/generators.rb +1 -6
- data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +0 -7
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +10 -1
- data/lib/rails/generators/erb/scaffold/templates/show.html.erb +2 -0
- data/lib/rails/generators/migration.rb +3 -3
- data/lib/rails/generators/rails/app/app_generator.rb +1 -1
- data/lib/rails/generators/rails/app/templates/Gemfile +2 -0
- data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb +1 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +14 -0
- data/lib/rails/generators/rails/app/templates/config/application.rb +4 -1
- data/lib/rails/generators/rails/app/templates/config/boot.rb +5 -13
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +3 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/{cookie_verification_secret.rb.tt → secret_token.rb.tt} +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +1 -3
- data/lib/rails/generators/rails/app/templates/public/index.html +2 -1
- data/lib/rails/generators/rails/app/templates/public/javascripts/rails.js +41 -32
- data/lib/rails/generators/rails/app/templates/test/{test_helper.rb → test_helper.rb.tt} +2 -0
- data/lib/rails/generators/rails/model/USAGE +15 -0
- data/lib/rails/generators/rails/stylesheets/templates/scaffold.css +3 -8
- data/lib/rails/paths.rb +17 -5
- data/lib/rails/plugin.rb +1 -1
- data/lib/rails/railtie.rb +3 -25
- data/lib/rails/test_unit/testing.rake +11 -7
- data/lib/rails/version.rb +1 -1
- data/lib/rails/webrick_server.rb +2 -2
- metadata +93 -92
- data/guides/source/credits.textile.erb +0 -60
- data/guides/source/index.textile.erb +0 -139
- data/lib/rails/generators/erb/scaffold/templates/layout.html.erb +0 -17
- data/lib/rails/generators/rails/app/templates/app/views/layouts/.empty_directory +0 -0
data/CHANGELOG
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
*Rails 3.0.0 [beta 3] (April 13th, 2010)*
|
|
2
|
+
|
|
3
|
+
* Renamed config.cookie_secret to config.secret_token and pass it as env key. [JV]
|
|
4
|
+
|
|
5
|
+
|
|
1
6
|
*Rails 3.0.0 [beta 2] (April 1st, 2010)*
|
|
2
7
|
|
|
3
8
|
* Session store configuration has changed [YK & CL]
|
|
@@ -6,12 +11,11 @@
|
|
|
6
11
|
config.cookie_secret = "fdsfhisdghfidugnfdlg"
|
|
7
12
|
|
|
8
13
|
* railtie_name and engine_name are deprecated. You can now add any object to
|
|
9
|
-
the configuration object: config.your_plugin = {} [
|
|
14
|
+
the configuration object: config.your_plugin = {} [JV]
|
|
10
15
|
|
|
11
16
|
* Added config.generators.templates to provide alternative paths for the generators
|
|
12
17
|
to look for templates [JV]
|
|
13
18
|
|
|
14
|
-
|
|
15
19
|
*Rails 3.0.0 [beta 1] (February 4, 2010)*
|
|
16
20
|
|
|
17
21
|
* Added "rake about" as a replacement for script/about [DHH]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -92,7 +92,7 @@ body {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
#header {
|
|
95
|
-
background: #c52f24 url(
|
|
95
|
+
background: #c52f24 url(../images/header_tile.gif) repeat-x;
|
|
96
96
|
color: #FFF;
|
|
97
97
|
padding: 1.5em 0;
|
|
98
98
|
position: relative;
|
|
@@ -100,7 +100,7 @@ body {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
#feature {
|
|
103
|
-
background: #d5e9f6 url(
|
|
103
|
+
background: #d5e9f6 url(../images/feature_tile.gif) repeat-x;
|
|
104
104
|
color: #333;
|
|
105
105
|
padding: 0.5em 0 1.5em;
|
|
106
106
|
}
|
|
@@ -132,7 +132,7 @@ body {
|
|
|
132
132
|
|
|
133
133
|
#footer {
|
|
134
134
|
padding: 2em 0;
|
|
135
|
-
background: url(
|
|
135
|
+
background: url(../images/footer_tile.gif) repeat-x;
|
|
136
136
|
}
|
|
137
137
|
#footer .wrapper {
|
|
138
138
|
padding-left: 2em;
|
|
@@ -179,7 +179,7 @@ a, a:link, a:visited {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
#header .nav .index a {
|
|
182
|
-
background: #980905 url(
|
|
182
|
+
background: #980905 url(../images/nav_arrow.gif) no-repeat right top;
|
|
183
183
|
padding-right: 1em;
|
|
184
184
|
position: relative;
|
|
185
185
|
z-index: 15;
|
|
@@ -285,7 +285,7 @@ h6 {
|
|
|
285
285
|
|
|
286
286
|
#header h1 {
|
|
287
287
|
float: left;
|
|
288
|
-
background: url(
|
|
288
|
+
background: url(../images/rails_guides_logo.gif) no-repeat;
|
|
289
289
|
width: 297px;
|
|
290
290
|
text-indent: -9999em;
|
|
291
291
|
margin: 0;
|
|
@@ -306,7 +306,7 @@ h6 {
|
|
|
306
306
|
#feature ul {margin-left: 0;}
|
|
307
307
|
#feature ul li {
|
|
308
308
|
list-style: none;
|
|
309
|
-
background: url(
|
|
309
|
+
background: url(../images/check_bullet.gif) no-repeat left 0.5em;
|
|
310
310
|
padding: 0.5em 1.75em 0.5em 1.75em;
|
|
311
311
|
font-size: 1.1428em;
|
|
312
312
|
font-weight: bold;
|
|
@@ -325,12 +325,12 @@ h6 {
|
|
|
325
325
|
font-size: 1.2857em;
|
|
326
326
|
padding: 0.125em 0 0.25em 0;
|
|
327
327
|
margin-bottom: 0;
|
|
328
|
-
/*background: url(
|
|
328
|
+
/*background: url(../images/book_icon.gif) no-repeat left top;
|
|
329
329
|
padding: 0.125em 0 0.25em 28px;*/
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
#mainCol dd.ticket, #subCol dd.ticket {
|
|
333
|
-
background: #fff9d8 url(
|
|
333
|
+
background: #fff9d8 url(../images/tab_yellow.gif) no-repeat left top;
|
|
334
334
|
border: none;
|
|
335
335
|
padding: 1.25em 1em 1.25em 48px;
|
|
336
336
|
margin-left: 0;
|
|
@@ -338,7 +338,7 @@ h6 {
|
|
|
338
338
|
}
|
|
339
339
|
|
|
340
340
|
#mainCol div.warning, #subCol dd.warning {
|
|
341
|
-
background: #f9d9d8 url(
|
|
341
|
+
background: #f9d9d8 url(../images/tab_red.gif) no-repeat left top;
|
|
342
342
|
border: none;
|
|
343
343
|
padding: 1.25em 1.25em 1.25em 48px;
|
|
344
344
|
margin-left: 0;
|
|
@@ -355,7 +355,7 @@ h6 {
|
|
|
355
355
|
#subCol .chapters ul li {
|
|
356
356
|
list-style: none;
|
|
357
357
|
padding: 0 0 0 1em;
|
|
358
|
-
background: url(
|
|
358
|
+
background: url(../images/bullet.gif) no-repeat left 0.45em;
|
|
359
359
|
margin-left: 0;
|
|
360
360
|
font-size: 1em;
|
|
361
361
|
font-weight: normal;
|
|
@@ -366,7 +366,7 @@ tt {
|
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
div.code_container {
|
|
369
|
-
background: #EEE url(
|
|
369
|
+
background: #EEE url(../images/tab_grey.gif) no-repeat left top;
|
|
370
370
|
padding: 0.25em 1em 0.5em 48px;
|
|
371
371
|
}
|
|
372
372
|
|
|
@@ -378,14 +378,14 @@ code {
|
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
.note {
|
|
381
|
-
background: #fff9d8 url(
|
|
381
|
+
background: #fff9d8 url(../images/tab_note.gif) no-repeat left top;
|
|
382
382
|
border: none;
|
|
383
383
|
padding: 1em 1em 0.25em 48px;
|
|
384
384
|
margin: 0.25em 0 1.5em 0;
|
|
385
385
|
}
|
|
386
386
|
|
|
387
387
|
.info {
|
|
388
|
-
background: #d5e9f6 url(
|
|
388
|
+
background: #d5e9f6 url(../images/tab_info.gif) no-repeat left top;
|
|
389
389
|
border: none;
|
|
390
390
|
padding: 1em 1em 0.25em 48px;
|
|
391
391
|
margin: 0.25em 0 1.5em 0;
|
|
@@ -395,7 +395,7 @@ code {
|
|
|
395
395
|
|
|
396
396
|
#mainCol ul li {
|
|
397
397
|
list-style:none;
|
|
398
|
-
background: url(
|
|
398
|
+
background: url(../images/grey_bullet.gif) no-repeat left 0.5em;
|
|
399
399
|
padding-left: 1em;
|
|
400
400
|
margin-left: 0;
|
|
401
401
|
}
|
|
@@ -437,5 +437,16 @@ div.code_container, div.important, div.caution, div.warning, div.note, div.info
|
|
|
437
437
|
/* Remove bottom margin of paragraphs in special boxes, otherwise they get a
|
|
438
438
|
spurious blank area below with the box background. */
|
|
439
439
|
div.important p, div.caution p, div.warning p, div.note p, div.info p {
|
|
440
|
-
margin-bottom:
|
|
440
|
+
margin-bottom: 1em;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/* Edge Badge
|
|
444
|
+
--------------------------------------- */
|
|
445
|
+
|
|
446
|
+
#edge-badge {
|
|
447
|
+
position: fixed;
|
|
448
|
+
right: 0px;
|
|
449
|
+
top: 0px;
|
|
450
|
+
z-index: 100;
|
|
451
|
+
border: none;
|
|
441
452
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,54 @@
|
|
|
1
|
+
# ---------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# This script generates the guides. It can be invoked either directly or via the
|
|
4
|
+
# generate_guides rake task within the railties directory.
|
|
5
|
+
#
|
|
6
|
+
# Guides are taken from the source directory, and the resulting HTML goes into the
|
|
7
|
+
# output directory. Assets are stored under files, and copied to output/files as
|
|
8
|
+
# part of the generation process.
|
|
9
|
+
#
|
|
10
|
+
# Some arguments may be passed via environment variables:
|
|
11
|
+
#
|
|
12
|
+
# WARNINGS
|
|
13
|
+
# If you are writing a guide, please work always with WARNINGS=1. Users can
|
|
14
|
+
# generate the guides, and thus this flag is off by default.
|
|
15
|
+
#
|
|
16
|
+
# Internal links (anchors) are checked. If a reference is broken levenshtein
|
|
17
|
+
# distance is used to suggest an existing one. This is useful since IDs are
|
|
18
|
+
# generated by Textile from headers and thus edits alter them.
|
|
19
|
+
#
|
|
20
|
+
# Also detects duplicated IDs. They happen if there are headers with the same
|
|
21
|
+
# text. Please do resolve them, if any, so guides are valid XHTML.
|
|
22
|
+
#
|
|
23
|
+
# ALL
|
|
24
|
+
# Set to "1" to force the generation of all guides.
|
|
25
|
+
#
|
|
26
|
+
# ONLY
|
|
27
|
+
# Use ONLY if you want to generate only one or a set of guides. Prefixes are
|
|
28
|
+
# enough:
|
|
29
|
+
#
|
|
30
|
+
# # generates only association_basics.html
|
|
31
|
+
# ONLY=assoc ruby rails_guides.rb
|
|
32
|
+
#
|
|
33
|
+
# Separate many using commas:
|
|
34
|
+
#
|
|
35
|
+
# # generates only
|
|
36
|
+
# ONLY=assoc,migrations ruby rails_guides.rb
|
|
37
|
+
#
|
|
38
|
+
# Note that if you are working on a guide generation will by default process
|
|
39
|
+
# only that one, so ONLY is rarely used nowadays.
|
|
40
|
+
#
|
|
41
|
+
# EDGE
|
|
42
|
+
# Set to "1" to indicate generated guides should be marked as edge. This
|
|
43
|
+
# inserts a badge and changes the preamble of the home page.
|
|
44
|
+
#
|
|
45
|
+
# ---------------------------------------------------------------------------
|
|
46
|
+
|
|
1
47
|
require 'set'
|
|
2
48
|
require 'fileutils'
|
|
3
49
|
|
|
4
50
|
require 'active_support/core_ext/string/output_safety'
|
|
51
|
+
require 'active_support/core_ext/object/blank'
|
|
5
52
|
require 'action_controller'
|
|
6
53
|
require 'action_view'
|
|
7
54
|
|
|
@@ -11,11 +58,14 @@ require 'rails_guides/levenshtein'
|
|
|
11
58
|
|
|
12
59
|
module RailsGuides
|
|
13
60
|
class Generator
|
|
14
|
-
attr_reader :guides_dir, :source_dir, :output_dir
|
|
61
|
+
attr_reader :guides_dir, :source_dir, :output_dir, :edge, :warnings, :all
|
|
62
|
+
|
|
63
|
+
GUIDES_RE = /\.(?:textile|html\.erb)$/
|
|
15
64
|
|
|
16
65
|
def initialize(output=nil)
|
|
17
66
|
initialize_dirs(output)
|
|
18
67
|
create_output_dir_if_needed
|
|
68
|
+
set_flags_from_environment
|
|
19
69
|
end
|
|
20
70
|
|
|
21
71
|
def generate
|
|
@@ -32,7 +82,13 @@ module RailsGuides
|
|
|
32
82
|
|
|
33
83
|
def create_output_dir_if_needed
|
|
34
84
|
FileUtils.mkdir_p(output_dir)
|
|
35
|
-
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def set_flags_from_environment
|
|
88
|
+
@edge = ENV['EDGE'] == '1'
|
|
89
|
+
@warnings = ENV['WARNINGS'] == '1'
|
|
90
|
+
@all = ENV['ALL'] == '1'
|
|
91
|
+
end
|
|
36
92
|
|
|
37
93
|
def generate_guides
|
|
38
94
|
guides_to_generate.each do |guide|
|
|
@@ -42,42 +98,40 @@ module RailsGuides
|
|
|
42
98
|
end
|
|
43
99
|
|
|
44
100
|
def guides_to_generate
|
|
45
|
-
guides = Dir.entries(source_dir).grep(
|
|
46
|
-
ENV.key?(
|
|
101
|
+
guides = Dir.entries(source_dir).grep(GUIDES_RE)
|
|
102
|
+
ENV.key?('ONLY') ? select_only(guides) : guides
|
|
47
103
|
end
|
|
48
104
|
|
|
49
105
|
def select_only(guides)
|
|
50
|
-
prefixes = ENV[
|
|
106
|
+
prefixes = ENV['ONLY'].split(",").map(&:strip)
|
|
51
107
|
guides.select do |guide|
|
|
52
108
|
prefixes.any? {|p| guide.start_with?(p)}
|
|
53
109
|
end
|
|
54
110
|
end
|
|
55
111
|
|
|
56
112
|
def copy_assets
|
|
57
|
-
FileUtils.cp_r(
|
|
58
|
-
FileUtils.cp_r(File.join(guides_dir, 'files'), File.join(output_dir, 'files'))
|
|
113
|
+
FileUtils.cp_r(Dir.glob("#{guides_dir}/assets/*"), output_dir)
|
|
59
114
|
end
|
|
60
115
|
|
|
61
116
|
def output_file_for(guide)
|
|
62
|
-
guide.sub(
|
|
117
|
+
guide.sub(GUIDES_RE, '.html')
|
|
63
118
|
end
|
|
64
119
|
|
|
65
120
|
def generate?(source_file, output_file)
|
|
66
121
|
fin = File.join(source_dir, source_file)
|
|
67
122
|
fout = File.join(output_dir, output_file)
|
|
68
|
-
|
|
123
|
+
all || !File.exists?(fout) || File.mtime(fout) < File.mtime(fin)
|
|
69
124
|
end
|
|
70
125
|
|
|
71
126
|
def generate_guide(guide, output_file)
|
|
72
127
|
puts "Generating #{output_file}"
|
|
73
128
|
File.open(File.join(output_dir, output_file), 'w') do |f|
|
|
74
|
-
view = ActionView::Base.new(source_dir)
|
|
129
|
+
view = ActionView::Base.new(source_dir, :edge => edge)
|
|
75
130
|
view.extend(Helpers)
|
|
76
|
-
|
|
77
|
-
if guide =~ /\.
|
|
78
|
-
# Generate the
|
|
131
|
+
|
|
132
|
+
if guide =~ /\.html\.erb$/
|
|
133
|
+
# Generate the special pages like the home.
|
|
79
134
|
result = view.render(:layout => 'layout', :file => guide)
|
|
80
|
-
result = textile(result)
|
|
81
135
|
else
|
|
82
136
|
body = File.read(File.join(source_dir, guide))
|
|
83
137
|
body = set_header_section(body, view)
|
|
@@ -85,10 +139,9 @@ module RailsGuides
|
|
|
85
139
|
|
|
86
140
|
result = view.render(:layout => 'layout', :text => textile(body))
|
|
87
141
|
|
|
88
|
-
warn_about_broken_links(result) if
|
|
142
|
+
warn_about_broken_links(result) if @warnings
|
|
89
143
|
end
|
|
90
|
-
|
|
91
|
-
result = insert_edge_badge(result) if ENV.key?('INSERT_EDGE_BADGE')
|
|
144
|
+
|
|
92
145
|
f.write result
|
|
93
146
|
end
|
|
94
147
|
end
|
|
@@ -98,7 +151,7 @@ module RailsGuides
|
|
|
98
151
|
header = $1
|
|
99
152
|
|
|
100
153
|
header =~ /h2\.(.*)/
|
|
101
|
-
page_title = $1.strip
|
|
154
|
+
page_title = "Ruby on Rails Guides: #{$1.strip}"
|
|
102
155
|
|
|
103
156
|
header = textile(header)
|
|
104
157
|
|
|
@@ -114,19 +167,19 @@ module RailsGuides
|
|
|
114
167
|
<ol class="chapters">
|
|
115
168
|
INDEX
|
|
116
169
|
|
|
117
|
-
i = Indexer.new(body)
|
|
170
|
+
i = Indexer.new(body, warnings)
|
|
118
171
|
i.index
|
|
119
172
|
|
|
120
173
|
# Set index for 2 levels
|
|
121
174
|
i.level_hash.each do |key, value|
|
|
122
|
-
link = view.content_tag(:a, :href => key[:id]) { textile(key[:title]).html_safe }
|
|
175
|
+
link = view.content_tag(:a, :href => key[:id]) { textile(key[:title], true).html_safe }
|
|
123
176
|
|
|
124
177
|
children = value.keys.map do |k|
|
|
125
|
-
|
|
126
|
-
|
|
178
|
+
view.content_tag(:li,
|
|
179
|
+
view.content_tag(:a, :href => k[:id]) { textile(k[:title], true).html_safe })
|
|
127
180
|
end
|
|
128
181
|
|
|
129
|
-
children_ul = view.content_tag(:ul, children.join(" ").html_safe)
|
|
182
|
+
children_ul = children.empty? ? "" : view.content_tag(:ul, children.join(" ").html_safe)
|
|
130
183
|
|
|
131
184
|
index << view.content_tag(:li, link.html_safe + children_ul.html_safe)
|
|
132
185
|
end
|
|
@@ -139,11 +192,12 @@ module RailsGuides
|
|
|
139
192
|
i.result
|
|
140
193
|
end
|
|
141
194
|
|
|
142
|
-
def textile(body)
|
|
195
|
+
def textile(body, lite_mode=false)
|
|
143
196
|
# If the issue with notextile is fixed just remove the wrapper.
|
|
144
197
|
with_workaround_for_notextile(body) do |body|
|
|
145
198
|
t = RedCloth.new(body)
|
|
146
199
|
t.hard_breaks = false
|
|
200
|
+
t.lite_mode = lite_mode
|
|
147
201
|
t.to_html(:notestuff, :plusplus, :code, :tip)
|
|
148
202
|
end
|
|
149
203
|
end
|
|
@@ -177,7 +231,7 @@ module RailsGuides
|
|
|
177
231
|
anchors = Set.new
|
|
178
232
|
html.scan(/<h\d\s+id="([^"]+)/).flatten.each do |anchor|
|
|
179
233
|
if anchors.member?(anchor)
|
|
180
|
-
puts "*** DUPLICATE
|
|
234
|
+
puts "*** DUPLICATE ID: #{anchor}, please put and explicit ID, e.g. h4(#explicit-id), or consider rewording"
|
|
181
235
|
else
|
|
182
236
|
anchors << anchor
|
|
183
237
|
end
|
|
@@ -199,9 +253,5 @@ module RailsGuides
|
|
|
199
253
|
end
|
|
200
254
|
end
|
|
201
255
|
end
|
|
202
|
-
|
|
203
|
-
def insert_edge_badge(html)
|
|
204
|
-
html.sub(/<body[^>]*>/, '\&<img src="images/edge_badge.png" style="position:fixed; right:0px; top:0px; border:none; z-index:100"/>')
|
|
205
|
-
end
|
|
206
256
|
end
|
|
207
257
|
end
|