jekyll-docs 3.6.0 → 3.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll.rb +195 -0
- data/lib/jekyll/cleaner.rb +110 -0
- data/lib/jekyll/collection.rb +230 -0
- data/lib/jekyll/command.rb +78 -0
- data/lib/jekyll/commands/build.rb +102 -0
- data/lib/jekyll/commands/clean.rb +43 -0
- data/lib/jekyll/commands/doctor.rb +153 -0
- data/lib/jekyll/commands/help.rb +34 -0
- data/lib/jekyll/commands/new.rb +156 -0
- data/lib/jekyll/commands/new_theme.rb +40 -0
- data/lib/jekyll/commands/serve.rb +245 -0
- data/lib/jekyll/commands/serve/servlet.rb +62 -0
- data/lib/jekyll/configuration.rb +410 -0
- data/lib/jekyll/converter.rb +54 -0
- data/lib/jekyll/converters/identity.rb +23 -0
- data/lib/jekyll/converters/markdown.rb +104 -0
- data/lib/jekyll/converters/markdown/kramdown_parser.rb +123 -0
- data/lib/jekyll/converters/markdown/rdiscount_parser.rb +35 -0
- data/lib/jekyll/converters/markdown/redcarpet_parser.rb +108 -0
- data/lib/jekyll/converters/smartypants.rb +36 -0
- data/lib/jekyll/convertible.rb +251 -0
- data/lib/jekyll/deprecator.rb +52 -0
- data/lib/jekyll/document.rb +507 -0
- data/lib/jekyll/drops/collection_drop.rb +22 -0
- data/lib/jekyll/drops/document_drop.rb +69 -0
- data/lib/jekyll/drops/drop.rb +214 -0
- data/lib/jekyll/drops/excerpt_drop.rb +15 -0
- data/lib/jekyll/drops/jekyll_drop.rb +33 -0
- data/lib/jekyll/drops/site_drop.rb +47 -0
- data/lib/jekyll/drops/static_file_drop.rb +13 -0
- data/lib/jekyll/drops/unified_payload_drop.rb +25 -0
- data/lib/jekyll/drops/url_drop.rb +88 -0
- data/lib/jekyll/entry_filter.rb +123 -0
- data/lib/jekyll/errors.rb +20 -0
- data/lib/jekyll/excerpt.rb +126 -0
- data/lib/jekyll/external.rb +74 -0
- data/lib/jekyll/filters.rb +430 -0
- data/lib/jekyll/filters/grouping_filters.rb +65 -0
- data/lib/jekyll/filters/url_filters.rb +60 -0
- data/lib/jekyll/frontmatter_defaults.rb +197 -0
- data/lib/jekyll/generator.rb +5 -0
- data/lib/jekyll/hooks.rb +104 -0
- data/lib/jekyll/layout.rb +62 -0
- data/lib/jekyll/liquid_extensions.rb +24 -0
- data/lib/jekyll/liquid_renderer.rb +49 -0
- data/lib/jekyll/liquid_renderer/file.rb +56 -0
- data/lib/jekyll/liquid_renderer/table.rb +96 -0
- data/lib/jekyll/log_adapter.rb +147 -0
- data/lib/jekyll/mime.types +825 -0
- data/lib/jekyll/page.rb +187 -0
- data/lib/jekyll/plugin.rb +98 -0
- data/lib/jekyll/plugin_manager.rb +113 -0
- data/lib/jekyll/publisher.rb +23 -0
- data/lib/jekyll/reader.rb +134 -0
- data/lib/jekyll/readers/collection_reader.rb +22 -0
- data/lib/jekyll/readers/data_reader.rb +77 -0
- data/lib/jekyll/readers/layout_reader.rb +71 -0
- data/lib/jekyll/readers/page_reader.rb +25 -0
- data/lib/jekyll/readers/post_reader.rb +72 -0
- data/lib/jekyll/readers/static_file_reader.rb +25 -0
- data/lib/jekyll/readers/theme_assets_reader.rb +49 -0
- data/lib/jekyll/regenerator.rb +201 -0
- data/lib/jekyll/related_posts.rb +52 -0
- data/lib/jekyll/renderer.rb +269 -0
- data/lib/jekyll/site.rb +471 -0
- data/lib/jekyll/static_file.rb +162 -0
- data/lib/jekyll/stevenson.rb +61 -0
- data/lib/jekyll/tags/highlight.rb +141 -0
- data/lib/jekyll/tags/include.rb +215 -0
- data/lib/jekyll/tags/link.rb +37 -0
- data/lib/jekyll/tags/post_url.rb +103 -0
- data/lib/jekyll/theme.rb +68 -0
- data/lib/jekyll/theme_builder.rb +119 -0
- data/lib/jekyll/url.rb +161 -0
- data/lib/jekyll/utils.rb +337 -0
- data/lib/jekyll/utils/ansi.rb +59 -0
- data/lib/jekyll/utils/exec.rb +27 -0
- data/lib/jekyll/utils/platforms.rb +82 -0
- data/lib/jekyll/utils/rouge.rb +21 -0
- data/lib/jekyll/utils/win_tz.rb +75 -0
- data/lib/jekyll/version.rb +5 -0
- data/lib/site_template/404.html +24 -0
- data/lib/site_template/_config.yml +43 -0
- data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +25 -0
- data/lib/site_template/about.md +18 -0
- data/lib/site_template/index.md +6 -0
- data/lib/theme_template/CODE_OF_CONDUCT.md.erb +74 -0
- data/lib/theme_template/Gemfile +4 -0
- data/lib/theme_template/LICENSE.txt.erb +21 -0
- data/lib/theme_template/README.md.erb +52 -0
- data/lib/theme_template/_layouts/default.html +1 -0
- data/lib/theme_template/_layouts/page.html +5 -0
- data/lib/theme_template/_layouts/post.html +5 -0
- data/lib/theme_template/example/_config.yml.erb +1 -0
- data/lib/theme_template/example/_post.md +12 -0
- data/lib/theme_template/example/index.html +14 -0
- data/lib/theme_template/example/style.scss +7 -0
- data/lib/theme_template/gitignore.erb +5 -0
- data/lib/theme_template/theme.gemspec.erb +19 -0
- metadata +103 -156
- data/lib/jekyll-docs.rb +0 -31
- data/site/404.html +0 -153
- data/site/CNAME +0 -1
- data/site/community/index.html +0 -299
- data/site/conduct/index.html +0 -10
- data/site/css/screen.css +0 -1
- data/site/docs/assets/index.html +0 -724
- data/site/docs/code_of_conduct/index.html +0 -730
- data/site/docs/collections/index.html +0 -1097
- data/site/docs/conduct/index.html +0 -744
- data/site/docs/configuration/index.html +0 -1403
- data/site/docs/continuous-integration/buddyworks/index.html +0 -726
- data/site/docs/continuous-integration/circleci/index.html +0 -757
- data/site/docs/continuous-integration/index.html +0 -681
- data/site/docs/continuous-integration/travis-ci/index.html +0 -891
- data/site/docs/contributing/index.html +0 -863
- data/site/docs/datafiles/index.html +0 -780
- data/site/docs/deployment-methods/index.html +0 -875
- data/site/docs/drafts/index.html +0 -636
- data/site/docs/extras/index.html +0 -689
- data/site/docs/frontmatter/index.html +0 -807
- data/site/docs/github-pages/index.html +0 -819
- data/site/docs/history/index.html +0 -3955
- data/site/docs/home/index.html +0 -644
- data/site/docs/includes/index.html +0 -800
- data/site/docs/index.html +0 -10
- data/site/docs/installation/index.html +0 -732
- data/site/docs/maintaining/affinity-team-captain/index.html +0 -706
- data/site/docs/maintaining/avoiding-burnout/index.html +0 -709
- data/site/docs/maintaining/becoming-a-maintainer/index.html +0 -717
- data/site/docs/maintaining/index.html +0 -713
- data/site/docs/maintaining/merging-a-pull-request/index.html +0 -747
- data/site/docs/maintaining/reviewing-a-pull-request/index.html +0 -725
- data/site/docs/maintaining/special-labels/index.html +0 -705
- data/site/docs/maintaining/triaging-an-issue/index.html +0 -735
- data/site/docs/migrations/index.html +0 -647
- data/site/docs/pages/index.html +0 -695
- data/site/docs/pagination/index.html +0 -870
- data/site/docs/permalinks/index.html +0 -1027
- data/site/docs/plugins/index.html +0 -1800
- data/site/docs/posts/index.html +0 -858
- data/site/docs/quickstart/index.html +0 -650
- data/site/docs/resources/index.html +0 -769
- data/site/docs/sites/index.html +0 -702
- data/site/docs/static-files/index.html +0 -720
- data/site/docs/structure/index.html +0 -822
- data/site/docs/templates/index.html +0 -1208
- data/site/docs/themes/index.html +0 -935
- data/site/docs/troubleshooting/index.html +0 -893
- data/site/docs/upgrading/0-to-2/index.html +0 -826
- data/site/docs/upgrading/2-to-3/index.html +0 -824
- data/site/docs/upgrading/index.html +0 -693
- data/site/docs/usage/index.html +0 -705
- data/site/docs/variables/index.html +0 -1048
- data/site/docs/windows/index.html +0 -799
- data/site/favicon.ico +0 -0
- data/site/feed.xml +0 -372
- data/site/fonts/FontAwesome.eot +0 -0
- data/site/fonts/FontAwesome.svg +0 -12
- data/site/fonts/FontAwesome.ttf +0 -0
- data/site/fonts/FontAwesome.woff +0 -0
- data/site/github.html +0 -10
- data/site/help/index.html +0 -244
- data/site/icomoon-selection.json +0 -96
- data/site/img/article-footer.png +0 -0
- data/site/img/footer-arrow.png +0 -0
- data/site/img/footer-logo.png +0 -0
- data/site/img/jekyll-sticker.jpg +0 -0
- data/site/img/jekylllayoutconcept.png +0 -0
- data/site/img/logo-2x.png +0 -0
- data/site/img/logo-rss.png +0 -0
- data/site/img/octojekyll.png +0 -0
- data/site/index.html +0 -267
- data/site/issues.html +0 -10
- data/site/js/html5shiv.min.js +0 -4
- data/site/js/respond.min.js +0 -5
- data/site/latest_version.txt +0 -1
- data/site/news/2013/05/05/jekyll-1-0-0-released/index.html +0 -570
- data/site/news/2013/05/08/jekyll-1-0-1-released/index.html +0 -570
- data/site/news/2013/05/12/jekyll-1-0-2-released/index.html +0 -571
- data/site/news/2013/06/07/jekyll-1-0-3-released/index.html +0 -568
- data/site/news/2013/07/14/jekyll-1-1-0-released/index.html +0 -570
- data/site/news/2013/07/24/jekyll-1-1-1-released/index.html +0 -569
- data/site/news/2013/07/25/jekyll-1-0-4-released/index.html +0 -565
- data/site/news/2013/07/25/jekyll-1-1-2-released/index.html +0 -565
- data/site/news/2013/09/06/jekyll-1-2-0-released/index.html +0 -572
- data/site/news/2013/09/14/jekyll-1-2-1-released/index.html +0 -566
- data/site/news/2013/10/28/jekyll-1-3-0-rc1-released/index.html +0 -564
- data/site/news/2013/11/04/jekyll-1-3-0-released/index.html +0 -599
- data/site/news/2013/11/26/jekyll-1-3-1-released/index.html +0 -568
- data/site/news/2013/12/07/jekyll-1-4-0-released/index.html +0 -583
- data/site/news/2013/12/09/jekyll-1-4-1-released/index.html +0 -565
- data/site/news/2013/12/16/jekyll-1-4-2-released/index.html +0 -564
- data/site/news/2014/01/13/jekyll-1-4-3-released/index.html +0 -573
- data/site/news/2014/03/24/jekyll-1-5-0-released/index.html +0 -564
- data/site/news/2014/03/27/jekyll-1-5-1-released/index.html +0 -569
- data/site/news/2014/05/06/jekyll-turns-2-0-0/index.html +0 -585
- data/site/news/2014/05/08/jekyll-2-0-3-released/index.html +0 -565
- data/site/news/2014/06/04/jekyll-stickers-1-dollar-stickermule/index.html +0 -567
- data/site/news/2014/06/28/jekyll-turns-21-i-mean-2-1-0/index.html +0 -582
- data/site/news/2014/07/01/jekyll-2-1-1-released/index.html +0 -579
- data/site/news/2014/07/29/jekyll-2-2-0-released/index.html +0 -568
- data/site/news/2014/08/10/jekyll-2-3-0-released/index.html +0 -588
- data/site/news/2014/09/09/jekyll-2-4-0-released/index.html +0 -574
- data/site/news/2014/11/05/jekylls-midlife-crisis-jekyll-turns-2-5-0/index.html +0 -597
- data/site/news/2014/11/09/jekyll-2-5-1-released/index.html +0 -575
- data/site/news/2014/11/12/jekyll-2-5-2-released/index.html +0 -565
- data/site/news/2014/12/17/alfredxing-welcome-to-jekyll-core/index.html +0 -572
- data/site/news/2014/12/22/jekyll-2-5-3-released/index.html +0 -567
- data/site/news/2015/01/20/jekyll-meet-and-greet/index.html +0 -568
- data/site/news/2015/01/24/jekyll-3-0-0-beta1-released/index.html +0 -588
- data/site/news/2015/02/26/introducing-jekyll-talk/index.html +0 -563
- data/site/news/2015/10/26/jekyll-3-0-released/index.html +0 -592
- data/site/news/2015/11/17/jekyll-3-0-1-released/index.html +0 -576
- data/site/news/2016/01/20/jekyll-3-0-2-released/index.html +0 -566
- data/site/news/2016/01/24/jekyll-3-1-0-released/index.html +0 -599
- data/site/news/2016/01/28/jekyll-3-1-1-released/index.html +0 -583
- data/site/news/2016/02/08/jekyll-3-0-3-released/index.html +0 -578
- data/site/news/2016/02/19/jekyll-3-1-2-released/index.html +0 -569
- data/site/news/2016/03/10/making-it-easier-to-contribute-to-jekyll/index.html +0 -565
- data/site/news/2016/04/19/jekyll-3-0-4-released/index.html +0 -571
- data/site/news/2016/04/19/jekyll-3-1-3-released/index.html +0 -566
- data/site/news/2016/04/26/jekyll-3-0-5-released/index.html +0 -572
- data/site/news/2016/05/18/jekyll-3-1-4-released/index.html +0 -576
- data/site/news/2016/05/18/jekyll-3-1-5-released/index.html +0 -564
- data/site/news/2016/05/19/jekyll-3-1-6-released/index.html +0 -566
- data/site/news/2016/06/03/update-on-jekyll-s-google-summer-of-code-projects/index.html +0 -567
- data/site/news/2016/07/26/jekyll-3-2-0-released/index.html +0 -676
- data/site/news/2016/08/02/jekyll-3-2-1-released/index.html +0 -571
- data/site/news/2016/08/24/jekyll-admin-initial-release/index.html +0 -566
- data/site/news/2016/10/06/jekyll-3-3-is-here/index.html +0 -645
- data/site/news/2016/11/14/jekyll-3-3-1-released/index.html +0 -569
- data/site/news/2017/01/18/jekyll-3-4-0-released/index.html +0 -592
- data/site/news/2017/03/02/jekyll-3-4-1-released/index.html +0 -649
- data/site/news/2017/03/09/jekyll-3-4-2-released/index.html +0 -598
- data/site/news/2017/03/21/jekyll-3-4-3-released/index.html +0 -594
- data/site/news/2017/06/15/jekyll-3-5-0-released/index.html +0 -589
- data/site/news/2017/07/17/jekyll-3-5-1-released/index.html +0 -569
- data/site/news/2017/08/12/jekyll-3-5-2-released/index.html +0 -573
- data/site/news/2017/09/21/jekyll-3-6-0-released/index.html +0 -565
- data/site/news/index.html +0 -3609
- data/site/news/releases/index.html +0 -3344
- data/site/philosophy.html +0 -46
- data/site/readme.md +0 -23
- data/site/robots.txt +0 -1
- data/site/sitemap.xml +0 -485
- data/site/tutorials/convert-site-to-jekyll/index.html +0 -793
- data/site/tutorials/custom-404-page/index.html +0 -358
- data/site/tutorials/home/index.html +0 -323
- data/site/tutorials/index.html +0 -10
- data/site/tutorials/navigation/index.html +0 -872
- data/site/tutorials/orderofinterpretation/index.html +0 -441
data/lib/jekyll/page.rb
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class Page
|
5
|
+
include Convertible
|
6
|
+
|
7
|
+
attr_writer :dir
|
8
|
+
attr_accessor :site, :pager
|
9
|
+
attr_accessor :name, :ext, :basename
|
10
|
+
attr_accessor :data, :content, :output
|
11
|
+
|
12
|
+
alias_method :extname, :ext
|
13
|
+
|
14
|
+
FORWARD_SLASH = "/".freeze
|
15
|
+
|
16
|
+
# Attributes for Liquid templates
|
17
|
+
ATTRIBUTES_FOR_LIQUID = %w(
|
18
|
+
content
|
19
|
+
dir
|
20
|
+
name
|
21
|
+
path
|
22
|
+
url
|
23
|
+
).freeze
|
24
|
+
|
25
|
+
# A set of extensions that are considered HTML or HTML-like so we
|
26
|
+
# should not alter them, this includes .xhtml through XHTM5.
|
27
|
+
|
28
|
+
HTML_EXTENSIONS = %w(
|
29
|
+
.html
|
30
|
+
.xhtml
|
31
|
+
.htm
|
32
|
+
).freeze
|
33
|
+
|
34
|
+
# Initialize a new Page.
|
35
|
+
#
|
36
|
+
# site - The Site object.
|
37
|
+
# base - The String path to the source.
|
38
|
+
# dir - The String path between the source and the file.
|
39
|
+
# name - The String filename of the file.
|
40
|
+
def initialize(site, base, dir, name)
|
41
|
+
@site = site
|
42
|
+
@base = base
|
43
|
+
@dir = dir
|
44
|
+
@name = name
|
45
|
+
@path = if site.in_theme_dir(base) == base # we're in a theme
|
46
|
+
site.in_theme_dir(base, dir, name)
|
47
|
+
else
|
48
|
+
site.in_source_dir(base, dir, name)
|
49
|
+
end
|
50
|
+
|
51
|
+
process(name)
|
52
|
+
read_yaml(File.join(base, dir), name)
|
53
|
+
|
54
|
+
data.default_proc = proc do |_, key|
|
55
|
+
site.frontmatter_defaults.find(File.join(dir, name), type, key)
|
56
|
+
end
|
57
|
+
|
58
|
+
Jekyll::Hooks.trigger :pages, :post_init, self
|
59
|
+
end
|
60
|
+
|
61
|
+
# The generated directory into which the page will be placed
|
62
|
+
# upon generation. This is derived from the permalink or, if
|
63
|
+
# permalink is absent, will be '/'
|
64
|
+
#
|
65
|
+
# Returns the String destination directory.
|
66
|
+
def dir
|
67
|
+
if url.end_with?(FORWARD_SLASH)
|
68
|
+
url
|
69
|
+
else
|
70
|
+
url_dir = File.dirname(url)
|
71
|
+
url_dir.end_with?(FORWARD_SLASH) ? url_dir : "#{url_dir}/"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# The full path and filename of the post. Defined in the YAML of the post
|
76
|
+
# body.
|
77
|
+
#
|
78
|
+
# Returns the String permalink or nil if none has been set.
|
79
|
+
def permalink
|
80
|
+
data.nil? ? nil : data["permalink"]
|
81
|
+
end
|
82
|
+
|
83
|
+
# The template of the permalink.
|
84
|
+
#
|
85
|
+
# Returns the template String.
|
86
|
+
def template
|
87
|
+
if !html?
|
88
|
+
"/:path/:basename:output_ext"
|
89
|
+
elsif index?
|
90
|
+
"/:path/"
|
91
|
+
else
|
92
|
+
Utils.add_permalink_suffix("/:path/:basename", site.permalink_style)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# The generated relative url of this page. e.g. /about.html.
|
97
|
+
#
|
98
|
+
# Returns the String url.
|
99
|
+
def url
|
100
|
+
@url ||= URL.new({
|
101
|
+
:template => template,
|
102
|
+
:placeholders => url_placeholders,
|
103
|
+
:permalink => permalink,
|
104
|
+
}).to_s
|
105
|
+
end
|
106
|
+
|
107
|
+
# Returns a hash of URL placeholder names (as symbols) mapping to the
|
108
|
+
# desired placeholder replacements. For details see "url.rb"
|
109
|
+
def url_placeholders
|
110
|
+
{
|
111
|
+
:path => @dir,
|
112
|
+
:basename => basename,
|
113
|
+
:output_ext => output_ext,
|
114
|
+
}
|
115
|
+
end
|
116
|
+
|
117
|
+
# Extract information from the page filename.
|
118
|
+
#
|
119
|
+
# name - The String filename of the page file.
|
120
|
+
#
|
121
|
+
# Returns nothing.
|
122
|
+
def process(name)
|
123
|
+
self.ext = File.extname(name)
|
124
|
+
self.basename = name[0..-ext.length - 1]
|
125
|
+
end
|
126
|
+
|
127
|
+
# Add any necessary layouts to this post
|
128
|
+
#
|
129
|
+
# layouts - The Hash of {"name" => "layout"}.
|
130
|
+
# site_payload - The site payload Hash.
|
131
|
+
#
|
132
|
+
# Returns String rendered page.
|
133
|
+
def render(layouts, site_payload)
|
134
|
+
site_payload["page"] = to_liquid
|
135
|
+
site_payload["paginator"] = pager.to_liquid
|
136
|
+
|
137
|
+
do_layout(site_payload, layouts)
|
138
|
+
end
|
139
|
+
|
140
|
+
# The path to the source file
|
141
|
+
#
|
142
|
+
# Returns the path to the source file
|
143
|
+
def path
|
144
|
+
data.fetch("path") { relative_path }
|
145
|
+
end
|
146
|
+
|
147
|
+
# The path to the page source file, relative to the site source
|
148
|
+
def relative_path
|
149
|
+
File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).sub(%r!\A\/!, "")
|
150
|
+
end
|
151
|
+
|
152
|
+
# Obtain destination path.
|
153
|
+
#
|
154
|
+
# dest - The String path to the destination dir.
|
155
|
+
#
|
156
|
+
# Returns the destination file path String.
|
157
|
+
def destination(dest)
|
158
|
+
path = site.in_dest_dir(dest, URL.unescape_path(url))
|
159
|
+
path = File.join(path, "index") if url.end_with?("/")
|
160
|
+
path << output_ext unless path.end_with? output_ext
|
161
|
+
path
|
162
|
+
end
|
163
|
+
|
164
|
+
# Returns the object as a debug String.
|
165
|
+
def inspect
|
166
|
+
"#<Jekyll:Page @name=#{name.inspect}>"
|
167
|
+
end
|
168
|
+
|
169
|
+
# Returns the Boolean of whether this Page is HTML or not.
|
170
|
+
def html?
|
171
|
+
HTML_EXTENSIONS.include?(output_ext)
|
172
|
+
end
|
173
|
+
|
174
|
+
# Returns the Boolean of whether this Page is an index file or not.
|
175
|
+
def index?
|
176
|
+
basename == "index"
|
177
|
+
end
|
178
|
+
|
179
|
+
def trigger_hooks(hook_name, *args)
|
180
|
+
Jekyll::Hooks.trigger :pages, hook_name, self, *args
|
181
|
+
end
|
182
|
+
|
183
|
+
def write?
|
184
|
+
true
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class Plugin
|
5
|
+
PRIORITIES = {
|
6
|
+
:low => -10,
|
7
|
+
:highest => 100,
|
8
|
+
:lowest => -100,
|
9
|
+
:normal => 0,
|
10
|
+
:high => 10,
|
11
|
+
}.freeze
|
12
|
+
|
13
|
+
#
|
14
|
+
|
15
|
+
def self.inherited(const)
|
16
|
+
return catch_inheritance(const) do |const_|
|
17
|
+
catch_inheritance(const_)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
|
23
|
+
def self.catch_inheritance(const)
|
24
|
+
const.define_singleton_method :inherited do |const_|
|
25
|
+
(@children ||= Set.new).add const_
|
26
|
+
if block_given?
|
27
|
+
yield const_
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
|
34
|
+
def self.descendants
|
35
|
+
@children ||= Set.new
|
36
|
+
out = @children.map(&:descendants)
|
37
|
+
out << self unless superclass == Plugin
|
38
|
+
Set.new(out).flatten
|
39
|
+
end
|
40
|
+
|
41
|
+
# Get or set the priority of this plugin. When called without an
|
42
|
+
# argument it returns the priority. When an argument is given, it will
|
43
|
+
# set the priority.
|
44
|
+
#
|
45
|
+
# priority - The Symbol priority (default: nil). Valid options are:
|
46
|
+
# :lowest, :low, :normal, :high, :highest
|
47
|
+
#
|
48
|
+
# Returns the Symbol priority.
|
49
|
+
def self.priority(priority = nil)
|
50
|
+
@priority ||= nil
|
51
|
+
if priority && PRIORITIES.key?(priority)
|
52
|
+
@priority = priority
|
53
|
+
end
|
54
|
+
@priority || :normal
|
55
|
+
end
|
56
|
+
|
57
|
+
# Get or set the safety of this plugin. When called without an argument
|
58
|
+
# it returns the safety. When an argument is given, it will set the
|
59
|
+
# safety.
|
60
|
+
#
|
61
|
+
# safe - The Boolean safety (default: nil).
|
62
|
+
#
|
63
|
+
# Returns the safety Boolean.
|
64
|
+
def self.safe(safe = nil)
|
65
|
+
unless defined?(@safe) && safe.nil?
|
66
|
+
@safe = safe
|
67
|
+
end
|
68
|
+
@safe || false
|
69
|
+
end
|
70
|
+
|
71
|
+
# Spaceship is priority [higher -> lower]
|
72
|
+
#
|
73
|
+
# other - The class to be compared.
|
74
|
+
#
|
75
|
+
# Returns -1, 0, 1.
|
76
|
+
def self.<=>(other)
|
77
|
+
PRIORITIES[other.priority] <=> PRIORITIES[self.priority]
|
78
|
+
end
|
79
|
+
|
80
|
+
# Spaceship is priority [higher -> lower]
|
81
|
+
#
|
82
|
+
# other - The class to be compared.
|
83
|
+
#
|
84
|
+
# Returns -1, 0, 1.
|
85
|
+
def <=>(other)
|
86
|
+
self.class <=> other.class
|
87
|
+
end
|
88
|
+
|
89
|
+
# Initialize a new plugin. This should be overridden by the subclass.
|
90
|
+
#
|
91
|
+
# config - The Hash of configuration options.
|
92
|
+
#
|
93
|
+
# Returns a new instance.
|
94
|
+
def initialize(config = {})
|
95
|
+
# no-op for default
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class PluginManager
|
5
|
+
attr_reader :site
|
6
|
+
|
7
|
+
# Create an instance of this class.
|
8
|
+
#
|
9
|
+
# site - the instance of Jekyll::Site we're concerned with
|
10
|
+
#
|
11
|
+
# Returns nothing
|
12
|
+
def initialize(site)
|
13
|
+
@site = site
|
14
|
+
end
|
15
|
+
|
16
|
+
# Require all the plugins which are allowed.
|
17
|
+
#
|
18
|
+
# Returns nothing
|
19
|
+
def conscientious_require
|
20
|
+
require_theme_deps if site.theme
|
21
|
+
require_plugin_files
|
22
|
+
require_gems
|
23
|
+
deprecation_checks
|
24
|
+
end
|
25
|
+
|
26
|
+
# Require each of the gem plugins specified.
|
27
|
+
#
|
28
|
+
# Returns nothing.
|
29
|
+
def require_gems
|
30
|
+
Jekyll::External.require_with_graceful_fail(
|
31
|
+
site.gems.select { |plugin| plugin_allowed?(plugin) }
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Require each of the runtime_dependencies specified by the theme's gemspec.
|
36
|
+
#
|
37
|
+
# Returns false only if no dependencies have been specified, otherwise nothing.
|
38
|
+
def require_theme_deps
|
39
|
+
return false unless site.theme.runtime_dependencies
|
40
|
+
site.theme.runtime_dependencies.each do |dep|
|
41
|
+
next if dep.name == "jekyll"
|
42
|
+
External.require_with_graceful_fail(dep.name) if plugin_allowed?(dep.name)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.require_from_bundler
|
47
|
+
if !ENV["JEKYLL_NO_BUNDLER_REQUIRE"] && File.file?("Gemfile")
|
48
|
+
require "bundler"
|
49
|
+
|
50
|
+
Bundler.setup
|
51
|
+
required_gems = Bundler.require(:jekyll_plugins)
|
52
|
+
message = "Required #{required_gems.map(&:name).join(", ")}"
|
53
|
+
Jekyll.logger.debug("PluginManager:", message)
|
54
|
+
ENV["JEKYLL_NO_BUNDLER_REQUIRE"] = "true"
|
55
|
+
|
56
|
+
true
|
57
|
+
else
|
58
|
+
false
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Check whether a gem plugin is allowed to be used during this build.
|
63
|
+
#
|
64
|
+
# plugin_name - the name of the plugin
|
65
|
+
#
|
66
|
+
# Returns true if the plugin name is in the whitelist or if the site is not
|
67
|
+
# in safe mode.
|
68
|
+
def plugin_allowed?(plugin_name)
|
69
|
+
!site.safe || whitelist.include?(plugin_name)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Build an array of allowed plugin gem names.
|
73
|
+
#
|
74
|
+
# Returns an array of strings, each string being the name of a gem name
|
75
|
+
# that is allowed to be used.
|
76
|
+
def whitelist
|
77
|
+
@whitelist ||= Array[site.config["whitelist"]].flatten
|
78
|
+
end
|
79
|
+
|
80
|
+
# Require all .rb files if safe mode is off
|
81
|
+
#
|
82
|
+
# Returns nothing.
|
83
|
+
def require_plugin_files
|
84
|
+
unless site.safe
|
85
|
+
plugins_path.each do |plugin_search_path|
|
86
|
+
plugin_files = Utils.safe_glob(plugin_search_path, File.join("**", "*.rb"))
|
87
|
+
Jekyll::External.require_with_graceful_fail(plugin_files)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Public: Setup the plugin search path
|
93
|
+
#
|
94
|
+
# Returns an Array of plugin search paths
|
95
|
+
def plugins_path
|
96
|
+
if site.config["plugins_dir"].eql? Jekyll::Configuration::DEFAULTS["plugins_dir"]
|
97
|
+
[site.in_source_dir(site.config["plugins_dir"])]
|
98
|
+
else
|
99
|
+
Array(site.config["plugins_dir"]).map { |d| File.expand_path(d) }
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def deprecation_checks
|
104
|
+
pagination_included = (site.config["plugins"] || []).include?("jekyll-paginate") ||
|
105
|
+
defined?(Jekyll::Paginate)
|
106
|
+
if site.config["paginate"] && !pagination_included
|
107
|
+
Jekyll::Deprecator.deprecation_message "You appear to have pagination " \
|
108
|
+
"turned on, but you haven't included the `jekyll-paginate` gem. " \
|
109
|
+
"Ensure you have `plugins: [jekyll-paginate]` in your configuration file."
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class Publisher
|
5
|
+
def initialize(site)
|
6
|
+
@site = site
|
7
|
+
end
|
8
|
+
|
9
|
+
def publish?(thing)
|
10
|
+
can_be_published?(thing) && !hidden_in_the_future?(thing)
|
11
|
+
end
|
12
|
+
|
13
|
+
def hidden_in_the_future?(thing)
|
14
|
+
thing.respond_to?(:date) && !@site.future && thing.date.to_i > @site.time.to_i
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def can_be_published?(thing)
|
20
|
+
thing.data.fetch("published", true) || @site.unpublished
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "csv"
|
4
|
+
|
5
|
+
module Jekyll
|
6
|
+
class Reader
|
7
|
+
attr_reader :site
|
8
|
+
|
9
|
+
def initialize(site)
|
10
|
+
@site = site
|
11
|
+
end
|
12
|
+
|
13
|
+
# Read Site data from disk and load it into internal data structures.
|
14
|
+
#
|
15
|
+
# Returns nothing.
|
16
|
+
def read
|
17
|
+
@site.layouts = LayoutReader.new(site).read
|
18
|
+
read_directories
|
19
|
+
sort_files!
|
20
|
+
@site.data = DataReader.new(site).read(site.config["data_dir"])
|
21
|
+
CollectionReader.new(site).read
|
22
|
+
ThemeAssetsReader.new(site).read
|
23
|
+
end
|
24
|
+
|
25
|
+
# Sorts posts, pages, and static files.
|
26
|
+
def sort_files!
|
27
|
+
site.collections.each_value { |c| c.docs.sort! }
|
28
|
+
site.pages.sort_by!(&:name)
|
29
|
+
site.static_files.sort_by!(&:relative_path)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Recursively traverse directories to find pages and static files
|
33
|
+
# that will become part of the site according to the rules in
|
34
|
+
# filter_entries.
|
35
|
+
#
|
36
|
+
# dir - The String relative path of the directory to read. Default: ''.
|
37
|
+
#
|
38
|
+
# Returns nothing.
|
39
|
+
def read_directories(dir = "")
|
40
|
+
base = site.in_source_dir(dir)
|
41
|
+
|
42
|
+
return unless File.directory?(base)
|
43
|
+
|
44
|
+
dot = Dir.chdir(base) { filter_entries(Dir.entries("."), base) }
|
45
|
+
dot_dirs = dot.select { |file| File.directory?(@site.in_source_dir(base, file)) }
|
46
|
+
dot_files = (dot - dot_dirs)
|
47
|
+
dot_pages = dot_files.select do |file|
|
48
|
+
Utils.has_yaml_header?(@site.in_source_dir(base, file))
|
49
|
+
end
|
50
|
+
dot_static_files = dot_files - dot_pages
|
51
|
+
|
52
|
+
retrieve_posts(dir)
|
53
|
+
retrieve_dirs(base, dir, dot_dirs)
|
54
|
+
retrieve_pages(dir, dot_pages)
|
55
|
+
retrieve_static_files(dir, dot_static_files)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Retrieves all the posts(posts/drafts) from the given directory
|
59
|
+
# and add them to the site and sort them.
|
60
|
+
#
|
61
|
+
# dir - The String representing the directory to retrieve the posts from.
|
62
|
+
#
|
63
|
+
# Returns nothing.
|
64
|
+
def retrieve_posts(dir)
|
65
|
+
site.posts.docs.concat(PostReader.new(site).read_posts(dir))
|
66
|
+
site.posts.docs.concat(PostReader.new(site).read_drafts(dir)) if site.show_drafts
|
67
|
+
end
|
68
|
+
|
69
|
+
# Recursively traverse directories with the read_directories function.
|
70
|
+
#
|
71
|
+
# base - The String representing the site's base directory.
|
72
|
+
# dir - The String representing the directory to traverse down.
|
73
|
+
# dot_dirs - The Array of subdirectories in the dir.
|
74
|
+
#
|
75
|
+
# Returns nothing.
|
76
|
+
def retrieve_dirs(_base, dir, dot_dirs)
|
77
|
+
dot_dirs.each do |file|
|
78
|
+
dir_path = site.in_source_dir(dir, file)
|
79
|
+
rel_path = File.join(dir, file)
|
80
|
+
unless @site.dest.sub(%r!/$!, "") == dir_path
|
81
|
+
@site.reader.read_directories(rel_path)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Retrieve all the pages from the current directory,
|
87
|
+
# add them to the site and sort them.
|
88
|
+
#
|
89
|
+
# dir - The String representing the directory retrieve the pages from.
|
90
|
+
# dot_pages - The Array of pages in the dir.
|
91
|
+
#
|
92
|
+
# Returns nothing.
|
93
|
+
def retrieve_pages(dir, dot_pages)
|
94
|
+
site.pages.concat(PageReader.new(site, dir).read(dot_pages))
|
95
|
+
end
|
96
|
+
|
97
|
+
# Retrieve all the static files from the current directory,
|
98
|
+
# add them to the site and sort them.
|
99
|
+
#
|
100
|
+
# dir - The directory retrieve the static files from.
|
101
|
+
# dot_static_files - The static files in the dir.
|
102
|
+
#
|
103
|
+
# Returns nothing.
|
104
|
+
def retrieve_static_files(dir, dot_static_files)
|
105
|
+
site.static_files.concat(StaticFileReader.new(site, dir).read(dot_static_files))
|
106
|
+
end
|
107
|
+
|
108
|
+
# Filter out any files/directories that are hidden or backup files (start
|
109
|
+
# with "." or "#" or end with "~"), or contain site content (start with "_"),
|
110
|
+
# or are excluded in the site configuration, unless they are web server
|
111
|
+
# files such as '.htaccess'.
|
112
|
+
#
|
113
|
+
# entries - The Array of String file/directory entries to filter.
|
114
|
+
# base_directory - The string representing the optional base directory.
|
115
|
+
#
|
116
|
+
# Returns the Array of filtered entries.
|
117
|
+
def filter_entries(entries, base_directory = nil)
|
118
|
+
EntryFilter.new(site, base_directory).filter(entries)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Read the entries from a particular directory for processing
|
122
|
+
#
|
123
|
+
# dir - The String representing the relative path of the directory to read.
|
124
|
+
# subfolder - The String representing the directory to read.
|
125
|
+
#
|
126
|
+
# Returns the list of entries to process
|
127
|
+
def get_entries(dir, subfolder)
|
128
|
+
base = site.in_source_dir(dir, subfolder)
|
129
|
+
return [] unless File.exist?(base)
|
130
|
+
entries = Dir.chdir(base) { filter_entries(Dir["**/*"], base) }
|
131
|
+
entries.delete_if { |e| File.directory?(site.in_source_dir(base, e)) }
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|