jekyllplusadmin 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +80 -0
  3. data/LICENSE +21 -0
  4. data/README.markdown +60 -0
  5. data/bin/jekyll +51 -0
  6. data/lib/jekyll.rb +180 -0
  7. data/lib/jekyll/cleaner.rb +105 -0
  8. data/lib/jekyll/collection.rb +205 -0
  9. data/lib/jekyll/command.rb +65 -0
  10. data/lib/jekyll/commands/build.rb +77 -0
  11. data/lib/jekyll/commands/clean.rb +42 -0
  12. data/lib/jekyll/commands/doctor.rb +114 -0
  13. data/lib/jekyll/commands/help.rb +31 -0
  14. data/lib/jekyll/commands/new.rb +82 -0
  15. data/lib/jekyll/commands/serve.rb +235 -0
  16. data/lib/jekyll/commands/serve/servlet.rb +61 -0
  17. data/lib/jekyll/configuration.rb +323 -0
  18. data/lib/jekyll/converter.rb +48 -0
  19. data/lib/jekyll/converters/identity.rb +21 -0
  20. data/lib/jekyll/converters/markdown.rb +92 -0
  21. data/lib/jekyll/converters/markdown/kramdown_parser.rb +117 -0
  22. data/lib/jekyll/converters/markdown/rdiscount_parser.rb +33 -0
  23. data/lib/jekyll/converters/markdown/redcarpet_parser.rb +102 -0
  24. data/lib/jekyll/converters/smartypants.rb +34 -0
  25. data/lib/jekyll/convertible.rb +297 -0
  26. data/lib/jekyll/deprecator.rb +46 -0
  27. data/lib/jekyll/document.rb +444 -0
  28. data/lib/jekyll/drops/collection_drop.rb +22 -0
  29. data/lib/jekyll/drops/document_drop.rb +27 -0
  30. data/lib/jekyll/drops/drop.rb +176 -0
  31. data/lib/jekyll/drops/jekyll_drop.rb +21 -0
  32. data/lib/jekyll/drops/site_drop.rb +38 -0
  33. data/lib/jekyll/drops/unified_payload_drop.rb +25 -0
  34. data/lib/jekyll/drops/url_drop.rb +83 -0
  35. data/lib/jekyll/entry_filter.rb +72 -0
  36. data/lib/jekyll/errors.rb +10 -0
  37. data/lib/jekyll/excerpt.rb +127 -0
  38. data/lib/jekyll/external.rb +59 -0
  39. data/lib/jekyll/filters.rb +367 -0
  40. data/lib/jekyll/frontmatter_defaults.rb +188 -0
  41. data/lib/jekyll/generator.rb +3 -0
  42. data/lib/jekyll/hooks.rb +101 -0
  43. data/lib/jekyll/layout.rb +49 -0
  44. data/lib/jekyll/liquid_extensions.rb +22 -0
  45. data/lib/jekyll/liquid_renderer.rb +39 -0
  46. data/lib/jekyll/liquid_renderer/file.rb +50 -0
  47. data/lib/jekyll/liquid_renderer/table.rb +94 -0
  48. data/lib/jekyll/log_adapter.rb +115 -0
  49. data/lib/jekyll/mime.types +800 -0
  50. data/lib/jekyll/page.rb +180 -0
  51. data/lib/jekyll/plugin.rb +96 -0
  52. data/lib/jekyll/plugin_manager.rb +95 -0
  53. data/lib/jekyll/publisher.rb +21 -0
  54. data/lib/jekyll/reader.rb +126 -0
  55. data/lib/jekyll/readers/collection_reader.rb +20 -0
  56. data/lib/jekyll/readers/data_reader.rb +69 -0
  57. data/lib/jekyll/readers/layout_reader.rb +53 -0
  58. data/lib/jekyll/readers/page_reader.rb +21 -0
  59. data/lib/jekyll/readers/post_reader.rb +62 -0
  60. data/lib/jekyll/readers/static_file_reader.rb +21 -0
  61. data/lib/jekyll/regenerator.rb +175 -0
  62. data/lib/jekyll/related_posts.rb +56 -0
  63. data/lib/jekyll/renderer.rb +191 -0
  64. data/lib/jekyll/site.rb +391 -0
  65. data/lib/jekyll/static_file.rb +141 -0
  66. data/lib/jekyll/stevenson.rb +58 -0
  67. data/lib/jekyll/tags/highlight.rb +122 -0
  68. data/lib/jekyll/tags/include.rb +190 -0
  69. data/lib/jekyll/tags/post_url.rb +88 -0
  70. data/lib/jekyll/url.rb +136 -0
  71. data/lib/jekyll/utils.rb +287 -0
  72. data/lib/jekyll/utils/ansi.rb +59 -0
  73. data/lib/jekyll/utils/platforms.rb +30 -0
  74. data/lib/jekyll/version.rb +3 -0
  75. data/lib/site_template/.gitignore +3 -0
  76. data/lib/site_template/_config.yml +21 -0
  77. data/lib/site_template/_includes/footer.html +38 -0
  78. data/lib/site_template/_includes/head.html +12 -0
  79. data/lib/site_template/_includes/header.html +27 -0
  80. data/lib/site_template/_includes/icon-github.html +1 -0
  81. data/lib/site_template/_includes/icon-github.svg +1 -0
  82. data/lib/site_template/_includes/icon-twitter.html +1 -0
  83. data/lib/site_template/_includes/icon-twitter.svg +1 -0
  84. data/lib/site_template/_layouts/default.html +20 -0
  85. data/lib/site_template/_layouts/page.html +14 -0
  86. data/lib/site_template/_layouts/post.html +15 -0
  87. data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +25 -0
  88. data/lib/site_template/_sass/_base.scss +206 -0
  89. data/lib/site_template/_sass/_layout.scss +242 -0
  90. data/lib/site_template/_sass/_syntax-highlighting.scss +71 -0
  91. data/lib/site_template/about.md +15 -0
  92. data/lib/site_template/css/main.scss +53 -0
  93. data/lib/site_template/feed.xml +30 -0
  94. data/lib/site_template/index.html +23 -0
  95. metadata +252 -0
@@ -0,0 +1,205 @@
1
+ module Jekyll
2
+ class Collection
3
+ attr_reader :site, :label, :metadata
4
+ attr_writer :docs
5
+
6
+ # Create a new Collection.
7
+ #
8
+ # site - the site to which this collection belongs.
9
+ # label - the name of the collection
10
+ #
11
+ # Returns nothing.
12
+ def initialize(site, label)
13
+ @site = site
14
+ @label = sanitize_label(label)
15
+ @metadata = extract_metadata
16
+ end
17
+
18
+ # Fetch the Documents in this collection.
19
+ # Defaults to an empty array if no documents have been read in.
20
+ #
21
+ # Returns an array of Jekyll::Document objects.
22
+ def docs
23
+ @docs ||= []
24
+ end
25
+
26
+ # Override of normal respond_to? to match method_missing's logic for
27
+ # looking in @data.
28
+ def respond_to?(method, include_private = false)
29
+ docs.respond_to?(method.to_sym, include_private) || super
30
+ end
31
+
32
+ # Override of method_missing to check in @data for the key.
33
+ def method_missing(method, *args, &blck)
34
+ if docs.respond_to?(method.to_sym)
35
+ Jekyll.logger.warn "Deprecation:", "#{label}.#{method} should be changed to #{label}.docs.#{method}."
36
+ Jekyll.logger.warn "", "Called by #{caller.first}."
37
+ docs.public_send(method.to_sym, *args, &blck)
38
+ else
39
+ super
40
+ end
41
+ end
42
+
43
+ # Fetch the static files in this collection.
44
+ # Defaults to an empty array if no static files have been read in.
45
+ #
46
+ # Returns an array of Jekyll::StaticFile objects.
47
+ def files
48
+ @files ||= []
49
+ end
50
+
51
+ # Read the allowed documents into the collection's array of docs.
52
+ #
53
+ # Returns the sorted array of docs.
54
+ def read
55
+ filtered_entries.each do |file_path|
56
+ full_path = collection_dir(file_path)
57
+ next if File.directory?(full_path)
58
+ if Utils.has_yaml_header? full_path
59
+ doc = Jekyll::Document.new(full_path, { :site => site, :collection => self })
60
+ doc.read
61
+ if site.publisher.publish?(doc) || !write?
62
+ docs << doc
63
+ else
64
+ Jekyll.logger.debug "Skipped From Publishing:", doc.relative_path
65
+ end
66
+ else
67
+ relative_dir = Jekyll.sanitized_path(relative_directory, File.dirname(file_path)).chomp("/.")
68
+ files << StaticFile.new(site, site.source, relative_dir, File.basename(full_path), self)
69
+ end
70
+ end
71
+ docs.sort!
72
+ end
73
+
74
+ # All the entries in this collection.
75
+ #
76
+ # Returns an Array of file paths to the documents in this collection
77
+ # relative to the collection's directory
78
+ def entries
79
+ return [] unless exists?
80
+ @entries ||=
81
+ Utils.safe_glob(collection_dir, ["**", "*.*"]).map do |entry|
82
+ entry["#{collection_dir}/"] = ''
83
+ entry
84
+ end
85
+ end
86
+
87
+ # Filtered version of the entries in this collection.
88
+ # See `Jekyll::EntryFilter#filter` for more information.
89
+ #
90
+ # Returns a list of filtered entry paths.
91
+ def filtered_entries
92
+ return [] unless exists?
93
+ @filtered_entries ||=
94
+ Dir.chdir(directory) do
95
+ entry_filter.filter(entries).reject do |f|
96
+ path = collection_dir(f)
97
+ File.directory?(path) || (File.symlink?(f) && site.safe)
98
+ end
99
+ end
100
+ end
101
+
102
+ # The directory for this Collection, relative to the site source.
103
+ #
104
+ # Returns a String containing the directory name where the collection
105
+ # is stored on the filesystem.
106
+ def relative_directory
107
+ @relative_directory ||= "_#{label}"
108
+ end
109
+
110
+ # The full path to the directory containing the collection.
111
+ #
112
+ # Returns a String containing th directory name where the collection
113
+ # is stored on the filesystem.
114
+ def directory
115
+ @directory ||= site.in_source_dir(relative_directory)
116
+ end
117
+
118
+ # The full path to the directory containing the collection, with
119
+ # optional subpaths.
120
+ #
121
+ # *files - (optional) any other path pieces relative to the
122
+ # directory to append to the path
123
+ #
124
+ # Returns a String containing th directory name where the collection
125
+ # is stored on the filesystem.
126
+ def collection_dir(*files)
127
+ return directory if files.empty?
128
+ site.in_source_dir(relative_directory, *files)
129
+ end
130
+
131
+ # Checks whether the directory "exists" for this collection.
132
+ # The directory must exist on the filesystem and must not be a symlink
133
+ # if in safe mode.
134
+ #
135
+ # Returns false if the directory doesn't exist or if it's a symlink
136
+ # and we're in safe mode.
137
+ def exists?
138
+ File.directory?(directory) && !(File.symlink?(directory) && site.safe)
139
+ end
140
+
141
+ # The entry filter for this collection.
142
+ # Creates an instance of Jekyll::EntryFilter.
143
+ #
144
+ # Returns the instance of Jekyll::EntryFilter for this collection.
145
+ def entry_filter
146
+ @entry_filter ||= Jekyll::EntryFilter.new(site, relative_directory)
147
+ end
148
+
149
+ # An inspect string.
150
+ #
151
+ # Returns the inspect string
152
+ def inspect
153
+ "#<Jekyll::Collection @label=#{label} docs=#{docs}>"
154
+ end
155
+
156
+ # Produce a sanitized label name
157
+ # Label names may not contain anything but alphanumeric characters,
158
+ # underscores, and hyphens.
159
+ #
160
+ # label - the possibly-unsafe label
161
+ #
162
+ # Returns a sanitized version of the label.
163
+ def sanitize_label(label)
164
+ label.gsub(/[^a-z0-9_\-\.]/i, '')
165
+ end
166
+
167
+ # Produce a representation of this Collection for use in Liquid.
168
+ # Exposes two attributes:
169
+ # - label
170
+ # - docs
171
+ #
172
+ # Returns a representation of this collection for use in Liquid.
173
+ def to_liquid
174
+ Drops::CollectionDrop.new self
175
+ end
176
+
177
+ # Whether the collection's documents ought to be written as individual
178
+ # files in the output.
179
+ #
180
+ # Returns true if the 'write' metadata is true, false otherwise.
181
+ def write?
182
+ !!metadata.fetch('output', false)
183
+ end
184
+
185
+ # The URL template to render collection's documents at.
186
+ #
187
+ # Returns the URL template to render collection's documents at.
188
+ def url_template
189
+ @url_template ||= metadata.fetch('permalink') do
190
+ Utils.add_permalink_suffix("/:collection/:path", site.permalink_style)
191
+ end
192
+ end
193
+
194
+ # Extract options for this collection from the site configuration.
195
+ #
196
+ # Returns the metadata for this collection
197
+ def extract_metadata
198
+ if site.config['collections'].is_a?(Hash)
199
+ site.config['collections'][label] || {}
200
+ else
201
+ {}
202
+ end
203
+ end
204
+ end
205
+ end
@@ -0,0 +1,65 @@
1
+ module Jekyll
2
+ class Command
3
+ class << self
4
+ # A list of subclasses of Jekyll::Command
5
+ def subclasses
6
+ @subclasses ||= []
7
+ end
8
+
9
+ # Keep a list of subclasses of Jekyll::Command every time it's inherited
10
+ # Called automatically.
11
+ #
12
+ # base - the subclass
13
+ #
14
+ # Returns nothing
15
+ def inherited(base)
16
+ subclasses << base
17
+ super(base)
18
+ end
19
+
20
+ # Run Site#process and catch errors
21
+ #
22
+ # site - the Jekyll::Site object
23
+ #
24
+ # Returns nothing
25
+ def process_site(site)
26
+ site.process
27
+ rescue Jekyll::Errors::FatalException => e
28
+ Jekyll.logger.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:"
29
+ Jekyll.logger.error "", "------------------------------------"
30
+ Jekyll.logger.error "", e.message
31
+ exit(1)
32
+ end
33
+
34
+ # Create a full Jekyll configuration with the options passed in as overrides
35
+ #
36
+ # options - the configuration overrides
37
+ #
38
+ # Returns a full Jekyll configuration
39
+ def configuration_from_options(options)
40
+ Jekyll.configuration(options)
41
+ end
42
+
43
+ # Add common options to a command for building configuration
44
+ #
45
+ # c - the Jekyll::Command to add these options to
46
+ #
47
+ # Returns nothing
48
+ def add_build_options(c)
49
+ c.option 'config', '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'
50
+ c.option 'destination', '-d', '--destination DESTINATION', 'The current folder will be generated into DESTINATION'
51
+ c.option 'source', '-s', '--source SOURCE', 'Custom source directory'
52
+ c.option 'future', '--future', 'Publishes posts with a future date'
53
+ c.option 'limit_posts', '--limit_posts MAX_POSTS', Integer, 'Limits the number of posts to parse and publish'
54
+ c.option 'watch', '-w', '--[no-]watch', 'Watch for changes and rebuild'
55
+ c.option 'force_polling', '--force_polling', 'Force watch to use polling'
56
+ c.option 'lsi', '--lsi', 'Use LSI for improved related posts'
57
+ c.option 'show_drafts', '-D', '--drafts', 'Render posts in the _drafts folder'
58
+ c.option 'unpublished', '--unpublished', 'Render posts that were marked as unpublished'
59
+ c.option 'quiet', '-q', '--quiet', 'Silence output.'
60
+ c.option 'verbose', '-V', '--verbose', 'Print verbose output.'
61
+ c.option 'incremental', '-I', '--incremental', 'Enable incremental rebuild.'
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,77 @@
1
+ module Jekyll
2
+ module Commands
3
+ class Build < Command
4
+ class << self
5
+ # Create the Mercenary command for the Jekyll CLI for this Command
6
+ def init_with_program(prog)
7
+ prog.command(:build) do |c|
8
+ c.syntax 'build [options]'
9
+ c.description 'Build your site'
10
+ c.alias :b
11
+
12
+ add_build_options(c)
13
+
14
+ c.action do |_, options|
15
+ options["serving"] = false
16
+ Jekyll::Commands::Build.process(options)
17
+ end
18
+ end
19
+ end
20
+
21
+ # Build your jekyll site
22
+ # Continuously watch if `watch` is set to true in the config.
23
+ def process(options)
24
+ # Adjust verbosity quickly
25
+ Jekyll.logger.adjust_verbosity(options)
26
+
27
+ options = configuration_from_options(options)
28
+ site = Jekyll::Site.new(options)
29
+
30
+ if options.fetch('skip_initial_build', false)
31
+ Jekyll.logger.warn "Build Warning:", "Skipping the initial build. This may result in an out-of-date site."
32
+ else
33
+ build(site, options)
34
+ end
35
+
36
+ if options.fetch('detach', false)
37
+ Jekyll.logger.info "Auto-regeneration:", "disabled when running server detached."
38
+ elsif options.fetch('watch', false)
39
+ watch(site, options)
40
+ else
41
+ Jekyll.logger.info "Auto-regeneration:", "disabled. Use --watch to enable."
42
+ end
43
+ end
44
+
45
+ # Build your Jekyll site.
46
+ #
47
+ # site - the Jekyll::Site instance to build
48
+ # options - A Hash of options passed to the command
49
+ #
50
+ # Returns nothing.
51
+ def build(site, options)
52
+ t = Time.now
53
+ source = options['source']
54
+ destination = options['destination']
55
+ incremental = options['incremental']
56
+ Jekyll.logger.info "Source:", source
57
+ Jekyll.logger.info "Destination:", destination
58
+ Jekyll.logger.info "Incremental build:", (incremental ? "enabled" : "disabled. Enable with --incremental")
59
+ Jekyll.logger.info "Generating..."
60
+ process_site(site)
61
+ Jekyll.logger.info "", "done in #{(Time.now - t).round(3)} seconds."
62
+ end
63
+
64
+ # Private: Watch for file changes and rebuild the site.
65
+ #
66
+ # site - A Jekyll::Site instance
67
+ # options - A Hash of options passed to the command
68
+ #
69
+ # Returns nothing.
70
+ def watch(_site, options)
71
+ External.require_with_graceful_fail 'jekyll-watch'
72
+ Jekyll::Watcher.watch(options)
73
+ end
74
+ end # end of class << self
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,42 @@
1
+ module Jekyll
2
+ module Commands
3
+ class Clean < Command
4
+ class << self
5
+ def init_with_program(prog)
6
+ prog.command(:clean) do |c|
7
+ c.syntax 'clean [subcommand]'
8
+ c.description 'Clean the site (removes site output and metadata file) without building.'
9
+
10
+ add_build_options(c)
11
+
12
+ c.action do |_, options|
13
+ Jekyll::Commands::Clean.process(options)
14
+ end
15
+ end
16
+ end
17
+
18
+ def process(options)
19
+ options = configuration_from_options(options)
20
+ destination = options['destination']
21
+ metadata_file = File.join(options['source'], '.jekyll-metadata')
22
+
23
+ if File.directory? destination
24
+ Jekyll.logger.info "Cleaning #{destination}..."
25
+ FileUtils.rm_rf(destination)
26
+ Jekyll.logger.info "", "done."
27
+ else
28
+ Jekyll.logger.info "Nothing to do for #{destination}."
29
+ end
30
+
31
+ if File.file? metadata_file
32
+ Jekyll.logger.info "Removing #{metadata_file}..."
33
+ FileUtils.rm_rf(metadata_file)
34
+ Jekyll.logger.info "", "done."
35
+ else
36
+ Jekyll.logger.info "Nothing to do for #{metadata_file}."
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,114 @@
1
+ module Jekyll
2
+ module Commands
3
+ class Doctor < Command
4
+ class << self
5
+ def init_with_program(prog)
6
+ prog.command(:doctor) do |c|
7
+ c.syntax 'doctor'
8
+ c.description 'Search site and print specific deprecation warnings'
9
+ c.alias(:hyde)
10
+
11
+ c.option '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'
12
+
13
+ c.action do |_, options|
14
+ Jekyll::Commands::Doctor.process(options)
15
+ end
16
+ end
17
+ end
18
+
19
+ def process(options)
20
+ site = Jekyll::Site.new(configuration_from_options(options))
21
+ site.read
22
+
23
+ if healthy?(site)
24
+ Jekyll.logger.info "Your test results", "are in. Everything looks fine."
25
+ else
26
+ abort
27
+ end
28
+ end
29
+
30
+ def healthy?(site)
31
+ [
32
+ fsnotify_buggy?(site),
33
+ !deprecated_relative_permalinks(site),
34
+ !conflicting_urls(site),
35
+ !urls_only_differ_by_case(site)
36
+ ].all?
37
+ end
38
+
39
+ def deprecated_relative_permalinks(site)
40
+ if site.config['relative_permalinks']
41
+ Jekyll::Deprecator.deprecation_message "Your site still uses relative" \
42
+ " permalinks, which was removed in" \
43
+ " Jekyll v3.0.0."
44
+ return true
45
+ end
46
+ end
47
+
48
+ def conflicting_urls(site)
49
+ conflicting_urls = false
50
+ urls = {}
51
+ urls = collect_urls(urls, site.pages, site.dest)
52
+ urls = collect_urls(urls, site.posts.docs, site.dest)
53
+ urls.each do |url, paths|
54
+ next unless paths.size > 1
55
+ conflicting_urls = true
56
+ Jekyll.logger.warn "Conflict:", "The URL '#{url}' is the destination" \
57
+ " for the following pages: #{paths.join(", ")}"
58
+ end
59
+ conflicting_urls
60
+ end
61
+
62
+ def fsnotify_buggy?(_site)
63
+ return true unless Utils::Platforms.osx?
64
+ if Dir.pwd != `pwd`.strip
65
+ Jekyll.logger.error " " + <<-STR.strip.gsub(/\n\s+/, "\n ")
66
+ We have detected that there might be trouble using fsevent on your
67
+ operating system, you can read https://github.com/thibaudgg/rb-fsevent/wiki/no-fsevents-fired-(OSX-bug)
68
+ for possible work arounds or you can work around it immediately
69
+ with `--force-polling`.
70
+ STR
71
+
72
+ false
73
+ end
74
+
75
+ true
76
+ end
77
+
78
+ def urls_only_differ_by_case(site)
79
+ urls_only_differ_by_case = false
80
+ urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest)
81
+ urls.each do |case_insensitive_url, real_urls|
82
+ next unless real_urls.uniq.size > 1
83
+ urls_only_differ_by_case = true
84
+ Jekyll.logger.warn "Warning:", "The following URLs only differ" \
85
+ " by case. On a case-insensitive file system one of the URLs" \
86
+ " will be overwritten by the other: #{real_urls.join(", ")}"
87
+ end
88
+ urls_only_differ_by_case
89
+ end
90
+
91
+ private
92
+ def collect_urls(urls, things, destination)
93
+ things.each do |thing|
94
+ dest = thing.destination(destination)
95
+ if urls[dest]
96
+ urls[dest] << thing.path
97
+ else
98
+ urls[dest] = [thing.path]
99
+ end
100
+ end
101
+ urls
102
+ end
103
+
104
+ def case_insensitive_urls(things, destination)
105
+ things.inject({}) do |memo, thing|
106
+ dest = thing.destination(destination)
107
+ (memo[dest.downcase] ||= []) << dest
108
+ memo
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end