Skip to content

Commit 208f2a9

Browse files
committed
init
0 parents  commit 208f2a9

File tree

161 files changed

+56104
-0
lines changed

Some content is hidden

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

161 files changed

+56104
-0
lines changed

.document

Whitespace-only changes.

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Don't put *.swp, *.bak, etc here; those belong in a global ~/.gitignore.
2+
# Check out https://help.github.com/articles/ignoring-files for how to set that up.
3+
4+
.bundle/
5+
/output/
6+
.DS_Store
7+
.sass-cache
8+
*.css.map

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: ruby
2+
cache: bundler
3+
install: bundle install --jobs 4
4+
rvm:
5+
- 2.6.0
6+
notifications:
7+
email: false

CHANGELOG.md

+1

CONTRIBUTING.md

+3

Gemfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# frozen_string_literal: true
2+
source 'https://rubygems.org'
3+
4+
gem 'rails'
5+
gem 'redcarpet'
6+
gem 'kindlerb'

Gemfile.lock

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
actioncable (5.2.2)
5+
actionpack (= 5.2.2)
6+
nio4r (~> 2.0)
7+
websocket-driver (>= 0.6.1)
8+
actionmailer (5.2.2)
9+
actionpack (= 5.2.2)
10+
actionview (= 5.2.2)
11+
activejob (= 5.2.2)
12+
mail (~> 2.5, >= 2.5.4)
13+
rails-dom-testing (~> 2.0)
14+
actionpack (5.2.2)
15+
actionview (= 5.2.2)
16+
activesupport (= 5.2.2)
17+
rack (~> 2.0)
18+
rack-test (>= 0.6.3)
19+
rails-dom-testing (~> 2.0)
20+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
21+
actionview (5.2.2)
22+
activesupport (= 5.2.2)
23+
builder (~> 3.1)
24+
erubi (~> 1.4)
25+
rails-dom-testing (~> 2.0)
26+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
27+
activejob (5.2.2)
28+
activesupport (= 5.2.2)
29+
globalid (>= 0.3.6)
30+
activemodel (5.2.2)
31+
activesupport (= 5.2.2)
32+
activerecord (5.2.2)
33+
activemodel (= 5.2.2)
34+
activesupport (= 5.2.2)
35+
arel (>= 9.0)
36+
activestorage (5.2.2)
37+
actionpack (= 5.2.2)
38+
activerecord (= 5.2.2)
39+
marcel (~> 0.3.1)
40+
activesupport (5.2.2)
41+
concurrent-ruby (~> 1.0, >= 1.0.2)
42+
i18n (>= 0.7, < 2)
43+
minitest (~> 5.1)
44+
tzinfo (~> 1.1)
45+
arel (9.0.0)
46+
builder (3.2.3)
47+
concurrent-ruby (1.1.4)
48+
crass (1.0.4)
49+
erubi (1.8.0)
50+
globalid (0.4.2)
51+
activesupport (>= 4.2.0)
52+
i18n (1.5.2)
53+
concurrent-ruby (~> 1.0)
54+
kindlerb (1.2.0)
55+
mustache
56+
nokogiri
57+
loofah (2.2.3)
58+
crass (~> 1.0.2)
59+
nokogiri (>= 1.5.9)
60+
mail (2.7.1)
61+
mini_mime (>= 0.1.1)
62+
marcel (0.3.3)
63+
mimemagic (~> 0.3.2)
64+
method_source (0.9.2)
65+
mimemagic (0.3.3)
66+
mini_mime (1.0.1)
67+
mini_portile2 (2.4.0)
68+
minitest (5.11.3)
69+
mustache (1.1.0)
70+
nio4r (2.3.1)
71+
nokogiri (1.10.1)
72+
mini_portile2 (~> 2.4.0)
73+
rack (2.0.6)
74+
rack-test (1.1.0)
75+
rack (>= 1.0, < 3)
76+
rails (5.2.2)
77+
actioncable (= 5.2.2)
78+
actionmailer (= 5.2.2)
79+
actionpack (= 5.2.2)
80+
actionview (= 5.2.2)
81+
activejob (= 5.2.2)
82+
activemodel (= 5.2.2)
83+
activerecord (= 5.2.2)
84+
activestorage (= 5.2.2)
85+
activesupport (= 5.2.2)
86+
bundler (>= 1.3.0)
87+
railties (= 5.2.2)
88+
sprockets-rails (>= 2.0.0)
89+
rails-dom-testing (2.0.3)
90+
activesupport (>= 4.2.0)
91+
nokogiri (>= 1.6)
92+
rails-html-sanitizer (1.0.4)
93+
loofah (~> 2.2, >= 2.2.2)
94+
railties (5.2.2)
95+
actionpack (= 5.2.2)
96+
activesupport (= 5.2.2)
97+
method_source
98+
rake (>= 0.8.7)
99+
thor (>= 0.19.0, < 2.0)
100+
rake (12.3.2)
101+
redcarpet (3.4.0)
102+
sprockets (3.7.2)
103+
concurrent-ruby (~> 1.0)
104+
rack (> 1, < 3)
105+
sprockets-rails (3.2.1)
106+
actionpack (>= 4.0)
107+
activesupport (>= 4.0)
108+
sprockets (>= 3.0.0)
109+
thor (0.20.3)
110+
thread_safe (0.3.6)
111+
tzinfo (1.2.5)
112+
thread_safe (~> 0.1)
113+
websocket-driver (0.7.0)
114+
websocket-extensions (>= 0.1.0)
115+
websocket-extensions (0.1.3)
116+
117+
PLATFORMS
118+
ruby
119+
120+
DEPENDENCIES
121+
kindlerb
122+
rails
123+
redcarpet
124+
125+
BUNDLED WITH
126+
1.17.1

README.md

+21

Rakefile

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# frozen_string_literal: true
2+
3+
namespace :guides do
4+
desc 'Generate guides (for authors), use ONLY=foo to process just "foo.md"'
5+
task generate: "generate:html"
6+
7+
# Guides are written in UTF-8, but the environment may be configured for some
8+
# other locale, these tasks are responsible for ensuring the default external
9+
# encoding is UTF-8.
10+
#
11+
# Real use cases: Generation was reported to fail on a machine configured with
12+
# GBK (Chinese). The docs server once got misconfigured somehow and had "C",
13+
# which broke generation too.
14+
task :encoding do
15+
%w(LANG LANGUAGE LC_ALL).each do |env_var|
16+
ENV[env_var] = "en_US.UTF-8"
17+
end
18+
end
19+
20+
namespace :generate do
21+
desc "Generate HTML guides"
22+
task html: :encoding do
23+
ENV["WARNINGS"] = "1" # authors can't disable this
24+
ruby "rails_guides.rb"
25+
end
26+
27+
desc "Generate .mobi file. The kindlegen executable must be in your PATH. You can get it for free from http://www.amazon.com/gp/feature.html?docId=1000765211"
28+
task kindle: :encoding do
29+
require "kindlerb"
30+
unless Kindlerb.kindlegen_available?
31+
abort "Please run `setupkindlerb` to install kindlegen"
32+
end
33+
unless /convert/.match?(`convert`)
34+
abort "Please install ImageMagick"
35+
end
36+
ENV["KINDLE"] = "1"
37+
Rake::Task["guides:generate:html"].invoke
38+
end
39+
end
40+
41+
# Validate guides -------------------------------------------------------------------------
42+
desc 'Validate guides, use ONLY=foo to process just "foo.html"'
43+
task validate: :encoding do
44+
ruby "w3c_validator.rb"
45+
end
46+
47+
desc "Show help"
48+
task :help do
49+
puts <<HELP
50+
51+
Guides are taken from the source directory, and the result goes into the
52+
output directory. Assets are stored under files, and copied to output/files as
53+
part of the generation process.
54+
55+
You can generate HTML, Kindle or both formats using the `guides:generate` task.
56+
57+
All of these processes are handled via rake tasks, here's a full list of them:
58+
59+
#{%x[rake -T]}
60+
Some arguments may be passed via environment variables:
61+
62+
RAILS_VERSION=tag
63+
If guides are being generated for a specific Rails version set the Git tag
64+
here, otherwise the current SHA1 is going to be used to generate edge guides.
65+
66+
ALL=1
67+
Force generation of all guides.
68+
69+
ONLY=name
70+
Useful if you want to generate only one or a set of guides.
71+
72+
Generate only association_basics.html:
73+
ONLY=assoc
74+
75+
Separate many using commas:
76+
ONLY=assoc,migrations
77+
78+
GUIDES_LANGUAGE
79+
Use it when you want to generate translated guides in
80+
source/<GUIDES_LANGUAGE> folder (such as source/es)
81+
82+
Examples:
83+
$ rake guides:generate ALL=1 RAILS_VERSION=v5.1.0
84+
$ rake guides:generate ONLY=migrations
85+
$ rake guides:generate:kindle
86+
$ rake guides:generate GUIDES_LANGUAGE=es
87+
HELP
88+
end
89+
end
90+
91+
task default: "guides:help"
34.2 KB
60 KB
35.4 KB
37.3 KB
82.8 KB

assets/images/book_icon.gif

329 Bytes

assets/images/bullet.gif

60 Bytes

assets/images/chapters_icon.gif

620 Bytes

assets/images/check_bullet.gif

376 Bytes

assets/images/edge_badge.png

5.56 KB

assets/images/favicon.ico

16.6 KB
Binary file not shown.

assets/images/feature_tile.gif

35 Bytes

assets/images/footer_tile.gif

36 Bytes
19.9 KB
17.1 KB
3.12 KB

assets/images/grey_bullet.gif

37 Bytes

assets/images/header_tile.gif

36 Bytes

assets/images/i18n/demo_html_safe.png

9.63 KB
11 KB
8.86 KB
9.74 KB
9.75 KB
8.77 KB

assets/images/nav_arrow.gif

419 Bytes
20.5 KB

assets/images/rails_guides_logo.gif

3.68 KB
2.29 KB
3.03 KB

assets/images/security/csrf.png

31.4 KB
37.4 KB

assets/images/tab_grey.gif

4.57 KB

assets/images/tab_info.gif

4.42 KB

assets/images/tab_note.gif

4.46 KB

assets/images/tab_red.gif

4.4 KB

assets/images/tab_yellow.gif

4.41 KB

assets/javascripts/guides.js

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
(function() {
2+
"use strict";
3+
4+
this.syntaxhighlighterConfig = { autoLinks: false };
5+
6+
this.wrap = function(elem, wrapper) {
7+
elem.parentNode.insertBefore(wrapper, elem);
8+
wrapper.appendChild(elem);
9+
}
10+
11+
this.unwrap = function(elem) {
12+
var wrapper = elem.parentNode;
13+
wrapper.parentNode.replaceChild(elem, wrapper);
14+
}
15+
16+
this.createElement = function(tagName, className) {
17+
var elem = document.createElement(tagName);
18+
elem.classList.add(className);
19+
return elem;
20+
}
21+
22+
// For old browsers
23+
this.each = function(node, callback) {
24+
var array = Array.prototype.slice.call(node);
25+
for(var i = 0; i < array.length; i++) callback(array[i]);
26+
}
27+
28+
// Viewable on local
29+
if (window.location.protocol === "file:") Turbolinks.supported = false;
30+
31+
document.addEventListener("turbolinks:load", function() {
32+
window.SyntaxHighlighter.highlight({ "auto-links": false });
33+
34+
var guidesMenu = document.getElementById("guidesMenu");
35+
var guides = document.getElementById("guides");
36+
37+
guidesMenu.addEventListener("click", function(e) {
38+
e.preventDefault();
39+
guides.classList.toggle("visible");
40+
});
41+
42+
each(document.querySelectorAll("#guides a"), function(element) {
43+
element.addEventListener("click", function(e) {
44+
guides.classList.toggle("visible");
45+
});
46+
});
47+
48+
var guidesIndexItem = document.querySelector("select.guides-index-item");
49+
var currentGuidePath = window.location.pathname;
50+
guidesIndexItem.value = currentGuidePath.substring(currentGuidePath.lastIndexOf("/") + 1);
51+
52+
guidesIndexItem.addEventListener("change", function(e) {
53+
if (Turbolinks.supported) {
54+
Turbolinks.visit(e.target.value);
55+
} else {
56+
window.location = e.target.value;
57+
}
58+
});
59+
60+
var moreInfoButton = document.querySelector(".more-info-button");
61+
var moreInfoLinks = document.querySelector(".more-info-links");
62+
63+
moreInfoButton.addEventListener("click", function(e) {
64+
e.preventDefault();
65+
66+
if (moreInfoLinks.classList.contains("s-hidden")) {
67+
wrap(moreInfoLinks, createElement("div", "more-info-container"));
68+
moreInfoLinks.classList.remove("s-hidden");
69+
} else {
70+
moreInfoLinks.classList.add("s-hidden");
71+
unwrap(moreInfoLinks);
72+
}
73+
});
74+
});
75+
}).call(this);
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
(function() {
2+
"use strict";
3+
4+
var switched = false;
5+
6+
var updateTables = function() {
7+
if (document.documentElement.clientWidth < 767 && !switched) {
8+
switched = true;
9+
each(document.querySelectorAll("table.responsive"), splitTable);
10+
} else {
11+
switched = false;
12+
each(document.querySelectorAll(".table-wrapper table.responsive"), unsplitTable);
13+
}
14+
}
15+
16+
document.addEventListener("turbolinks:load", function() {
17+
each(document.querySelectorAll(":not(.syntaxhighlighter)>table"), function(element) {
18+
element.classList.add("responsive");
19+
});
20+
updateTables();
21+
});
22+
23+
window.addEventListener("resize", updateTables);
24+
25+
var splitTable = function(original) {
26+
wrap(original, createElement("div", "table-wrapper"));
27+
28+
var copy = original.cloneNode(true);
29+
each(copy.querySelectorAll("td:not(:first-child), th:not(:first-child)"), function(element) {
30+
element.style.display = "none";
31+
});
32+
copy.classList.remove("responsive");
33+
34+
original.parentNode.append(copy);
35+
wrap(copy, createElement("div", "pinned"))
36+
wrap(original, createElement("div", "scrollable"));
37+
}
38+
39+
var unsplitTable = function(original) {
40+
each(document.querySelectorAll(".table-wrapper .pinned"), function(element) {
41+
element.parentNode.removeChild(element);
42+
});
43+
unwrap(original.parentNode);
44+
unwrap(original);
45+
}
46+
}).call(this);

0 commit comments

Comments
 (0)