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
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class CollectionReader
|
5
|
+
SPECIAL_COLLECTIONS = %w(posts data).freeze
|
6
|
+
|
7
|
+
attr_reader :site, :content
|
8
|
+
def initialize(site)
|
9
|
+
@site = site
|
10
|
+
@content = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
# Read in all collections specified in the configuration
|
14
|
+
#
|
15
|
+
# Returns nothing.
|
16
|
+
def read
|
17
|
+
site.collections.each_value do |collection|
|
18
|
+
collection.read unless SPECIAL_COLLECTIONS.include?(collection.label)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class DataReader
|
5
|
+
attr_reader :site, :content
|
6
|
+
def initialize(site)
|
7
|
+
@site = site
|
8
|
+
@content = {}
|
9
|
+
@entry_filter = EntryFilter.new(site)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Read all the files in <dir> and adds them to @content
|
13
|
+
#
|
14
|
+
# dir - The String relative path of the directory to read.
|
15
|
+
#
|
16
|
+
# Returns @content, a Hash of the .yaml, .yml,
|
17
|
+
# .json, and .csv files in the base directory
|
18
|
+
def read(dir)
|
19
|
+
base = site.in_source_dir(dir)
|
20
|
+
read_data_to(base, @content)
|
21
|
+
@content
|
22
|
+
end
|
23
|
+
|
24
|
+
# Read and parse all .yaml, .yml, .json, .csv and .tsv
|
25
|
+
# files under <dir> and add them to the <data> variable.
|
26
|
+
#
|
27
|
+
# dir - The string absolute path of the directory to read.
|
28
|
+
# data - The variable to which data will be added.
|
29
|
+
#
|
30
|
+
# Returns nothing
|
31
|
+
def read_data_to(dir, data)
|
32
|
+
return unless File.directory?(dir) && !@entry_filter.symlink?(dir)
|
33
|
+
|
34
|
+
entries = Dir.chdir(dir) do
|
35
|
+
Dir["*.{yaml,yml,json,csv,tsv}"] + Dir["*"].select { |fn| File.directory?(fn) }
|
36
|
+
end
|
37
|
+
|
38
|
+
entries.each do |entry|
|
39
|
+
path = @site.in_source_dir(dir, entry)
|
40
|
+
next if @entry_filter.symlink?(path)
|
41
|
+
|
42
|
+
if File.directory?(path)
|
43
|
+
read_data_to(path, data[sanitize_filename(entry)] = {})
|
44
|
+
else
|
45
|
+
key = sanitize_filename(File.basename(entry, ".*"))
|
46
|
+
data[key] = read_data_file(path)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Determines how to read a data file.
|
52
|
+
#
|
53
|
+
# Returns the contents of the data file.
|
54
|
+
def read_data_file(path)
|
55
|
+
case File.extname(path).downcase
|
56
|
+
when ".csv"
|
57
|
+
CSV.read(path, {
|
58
|
+
:headers => true,
|
59
|
+
:encoding => site.config["encoding"],
|
60
|
+
}).map(&:to_hash)
|
61
|
+
when ".tsv"
|
62
|
+
CSV.read(path, {
|
63
|
+
:col_sep => "\t",
|
64
|
+
:headers => true,
|
65
|
+
:encoding => site.config["encoding"],
|
66
|
+
}).map(&:to_hash)
|
67
|
+
else
|
68
|
+
SafeYAML.load_file(path)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def sanitize_filename(name)
|
73
|
+
name.gsub(%r![^\w\s-]+|(?<=^|\b\s)\s+(?=$|\s?\b)!, "")
|
74
|
+
.gsub(%r!\s+!, "_")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class LayoutReader
|
5
|
+
attr_reader :site
|
6
|
+
def initialize(site)
|
7
|
+
@site = site
|
8
|
+
@layouts = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def read
|
12
|
+
layout_entries.each do |layout_file|
|
13
|
+
@layouts[layout_name(layout_file)] = \
|
14
|
+
Layout.new(site, layout_directory, layout_file)
|
15
|
+
end
|
16
|
+
|
17
|
+
theme_layout_entries.each do |layout_file|
|
18
|
+
@layouts[layout_name(layout_file)] ||= \
|
19
|
+
Layout.new(site, theme_layout_directory, layout_file)
|
20
|
+
end
|
21
|
+
|
22
|
+
@layouts
|
23
|
+
end
|
24
|
+
|
25
|
+
def layout_directory
|
26
|
+
@layout_directory ||= (layout_directory_in_cwd || layout_directory_inside_source)
|
27
|
+
end
|
28
|
+
|
29
|
+
def theme_layout_directory
|
30
|
+
@theme_layout_directory ||= site.theme.layouts_path if site.theme
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def layout_entries
|
36
|
+
entries_in layout_directory
|
37
|
+
end
|
38
|
+
|
39
|
+
def theme_layout_entries
|
40
|
+
theme_layout_directory ? entries_in(theme_layout_directory) : []
|
41
|
+
end
|
42
|
+
|
43
|
+
def entries_in(dir)
|
44
|
+
entries = []
|
45
|
+
within(dir) do
|
46
|
+
entries = EntryFilter.new(site).filter(Dir["**/*.*"])
|
47
|
+
end
|
48
|
+
entries
|
49
|
+
end
|
50
|
+
|
51
|
+
def layout_name(file)
|
52
|
+
file.split(".")[0..-2].join(".")
|
53
|
+
end
|
54
|
+
|
55
|
+
def within(directory)
|
56
|
+
return unless File.exist?(directory)
|
57
|
+
Dir.chdir(directory) { yield }
|
58
|
+
end
|
59
|
+
|
60
|
+
def layout_directory_inside_source
|
61
|
+
site.in_source_dir(site.config["layouts_dir"])
|
62
|
+
end
|
63
|
+
|
64
|
+
def layout_directory_in_cwd
|
65
|
+
dir = Jekyll.sanitized_path(Dir.pwd, site.config["layouts_dir"])
|
66
|
+
if File.directory?(dir) && !site.safe
|
67
|
+
dir
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class PageReader
|
5
|
+
attr_reader :site, :dir, :unfiltered_content
|
6
|
+
def initialize(site, dir)
|
7
|
+
@site = site
|
8
|
+
@dir = dir
|
9
|
+
@unfiltered_content = []
|
10
|
+
end
|
11
|
+
|
12
|
+
# Read all the files in <source>/<dir>/ for Yaml header and create a new Page
|
13
|
+
# object for each file.
|
14
|
+
#
|
15
|
+
# dir - The String relative path of the directory to read.
|
16
|
+
#
|
17
|
+
# Returns an array of static pages.
|
18
|
+
def read(files)
|
19
|
+
files.map do |page|
|
20
|
+
@unfiltered_content << Page.new(@site, @site.source, @dir, page)
|
21
|
+
end
|
22
|
+
@unfiltered_content.select { |page| site.publisher.publish?(page) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class PostReader
|
5
|
+
attr_reader :site, :unfiltered_content
|
6
|
+
def initialize(site)
|
7
|
+
@site = site
|
8
|
+
end
|
9
|
+
|
10
|
+
# Read all the files in <source>/<dir>/_drafts and create a new
|
11
|
+
# Document object with each one.
|
12
|
+
#
|
13
|
+
# dir - The String relative path of the directory to read.
|
14
|
+
#
|
15
|
+
# Returns nothing.
|
16
|
+
def read_drafts(dir)
|
17
|
+
read_publishable(dir, "_drafts", Document::DATELESS_FILENAME_MATCHER)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Read all the files in <source>/<dir>/_posts and create a new Document
|
21
|
+
# object with each one.
|
22
|
+
#
|
23
|
+
# dir - The String relative path of the directory to read.
|
24
|
+
#
|
25
|
+
# Returns nothing.
|
26
|
+
def read_posts(dir)
|
27
|
+
read_publishable(dir, "_posts", Document::DATE_FILENAME_MATCHER)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Read all the files in <source>/<dir>/<magic_dir> and create a new
|
31
|
+
# Document object with each one insofar as it matches the regexp matcher.
|
32
|
+
#
|
33
|
+
# dir - The String relative path of the directory to read.
|
34
|
+
#
|
35
|
+
# Returns nothing.
|
36
|
+
def read_publishable(dir, magic_dir, matcher)
|
37
|
+
read_content(dir, magic_dir, matcher).tap { |docs| docs.each(&:read) }
|
38
|
+
.select do |doc|
|
39
|
+
if doc.content.valid_encoding?
|
40
|
+
site.publisher.publish?(doc).tap do |will_publish|
|
41
|
+
if !will_publish && site.publisher.hidden_in_the_future?(doc)
|
42
|
+
Jekyll.logger.debug "Skipping:", "#{doc.relative_path} has a future date"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
else
|
46
|
+
Jekyll.logger.debug "Skipping:", "#{doc.relative_path} is not valid UTF-8"
|
47
|
+
false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Read all the content files from <source>/<dir>/magic_dir
|
53
|
+
# and return them with the type klass.
|
54
|
+
#
|
55
|
+
# dir - The String relative path of the directory to read.
|
56
|
+
# magic_dir - The String relative directory to <dir>,
|
57
|
+
# looks for content here.
|
58
|
+
# klass - The return type of the content.
|
59
|
+
#
|
60
|
+
# Returns klass type of content files
|
61
|
+
def read_content(dir, magic_dir, matcher)
|
62
|
+
@site.reader.get_entries(dir, magic_dir).map do |entry|
|
63
|
+
next unless entry =~ matcher
|
64
|
+
path = @site.in_source_dir(File.join(dir, magic_dir, entry))
|
65
|
+
Document.new(path, {
|
66
|
+
:site => @site,
|
67
|
+
:collection => @site.posts,
|
68
|
+
})
|
69
|
+
end.reject(&:nil?)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class StaticFileReader
|
5
|
+
attr_reader :site, :dir, :unfiltered_content
|
6
|
+
def initialize(site, dir)
|
7
|
+
@site = site
|
8
|
+
@dir = dir
|
9
|
+
@unfiltered_content = []
|
10
|
+
end
|
11
|
+
|
12
|
+
# Read all the files in <source>/<dir>/ for Yaml header and create a new Page
|
13
|
+
# object for each file.
|
14
|
+
#
|
15
|
+
# dir - The String relative path of the directory to read.
|
16
|
+
#
|
17
|
+
# Returns an array of static files.
|
18
|
+
def read(files)
|
19
|
+
files.map do |file|
|
20
|
+
@unfiltered_content << StaticFile.new(@site, @site.source, @dir, file)
|
21
|
+
end
|
22
|
+
@unfiltered_content
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class ThemeAssetsReader
|
5
|
+
attr_reader :site
|
6
|
+
def initialize(site)
|
7
|
+
@site = site
|
8
|
+
end
|
9
|
+
|
10
|
+
def read
|
11
|
+
return unless site.theme && site.theme.assets_path
|
12
|
+
|
13
|
+
Find.find(site.theme.assets_path) do |path|
|
14
|
+
next if File.directory?(path)
|
15
|
+
if File.symlink?(path)
|
16
|
+
Jekyll.logger.warn "Theme reader:", "Ignored symlinked asset: #{path}"
|
17
|
+
else
|
18
|
+
read_theme_asset(path)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def read_theme_asset(path)
|
25
|
+
base = site.theme.root
|
26
|
+
dir = File.dirname(path.sub("#{site.theme.root}/", ""))
|
27
|
+
name = File.basename(path)
|
28
|
+
|
29
|
+
if Utils.has_yaml_header?(path)
|
30
|
+
append_unless_exists site.pages,
|
31
|
+
Jekyll::Page.new(site, base, dir, name)
|
32
|
+
else
|
33
|
+
append_unless_exists site.static_files,
|
34
|
+
Jekyll::StaticFile.new(site, base, "/#{dir}", name)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def append_unless_exists(haystack, new_item)
|
39
|
+
if haystack.any? { |file| file.relative_path == new_item.relative_path }
|
40
|
+
Jekyll.logger.debug "Theme:",
|
41
|
+
"Ignoring #{new_item.relative_path} in theme due to existing file " \
|
42
|
+
"with that path in site."
|
43
|
+
return
|
44
|
+
end
|
45
|
+
|
46
|
+
haystack << new_item
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,201 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class Regenerator
|
5
|
+
attr_reader :site, :metadata, :cache
|
6
|
+
attr_accessor :disabled
|
7
|
+
private :disabled, :disabled=
|
8
|
+
|
9
|
+
def initialize(site)
|
10
|
+
@site = site
|
11
|
+
|
12
|
+
# Read metadata from file
|
13
|
+
read_metadata
|
14
|
+
|
15
|
+
# Initialize cache to an empty hash
|
16
|
+
clear_cache
|
17
|
+
end
|
18
|
+
|
19
|
+
# Checks if a renderable object needs to be regenerated
|
20
|
+
#
|
21
|
+
# Returns a boolean.
|
22
|
+
def regenerate?(document)
|
23
|
+
case document
|
24
|
+
when Page
|
25
|
+
regenerate_page?(document)
|
26
|
+
when Document
|
27
|
+
regenerate_document?(document)
|
28
|
+
else
|
29
|
+
source_path = document.respond_to?(:path) ? document.path : nil
|
30
|
+
dest_path = if document.respond_to?(:destination)
|
31
|
+
document.destination(@site.dest)
|
32
|
+
end
|
33
|
+
source_modified_or_dest_missing?(source_path, dest_path)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Add a path to the metadata
|
38
|
+
#
|
39
|
+
# Returns true, also on failure.
|
40
|
+
def add(path)
|
41
|
+
return true unless File.exist?(path)
|
42
|
+
|
43
|
+
metadata[path] = {
|
44
|
+
"mtime" => File.mtime(path),
|
45
|
+
"deps" => [],
|
46
|
+
}
|
47
|
+
cache[path] = true
|
48
|
+
end
|
49
|
+
|
50
|
+
# Force a path to regenerate
|
51
|
+
#
|
52
|
+
# Returns true.
|
53
|
+
def force(path)
|
54
|
+
cache[path] = true
|
55
|
+
end
|
56
|
+
|
57
|
+
# Clear the metadata and cache
|
58
|
+
#
|
59
|
+
# Returns nothing
|
60
|
+
def clear
|
61
|
+
@metadata = {}
|
62
|
+
clear_cache
|
63
|
+
end
|
64
|
+
|
65
|
+
# Clear just the cache
|
66
|
+
#
|
67
|
+
# Returns nothing
|
68
|
+
def clear_cache
|
69
|
+
@cache = {}
|
70
|
+
end
|
71
|
+
|
72
|
+
# Checks if the source has been modified or the
|
73
|
+
# destination is missing
|
74
|
+
#
|
75
|
+
# returns a boolean
|
76
|
+
def source_modified_or_dest_missing?(source_path, dest_path)
|
77
|
+
modified?(source_path) || (dest_path && !File.exist?(dest_path))
|
78
|
+
end
|
79
|
+
|
80
|
+
# Checks if a path's (or one of its dependencies)
|
81
|
+
# mtime has changed
|
82
|
+
#
|
83
|
+
# Returns a boolean.
|
84
|
+
def modified?(path)
|
85
|
+
return true if disabled?
|
86
|
+
|
87
|
+
# objects that don't have a path are always regenerated
|
88
|
+
return true if path.nil?
|
89
|
+
|
90
|
+
# Check for path in cache
|
91
|
+
if cache.key? path
|
92
|
+
return cache[path]
|
93
|
+
end
|
94
|
+
|
95
|
+
if metadata[path]
|
96
|
+
# If we have seen this file before,
|
97
|
+
# check if it or one of its dependencies has been modified
|
98
|
+
existing_file_modified?(path)
|
99
|
+
else
|
100
|
+
# If we have not seen this file before, add it to the metadata and regenerate it
|
101
|
+
add(path)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# Add a dependency of a path
|
106
|
+
#
|
107
|
+
# Returns nothing.
|
108
|
+
def add_dependency(path, dependency)
|
109
|
+
return if metadata[path].nil? || disabled
|
110
|
+
|
111
|
+
unless metadata[path]["deps"].include? dependency
|
112
|
+
metadata[path]["deps"] << dependency
|
113
|
+
add(dependency) unless metadata.include?(dependency)
|
114
|
+
end
|
115
|
+
regenerate? dependency
|
116
|
+
end
|
117
|
+
|
118
|
+
# Write the metadata to disk
|
119
|
+
#
|
120
|
+
# Returns nothing.
|
121
|
+
def write_metadata
|
122
|
+
unless disabled?
|
123
|
+
File.binwrite(metadata_file, Marshal.dump(metadata))
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
# Produce the absolute path of the metadata file
|
128
|
+
#
|
129
|
+
# Returns the String path of the file.
|
130
|
+
def metadata_file
|
131
|
+
site.in_source_dir(".jekyll-metadata")
|
132
|
+
end
|
133
|
+
|
134
|
+
# Check if metadata has been disabled
|
135
|
+
#
|
136
|
+
# Returns a Boolean (true for disabled, false for enabled).
|
137
|
+
def disabled?
|
138
|
+
self.disabled = !site.incremental? if disabled.nil?
|
139
|
+
disabled
|
140
|
+
end
|
141
|
+
|
142
|
+
private
|
143
|
+
|
144
|
+
# Read metadata from the metadata file, if no file is found,
|
145
|
+
# initialize with an empty hash
|
146
|
+
#
|
147
|
+
# Returns the read metadata.
|
148
|
+
def read_metadata
|
149
|
+
@metadata =
|
150
|
+
if !disabled? && File.file?(metadata_file)
|
151
|
+
content = File.binread(metadata_file)
|
152
|
+
|
153
|
+
begin
|
154
|
+
Marshal.load(content)
|
155
|
+
rescue TypeError
|
156
|
+
SafeYAML.load(content)
|
157
|
+
rescue ArgumentError => e
|
158
|
+
Jekyll.logger.warn("Failed to load #{metadata_file}: #{e}")
|
159
|
+
{}
|
160
|
+
end
|
161
|
+
else
|
162
|
+
{}
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
private
|
167
|
+
def regenerate_page?(document)
|
168
|
+
document.asset_file? || document.data["regenerate"] ||
|
169
|
+
source_modified_or_dest_missing?(
|
170
|
+
site.in_source_dir(document.relative_path), document.destination(@site.dest)
|
171
|
+
)
|
172
|
+
end
|
173
|
+
|
174
|
+
private
|
175
|
+
def regenerate_document?(document)
|
176
|
+
!document.write? || document.data["regenerate"] ||
|
177
|
+
source_modified_or_dest_missing?(
|
178
|
+
document.path, document.destination(@site.dest)
|
179
|
+
)
|
180
|
+
end
|
181
|
+
|
182
|
+
private
|
183
|
+
def existing_file_modified?(path)
|
184
|
+
# If one of this file dependencies have been modified,
|
185
|
+
# set the regeneration bit for both the dependency and the file to true
|
186
|
+
metadata[path]["deps"].each do |dependency|
|
187
|
+
if modified?(dependency)
|
188
|
+
return cache[dependency] = cache[path] = true
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
if File.exist?(path) && metadata[path]["mtime"].eql?(File.mtime(path))
|
193
|
+
# If this file has not been modified, set the regeneration bit to false
|
194
|
+
cache[path] = false
|
195
|
+
else
|
196
|
+
# If it has been modified, set it to true
|
197
|
+
add(path)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|