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.
Files changed (253) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll.rb +195 -0
  3. data/lib/jekyll/cleaner.rb +110 -0
  4. data/lib/jekyll/collection.rb +230 -0
  5. data/lib/jekyll/command.rb +78 -0
  6. data/lib/jekyll/commands/build.rb +102 -0
  7. data/lib/jekyll/commands/clean.rb +43 -0
  8. data/lib/jekyll/commands/doctor.rb +153 -0
  9. data/lib/jekyll/commands/help.rb +34 -0
  10. data/lib/jekyll/commands/new.rb +156 -0
  11. data/lib/jekyll/commands/new_theme.rb +40 -0
  12. data/lib/jekyll/commands/serve.rb +245 -0
  13. data/lib/jekyll/commands/serve/servlet.rb +62 -0
  14. data/lib/jekyll/configuration.rb +410 -0
  15. data/lib/jekyll/converter.rb +54 -0
  16. data/lib/jekyll/converters/identity.rb +23 -0
  17. data/lib/jekyll/converters/markdown.rb +104 -0
  18. data/lib/jekyll/converters/markdown/kramdown_parser.rb +123 -0
  19. data/lib/jekyll/converters/markdown/rdiscount_parser.rb +35 -0
  20. data/lib/jekyll/converters/markdown/redcarpet_parser.rb +108 -0
  21. data/lib/jekyll/converters/smartypants.rb +36 -0
  22. data/lib/jekyll/convertible.rb +251 -0
  23. data/lib/jekyll/deprecator.rb +52 -0
  24. data/lib/jekyll/document.rb +507 -0
  25. data/lib/jekyll/drops/collection_drop.rb +22 -0
  26. data/lib/jekyll/drops/document_drop.rb +69 -0
  27. data/lib/jekyll/drops/drop.rb +214 -0
  28. data/lib/jekyll/drops/excerpt_drop.rb +15 -0
  29. data/lib/jekyll/drops/jekyll_drop.rb +33 -0
  30. data/lib/jekyll/drops/site_drop.rb +47 -0
  31. data/lib/jekyll/drops/static_file_drop.rb +13 -0
  32. data/lib/jekyll/drops/unified_payload_drop.rb +25 -0
  33. data/lib/jekyll/drops/url_drop.rb +88 -0
  34. data/lib/jekyll/entry_filter.rb +123 -0
  35. data/lib/jekyll/errors.rb +20 -0
  36. data/lib/jekyll/excerpt.rb +126 -0
  37. data/lib/jekyll/external.rb +74 -0
  38. data/lib/jekyll/filters.rb +430 -0
  39. data/lib/jekyll/filters/grouping_filters.rb +65 -0
  40. data/lib/jekyll/filters/url_filters.rb +60 -0
  41. data/lib/jekyll/frontmatter_defaults.rb +197 -0
  42. data/lib/jekyll/generator.rb +5 -0
  43. data/lib/jekyll/hooks.rb +104 -0
  44. data/lib/jekyll/layout.rb +62 -0
  45. data/lib/jekyll/liquid_extensions.rb +24 -0
  46. data/lib/jekyll/liquid_renderer.rb +49 -0
  47. data/lib/jekyll/liquid_renderer/file.rb +56 -0
  48. data/lib/jekyll/liquid_renderer/table.rb +96 -0
  49. data/lib/jekyll/log_adapter.rb +147 -0
  50. data/lib/jekyll/mime.types +825 -0
  51. data/lib/jekyll/page.rb +187 -0
  52. data/lib/jekyll/plugin.rb +98 -0
  53. data/lib/jekyll/plugin_manager.rb +113 -0
  54. data/lib/jekyll/publisher.rb +23 -0
  55. data/lib/jekyll/reader.rb +134 -0
  56. data/lib/jekyll/readers/collection_reader.rb +22 -0
  57. data/lib/jekyll/readers/data_reader.rb +77 -0
  58. data/lib/jekyll/readers/layout_reader.rb +71 -0
  59. data/lib/jekyll/readers/page_reader.rb +25 -0
  60. data/lib/jekyll/readers/post_reader.rb +72 -0
  61. data/lib/jekyll/readers/static_file_reader.rb +25 -0
  62. data/lib/jekyll/readers/theme_assets_reader.rb +49 -0
  63. data/lib/jekyll/regenerator.rb +201 -0
  64. data/lib/jekyll/related_posts.rb +52 -0
  65. data/lib/jekyll/renderer.rb +269 -0
  66. data/lib/jekyll/site.rb +471 -0
  67. data/lib/jekyll/static_file.rb +162 -0
  68. data/lib/jekyll/stevenson.rb +61 -0
  69. data/lib/jekyll/tags/highlight.rb +141 -0
  70. data/lib/jekyll/tags/include.rb +215 -0
  71. data/lib/jekyll/tags/link.rb +37 -0
  72. data/lib/jekyll/tags/post_url.rb +103 -0
  73. data/lib/jekyll/theme.rb +68 -0
  74. data/lib/jekyll/theme_builder.rb +119 -0
  75. data/lib/jekyll/url.rb +161 -0
  76. data/lib/jekyll/utils.rb +337 -0
  77. data/lib/jekyll/utils/ansi.rb +59 -0
  78. data/lib/jekyll/utils/exec.rb +27 -0
  79. data/lib/jekyll/utils/platforms.rb +82 -0
  80. data/lib/jekyll/utils/rouge.rb +21 -0
  81. data/lib/jekyll/utils/win_tz.rb +75 -0
  82. data/lib/jekyll/version.rb +5 -0
  83. data/lib/site_template/404.html +24 -0
  84. data/lib/site_template/_config.yml +43 -0
  85. data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +25 -0
  86. data/lib/site_template/about.md +18 -0
  87. data/lib/site_template/index.md +6 -0
  88. data/lib/theme_template/CODE_OF_CONDUCT.md.erb +74 -0
  89. data/lib/theme_template/Gemfile +4 -0
  90. data/lib/theme_template/LICENSE.txt.erb +21 -0
  91. data/lib/theme_template/README.md.erb +52 -0
  92. data/lib/theme_template/_layouts/default.html +1 -0
  93. data/lib/theme_template/_layouts/page.html +5 -0
  94. data/lib/theme_template/_layouts/post.html +5 -0
  95. data/lib/theme_template/example/_config.yml.erb +1 -0
  96. data/lib/theme_template/example/_post.md +12 -0
  97. data/lib/theme_template/example/index.html +14 -0
  98. data/lib/theme_template/example/style.scss +7 -0
  99. data/lib/theme_template/gitignore.erb +5 -0
  100. data/lib/theme_template/theme.gemspec.erb +19 -0
  101. metadata +103 -156
  102. data/lib/jekyll-docs.rb +0 -31
  103. data/site/404.html +0 -153
  104. data/site/CNAME +0 -1
  105. data/site/community/index.html +0 -299
  106. data/site/conduct/index.html +0 -10
  107. data/site/css/screen.css +0 -1
  108. data/site/docs/assets/index.html +0 -724
  109. data/site/docs/code_of_conduct/index.html +0 -730
  110. data/site/docs/collections/index.html +0 -1097
  111. data/site/docs/conduct/index.html +0 -744
  112. data/site/docs/configuration/index.html +0 -1403
  113. data/site/docs/continuous-integration/buddyworks/index.html +0 -726
  114. data/site/docs/continuous-integration/circleci/index.html +0 -757
  115. data/site/docs/continuous-integration/index.html +0 -681
  116. data/site/docs/continuous-integration/travis-ci/index.html +0 -891
  117. data/site/docs/contributing/index.html +0 -863
  118. data/site/docs/datafiles/index.html +0 -780
  119. data/site/docs/deployment-methods/index.html +0 -875
  120. data/site/docs/drafts/index.html +0 -636
  121. data/site/docs/extras/index.html +0 -689
  122. data/site/docs/frontmatter/index.html +0 -807
  123. data/site/docs/github-pages/index.html +0 -819
  124. data/site/docs/history/index.html +0 -3955
  125. data/site/docs/home/index.html +0 -644
  126. data/site/docs/includes/index.html +0 -800
  127. data/site/docs/index.html +0 -10
  128. data/site/docs/installation/index.html +0 -732
  129. data/site/docs/maintaining/affinity-team-captain/index.html +0 -706
  130. data/site/docs/maintaining/avoiding-burnout/index.html +0 -709
  131. data/site/docs/maintaining/becoming-a-maintainer/index.html +0 -717
  132. data/site/docs/maintaining/index.html +0 -713
  133. data/site/docs/maintaining/merging-a-pull-request/index.html +0 -747
  134. data/site/docs/maintaining/reviewing-a-pull-request/index.html +0 -725
  135. data/site/docs/maintaining/special-labels/index.html +0 -705
  136. data/site/docs/maintaining/triaging-an-issue/index.html +0 -735
  137. data/site/docs/migrations/index.html +0 -647
  138. data/site/docs/pages/index.html +0 -695
  139. data/site/docs/pagination/index.html +0 -870
  140. data/site/docs/permalinks/index.html +0 -1027
  141. data/site/docs/plugins/index.html +0 -1800
  142. data/site/docs/posts/index.html +0 -858
  143. data/site/docs/quickstart/index.html +0 -650
  144. data/site/docs/resources/index.html +0 -769
  145. data/site/docs/sites/index.html +0 -702
  146. data/site/docs/static-files/index.html +0 -720
  147. data/site/docs/structure/index.html +0 -822
  148. data/site/docs/templates/index.html +0 -1208
  149. data/site/docs/themes/index.html +0 -935
  150. data/site/docs/troubleshooting/index.html +0 -893
  151. data/site/docs/upgrading/0-to-2/index.html +0 -826
  152. data/site/docs/upgrading/2-to-3/index.html +0 -824
  153. data/site/docs/upgrading/index.html +0 -693
  154. data/site/docs/usage/index.html +0 -705
  155. data/site/docs/variables/index.html +0 -1048
  156. data/site/docs/windows/index.html +0 -799
  157. data/site/favicon.ico +0 -0
  158. data/site/feed.xml +0 -372
  159. data/site/fonts/FontAwesome.eot +0 -0
  160. data/site/fonts/FontAwesome.svg +0 -12
  161. data/site/fonts/FontAwesome.ttf +0 -0
  162. data/site/fonts/FontAwesome.woff +0 -0
  163. data/site/github.html +0 -10
  164. data/site/help/index.html +0 -244
  165. data/site/icomoon-selection.json +0 -96
  166. data/site/img/article-footer.png +0 -0
  167. data/site/img/footer-arrow.png +0 -0
  168. data/site/img/footer-logo.png +0 -0
  169. data/site/img/jekyll-sticker.jpg +0 -0
  170. data/site/img/jekylllayoutconcept.png +0 -0
  171. data/site/img/logo-2x.png +0 -0
  172. data/site/img/logo-rss.png +0 -0
  173. data/site/img/octojekyll.png +0 -0
  174. data/site/index.html +0 -267
  175. data/site/issues.html +0 -10
  176. data/site/js/html5shiv.min.js +0 -4
  177. data/site/js/respond.min.js +0 -5
  178. data/site/latest_version.txt +0 -1
  179. data/site/news/2013/05/05/jekyll-1-0-0-released/index.html +0 -570
  180. data/site/news/2013/05/08/jekyll-1-0-1-released/index.html +0 -570
  181. data/site/news/2013/05/12/jekyll-1-0-2-released/index.html +0 -571
  182. data/site/news/2013/06/07/jekyll-1-0-3-released/index.html +0 -568
  183. data/site/news/2013/07/14/jekyll-1-1-0-released/index.html +0 -570
  184. data/site/news/2013/07/24/jekyll-1-1-1-released/index.html +0 -569
  185. data/site/news/2013/07/25/jekyll-1-0-4-released/index.html +0 -565
  186. data/site/news/2013/07/25/jekyll-1-1-2-released/index.html +0 -565
  187. data/site/news/2013/09/06/jekyll-1-2-0-released/index.html +0 -572
  188. data/site/news/2013/09/14/jekyll-1-2-1-released/index.html +0 -566
  189. data/site/news/2013/10/28/jekyll-1-3-0-rc1-released/index.html +0 -564
  190. data/site/news/2013/11/04/jekyll-1-3-0-released/index.html +0 -599
  191. data/site/news/2013/11/26/jekyll-1-3-1-released/index.html +0 -568
  192. data/site/news/2013/12/07/jekyll-1-4-0-released/index.html +0 -583
  193. data/site/news/2013/12/09/jekyll-1-4-1-released/index.html +0 -565
  194. data/site/news/2013/12/16/jekyll-1-4-2-released/index.html +0 -564
  195. data/site/news/2014/01/13/jekyll-1-4-3-released/index.html +0 -573
  196. data/site/news/2014/03/24/jekyll-1-5-0-released/index.html +0 -564
  197. data/site/news/2014/03/27/jekyll-1-5-1-released/index.html +0 -569
  198. data/site/news/2014/05/06/jekyll-turns-2-0-0/index.html +0 -585
  199. data/site/news/2014/05/08/jekyll-2-0-3-released/index.html +0 -565
  200. data/site/news/2014/06/04/jekyll-stickers-1-dollar-stickermule/index.html +0 -567
  201. data/site/news/2014/06/28/jekyll-turns-21-i-mean-2-1-0/index.html +0 -582
  202. data/site/news/2014/07/01/jekyll-2-1-1-released/index.html +0 -579
  203. data/site/news/2014/07/29/jekyll-2-2-0-released/index.html +0 -568
  204. data/site/news/2014/08/10/jekyll-2-3-0-released/index.html +0 -588
  205. data/site/news/2014/09/09/jekyll-2-4-0-released/index.html +0 -574
  206. data/site/news/2014/11/05/jekylls-midlife-crisis-jekyll-turns-2-5-0/index.html +0 -597
  207. data/site/news/2014/11/09/jekyll-2-5-1-released/index.html +0 -575
  208. data/site/news/2014/11/12/jekyll-2-5-2-released/index.html +0 -565
  209. data/site/news/2014/12/17/alfredxing-welcome-to-jekyll-core/index.html +0 -572
  210. data/site/news/2014/12/22/jekyll-2-5-3-released/index.html +0 -567
  211. data/site/news/2015/01/20/jekyll-meet-and-greet/index.html +0 -568
  212. data/site/news/2015/01/24/jekyll-3-0-0-beta1-released/index.html +0 -588
  213. data/site/news/2015/02/26/introducing-jekyll-talk/index.html +0 -563
  214. data/site/news/2015/10/26/jekyll-3-0-released/index.html +0 -592
  215. data/site/news/2015/11/17/jekyll-3-0-1-released/index.html +0 -576
  216. data/site/news/2016/01/20/jekyll-3-0-2-released/index.html +0 -566
  217. data/site/news/2016/01/24/jekyll-3-1-0-released/index.html +0 -599
  218. data/site/news/2016/01/28/jekyll-3-1-1-released/index.html +0 -583
  219. data/site/news/2016/02/08/jekyll-3-0-3-released/index.html +0 -578
  220. data/site/news/2016/02/19/jekyll-3-1-2-released/index.html +0 -569
  221. data/site/news/2016/03/10/making-it-easier-to-contribute-to-jekyll/index.html +0 -565
  222. data/site/news/2016/04/19/jekyll-3-0-4-released/index.html +0 -571
  223. data/site/news/2016/04/19/jekyll-3-1-3-released/index.html +0 -566
  224. data/site/news/2016/04/26/jekyll-3-0-5-released/index.html +0 -572
  225. data/site/news/2016/05/18/jekyll-3-1-4-released/index.html +0 -576
  226. data/site/news/2016/05/18/jekyll-3-1-5-released/index.html +0 -564
  227. data/site/news/2016/05/19/jekyll-3-1-6-released/index.html +0 -566
  228. data/site/news/2016/06/03/update-on-jekyll-s-google-summer-of-code-projects/index.html +0 -567
  229. data/site/news/2016/07/26/jekyll-3-2-0-released/index.html +0 -676
  230. data/site/news/2016/08/02/jekyll-3-2-1-released/index.html +0 -571
  231. data/site/news/2016/08/24/jekyll-admin-initial-release/index.html +0 -566
  232. data/site/news/2016/10/06/jekyll-3-3-is-here/index.html +0 -645
  233. data/site/news/2016/11/14/jekyll-3-3-1-released/index.html +0 -569
  234. data/site/news/2017/01/18/jekyll-3-4-0-released/index.html +0 -592
  235. data/site/news/2017/03/02/jekyll-3-4-1-released/index.html +0 -649
  236. data/site/news/2017/03/09/jekyll-3-4-2-released/index.html +0 -598
  237. data/site/news/2017/03/21/jekyll-3-4-3-released/index.html +0 -594
  238. data/site/news/2017/06/15/jekyll-3-5-0-released/index.html +0 -589
  239. data/site/news/2017/07/17/jekyll-3-5-1-released/index.html +0 -569
  240. data/site/news/2017/08/12/jekyll-3-5-2-released/index.html +0 -573
  241. data/site/news/2017/09/21/jekyll-3-6-0-released/index.html +0 -565
  242. data/site/news/index.html +0 -3609
  243. data/site/news/releases/index.html +0 -3344
  244. data/site/philosophy.html +0 -46
  245. data/site/readme.md +0 -23
  246. data/site/robots.txt +0 -1
  247. data/site/sitemap.xml +0 -485
  248. data/site/tutorials/convert-site-to-jekyll/index.html +0 -793
  249. data/site/tutorials/custom-404-page/index.html +0 -358
  250. data/site/tutorials/home/index.html +0 -323
  251. data/site/tutorials/index.html +0 -10
  252. data/site/tutorials/navigation/index.html +0 -872
  253. data/site/tutorials/orderofinterpretation/index.html +0 -441
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class Command
5
+ class << self
6
+ # A list of subclasses of Jekyll::Command
7
+ def subclasses
8
+ @subclasses ||= []
9
+ end
10
+
11
+ # Keep a list of subclasses of Jekyll::Command every time it's inherited
12
+ # Called automatically.
13
+ #
14
+ # base - the subclass
15
+ #
16
+ # Returns nothing
17
+ def inherited(base)
18
+ subclasses << base
19
+ super(base)
20
+ end
21
+
22
+ # Run Site#process and catch errors
23
+ #
24
+ # site - the Jekyll::Site object
25
+ #
26
+ # Returns nothing
27
+ def process_site(site)
28
+ site.process
29
+ rescue Jekyll::Errors::FatalException => e
30
+ Jekyll.logger.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:"
31
+ Jekyll.logger.error "", "------------------------------------"
32
+ Jekyll.logger.error "", e.message
33
+ exit(1)
34
+ end
35
+
36
+ # Create a full Jekyll configuration with the options passed in as overrides
37
+ #
38
+ # options - the configuration overrides
39
+ #
40
+ # Returns a full Jekyll configuration
41
+ def configuration_from_options(options)
42
+ return options if options.is_a?(Jekyll::Configuration)
43
+ Jekyll.configuration(options)
44
+ end
45
+
46
+ # Add common options to a command for building configuration
47
+ #
48
+ # c - the Jekyll::Command to add these options to
49
+ #
50
+ # Returns nothing
51
+ # rubocop:disable Metrics/MethodLength
52
+ def add_build_options(c)
53
+ c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]",
54
+ Array, "Custom configuration file"
55
+ c.option "destination", "-d", "--destination DESTINATION",
56
+ "The current folder will be generated into DESTINATION"
57
+ c.option "source", "-s", "--source SOURCE", "Custom source directory"
58
+ c.option "future", "--future", "Publishes posts with a future date"
59
+ c.option "limit_posts", "--limit_posts MAX_POSTS", Integer,
60
+ "Limits the number of posts to parse and publish"
61
+ c.option "watch", "-w", "--[no-]watch", "Watch for changes and rebuild"
62
+ c.option "baseurl", "-b", "--baseurl URL",
63
+ "Serve the website from the given base URL"
64
+ c.option "force_polling", "--force_polling", "Force watch to use polling"
65
+ c.option "lsi", "--lsi", "Use LSI for improved related posts"
66
+ c.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder"
67
+ c.option "unpublished", "--unpublished",
68
+ "Render posts that were marked as unpublished"
69
+ c.option "quiet", "-q", "--quiet", "Silence output."
70
+ c.option "verbose", "-V", "--verbose", "Print verbose output."
71
+ c.option "incremental", "-I", "--incremental", "Enable incremental rebuild."
72
+ c.option "strict_front_matter", "--strict_front_matter",
73
+ "Fail if errors are present in front matter"
74
+ end
75
+ # rubocop:enable Metrics/MethodLength
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Commands
5
+ class Build < Command
6
+ class << self
7
+ # Create the Mercenary command for the Jekyll CLI for this Command
8
+ def init_with_program(prog)
9
+ prog.command(:build) do |c|
10
+ c.syntax "build [options]"
11
+ c.description "Build your site"
12
+ c.alias :b
13
+
14
+ add_build_options(c)
15
+
16
+ c.action do |_, options|
17
+ options["serving"] = false
18
+ Jekyll::Commands::Build.process(options)
19
+ end
20
+ end
21
+ end
22
+
23
+ # Build your jekyll site
24
+ # Continuously watch if `watch` is set to true in the config.
25
+ def process(options)
26
+ # Adjust verbosity quickly
27
+ Jekyll.logger.adjust_verbosity(options)
28
+
29
+ options = configuration_from_options(options)
30
+ site = Jekyll::Site.new(options)
31
+
32
+ if options.fetch("skip_initial_build", false)
33
+ Jekyll.logger.warn "Build Warning:", "Skipping the initial build." \
34
+ " This may result in an out-of-date site."
35
+ else
36
+ build(site, options)
37
+ end
38
+
39
+ if options.fetch("detach", false)
40
+ Jekyll.logger.info "Auto-regeneration:",
41
+ "disabled when running server detached."
42
+ elsif options.fetch("watch", false)
43
+ watch(site, options)
44
+ else
45
+ Jekyll.logger.info "Auto-regeneration:", "disabled. Use --watch to enable."
46
+ end
47
+ end
48
+
49
+ # Build your Jekyll site.
50
+ #
51
+ # site - the Jekyll::Site instance to build
52
+ # options - A Hash of options passed to the command
53
+ #
54
+ # Returns nothing.
55
+ def build(site, options)
56
+ t = Time.now
57
+ source = options["source"]
58
+ destination = options["destination"]
59
+ incremental = options["incremental"]
60
+ Jekyll.logger.info "Source:", source
61
+ Jekyll.logger.info "Destination:", destination
62
+ Jekyll.logger.info "Incremental build:",
63
+ (incremental ? "enabled" : "disabled. Enable with --incremental")
64
+ Jekyll.logger.info "Generating..."
65
+ process_site(site)
66
+ Jekyll.logger.info "", "done in #{(Time.now - t).round(3)} seconds."
67
+ end
68
+
69
+ # Private: Watch for file changes and rebuild the site.
70
+ #
71
+ # site - A Jekyll::Site instance
72
+ # options - A Hash of options passed to the command
73
+ #
74
+ # Returns nothing.
75
+ def watch(site, options)
76
+ # Warn Windows users that they might need to upgrade.
77
+ if Utils::Platforms.bash_on_windows?
78
+ Jekyll.logger.warn "",
79
+ "Auto-regeneration may not work on some Windows versions."
80
+ Jekyll.logger.warn "",
81
+ "Please see: https://github.com/Microsoft/BashOnWindows/issues/216"
82
+ Jekyll.logger.warn "",
83
+ "If it does not work, please upgrade Bash on Windows or "\
84
+ "run Jekyll with --no-watch."
85
+ end
86
+
87
+ External.require_with_graceful_fail "jekyll-watch"
88
+ watch_method = Jekyll::Watcher.method(:watch)
89
+ if watch_method.parameters.size == 1
90
+ watch_method.call(
91
+ options
92
+ )
93
+ else
94
+ watch_method.call(
95
+ options, site
96
+ )
97
+ end
98
+ end
99
+ end # end of class << self
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Commands
5
+ class Clean < Command
6
+ class << self
7
+ def init_with_program(prog)
8
+ prog.command(:clean) do |c|
9
+ c.syntax "clean [subcommand]"
10
+ c.description "Clean the site " \
11
+ "(removes site output and metadata file) without building."
12
+
13
+ add_build_options(c)
14
+
15
+ c.action do |_, options|
16
+ Jekyll::Commands::Clean.process(options)
17
+ end
18
+ end
19
+ end
20
+
21
+ def process(options)
22
+ options = configuration_from_options(options)
23
+ destination = options["destination"]
24
+ metadata_file = File.join(options["source"], ".jekyll-metadata")
25
+ sass_cache = File.join(options["source"], ".sass-cache")
26
+
27
+ remove(destination, :checker_func => :directory?)
28
+ remove(metadata_file, :checker_func => :file?)
29
+ remove(sass_cache, :checker_func => :directory?)
30
+ end
31
+
32
+ def remove(filename, checker_func: :file?)
33
+ if File.public_send(checker_func, filename)
34
+ Jekyll.logger.info "Cleaner:", "Removing #{filename}..."
35
+ FileUtils.rm_rf(filename)
36
+ else
37
+ Jekyll.logger.info "Cleaner:", "Nothing to do for #{filename}."
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,153 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "addressable/uri"
4
+
5
+ module Jekyll
6
+ module Commands
7
+ class Doctor < Command
8
+ class << self
9
+ def init_with_program(prog)
10
+ prog.command(:doctor) do |c|
11
+ c.syntax "doctor"
12
+ c.description "Search site and print specific deprecation warnings"
13
+ c.alias(:hyde)
14
+
15
+ c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array,
16
+ "Custom configuration file"
17
+
18
+ c.action do |_, options|
19
+ Jekyll::Commands::Doctor.process(options)
20
+ end
21
+ end
22
+ end
23
+
24
+ def process(options)
25
+ site = Jekyll::Site.new(configuration_from_options(options))
26
+ site.reset
27
+ site.read
28
+ site.generate
29
+
30
+ if healthy?(site)
31
+ Jekyll.logger.info "Your test results", "are in. Everything looks fine."
32
+ else
33
+ abort
34
+ end
35
+ end
36
+
37
+ def healthy?(site)
38
+ [
39
+ fsnotify_buggy?(site),
40
+ !deprecated_relative_permalinks(site),
41
+ !conflicting_urls(site),
42
+ !urls_only_differ_by_case(site),
43
+ proper_site_url?(site),
44
+ ].all?
45
+ end
46
+
47
+ def deprecated_relative_permalinks(site)
48
+ if site.config["relative_permalinks"]
49
+ Jekyll::Deprecator.deprecation_message "Your site still uses relative" \
50
+ " permalinks, which was removed in" \
51
+ " Jekyll v3.0.0."
52
+ return true
53
+ end
54
+ end
55
+
56
+ def conflicting_urls(site)
57
+ conflicting_urls = false
58
+ urls = {}
59
+ urls = collect_urls(urls, site.pages, site.dest)
60
+ urls = collect_urls(urls, site.posts.docs, site.dest)
61
+ urls.each do |url, paths|
62
+ next unless paths.size > 1
63
+ conflicting_urls = true
64
+ Jekyll.logger.warn "Conflict:", "The URL '#{url}' is the destination" \
65
+ " for the following pages: #{paths.join(", ")}"
66
+ end
67
+ conflicting_urls
68
+ end
69
+
70
+ def fsnotify_buggy?(_site)
71
+ return true unless Utils::Platforms.osx?
72
+ if Dir.pwd != `pwd`.strip
73
+ Jekyll.logger.error " " + <<-STR.strip.gsub(%r!\n\s+!, "\n ")
74
+ We have detected that there might be trouble using fsevent on your
75
+ operating system, you can read https://github.com/thibaudgg/rb-fsevent/wiki/no-fsevents-fired-(OSX-bug)
76
+ for possible work arounds or you can work around it immediately
77
+ with `--force-polling`.
78
+ STR
79
+
80
+ false
81
+ end
82
+
83
+ true
84
+ end
85
+
86
+ def urls_only_differ_by_case(site)
87
+ urls_only_differ_by_case = false
88
+ urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest)
89
+ urls.each_value do |real_urls|
90
+ next unless real_urls.uniq.size > 1
91
+ urls_only_differ_by_case = true
92
+ Jekyll.logger.warn "Warning:", "The following URLs only differ" \
93
+ " by case. On a case-insensitive file system one of the URLs" \
94
+ " will be overwritten by the other: #{real_urls.join(", ")}"
95
+ end
96
+ urls_only_differ_by_case
97
+ end
98
+
99
+ def proper_site_url?(site)
100
+ url = site.config["url"]
101
+ [
102
+ url_exists?(url),
103
+ url_valid?(url),
104
+ url_absolute(url),
105
+ ].all?
106
+ end
107
+
108
+ private
109
+ def collect_urls(urls, things, destination)
110
+ things.each do |thing|
111
+ dest = thing.destination(destination)
112
+ if urls[dest]
113
+ urls[dest] << thing.path
114
+ else
115
+ urls[dest] = [thing.path]
116
+ end
117
+ end
118
+ urls
119
+ end
120
+
121
+ def case_insensitive_urls(things, destination)
122
+ things.each_with_object({}) do |thing, memo|
123
+ dest = thing.destination(destination)
124
+ (memo[dest.downcase] ||= []) << dest
125
+ end
126
+ end
127
+
128
+ def url_exists?(url)
129
+ return true unless url.nil? || url.empty?
130
+ Jekyll.logger.warn "Warning:", "You didn't set an URL in the config file, "\
131
+ "you may encounter problems with some plugins."
132
+ false
133
+ end
134
+
135
+ def url_valid?(url)
136
+ Addressable::URI.parse(url)
137
+ true
138
+ rescue
139
+ Jekyll.logger.warn "Warning:", "The site URL does not seem to be valid, "\
140
+ "check the value of `url` in your config file."
141
+ false
142
+ end
143
+
144
+ def url_absolute(url)
145
+ return true if Addressable::URI.parse(url).absolute?
146
+ Jekyll.logger.warn "Warning:", "Your site URL does not seem to be absolute, "\
147
+ "check the value of `url` in your config file."
148
+ false
149
+ end
150
+ end
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Commands
5
+ class Help < Command
6
+ class << self
7
+ def init_with_program(prog)
8
+ prog.command(:help) do |c|
9
+ c.syntax "help [subcommand]"
10
+ c.description "Show the help message, optionally for a given subcommand."
11
+
12
+ c.action do |args, _|
13
+ cmd = (args.first || "").to_sym
14
+ if args.empty?
15
+ puts prog
16
+ elsif prog.has_command? cmd
17
+ puts prog.commands[cmd]
18
+ else
19
+ invalid_command(prog, cmd)
20
+ abort
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ def invalid_command(prog, cmd)
27
+ Jekyll.logger.error "Error:",
28
+ "Hmm... we don't know what the '#{cmd}' command is."
29
+ Jekyll.logger.info "Valid commands:", prog.commands.keys.join(", ")
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,156 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "erb"
4
+
5
+ module Jekyll
6
+ module Commands
7
+ class New < Command
8
+ class << self
9
+ def init_with_program(prog)
10
+ prog.command(:new) do |c|
11
+ c.syntax "new PATH"
12
+ c.description "Creates a new Jekyll site scaffold in PATH"
13
+
14
+ c.option "force", "--force", "Force creation even if PATH already exists"
15
+ c.option "blank", "--blank", "Creates scaffolding but with empty files"
16
+ c.option "skip-bundle", "--skip-bundle", "Skip 'bundle install'"
17
+
18
+ c.action do |args, options|
19
+ Jekyll::Commands::New.process(args, options)
20
+ end
21
+ end
22
+ end
23
+
24
+ def process(args, options = {})
25
+ raise ArgumentError, "You must specify a path." if args.empty?
26
+
27
+ new_blog_path = File.expand_path(args.join(" "), Dir.pwd)
28
+ FileUtils.mkdir_p new_blog_path
29
+ if preserve_source_location?(new_blog_path, options)
30
+ Jekyll.logger.abort_with "Conflict:",
31
+ "#{new_blog_path} exists and is not empty."
32
+ end
33
+
34
+ if options["blank"]
35
+ create_blank_site new_blog_path
36
+ else
37
+ create_site new_blog_path
38
+ end
39
+
40
+ after_install(new_blog_path, options)
41
+ end
42
+
43
+ def create_blank_site(path)
44
+ Dir.chdir(path) do
45
+ FileUtils.mkdir(%w(_layouts _posts _drafts))
46
+ FileUtils.touch("index.html")
47
+ end
48
+ end
49
+
50
+ def scaffold_post_content
51
+ ERB.new(File.read(File.expand_path(scaffold_path, site_template))).result
52
+ end
53
+
54
+ # Internal: Gets the filename of the sample post to be created
55
+ #
56
+ # Returns the filename of the sample post, as a String
57
+ def initialized_post_name
58
+ "_posts/#{Time.now.strftime("%Y-%m-%d")}-welcome-to-jekyll.markdown"
59
+ end
60
+
61
+ private
62
+
63
+ def gemfile_contents
64
+ <<-RUBY
65
+ source "https://rubygems.org"
66
+
67
+ # Hello! This is where you manage which Jekyll version is used to run.
68
+ # When you want to use a different version, change it below, save the
69
+ # file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
70
+ #
71
+ # bundle exec jekyll serve
72
+ #
73
+ # This will help ensure the proper Jekyll version is running.
74
+ # Happy Jekylling!
75
+ gem "jekyll", "~> #{Jekyll::VERSION}"
76
+
77
+ # This is the default theme for new Jekyll sites. You may change this to anything you like.
78
+ gem "minima", "~> 2.0"
79
+
80
+ # If you want to use GitHub Pages, remove the "gem "jekyll"" above and
81
+ # uncomment the line below. To upgrade, run `bundle update github-pages`.
82
+ # gem "github-pages", group: :jekyll_plugins
83
+
84
+ # If you have any plugins, put them here!
85
+ group :jekyll_plugins do
86
+ gem "jekyll-feed", "~> 0.6"
87
+ end
88
+
89
+ # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
90
+ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
91
+
92
+ RUBY
93
+ end
94
+
95
+ def create_site(new_blog_path)
96
+ create_sample_files new_blog_path
97
+
98
+ File.open(File.expand_path(initialized_post_name, new_blog_path), "w") do |f|
99
+ f.write(scaffold_post_content)
100
+ end
101
+
102
+ File.open(File.expand_path("Gemfile", new_blog_path), "w") do |f|
103
+ f.write(gemfile_contents)
104
+ end
105
+ end
106
+
107
+ def preserve_source_location?(path, options)
108
+ !options["force"] && !Dir["#{path}/**/*"].empty?
109
+ end
110
+
111
+ def create_sample_files(path)
112
+ FileUtils.cp_r site_template + "/.", path
113
+ FileUtils.chmod_R "u+w", path
114
+ FileUtils.rm File.expand_path(scaffold_path, path)
115
+ end
116
+
117
+ def site_template
118
+ File.expand_path("../../site_template", __dir__)
119
+ end
120
+
121
+ def scaffold_path
122
+ "_posts/0000-00-00-welcome-to-jekyll.markdown.erb"
123
+ end
124
+
125
+ # After a new blog has been created, print a success notification and
126
+ # then automatically execute bundle install from within the new blog dir
127
+ # unless the user opts to generate a blank blog or skip 'bundle install'.
128
+
129
+ def after_install(path, options = {})
130
+ unless options["blank"] || options["skip-bundle"]
131
+ begin
132
+ require "bundler"
133
+ bundle_install path
134
+ rescue LoadError
135
+ Jekyll.logger.info "Could not load Bundler. Bundle install skipped."
136
+ end
137
+ end
138
+
139
+ Jekyll.logger.info "New jekyll site installed in #{path.cyan}."
140
+ Jekyll.logger.info "Bundle install skipped." if options["skip-bundle"]
141
+ end
142
+
143
+ def bundle_install(path)
144
+ Jekyll.logger.info "Running bundle install in #{path.cyan}..."
145
+ Dir.chdir(path) do
146
+ process, output = Jekyll::Utils::Exec.run("bundle", "install")
147
+ output.to_s.each_line do |line|
148
+ Jekyll.logger.info("Bundler:".green, line.strip) unless line.to_s.empty?
149
+ end
150
+ raise SystemExit unless process.success?
151
+ end
152
+ end
153
+ end
154
+ end
155
+ end
156
+ end