Made corrections as suggested by @mattr-.
- Corrected TomDoc, added variables and fixed typos. - deprecated_rel_permalink -> relative_permalinks_are_deprecated. - Grouped calls together in @reader.read. - Removed dynamic and static reader subdirectories. - Removed unnecessary move of limit_posts. Signed-off-by: Martin Jorn Rogalla <martin@martinrogalla.com>
This commit is contained in:
parent
324748a5a6
commit
63a1ec8949
|
@ -49,13 +49,13 @@ module Jekyll
|
|||
autoload :Filters, 'jekyll/filters'
|
||||
autoload :FrontmatterDefaults, 'jekyll/frontmatter_defaults'
|
||||
autoload :Layout, 'jekyll/layout'
|
||||
autoload :CollectionReader, 'jekyll/readers/dynamic/collection_reader'
|
||||
autoload :DataReader, 'jekyll/readers/dynamic/data_reader'
|
||||
autoload :LayoutReader, 'jekyll/readers/dynamic/layout_reader'
|
||||
autoload :DraftReader, 'jekyll/readers/dynamic/draft_reader'
|
||||
autoload :PostReader, 'jekyll/readers/dynamic/post_reader'
|
||||
autoload :PageReader, 'jekyll/readers/dynamic/page_reader'
|
||||
autoload :StaticFileReader, 'jekyll/readers/static/static_file_reader'
|
||||
autoload :CollectionReader, 'jekyll/readers/collection_reader'
|
||||
autoload :DataReader, 'jekyll/readers/data_reader'
|
||||
autoload :LayoutReader, 'jekyll/readers/layout_reader'
|
||||
autoload :DraftReader, 'jekyll/readers/draft_reader'
|
||||
autoload :PostReader, 'jekyll/readers/post_reader'
|
||||
autoload :PageReader, 'jekyll/readers/page_reader'
|
||||
autoload :StaticFileReader, 'jekyll/readers/static_file_reader'
|
||||
autoload :LogAdapter, 'jekyll/log_adapter'
|
||||
autoload :Page, 'jekyll/page'
|
||||
autoload :PluginManager, 'jekyll/plugin_manager'
|
||||
|
|
|
@ -27,28 +27,25 @@ module Jekyll
|
|||
#
|
||||
# Returns nothing.
|
||||
def read_directories(dir = '')
|
||||
retrieve_posts(dir)
|
||||
|
||||
# Obtain sub-directories in order to recursively read them.
|
||||
base = site.in_source_dir(dir)
|
||||
|
||||
dot = Dir.chdir(base) { filter_entries(Dir.entries('.'), base) }
|
||||
dot_dirs = dot.select{ |file| File.directory?(@site.in_source_dir(base,file)) }
|
||||
retrieve_dirs(base, dir, dot_dirs)
|
||||
|
||||
dot_files = (dot - dot_dirs)
|
||||
|
||||
# Obtain all the pages.
|
||||
dot_pages = dot_files.select{ |file| Utils.has_yaml_header?(@site.in_source_dir(base,file)) }
|
||||
retrieve_pages(dir, dot_pages)
|
||||
|
||||
# Assume the remaining files to be static files.
|
||||
dot_static_files = dot_files - dot_pages
|
||||
|
||||
retrieve_posts(dir)
|
||||
retrieve_dirs(base, dir, dot_dirs)
|
||||
retrieve_pages(dir, dot_pages)
|
||||
retrieve_static_files(dir, dot_static_files)
|
||||
end
|
||||
|
||||
# Retrieves all the posts(posts/drafts) from the given directory
|
||||
# and add them to the site and sort them.
|
||||
#
|
||||
# dir - The String representing the directory to retrieve the posts from.
|
||||
#
|
||||
# Returns nothing.
|
||||
def retrieve_posts(dir)
|
||||
site.posts.concat(PostReader.new(site).read(dir))
|
||||
|
@ -58,6 +55,10 @@ module Jekyll
|
|||
|
||||
# Recursively traverse directories with the read_directories function.
|
||||
#
|
||||
# base - The String representing the site's base directory.
|
||||
# dir - The String representing the directory to traverse down.
|
||||
# dot_dirs - The Array of subdirectories in the dir.
|
||||
#
|
||||
# Returns nothing.
|
||||
def retrieve_dirs(base, dir, dot_dirs)
|
||||
dot_dirs.map { |file|
|
||||
|
@ -70,6 +71,9 @@ module Jekyll
|
|||
# Retrieve all the pages from the current directory,
|
||||
# add them to the site and sort them.
|
||||
#
|
||||
# dir - The String representing the directory retrieve the pages from.
|
||||
# dot_pages - The Array of pages in the dir.
|
||||
#
|
||||
# Returns nothing.
|
||||
def retrieve_pages(dir, dot_pages)
|
||||
site.pages.concat(PageReader.new(site, dir).read(dot_pages))
|
||||
|
@ -79,6 +83,9 @@ module Jekyll
|
|||
# Retrieve all the static files from the current directory,
|
||||
# add them to the site and sort them.
|
||||
#
|
||||
# dir - The directory retrieve the static files from.
|
||||
# dot_static_files - The static files in the dir.
|
||||
#
|
||||
# Returns nothing.
|
||||
def retrieve_static_files(dir, dot_static_files)
|
||||
site.static_files.concat(StaticFileReader.new(site, dir).read(dot_static_files))
|
||||
|
@ -91,6 +98,7 @@ module Jekyll
|
|||
# files such as '.htaccess'.
|
||||
#
|
||||
# entries - The Array of String file/directory entries to filter.
|
||||
# base_directory - The string representing the optional base directory.
|
||||
#
|
||||
# Returns the Array of filtered entries.
|
||||
def filter_entries(entries, base_directory = nil)
|
||||
|
@ -99,8 +107,8 @@ module Jekyll
|
|||
|
||||
# Read the entries from a particular directory for processing
|
||||
#
|
||||
# dir - The String relative path of the directory to read
|
||||
# subfolder - The String directory to read
|
||||
# dir - The String representing the relative path of the directory to read.
|
||||
# subfolder - The String representing the directory to read.
|
||||
#
|
||||
# Returns the list of entries to process
|
||||
def get_entries(dir, subfolder)
|
||||
|
|
|
@ -146,7 +146,7 @@ module Jekyll
|
|||
#
|
||||
# Returns nothing.
|
||||
def render
|
||||
deprecated_rel_permalink
|
||||
relative_permalinks_are_deprecated
|
||||
|
||||
payload = site_payload
|
||||
collections.each do |label, collection|
|
||||
|
@ -281,12 +281,12 @@ module Jekyll
|
|||
end
|
||||
end
|
||||
|
||||
# Warns the user if permanent links are relative tot the parent
|
||||
# Warns the user if permanent links are relative to the parent
|
||||
# directory. As this is a deprecated function of Jekyll.
|
||||
#
|
||||
# Returns
|
||||
def deprecated_rel_permalink
|
||||
if config['relative_permalinks'] && has_relative_page?
|
||||
def relative_permalinks_are_deprecated
|
||||
if config['relative_permalinks'] && has_relative_page?
|
||||
Jekyll::Deprecator.deprecation_message "Since v2.0, permalinks for pages" +
|
||||
" in subfolders must be relative to the" +
|
||||
" site source directory, not the parent" +
|
||||
|
@ -377,14 +377,6 @@ module Jekyll
|
|||
pages.any? { |page| page.uses_relative_permalinks }
|
||||
end
|
||||
|
||||
# Returns the Cleaner or creates a new Cleaner if it doesn't
|
||||
# already exist.
|
||||
#
|
||||
# Returns The Cleaner
|
||||
def site_cleaner
|
||||
@site_cleaner ||= Cleaner.new(self)
|
||||
end
|
||||
|
||||
# Limits the current posts; removes the posts which exceed the limit_posts
|
||||
#
|
||||
# Returns nothing
|
||||
|
@ -394,5 +386,13 @@ module Jekyll
|
|||
self.posts = posts[-limit, limit]
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the Cleaner or creates a new Cleaner if it doesn't
|
||||
# already exist.
|
||||
#
|
||||
# Returns The Cleaner
|
||||
def site_cleaner
|
||||
@site_cleaner ||= Cleaner.new(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue