ngage 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/exe/ngage +55 -0
  4. data/lib/ngage.rb +3 -0
  5. data/lib/ngage/jekyll.rb +204 -0
  6. data/lib/ngage/jekyll/cleaner.rb +111 -0
  7. data/lib/ngage/jekyll/collection.rb +235 -0
  8. data/lib/ngage/jekyll/command.rb +103 -0
  9. data/lib/ngage/jekyll/commands/build.rb +93 -0
  10. data/lib/ngage/jekyll/commands/clean.rb +45 -0
  11. data/lib/ngage/jekyll/commands/doctor.rb +173 -0
  12. data/lib/ngage/jekyll/commands/help.rb +34 -0
  13. data/lib/ngage/jekyll/commands/new.rb +157 -0
  14. data/lib/ngage/jekyll/commands/new_theme.rb +42 -0
  15. data/lib/ngage/jekyll/commands/serve.rb +354 -0
  16. data/lib/ngage/jekyll/commands/serve/live_reload_reactor.rb +122 -0
  17. data/lib/ngage/jekyll/commands/serve/livereload_assets/livereload.js +1183 -0
  18. data/lib/ngage/jekyll/commands/serve/servlet.rb +203 -0
  19. data/lib/ngage/jekyll/commands/serve/websockets.rb +81 -0
  20. data/lib/ngage/jekyll/configuration.rb +391 -0
  21. data/lib/ngage/jekyll/converter.rb +54 -0
  22. data/lib/ngage/jekyll/converters/identity.rb +41 -0
  23. data/lib/ngage/jekyll/converters/markdown.rb +116 -0
  24. data/lib/ngage/jekyll/converters/markdown/kramdown_parser.rb +122 -0
  25. data/lib/ngage/jekyll/converters/smartypants.rb +70 -0
  26. data/lib/ngage/jekyll/convertible.rb +253 -0
  27. data/lib/ngage/jekyll/deprecator.rb +50 -0
  28. data/lib/ngage/jekyll/document.rb +503 -0
  29. data/lib/ngage/jekyll/drops/collection_drop.rb +20 -0
  30. data/lib/ngage/jekyll/drops/document_drop.rb +69 -0
  31. data/lib/ngage/jekyll/drops/drop.rb +209 -0
  32. data/lib/ngage/jekyll/drops/excerpt_drop.rb +15 -0
  33. data/lib/ngage/jekyll/drops/jekyll_drop.rb +32 -0
  34. data/lib/ngage/jekyll/drops/site_drop.rb +56 -0
  35. data/lib/ngage/jekyll/drops/static_file_drop.rb +14 -0
  36. data/lib/ngage/jekyll/drops/unified_payload_drop.rb +26 -0
  37. data/lib/ngage/jekyll/drops/url_drop.rb +89 -0
  38. data/lib/ngage/jekyll/entry_filter.rb +127 -0
  39. data/lib/ngage/jekyll/errors.rb +20 -0
  40. data/lib/ngage/jekyll/excerpt.rb +180 -0
  41. data/lib/ngage/jekyll/external.rb +76 -0
  42. data/lib/ngage/jekyll/filters.rb +390 -0
  43. data/lib/ngage/jekyll/filters/date_filters.rb +110 -0
  44. data/lib/ngage/jekyll/filters/grouping_filters.rb +64 -0
  45. data/lib/ngage/jekyll/filters/url_filters.rb +68 -0
  46. data/lib/ngage/jekyll/frontmatter_defaults.rb +233 -0
  47. data/lib/ngage/jekyll/generator.rb +5 -0
  48. data/lib/ngage/jekyll/hooks.rb +106 -0
  49. data/lib/ngage/jekyll/layout.rb +62 -0
  50. data/lib/ngage/jekyll/liquid_extensions.rb +22 -0
  51. data/lib/ngage/jekyll/liquid_renderer.rb +63 -0
  52. data/lib/ngage/jekyll/liquid_renderer/file.rb +56 -0
  53. data/lib/ngage/jekyll/liquid_renderer/table.rb +98 -0
  54. data/lib/ngage/jekyll/log_adapter.rb +151 -0
  55. data/lib/ngage/jekyll/mime.types +825 -0
  56. data/lib/ngage/jekyll/page.rb +185 -0
  57. data/lib/ngage/jekyll/page_without_a_file.rb +14 -0
  58. data/lib/ngage/jekyll/plugin.rb +92 -0
  59. data/lib/ngage/jekyll/plugin_manager.rb +115 -0
  60. data/lib/ngage/jekyll/publisher.rb +23 -0
  61. data/lib/ngage/jekyll/reader.rb +154 -0
  62. data/lib/ngage/jekyll/readers/collection_reader.rb +22 -0
  63. data/lib/ngage/jekyll/readers/data_reader.rb +75 -0
  64. data/lib/ngage/jekyll/readers/layout_reader.rb +70 -0
  65. data/lib/ngage/jekyll/readers/page_reader.rb +25 -0
  66. data/lib/ngage/jekyll/readers/post_reader.rb +72 -0
  67. data/lib/ngage/jekyll/readers/static_file_reader.rb +25 -0
  68. data/lib/ngage/jekyll/readers/theme_assets_reader.rb +51 -0
  69. data/lib/ngage/jekyll/regenerator.rb +195 -0
  70. data/lib/ngage/jekyll/related_posts.rb +52 -0
  71. data/lib/ngage/jekyll/renderer.rb +266 -0
  72. data/lib/ngage/jekyll/site.rb +476 -0
  73. data/lib/ngage/jekyll/static_file.rb +169 -0
  74. data/lib/ngage/jekyll/stevenson.rb +60 -0
  75. data/lib/ngage/jekyll/tags/highlight.rb +108 -0
  76. data/lib/ngage/jekyll/tags/include.rb +226 -0
  77. data/lib/ngage/jekyll/tags/link.rb +40 -0
  78. data/lib/ngage/jekyll/tags/post_url.rb +104 -0
  79. data/lib/ngage/jekyll/theme.rb +73 -0
  80. data/lib/ngage/jekyll/theme_builder.rb +121 -0
  81. data/lib/ngage/jekyll/url.rb +160 -0
  82. data/lib/ngage/jekyll/utils.rb +370 -0
  83. data/lib/ngage/jekyll/utils/ansi.rb +57 -0
  84. data/lib/ngage/jekyll/utils/exec.rb +26 -0
  85. data/lib/ngage/jekyll/utils/internet.rb +37 -0
  86. data/lib/ngage/jekyll/utils/platforms.rb +82 -0
  87. data/lib/ngage/jekyll/utils/thread_event.rb +31 -0
  88. data/lib/ngage/jekyll/utils/win_tz.rb +75 -0
  89. data/lib/ngage/site_template/.gitignore +5 -0
  90. data/lib/ngage/site_template/404.html +25 -0
  91. data/lib/ngage/site_template/_config.yml +47 -0
  92. data/lib/ngage/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +29 -0
  93. data/lib/ngage/site_template/about.markdown +18 -0
  94. data/lib/ngage/site_template/index.markdown +6 -0
  95. data/lib/ngage/theme_template/CODE_OF_CONDUCT.md.erb +74 -0
  96. data/lib/ngage/theme_template/Gemfile +4 -0
  97. data/lib/ngage/theme_template/LICENSE.txt.erb +21 -0
  98. data/lib/ngage/theme_template/README.md.erb +52 -0
  99. data/lib/ngage/theme_template/_layouts/default.html +1 -0
  100. data/lib/ngage/theme_template/_layouts/page.html +5 -0
  101. data/lib/ngage/theme_template/_layouts/post.html +5 -0
  102. data/lib/ngage/theme_template/example/_config.yml.erb +1 -0
  103. data/lib/ngage/theme_template/example/_post.md +12 -0
  104. data/lib/ngage/theme_template/example/index.html +14 -0
  105. data/lib/ngage/theme_template/example/style.scss +7 -0
  106. data/lib/ngage/theme_template/gitignore.erb +6 -0
  107. data/lib/ngage/theme_template/theme.gemspec.erb +19 -0
  108. data/lib/ngage/version.rb +5 -0
  109. metadata +328 -0
@@ -0,0 +1,103 @@
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
+
44
+ Jekyll.configuration(options)
45
+ end
46
+
47
+ # Add common options to a command for building configuration
48
+ #
49
+ # cmd - the Jekyll::Command to add these options to
50
+ #
51
+ # Returns nothing
52
+ # rubocop:disable Metrics/MethodLength
53
+ def add_build_options(cmd)
54
+ cmd.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]",
55
+ Array, "Custom configuration file"
56
+ cmd.option "destination", "-d", "--destination DESTINATION",
57
+ "The current folder will be generated into DESTINATION"
58
+ cmd.option "source", "-s", "--source SOURCE", "Custom source directory"
59
+ cmd.option "future", "--future", "Publishes posts with a future date"
60
+ cmd.option "limit_posts", "--limit_posts MAX_POSTS", Integer,
61
+ "Limits the number of posts to parse and publish"
62
+ cmd.option "watch", "-w", "--[no-]watch", "Watch for changes and rebuild"
63
+ cmd.option "baseurl", "-b", "--baseurl URL",
64
+ "Serve the website from the given base URL"
65
+ cmd.option "force_polling", "--force_polling", "Force watch to use polling"
66
+ cmd.option "lsi", "--lsi", "Use LSI for improved related posts"
67
+ cmd.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder"
68
+ cmd.option "unpublished", "--unpublished",
69
+ "Render posts that were marked as unpublished"
70
+ cmd.option "quiet", "-q", "--quiet", "Silence output."
71
+ cmd.option "verbose", "-V", "--verbose", "Print verbose output."
72
+ cmd.option "incremental", "-I", "--incremental", "Enable incremental rebuild."
73
+ cmd.option "strict_front_matter", "--strict_front_matter",
74
+ "Fail if errors are present in front matter"
75
+ end
76
+ # rubocop:enable Metrics/MethodLength
77
+
78
+ # Run ::process method in a given set of Jekyll::Command subclasses and suggest
79
+ # re-running the associated command with --trace switch to obtain any additional
80
+ # information or backtrace regarding the encountered Exception.
81
+ #
82
+ # cmd - the Jekyll::Command to be handled
83
+ # options - configuration overrides
84
+ # klass - an array of Jekyll::Command subclasses associated with the command
85
+ #
86
+ # Note that all exceptions are rescued..
87
+ # rubocop: disable RescueException
88
+ def process_with_graceful_fail(cmd, options, *klass)
89
+ klass.each { |k| k.process(options) if k.respond_to?(:process) }
90
+ rescue Exception => e
91
+ raise e if cmd.trace
92
+
93
+ msg = " Please append `--trace` to the `#{cmd.name}` command "
94
+ dashes = "-" * msg.length
95
+ Jekyll.logger.error "", dashes
96
+ Jekyll.logger.error "Jekyll #{Jekyll::VERSION} ", msg
97
+ Jekyll.logger.error "", " for any additional information or backtrace. "
98
+ Jekyll.logger.abort_with "", dashes
99
+ end
100
+ # rubocop: enable RescueException
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,93 @@
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
+ process_with_graceful_fail(c, options, self)
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
+ Jekyll::Watcher.watch(options, site)
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,45 @@
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
+ cache_dir = File.join(options["source"], options["cache_dir"])
26
+ sass_cache = ".sass-cache"
27
+
28
+ remove(destination, :checker_func => :directory?)
29
+ remove(metadata_file, :checker_func => :file?)
30
+ remove(cache_dir, :checker_func => :directory?)
31
+ remove(sass_cache, :checker_func => :directory?)
32
+ end
33
+
34
+ def remove(filename, checker_func: :file?)
35
+ if File.public_send(checker_func, filename)
36
+ Jekyll.logger.info "Cleaner:", "Removing #{filename}..."
37
+ FileUtils.rm_rf(filename)
38
+ else
39
+ Jekyll.logger.info "Cleaner:", "Nothing to do for #{filename}."
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,173 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Commands
5
+ class Doctor < Command
6
+ class << self
7
+ def init_with_program(prog)
8
+ prog.command(:doctor) do |c|
9
+ c.syntax "doctor"
10
+ c.description "Search site and print specific deprecation warnings"
11
+ c.alias(:hyde)
12
+
13
+ c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array,
14
+ "Custom configuration file"
15
+
16
+ c.action do |_, options|
17
+ Jekyll::Commands::Doctor.process(options)
18
+ end
19
+ end
20
+ end
21
+
22
+ def process(options)
23
+ site = Jekyll::Site.new(configuration_from_options(options))
24
+ site.reset
25
+ site.read
26
+ site.generate
27
+
28
+ if healthy?(site)
29
+ Jekyll.logger.info "Your test results", "are in. Everything looks fine."
30
+ else
31
+ abort
32
+ end
33
+ end
34
+
35
+ def healthy?(site)
36
+ [
37
+ fsnotify_buggy?(site),
38
+ !deprecated_relative_permalinks(site),
39
+ !conflicting_urls(site),
40
+ !urls_only_differ_by_case(site),
41
+ proper_site_url?(site),
42
+ properly_gathered_posts?(site),
43
+ ].all?
44
+ end
45
+
46
+ def properly_gathered_posts?(site)
47
+ return true if site.config["collections_dir"].empty?
48
+
49
+ posts_at_root = site.in_source_dir("_posts")
50
+ return true unless File.directory?(posts_at_root)
51
+
52
+ Jekyll.logger.warn "Warning:",
53
+ "Detected '_posts' directory outside custom `collections_dir`!"
54
+ Jekyll.logger.warn "",
55
+ "Please move '#{posts_at_root}' into the custom directory at " \
56
+ "'#{site.in_source_dir(site.config["collections_dir"])}'"
57
+ false
58
+ end
59
+
60
+ def deprecated_relative_permalinks(site)
61
+ if site.config["relative_permalinks"]
62
+ Jekyll::Deprecator.deprecation_message "Your site still uses relative permalinks," \
63
+ " which was removed in Jekyll v3.0.0."
64
+ true
65
+ end
66
+ end
67
+
68
+ def conflicting_urls(site)
69
+ conflicting_urls = false
70
+ urls = {}
71
+ urls = collect_urls(urls, site.pages, site.dest)
72
+ urls = collect_urls(urls, site.posts.docs, site.dest)
73
+ urls.each do |url, paths|
74
+ next unless paths.size > 1
75
+
76
+ conflicting_urls = true
77
+ Jekyll.logger.warn "Conflict:", "The URL '#{url}' is the destination" \
78
+ " for the following pages: #{paths.join(", ")}"
79
+ end
80
+ conflicting_urls
81
+ end
82
+
83
+ def fsnotify_buggy?(_site)
84
+ return true unless Utils::Platforms.osx?
85
+
86
+ if Dir.pwd != `pwd`.strip
87
+ Jekyll.logger.error " " + <<-STR.strip.gsub(%r!\n\s+!, "\n ")
88
+ We have detected that there might be trouble using fsevent on your
89
+ operating system, you can read https://github.com/thibaudgg/rb-fsevent/wiki/no-fsevents-fired-(OSX-bug)
90
+ for possible work arounds or you can work around it immediately
91
+ with `--force-polling`.
92
+ STR
93
+
94
+ false
95
+ end
96
+
97
+ true
98
+ end
99
+
100
+ def urls_only_differ_by_case(site)
101
+ urls_only_differ_by_case = false
102
+ urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest)
103
+ urls.each_value do |real_urls|
104
+ next unless real_urls.uniq.size > 1
105
+
106
+ urls_only_differ_by_case = true
107
+ Jekyll.logger.warn "Warning:", "The following URLs only differ" \
108
+ " by case. On a case-insensitive file system one of the URLs" \
109
+ " will be overwritten by the other: #{real_urls.join(", ")}"
110
+ end
111
+ urls_only_differ_by_case
112
+ end
113
+
114
+ def proper_site_url?(site)
115
+ url = site.config["url"]
116
+ [
117
+ url_exists?(url),
118
+ url_valid?(url),
119
+ url_absolute(url),
120
+ ].all?
121
+ end
122
+
123
+ private
124
+
125
+ def collect_urls(urls, things, destination)
126
+ things.each do |thing|
127
+ dest = thing.destination(destination)
128
+ if urls[dest]
129
+ urls[dest] << thing.path
130
+ else
131
+ urls[dest] = [thing.path]
132
+ end
133
+ end
134
+ urls
135
+ end
136
+
137
+ def case_insensitive_urls(things, destination)
138
+ things.each_with_object({}) do |thing, memo|
139
+ dest = thing.destination(destination)
140
+ (memo[dest.downcase] ||= []) << dest
141
+ end
142
+ end
143
+
144
+ def url_exists?(url)
145
+ return true unless url.nil? || url.empty?
146
+
147
+ Jekyll.logger.warn "Warning:", "You didn't set an URL in the config file, "\
148
+ "you may encounter problems with some plugins."
149
+ false
150
+ end
151
+
152
+ def url_valid?(url)
153
+ Addressable::URI.parse(url)
154
+ true
155
+ # Addressable::URI#parse only raises a TypeError
156
+ # https://git.io/vFfbx
157
+ rescue TypeError
158
+ Jekyll.logger.warn "Warning:", "The site URL does not seem to be valid, "\
159
+ "check the value of `url` in your config file."
160
+ false
161
+ end
162
+
163
+ def url_absolute(url)
164
+ return true if Addressable::URI.parse(url).absolute?
165
+
166
+ Jekyll.logger.warn "Warning:", "Your site URL does not seem to be absolute, "\
167
+ "check the value of `url` in your config file."
168
+ false
169
+ end
170
+ end
171
+ end
172
+ end
173
+ 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
+ Jekyll.logger.info prog.to_s
16
+ elsif prog.has_command? cmd
17
+ Jekyll.logger.info prog.commands[cmd].to_s
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