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,180 @@
1
+ module Jekyll
2
+ class Page
3
+ include Convertible
4
+
5
+ attr_writer :dir
6
+ attr_accessor :site, :pager
7
+ attr_accessor :name, :ext, :basename
8
+ attr_accessor :data, :content, :output
9
+
10
+ alias_method :extname, :ext
11
+
12
+ FORWARD_SLASH = '/'.freeze
13
+
14
+ # Attributes for Liquid templates
15
+ ATTRIBUTES_FOR_LIQUID = %w(
16
+ content
17
+ dir
18
+ name
19
+ path
20
+ url
21
+ )
22
+
23
+ # A set of extensions that are considered HTML or HTML-like so we
24
+ # should not alter them, this includes .xhtml through XHTM5.
25
+
26
+ HTML_EXTENSIONS = %W(
27
+ .html
28
+ .xhtml
29
+ .htm
30
+ )
31
+
32
+ # Initialize a new Page.
33
+ #
34
+ # site - The Site object.
35
+ # base - The String path to the source.
36
+ # dir - The String path between the source and the file.
37
+ # name - The String filename of the file.
38
+ def initialize(site, base, dir, name)
39
+ @site = site
40
+ @base = base
41
+ @dir = dir
42
+ @name = name
43
+
44
+ process(name)
45
+ read_yaml(File.join(base, dir), name)
46
+
47
+ data.default_proc = proc do |_, key|
48
+ site.frontmatter_defaults.find(File.join(dir, name), type, key)
49
+ end
50
+
51
+ Jekyll::Hooks.trigger :pages, :post_init, self
52
+ end
53
+
54
+ # The generated directory into which the page will be placed
55
+ # upon generation. This is derived from the permalink or, if
56
+ # permalink is absent, we be '/'
57
+ #
58
+ # Returns the String destination directory.
59
+ def dir
60
+ if url.end_with?(FORWARD_SLASH)
61
+ url
62
+ else
63
+ url_dir = File.dirname(url)
64
+ url_dir.end_with?(FORWARD_SLASH) ? url_dir : "#{url_dir}/"
65
+ end
66
+ end
67
+
68
+ # The full path and filename of the post. Defined in the YAML of the post
69
+ # body.
70
+ #
71
+ # Returns the String permalink or nil if none has been set.
72
+ def permalink
73
+ data.nil? ? nil : data['permalink']
74
+ end
75
+
76
+ # The template of the permalink.
77
+ #
78
+ # Returns the template String.
79
+ def template
80
+ if !html?
81
+ "/:path/:basename:output_ext"
82
+ elsif index?
83
+ "/:path/"
84
+ else
85
+ Utils.add_permalink_suffix("/:path/:basename", site.permalink_style)
86
+ end
87
+ end
88
+
89
+ # The generated relative url of this page. e.g. /about.html.
90
+ #
91
+ # Returns the String url.
92
+ def url
93
+ @url ||= URL.new({
94
+ :template => template,
95
+ :placeholders => url_placeholders,
96
+ :permalink => permalink
97
+ }).to_s
98
+ end
99
+
100
+ # Returns a hash of URL placeholder names (as symbols) mapping to the
101
+ # desired placeholder replacements. For details see "url.rb"
102
+ def url_placeholders
103
+ {
104
+ :path => @dir,
105
+ :basename => basename,
106
+ :output_ext => output_ext
107
+ }
108
+ end
109
+
110
+ # Extract information from the page filename.
111
+ #
112
+ # name - The String filename of the page file.
113
+ #
114
+ # Returns nothing.
115
+ def process(name)
116
+ self.ext = File.extname(name)
117
+ self.basename = name[0..-ext.length - 1]
118
+ end
119
+
120
+ # Add any necessary layouts to this post
121
+ #
122
+ # layouts - The Hash of {"name" => "layout"}.
123
+ # site_payload - The site payload Hash.
124
+ #
125
+ # Returns nothing.
126
+ def render(layouts, site_payload)
127
+ site_payload["page"] = to_liquid
128
+ site_payload["paginator"] = pager.to_liquid
129
+
130
+ do_layout(site_payload, layouts)
131
+ end
132
+
133
+ # The path to the source file
134
+ #
135
+ # Returns the path to the source file
136
+ def path
137
+ data.fetch('path') { relative_path.sub(/\A\//, '') }
138
+ end
139
+
140
+ # The path to the page source file, relative to the site source
141
+ def relative_path
142
+ File.join(*[@dir, @name].map(&:to_s).reject(&:empty?))
143
+ end
144
+
145
+ # Obtain destination path.
146
+ #
147
+ # dest - The String path to the destination dir.
148
+ #
149
+ # Returns the destination file path String.
150
+ def destination(dest)
151
+ path = site.in_dest_dir(dest, URL.unescape_path(url))
152
+ path = File.join(path, "index") if url.end_with?("/")
153
+ path << output_ext unless path.end_with? output_ext
154
+ path
155
+ end
156
+
157
+ # Returns the object as a debug String.
158
+ def inspect
159
+ "#<Jekyll:Page @name=#{name.inspect}>"
160
+ end
161
+
162
+ # Returns the Boolean of whether this Page is HTML or not.
163
+ def html?
164
+ HTML_EXTENSIONS.include?(output_ext)
165
+ end
166
+
167
+ # Returns the Boolean of whether this Page is an index file or not.
168
+ def index?
169
+ basename == 'index'
170
+ end
171
+
172
+ def trigger_hooks(hook_name, *args)
173
+ Jekyll::Hooks.trigger :pages, hook_name, self, *args
174
+ end
175
+
176
+ def write?
177
+ true
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,96 @@
1
+ module Jekyll
2
+ class Plugin
3
+ PRIORITIES = {
4
+ :low => -10,
5
+ :highest => 100,
6
+ :lowest => -100,
7
+ :normal => 0,
8
+ :high => 10
9
+ }
10
+
11
+ #
12
+
13
+ def self.inherited(const)
14
+ return catch_inheritance(const) do |const_|
15
+ catch_inheritance(const_)
16
+ end
17
+ end
18
+
19
+ #
20
+
21
+ def self.catch_inheritance(const)
22
+ const.define_singleton_method :inherited do |const_|
23
+ (@children ||= Set.new).add const_
24
+ if block_given?
25
+ yield const_
26
+ end
27
+ end
28
+ end
29
+
30
+ #
31
+
32
+ def self.descendants
33
+ @children ||= Set.new
34
+ out = @children.map(&:descendants)
35
+ out << self unless superclass == Plugin
36
+ Set.new(out).flatten
37
+ end
38
+
39
+ # Get or set the priority of this plugin. When called without an
40
+ # argument it returns the priority. When an argument is given, it will
41
+ # set the priority.
42
+ #
43
+ # priority - The Symbol priority (default: nil). Valid options are:
44
+ # :lowest, :low, :normal, :high, :highest
45
+ #
46
+ # Returns the Symbol priority.
47
+ def self.priority(priority = nil)
48
+ @priority ||= nil
49
+ if priority && PRIORITIES.key?(priority)
50
+ @priority = priority
51
+ end
52
+ @priority || :normal
53
+ end
54
+
55
+ # Get or set the safety of this plugin. When called without an argument
56
+ # it returns the safety. When an argument is given, it will set the
57
+ # safety.
58
+ #
59
+ # safe - The Boolean safety (default: nil).
60
+ #
61
+ # Returns the safety Boolean.
62
+ def self.safe(safe = nil)
63
+ if safe
64
+ @safe = safe
65
+ end
66
+ @safe || false
67
+ end
68
+
69
+ # Spaceship is priority [higher -> lower]
70
+ #
71
+ # other - The class to be compared.
72
+ #
73
+ # Returns -1, 0, 1.
74
+ def self.<=>(other)
75
+ PRIORITIES[other.priority] <=> PRIORITIES[self.priority]
76
+ end
77
+
78
+ # Spaceship is priority [higher -> lower]
79
+ #
80
+ # other - The class to be compared.
81
+ #
82
+ # Returns -1, 0, 1.
83
+ def <=>(other)
84
+ self.class <=> other.class
85
+ end
86
+
87
+ # Initialize a new plugin. This should be overridden by the subclass.
88
+ #
89
+ # config - The Hash of configuration options.
90
+ #
91
+ # Returns a new instance.
92
+ def initialize(config = {})
93
+ # no-op for default
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,95 @@
1
+ module Jekyll
2
+ class PluginManager
3
+ attr_reader :site
4
+
5
+ # Create an instance of this class.
6
+ #
7
+ # site - the instance of Jekyll::Site we're concerned with
8
+ #
9
+ # Returns nothing
10
+ def initialize(site)
11
+ @site = site
12
+ end
13
+
14
+ # Require all the plugins which are allowed.
15
+ #
16
+ # Returns nothing
17
+ def conscientious_require
18
+ require_plugin_files
19
+ require_gems
20
+ deprecation_checks
21
+ end
22
+
23
+ # Require each of the gem plugins specified.
24
+ #
25
+ # Returns nothing.
26
+ def require_gems
27
+ Jekyll::External.require_with_graceful_fail(site.gems.select { |gem| plugin_allowed?(gem) })
28
+ end
29
+
30
+ def self.require_from_bundler
31
+ if !ENV["JEKYLL_NO_BUNDLER_REQUIRE"] && File.file?("Gemfile")
32
+ require "bundler"
33
+ Bundler.setup # puts all groups on the load path
34
+ required_gems = Bundler.require(:jekyll_plugins) # requires the gems in this group only
35
+ Jekyll.logger.debug("PluginManager:", "Required #{required_gems.map(&:name).join(', ')}")
36
+ ENV["JEKYLL_NO_BUNDLER_REQUIRE"] = "true"
37
+ true
38
+ else
39
+ false
40
+ end
41
+ rescue LoadError, Bundler::GemfileNotFound
42
+ false
43
+ end
44
+
45
+ # Check whether a gem plugin is allowed to be used during this build.
46
+ #
47
+ # gem_name - the name of the gem
48
+ #
49
+ # Returns true if the gem name is in the whitelist or if the site is not
50
+ # in safe mode.
51
+ def plugin_allowed?(gem_name)
52
+ !site.safe || whitelist.include?(gem_name)
53
+ end
54
+
55
+ # Build an array of allowed plugin gem names.
56
+ #
57
+ # Returns an array of strings, each string being the name of a gem name
58
+ # that is allowed to be used.
59
+ def whitelist
60
+ @whitelist ||= Array[site.config['whitelist']].flatten
61
+ end
62
+
63
+ # Require all .rb files if safe mode is off
64
+ #
65
+ # Returns nothing.
66
+ def require_plugin_files
67
+ unless site.safe
68
+ plugins_path.each do |plugin_search_path|
69
+ plugin_files = Utils.safe_glob(plugin_search_path, File.join("**", "*.rb"))
70
+ Jekyll::External.require_with_graceful_fail(plugin_files)
71
+ end
72
+ end
73
+ end
74
+
75
+ # Public: Setup the plugin search path
76
+ #
77
+ # Returns an Array of plugin search paths
78
+ def plugins_path
79
+ if site.config['plugins_dir'] == Jekyll::Configuration::DEFAULTS['plugins_dir']
80
+ [site.in_source_dir(site.config['plugins_dir'])]
81
+ else
82
+ Array(site.config['plugins_dir']).map { |d| File.expand_path(d) }
83
+ end
84
+ end
85
+
86
+ def deprecation_checks
87
+ pagination_included = (site.config['gems'] || []).include?('jekyll-paginate') || defined?(Jekyll::Paginate)
88
+ if site.config['paginate'] && !pagination_included
89
+ Jekyll::Deprecator.deprecation_message "You appear to have pagination " \
90
+ "turned on, but you haven't included the `jekyll-paginate` gem. " \
91
+ "Ensure you have `gems: [jekyll-paginate]` in your configuration file."
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,21 @@
1
+ module Jekyll
2
+ class Publisher
3
+ def initialize(site)
4
+ @site = site
5
+ end
6
+
7
+ def publish?(thing)
8
+ can_be_published?(thing) && !hidden_in_the_future?(thing)
9
+ end
10
+
11
+ private
12
+
13
+ def can_be_published?(thing)
14
+ thing.data.fetch('published', true) || @site.unpublished
15
+ end
16
+
17
+ def hidden_in_the_future?(thing)
18
+ thing.respond_to?(:date) && !@site.future && thing.date.to_i > @site.time.to_i
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,126 @@
1
+ # encoding: UTF-8
2
+ require 'csv'
3
+
4
+ module Jekyll
5
+ class Reader
6
+ attr_reader :site
7
+
8
+ def initialize(site)
9
+ @site = site
10
+ end
11
+
12
+ # Read Site data from disk and load it into internal data structures.
13
+ #
14
+ # Returns nothing.
15
+ def read
16
+ @site.layouts = LayoutReader.new(site).read
17
+ read_directories
18
+ sort_files!
19
+ @site.data = DataReader.new(site).read(site.config['data_dir'])
20
+ CollectionReader.new(site).read
21
+ end
22
+
23
+ # Sorts posts, pages, and static files.
24
+ def sort_files!
25
+ site.collections.values.each { |c| c.docs.sort! }
26
+ site.pages.sort_by!(&:name)
27
+ site.static_files.sort_by!(&:relative_path)
28
+ end
29
+
30
+ # Recursively traverse directories to find pages and static files
31
+ # that will become part of the site according to the rules in
32
+ # filter_entries.
33
+ #
34
+ # dir - The String relative path of the directory to read. Default: ''.
35
+ #
36
+ # Returns nothing.
37
+ def read_directories(dir = '')
38
+ base = site.in_source_dir(dir)
39
+
40
+ dot = Dir.chdir(base) { filter_entries(Dir.entries('.'), base) }
41
+ dot_dirs = dot.select { |file| File.directory?(@site.in_source_dir(base, file)) }
42
+ dot_files = (dot - dot_dirs)
43
+ dot_pages = dot_files.select { |file| Utils.has_yaml_header?(@site.in_source_dir(base, file)) }
44
+ dot_static_files = dot_files - dot_pages
45
+
46
+ retrieve_posts(dir)
47
+ retrieve_dirs(base, dir, dot_dirs)
48
+ retrieve_pages(dir, dot_pages)
49
+ retrieve_static_files(dir, dot_static_files)
50
+ end
51
+
52
+ # Retrieves all the posts(posts/drafts) from the given directory
53
+ # and add them to the site and sort them.
54
+ #
55
+ # dir - The String representing the directory to retrieve the posts from.
56
+ #
57
+ # Returns nothing.
58
+ def retrieve_posts(dir)
59
+ site.posts.docs.concat(PostReader.new(site).read_posts(dir))
60
+ site.posts.docs.concat(PostReader.new(site).read_drafts(dir)) if site.show_drafts
61
+ end
62
+
63
+ # Recursively traverse directories with the read_directories function.
64
+ #
65
+ # base - The String representing the site's base directory.
66
+ # dir - The String representing the directory to traverse down.
67
+ # dot_dirs - The Array of subdirectories in the dir.
68
+ #
69
+ # Returns nothing.
70
+ def retrieve_dirs(_base, dir, dot_dirs)
71
+ dot_dirs.map do |file|
72
+ dir_path = site.in_source_dir(dir, file)
73
+ rel_path = File.join(dir, file)
74
+ @site.reader.read_directories(rel_path) unless @site.dest.sub(/\/$/, '') == dir_path
75
+ end
76
+ end
77
+
78
+ # Retrieve all the pages from the current directory,
79
+ # add them to the site and sort them.
80
+ #
81
+ # dir - The String representing the directory retrieve the pages from.
82
+ # dot_pages - The Array of pages in the dir.
83
+ #
84
+ # Returns nothing.
85
+ def retrieve_pages(dir, dot_pages)
86
+ site.pages.concat(PageReader.new(site, dir).read(dot_pages))
87
+ end
88
+
89
+ # Retrieve all the static files from the current directory,
90
+ # add them to the site and sort them.
91
+ #
92
+ # dir - The directory retrieve the static files from.
93
+ # dot_static_files - The static files in the dir.
94
+ #
95
+ # Returns nothing.
96
+ def retrieve_static_files(dir, dot_static_files)
97
+ site.static_files.concat(StaticFileReader.new(site, dir).read(dot_static_files))
98
+ end
99
+
100
+ # Filter out any files/directories that are hidden or backup files (start
101
+ # with "." or "#" or end with "~"), or contain site content (start with "_"),
102
+ # or are excluded in the site configuration, unless they are web server
103
+ # files such as '.htaccess'.
104
+ #
105
+ # entries - The Array of String file/directory entries to filter.
106
+ # base_directory - The string representing the optional base directory.
107
+ #
108
+ # Returns the Array of filtered entries.
109
+ def filter_entries(entries, base_directory = nil)
110
+ EntryFilter.new(site, base_directory).filter(entries)
111
+ end
112
+
113
+ # Read the entries from a particular directory for processing
114
+ #
115
+ # dir - The String representing the relative path of the directory to read.
116
+ # subfolder - The String representing the directory to read.
117
+ #
118
+ # Returns the list of entries to process
119
+ def get_entries(dir, subfolder)
120
+ base = site.in_source_dir(dir, subfolder)
121
+ return [] unless File.exist?(base)
122
+ entries = Dir.chdir(base) { filter_entries(Dir['**/*'], base) }
123
+ entries.delete_if { |e| File.directory?(site.in_source_dir(base, e)) }
124
+ end
125
+ end
126
+ end