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
|
+
module Drops
|
5
|
+
class CollectionDrop < Drop
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
mutable false
|
9
|
+
|
10
|
+
def_delegator :@obj, :write?, :output
|
11
|
+
def_delegators :@obj, :label, :docs, :files, :directory,
|
12
|
+
:relative_directory
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
docs.to_s
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def_delegator :@obj, :metadata, :fallback_data
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Drops
|
5
|
+
class DocumentDrop < Drop
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
NESTED_OBJECT_FIELD_BLACKLIST = %w(
|
9
|
+
content output excerpt next previous
|
10
|
+
).freeze
|
11
|
+
|
12
|
+
mutable false
|
13
|
+
|
14
|
+
def_delegator :@obj, :relative_path, :path
|
15
|
+
def_delegators :@obj, :id, :output, :content, :to_s, :relative_path, :url
|
16
|
+
|
17
|
+
def collection
|
18
|
+
@obj.collection.label
|
19
|
+
end
|
20
|
+
|
21
|
+
def excerpt
|
22
|
+
fallback_data["excerpt"].to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
def <=>(other)
|
26
|
+
return nil unless other.is_a? DocumentDrop
|
27
|
+
cmp = self["date"] <=> other["date"]
|
28
|
+
cmp = self["path"] <=> other["path"] if cmp.nil? || cmp.zero?
|
29
|
+
cmp
|
30
|
+
end
|
31
|
+
|
32
|
+
def previous
|
33
|
+
@obj.previous_doc.to_liquid
|
34
|
+
end
|
35
|
+
|
36
|
+
def next
|
37
|
+
@obj.next_doc.to_liquid
|
38
|
+
end
|
39
|
+
|
40
|
+
# Generate a Hash for use in generating JSON.
|
41
|
+
# This is useful if fields need to be cleared before the JSON can generate.
|
42
|
+
#
|
43
|
+
# state - the JSON::State object which determines the state of current processing.
|
44
|
+
#
|
45
|
+
# Returns a Hash ready for JSON generation.
|
46
|
+
def hash_for_json(state = nil)
|
47
|
+
to_h.tap do |hash|
|
48
|
+
if state && state.depth >= 2
|
49
|
+
hash["previous"] = collapse_document(hash["previous"]) if hash["previous"]
|
50
|
+
hash["next"] = collapse_document(hash["next"]) if hash["next"]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Generate a Hash which breaks the recursive chain.
|
56
|
+
# Certain fields which are normally available are omitted.
|
57
|
+
#
|
58
|
+
# Returns a Hash with only non-recursive fields present.
|
59
|
+
def collapse_document(doc)
|
60
|
+
doc.keys.each_with_object({}) do |(key, _), result|
|
61
|
+
result[key] = doc[key] unless NESTED_OBJECT_FIELD_BLACKLIST.include?(key)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
def_delegator :@obj, :data, :fallback_data
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,214 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Drops
|
5
|
+
class Drop < Liquid::Drop
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
NON_CONTENT_METHODS = [:fallback_data, :collapse_document].freeze
|
9
|
+
|
10
|
+
# Get or set whether the drop class is mutable.
|
11
|
+
# Mutability determines whether or not pre-defined fields may be
|
12
|
+
# overwritten.
|
13
|
+
#
|
14
|
+
# is_mutable - Boolean set mutability of the class (default: nil)
|
15
|
+
#
|
16
|
+
# Returns the mutability of the class
|
17
|
+
def self.mutable(is_mutable = nil)
|
18
|
+
@is_mutable = if is_mutable
|
19
|
+
is_mutable
|
20
|
+
else
|
21
|
+
false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.mutable?
|
26
|
+
@is_mutable
|
27
|
+
end
|
28
|
+
|
29
|
+
# Create a new Drop
|
30
|
+
#
|
31
|
+
# obj - the Jekyll Site, Collection, or Document required by the
|
32
|
+
# drop.
|
33
|
+
#
|
34
|
+
# Returns nothing
|
35
|
+
def initialize(obj)
|
36
|
+
@obj = obj
|
37
|
+
@mutations = {} # only if mutable: true
|
38
|
+
end
|
39
|
+
|
40
|
+
# Access a method in the Drop or a field in the underlying hash data.
|
41
|
+
# If mutable, checks the mutations first. Then checks the methods,
|
42
|
+
# and finally check the underlying hash (e.g. document front matter)
|
43
|
+
# if all the previous places didn't match.
|
44
|
+
#
|
45
|
+
# key - the string key whose value to fetch
|
46
|
+
#
|
47
|
+
# Returns the value for the given key, or nil if none exists
|
48
|
+
def [](key)
|
49
|
+
if self.class.mutable? && @mutations.key?(key)
|
50
|
+
@mutations[key]
|
51
|
+
elsif self.class.invokable? key
|
52
|
+
public_send key
|
53
|
+
else
|
54
|
+
fallback_data[key]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
alias_method :invoke_drop, :[]
|
58
|
+
|
59
|
+
# Set a field in the Drop. If mutable, sets in the mutations and
|
60
|
+
# returns. If not mutable, checks first if it's trying to override a
|
61
|
+
# Drop method and raises a DropMutationException if so. If not
|
62
|
+
# mutable and the key is not a method on the Drop, then it sets the
|
63
|
+
# key to the value in the underlying hash (e.g. document front
|
64
|
+
# matter)
|
65
|
+
#
|
66
|
+
# key - the String key whose value to set
|
67
|
+
# val - the Object to set the key's value to
|
68
|
+
#
|
69
|
+
# Returns the value the key was set to unless the Drop is not mutable
|
70
|
+
# and the key matches a method in which case it raises a
|
71
|
+
# DropMutationException.
|
72
|
+
def []=(key, val)
|
73
|
+
if respond_to?("#{key}=")
|
74
|
+
public_send("#{key}=", val)
|
75
|
+
elsif respond_to?(key.to_s)
|
76
|
+
if self.class.mutable?
|
77
|
+
@mutations[key] = val
|
78
|
+
else
|
79
|
+
raise Errors::DropMutationException, "Key #{key} cannot be set in the drop."
|
80
|
+
end
|
81
|
+
else
|
82
|
+
fallback_data[key] = val
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Generates a list of strings which correspond to content getter
|
87
|
+
# methods.
|
88
|
+
#
|
89
|
+
# Returns an Array of strings which represent method-specific keys.
|
90
|
+
def content_methods
|
91
|
+
@content_methods ||= (
|
92
|
+
self.class.instance_methods \
|
93
|
+
- Jekyll::Drops::Drop.instance_methods \
|
94
|
+
- NON_CONTENT_METHODS
|
95
|
+
).map(&:to_s).reject do |method|
|
96
|
+
method.end_with?("=")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Check if key exists in Drop
|
101
|
+
#
|
102
|
+
# key - the string key whose value to fetch
|
103
|
+
#
|
104
|
+
# Returns true if the given key is present
|
105
|
+
def key?(key)
|
106
|
+
return false if key.nil?
|
107
|
+
return true if self.class.mutable? && @mutations.key?(key)
|
108
|
+
respond_to?(key) || fallback_data.key?(key)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Generates a list of keys with user content as their values.
|
112
|
+
# This gathers up the Drop methods and keys of the mutations and
|
113
|
+
# underlying data hashes and performs a set union to ensure a list
|
114
|
+
# of unique keys for the Drop.
|
115
|
+
#
|
116
|
+
# Returns an Array of unique keys for content for the Drop.
|
117
|
+
def keys
|
118
|
+
(content_methods |
|
119
|
+
@mutations.keys |
|
120
|
+
fallback_data.keys).flatten
|
121
|
+
end
|
122
|
+
|
123
|
+
# Generate a Hash representation of the Drop by resolving each key's
|
124
|
+
# value. It includes Drop methods, mutations, and the underlying object's
|
125
|
+
# data. See the documentation for Drop#keys for more.
|
126
|
+
#
|
127
|
+
# Returns a Hash with all the keys and values resolved.
|
128
|
+
def to_h
|
129
|
+
keys.each_with_object({}) do |(key, _), result|
|
130
|
+
result[key] = self[key]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
alias_method :to_hash, :to_h
|
134
|
+
|
135
|
+
# Inspect the drop's keys and values through a JSON representation
|
136
|
+
# of its keys and values.
|
137
|
+
#
|
138
|
+
# Returns a pretty generation of the hash representation of the Drop.
|
139
|
+
def inspect
|
140
|
+
require "json"
|
141
|
+
JSON.pretty_generate to_h
|
142
|
+
end
|
143
|
+
|
144
|
+
# Generate a Hash for use in generating JSON.
|
145
|
+
# This is useful if fields need to be cleared before the JSON can generate.
|
146
|
+
#
|
147
|
+
# Returns a Hash ready for JSON generation.
|
148
|
+
def hash_for_json(*)
|
149
|
+
to_h
|
150
|
+
end
|
151
|
+
|
152
|
+
# Generate a JSON representation of the Drop.
|
153
|
+
#
|
154
|
+
# state - the JSON::State object which determines the state of current processing.
|
155
|
+
#
|
156
|
+
# Returns a JSON representation of the Drop in a String.
|
157
|
+
def to_json(state = nil)
|
158
|
+
require "json"
|
159
|
+
JSON.generate(hash_for_json(state), state)
|
160
|
+
end
|
161
|
+
|
162
|
+
# Collects all the keys and passes each to the block in turn.
|
163
|
+
#
|
164
|
+
# block - a block which accepts one argument, the key
|
165
|
+
#
|
166
|
+
# Returns nothing.
|
167
|
+
def each_key(&block)
|
168
|
+
keys.each(&block)
|
169
|
+
end
|
170
|
+
|
171
|
+
def each
|
172
|
+
each_key.each do |key|
|
173
|
+
yield key, self[key]
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def merge(other, &block)
|
178
|
+
self.dup.tap do |me|
|
179
|
+
if block.nil?
|
180
|
+
me.merge!(other)
|
181
|
+
else
|
182
|
+
me.merge!(other, block)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def merge!(other)
|
188
|
+
other.each_key do |key|
|
189
|
+
if block_given?
|
190
|
+
self[key] = yield key, self[key], other[key]
|
191
|
+
else
|
192
|
+
if Utils.mergable?(self[key]) && Utils.mergable?(other[key])
|
193
|
+
self[key] = Utils.deep_merge_hashes(self[key], other[key])
|
194
|
+
next
|
195
|
+
end
|
196
|
+
|
197
|
+
self[key] = other[key] unless other[key].nil?
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
# Imitate Hash.fetch method in Drop
|
203
|
+
#
|
204
|
+
# Returns value if key is present in Drop, otherwise returns default value
|
205
|
+
# KeyError is raised if key is not present and no default value given
|
206
|
+
def fetch(key, default = nil, &block)
|
207
|
+
return self[key] if key?(key)
|
208
|
+
raise KeyError, %(key not found: "#{key}") if default.nil? && block.nil?
|
209
|
+
return yield(key) unless block.nil?
|
210
|
+
return default unless default.nil?
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Drops
|
5
|
+
class JekyllDrop < Liquid::Drop
|
6
|
+
class << self
|
7
|
+
def global
|
8
|
+
@global ||= JekyllDrop.new
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def version
|
13
|
+
Jekyll::VERSION
|
14
|
+
end
|
15
|
+
|
16
|
+
def environment
|
17
|
+
Jekyll.env
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_h
|
21
|
+
@to_h ||= {
|
22
|
+
"version" => version,
|
23
|
+
"environment" => environment,
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_json(state = nil)
|
28
|
+
require "json"
|
29
|
+
JSON.generate(to_h, state)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Drops
|
5
|
+
class SiteDrop < Drop
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
mutable false
|
9
|
+
|
10
|
+
def_delegator :@obj, :site_data, :data
|
11
|
+
def_delegators :@obj, :time, :pages, :static_files, :documents,
|
12
|
+
:tags, :categories
|
13
|
+
|
14
|
+
def [](key)
|
15
|
+
if @obj.collections.key?(key) && key != "posts"
|
16
|
+
@obj.collections[key].docs
|
17
|
+
else
|
18
|
+
super(key)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def key?(key)
|
23
|
+
(@obj.collections.key?(key) && key != "posts") || super
|
24
|
+
end
|
25
|
+
|
26
|
+
def posts
|
27
|
+
@site_posts ||= @obj.posts.docs.sort { |a, b| b <=> a }
|
28
|
+
end
|
29
|
+
|
30
|
+
def html_pages
|
31
|
+
@site_html_pages ||= @obj.pages.select do |page|
|
32
|
+
page.html? || page.url.end_with?("/")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def collections
|
37
|
+
@site_collections ||= @obj.collections.values.sort_by(&:label).map(&:to_liquid)
|
38
|
+
end
|
39
|
+
|
40
|
+
# return nil for `{{ site.config }}` even if --config was passed via CLI
|
41
|
+
def config; end
|
42
|
+
|
43
|
+
private
|
44
|
+
def_delegator :@obj, :config, :fallback_data
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Drops
|
5
|
+
class StaticFileDrop < Drop
|
6
|
+
extend Forwardable
|
7
|
+
def_delegators :@obj, :name, :extname, :modified_time, :basename
|
8
|
+
def_delegator :@obj, :relative_path, :path
|
9
|
+
def_delegator :@obj, :data, :fallback_data
|
10
|
+
def_delegator :@obj, :type, :collection
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Drops
|
5
|
+
class UnifiedPayloadDrop < Drop
|
6
|
+
mutable true
|
7
|
+
|
8
|
+
attr_accessor :page, :layout, :content, :paginator
|
9
|
+
attr_accessor :highlighter_prefix, :highlighter_suffix
|
10
|
+
|
11
|
+
def jekyll
|
12
|
+
JekyllDrop.global
|
13
|
+
end
|
14
|
+
|
15
|
+
def site
|
16
|
+
@site_drop ||= SiteDrop.new(@obj)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def fallback_data
|
21
|
+
@fallback_data ||= {}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|