Skip to content

Commit 9769ea3

Browse files
authored
Merge pull request #82 from AndorChen/511
更新到 Rails 5.1.1
2 parents 3f7a211 + 7a8f602 commit 9769ea3

File tree

117 files changed

+12194
-8298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+12194
-8298
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Rails 5.1.0 (April 27, 2017) ##
2+
3+
* No changes.
4+
15
## Rails 5.0.1 (December 21, 2016) ##
26

37
* No changes.

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ruby:2.3
1+
FROM ruby:2.4.1
22

33
ENV LC_ALL C.UTF-8
44
ENV LANG en_US.UTF-8
@@ -21,4 +21,4 @@ COPY Gemfile.lock /app
2121
RUN bundle install
2222

2323
ENV GUIDES_LANGUAGE=zh-CN
24-
ENV RAILS_VERSION=v5.0.1
24+
ENV RAILS_VERSION=v5.1.1

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22
source 'https://rubygems.org'
33

4-
gem 'rails', '5.0.1'
4+
gem 'rails', '5.1.1'
55
gem 'redcarpet'
6-
gem 'kindlerb', '0.1.1'
6+
gem 'kindlerb', '1.2.0'

Gemfile.lock

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,90 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actioncable (5.0.1)
5-
actionpack (= 5.0.1)
6-
nio4r (~> 1.2)
4+
actioncable (5.1.1)
5+
actionpack (= 5.1.1)
6+
nio4r (~> 2.0)
77
websocket-driver (~> 0.6.1)
8-
actionmailer (5.0.1)
9-
actionpack (= 5.0.1)
10-
actionview (= 5.0.1)
11-
activejob (= 5.0.1)
8+
actionmailer (5.1.1)
9+
actionpack (= 5.1.1)
10+
actionview (= 5.1.1)
11+
activejob (= 5.1.1)
1212
mail (~> 2.5, >= 2.5.4)
1313
rails-dom-testing (~> 2.0)
14-
actionpack (5.0.1)
15-
actionview (= 5.0.1)
16-
activesupport (= 5.0.1)
14+
actionpack (5.1.1)
15+
actionview (= 5.1.1)
16+
activesupport (= 5.1.1)
1717
rack (~> 2.0)
1818
rack-test (~> 0.6.3)
1919
rails-dom-testing (~> 2.0)
2020
rails-html-sanitizer (~> 1.0, >= 1.0.2)
21-
actionview (5.0.1)
22-
activesupport (= 5.0.1)
21+
actionview (5.1.1)
22+
activesupport (= 5.1.1)
2323
builder (~> 3.1)
24-
erubis (~> 2.7.0)
24+
erubi (~> 1.4)
2525
rails-dom-testing (~> 2.0)
26-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
27-
activejob (5.0.1)
28-
activesupport (= 5.0.1)
26+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
27+
activejob (5.1.1)
28+
activesupport (= 5.1.1)
2929
globalid (>= 0.3.6)
30-
activemodel (5.0.1)
31-
activesupport (= 5.0.1)
32-
activerecord (5.0.1)
33-
activemodel (= 5.0.1)
34-
activesupport (= 5.0.1)
35-
arel (~> 7.0)
36-
activesupport (5.0.1)
30+
activemodel (5.1.1)
31+
activesupport (= 5.1.1)
32+
activerecord (5.1.1)
33+
activemodel (= 5.1.1)
34+
activesupport (= 5.1.1)
35+
arel (~> 8.0)
36+
activesupport (5.1.1)
3737
concurrent-ruby (~> 1.0, >= 1.0.2)
3838
i18n (~> 0.7)
3939
minitest (~> 5.1)
4040
tzinfo (~> 1.1)
41-
arel (7.1.4)
41+
arel (8.0.0)
4242
builder (3.2.3)
43-
concurrent-ruby (1.0.4)
44-
erubis (2.7.0)
45-
globalid (0.3.7)
46-
activesupport (>= 4.1.0)
43+
concurrent-ruby (1.0.5)
44+
erubi (1.6.0)
45+
globalid (0.4.0)
46+
activesupport (>= 4.2.0)
4747
i18n (0.8.1)
48-
kindlerb (0.1.1)
48+
kindlerb (1.2.0)
4949
mustache
5050
nokogiri
5151
loofah (2.0.3)
5252
nokogiri (>= 1.5.9)
53-
mail (2.6.4)
53+
mail (2.6.5)
5454
mime-types (>= 1.16, < 4)
5555
method_source (0.8.2)
5656
mime-types (3.1)
5757
mime-types-data (~> 3.2015)
5858
mime-types-data (3.2016.0521)
5959
mini_portile2 (2.1.0)
60-
minitest (5.10.1)
61-
mustache (1.0.3)
62-
nio4r (1.2.1)
63-
nokogiri (1.7.0.1)
60+
minitest (5.10.2)
61+
mustache (1.0.5)
62+
nio4r (2.0.0)
63+
nokogiri (1.7.2)
6464
mini_portile2 (~> 2.1.0)
65-
rack (2.0.1)
65+
rack (2.0.3)
6666
rack-test (0.6.3)
6767
rack (>= 1.0)
68-
rails (5.0.1)
69-
actioncable (= 5.0.1)
70-
actionmailer (= 5.0.1)
71-
actionpack (= 5.0.1)
72-
actionview (= 5.0.1)
73-
activejob (= 5.0.1)
74-
activemodel (= 5.0.1)
75-
activerecord (= 5.0.1)
76-
activesupport (= 5.0.1)
68+
rails (5.1.1)
69+
actioncable (= 5.1.1)
70+
actionmailer (= 5.1.1)
71+
actionpack (= 5.1.1)
72+
actionview (= 5.1.1)
73+
activejob (= 5.1.1)
74+
activemodel (= 5.1.1)
75+
activerecord (= 5.1.1)
76+
activesupport (= 5.1.1)
7777
bundler (>= 1.3.0, < 2.0)
78-
railties (= 5.0.1)
78+
railties (= 5.1.1)
7979
sprockets-rails (>= 2.0.0)
80-
rails-dom-testing (2.0.2)
81-
activesupport (>= 4.2.0, < 6.0)
82-
nokogiri (~> 1.6)
80+
rails-dom-testing (2.0.3)
81+
activesupport (>= 4.2.0)
82+
nokogiri (>= 1.6)
8383
rails-html-sanitizer (1.0.3)
8484
loofah (~> 2.0)
85-
railties (5.0.1)
86-
actionpack (= 5.0.1)
87-
activesupport (= 5.0.1)
85+
railties (5.1.1)
86+
actionpack (= 5.1.1)
87+
activesupport (= 5.1.1)
8888
method_source
8989
rake (>= 0.8.7)
9090
thor (>= 0.18.1, < 2.0)
@@ -99,7 +99,7 @@ GEM
9999
sprockets (>= 3.0.0)
100100
thor (0.19.4)
101101
thread_safe (0.3.6)
102-
tzinfo (1.2.2)
102+
tzinfo (1.2.3)
103103
thread_safe (~> 0.1)
104104
websocket-driver (0.6.5)
105105
websocket-extensions (>= 0.1.0)
@@ -109,9 +109,9 @@ PLATFORMS
109109
ruby
110110

111111
DEPENDENCIES
112-
kindlerb (= 0.1.1)
113-
rails (= 5.0.1)
112+
kindlerb (= 1.2.0)
113+
rails (= 5.1.1)
114114
redcarpet
115115

116116
BUNDLED WITH
117-
1.14.5
117+
1.14.6

rails_guides.rb

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
pwd = File.dirname(__FILE__)
2-
$:.unshift pwd
1+
$:.unshift __dir__
32

4-
begin
5-
# Guides generation in the Rails repo.
6-
as_lib = File.join(pwd, "../activesupport/lib")
7-
ap_lib = File.join(pwd, "../actionpack/lib")
3+
require "rails_guides/generator"
4+
require "rails_guides/cn" # PLEASE DO NOT FORGET ME
5+
require "active_support/core_ext/object/blank"
86

9-
$:.unshift as_lib if File.directory?(as_lib)
10-
$:.unshift ap_lib if File.directory?(ap_lib)
11-
rescue LoadError
12-
# Guides generation from gems.
13-
gem "actionpack", '>= 3.0'
14-
end
7+
env_value = ->(name) { ENV[name].presence }
8+
env_flag = ->(name) { "1" == env_value[name] }
159

16-
require "rails_guides/generator"
17-
require "rails_guides/cn"
18-
RailsGuides::Generator.new.generate
10+
version = env_value["RAILS_VERSION"]
11+
edge = `git rev-parse HEAD`.strip unless version
12+
13+
RailsGuides::Generator.new(
14+
edge: edge,
15+
version: version,
16+
all: env_flag["ALL"],
17+
only: env_value["ONLY"],
18+
kindle: env_flag["KINDLE"],
19+
language: env_value["GUIDES_LANGUAGE"]
20+
).generate

rails_guides/cn.rb

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# Patch for cn generator
2-
require 'uri'
1+
# Patch for zh-CN generation
32

43
module RailsGuides
54
class Markdown
65
private
76

87
def dom_id(nodes)
9-
dom_id = dom_id_text(nodes.last.text)
8+
dom_id = dom_id_text(nodes.last)
109

1110
# Fix duplicate node by prefix with its parent node
1211
if @node_ids[dom_id]
@@ -17,15 +16,50 @@ def dom_id(nodes)
1716
@node_ids[new_node_id] = duplicate_nodes
1817
end
1918

20-
dom_id = "#{nodes[-2][:id]}-#{dom_id}" if nodes.size > 1
19+
dom_id = "#{nodes[-2][:id]}-#{dom_id}"
2120
end
2221

2322
@node_ids[dom_id] = nodes
2423
dom_id
2524
end
2625

27-
def dom_id_text(text)
28-
URI.escape(text, /[^\-_.!~*'()a-zA-Z\d;\/?:@&=+$,]/)
26+
def dom_id_text(node)
27+
if node.previous_element && node.previous_element.inner_html.include?('class="anchor"')
28+
node.previous_element.children.first['id']
29+
else
30+
escaped_chars = Regexp.escape('\\/`*_{}[]()#+-.!:,;|&<>^~=\'"')
31+
32+
node.text.downcase.gsub(/\?/, "-questionmark")
33+
.gsub(/!/, "-bang")
34+
.gsub(/[#{escaped_chars}]+/, " ").strip
35+
.gsub(/\s+/, "-")
36+
end
2937
end
38+
39+
def generate_index
40+
if @headings_for_index.present?
41+
raw_index = ""
42+
@headings_for_index.each do |level, node, label|
43+
if level == 1
44+
raw_index += "1. [#{label}](##{node[:id]})\n"
45+
elsif level == 2
46+
raw_index += " * [#{label}](##{node[:id]})\n"
47+
end
48+
end
49+
50+
@index = Nokogiri::HTML.fragment(engine.render(raw_index)).tap do |doc|
51+
doc.at("ol")[:class] = "chapters"
52+
end.to_html
53+
54+
# Only change `Chapters' to `目录'
55+
@index = <<-INDEX.html_safe
56+
<div id="subCol">
57+
<h3 class="chapter"><img src="images/chapters_icon.gif" alt="" />目录</h3>
58+
#{@index}
59+
</div>
60+
INDEX
61+
end
62+
end
63+
3064
end
3165
end

0 commit comments

Comments
 (0)