Compare commits

...

7 Commits

Author SHA1 Message Date
Pat Hawks
2d191bce81 Fix backwards compatible relative_path 2018-07-02 12:40:52 -05:00
Pat Hawks
49c4666ec9 I don't know why this works, but it does 2018-07-02 10:10:10 -05:00
Pat Hawks
b16080d016 Fix hash diffs 2018-07-02 08:53:45 -05:00
Pat Hawks
94fb5985b7 Fix bugs 2018-07-01 21:16:48 -05:00
Pat Hawks
0ae6fa4c7a Merge branch 'master' into pages-as-documents 2018-06-26 13:52:55 -05:00
Ben Balter
21d5dd7761 distinguish absolute_path from relative_path 2016-08-07 20:09:38 -04:00
Ben Balter
ef3e660620 initial pass at Pages as Documents 2016-08-07 19:03:24 -04:00
21 changed files with 219 additions and 211 deletions

View File

@@ -82,10 +82,10 @@ Feature: Create sites
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see "Page : Site contains 2 pages and 4 posts" in "_site/index.html"
And I should see "Page Index: Site contains 2 pages and 4 posts" in "_site/index.html"
And I should see "No replacement \{\{ site.posts.size \}\}" in "_site/about.html"
And I should see "" in "_site/another_file"
And I should see "Page : blog category index page" in "_site/blog/index.html"
And I should see "Page Index: blog category index page" in "_site/blog/index.html"
And I should see "Post entry1: <p>content for entry1.</p>" in "_site/2009/03/27/entry1.html"
And I should see "Post entry2: <p>content for entry2.</p>" in "_site/2009/04/27/entry2.html"
And I should see "Post entry3: <p>content for entry3.</p>" in "_site/category/2009/05/27/entry3.html"
@@ -200,6 +200,6 @@ Feature: Create sites
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see "Page : Site contains 1 pages and 2 posts; Related posts: 0" in "_site/index.html"
And I should see "Page Index: Site contains 1 pages and 2 posts; Related posts: 0" in "_site/index.html"
And I should see "Post entry1: <p>content for entry1.</p>\nRelated posts: 1" in "_site/2009/03/27/entry1.html"
And I should see "Post entry2: <p>content for entry2.</p>\nRelated posts: 1" in "_site/2009/04/27/entry2.html"

View File

@@ -106,4 +106,4 @@ Feature: Embed filters
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see exactly "The rule of 3: Fly, Run, Jump," in "_site/bird.html"
And I should see exactly "The rule of 3: Jump, Fly, Run," in "_site/bird.html"

View File

@@ -7,20 +7,9 @@ Feature: Hooks
And I have a "_plugins/ext.rb" file with content:
"""
Jekyll::Hooks.register :site, :after_reset do |site|
pageklass = Class.new(Jekyll::Page) do
def initialize(site, base)
@site = site
@base = base
@data = {}
@dir = '/'
@name = 'foo.html'
@content = 'mytinypage'
self.process(@name)
end
end
site.pages << pageklass.new(site, site.source)
page = Jekyll::Page.new(site, site.source, "/", "foo.html")
page.content = "mytinypage"
site.pages.docs << page
end
"""
When I run jekyll build
@@ -79,7 +68,7 @@ Feature: Hooks
And I have a "_plugins/ext.rb" file with content:
"""
Jekyll::Hooks.register :pages, :post_init do |page|
page.name = 'renamed.html'
page.instance_variable_set "@relative_path", '/renamed.html'
page.process(page.name)
end
"""
@@ -256,6 +245,7 @@ Feature: Hooks
And I have a "_plugins/ext.rb" file with content:
"""
Jekyll::Hooks.register :documents, :pre_render do |doc, payload|
doc.data['text'] ||= ''
doc.data['text'] = doc.data['text'] << ' are belong to us'
end
"""

View File

@@ -66,7 +66,7 @@ module Jekyll
def conflicting_urls(site)
conflicting_urls = false
urls = {}
urls = collect_urls(urls, site.pages, site.dest)
urls = collect_urls(urls, site.pages.docs, site.dest)
urls = collect_urls(urls, site.posts.docs, site.dest)
urls.each do |url, paths|
next unless paths.size > 1
@@ -95,7 +95,7 @@ module Jekyll
def urls_only_differ_by_case(site)
urls_only_differ_by_case = false
urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest)
urls = case_insensitive_urls(site.docs_to_write, site.dest)
urls.each_value do |real_urls|
next unless real_urls.uniq.size > 1
urls_only_differ_by_case = true

View File

@@ -257,9 +257,10 @@ module Jekyll
end
config["collections"] = Utils.deep_merge_hashes(
{ "posts" => {} }, config["collections"]
{ "posts" => {}, "pages" => {} }, config["collections"]
).tap do |collections|
collections["posts"]["output"] = true
collections["pages"]["output"] = true
if config["permalink"]
collections["posts"]["permalink"] ||= style_to_permalink(config["permalink"])
end

View File

@@ -5,15 +5,28 @@ module Jekyll
include Comparable
extend Forwardable
attr_reader :path, :site, :extname, :collection
attr_reader :site, :extname, :collection
attr_accessor :content, :output
# In order to retain backwards compatability, @path is the absolute path
# in Documents, but the relative path in Pages. If you need the Document's
# path, it's better to use #absolute_path and #relative_path
attr_reader :path
def_delegator :self, :read_post_data, :post_read
YAML_FRONT_MATTER_REGEXP = %r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m
DATELESS_FILENAME_MATCHER = %r!^(?:.+/)*(.*)(\.[^.]+)$!
DATE_FILENAME_MATCHER = %r!^(?:.+/)*(\d{2,4}-\d{1,2}-\d{1,2})-(.*)(\.[^.]+)$!
# A set of extensions that are considered HTML or HTML-like so we
# should not alter them, this includes .xhtml through XHTM5.
HTML_EXTENSIONS = %w(
.html
.xhtml
.htm
).freeze
# Create a new Document.
#
# path - the path to the file
@@ -83,7 +96,23 @@ module Jekyll
# Returns a String path which represents the relative path from the collections_dir
# to this document.
def relative_path
@relative_path ||= path.sub("#{site.collections_path}/", "")
@relative_path ||= Pathname.new(absolute_path)
.relative_path_from(Pathname.new(site.source)).to_s
end
# The path to the document's containing directory, relative to the site source
#
# Returns a String path which represents the relative path
# from the site source to this document's containing directory
def relative_path_without_basename
@relative_path_without_basename = relative_path.sub(%r!#{basename}\z!, "")
end
# The absolute path to the document
#
# Returns a String path which represents the absolute pat to this document
def absolute_path
Pathname.new(@path).to_s
end
# The output extension of the document.
@@ -97,14 +126,14 @@ module Jekyll
#
# Returns the basename without the file extname.
def basename_without_ext
@basename_without_ext ||= File.basename(path, ".*")
@basename_without_ext ||= File.basename(absolute_path, ".*")
end
# The base filename of the document.
#
# Returns the base filename of the document.
def basename
@basename ||= File.basename(path)
@basename ||= File.basename(absolute_path)
end
# Produces a "cleaned" relative path.
@@ -159,7 +188,7 @@ module Jekyll
# or if the document doesn't contain any Liquid Tags or Variables,
# true otherwise.
def render_with_liquid?
!(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content))
!(yaml_file? || !Utils.has_liquid_construct?(content))
end
# Determine whether the file should be rendered with a layout.
@@ -177,6 +206,16 @@ module Jekyll
!(asset_file? || yaml_file? || no_layout?)
end
# Returns the Boolean of whether this Page is HTML or not.
def html?
HTML_EXTENSIONS.include?(output_ext)
end
# Returns the Boolean of whether this Page is an index file or not.
def index?
basename_without_ext == "index"
end
# The URL template where the document would be accessible.
#
# Returns the URL template for the document.
@@ -224,7 +263,7 @@ module Jekyll
dest = site.in_dest_dir(base_directory)
path = site.in_dest_dir(dest, URL.unescape_path(url))
if url.end_with? "/"
path = File.join(path, "index.html")
path = File.join(path, "index#{output_ext}")
else
path << output_ext unless path.end_with? output_ext
end
@@ -262,7 +301,7 @@ module Jekyll
Jekyll.logger.debug "Reading:", relative_path
if yaml_file?
@data = SafeYAML.load_file(path)
@data = SafeYAML.load_file(absolute_path)
else
begin
merge_defaults
@@ -304,7 +343,7 @@ module Jekyll
def <=>(other)
return nil unless other.respond_to?(:data)
cmp = data["date"] <=> other.data["date"]
cmp = path <=> other.path if cmp.nil? || cmp.zero?
cmp = relative_path <=> other.relative_path if cmp.nil? || cmp.zero?
cmp
end
@@ -438,7 +477,7 @@ module Jekyll
end
def read_content(opts)
self.content = File.read(path, Utils.merged_file_read_opts(site, opts))
self.content = File.read(absolute_path, Utils.merged_file_read_opts(site, opts))
if content =~ YAML_FRONT_MATTER_REGEXP
self.content = $POSTMATCH
data_file = SafeYAML.load(Regexp.last_match(1))
@@ -455,9 +494,9 @@ module Jekyll
def handle_read_error(error)
if error.is_a? Psych::SyntaxError
Jekyll.logger.error "Error:", "YAML Exception reading #{path}: #{error.message}"
Jekyll.logger.error "Error:", "YAML Exception reading #{relative_path}: #{error.message}"
else
Jekyll.logger.error "Error:", "could not read file #{path}: #{error.message}"
Jekyll.logger.error "Error:", "could not read file #{relative_path}: #{error.message}"
end
if site.config["strict_front_matter"] || error.is_a?(Jekyll::Errors::FatalException)

View File

@@ -29,7 +29,7 @@ module Jekyll
end
def html_pages
@site_html_pages ||= @obj.pages.select do |page|
@site_html_pages ||= @obj.pages.docs.select do |page|
page.html? || page.url.end_with?("/")
end
end

View File

@@ -9,6 +9,7 @@ module Jekyll
def_delegator :@obj, :cleaned_relative_path, :path
def_delegator :@obj, :output_ext, :output_ext
def_delegator :@obj, :relative_path_without_basename
def collection
@obj.collection.label

View File

@@ -1,15 +1,13 @@
# frozen_string_literal: true
module Jekyll
class Page
include Convertible
class Page < Document
attr_writer :dir
attr_accessor :site, :pager
attr_accessor :name, :ext, :basename
attr_accessor :data, :content, :output
attr_accessor :pager
alias_method :extname, :ext
alias_method :ext, :extname
alias_method :name, :basename
alias_method :process, :read
# Attributes for Liquid templates
ATTRIBUTES_FOR_LIQUID = %w(
@@ -20,47 +18,39 @@ module Jekyll
url
).freeze
# A set of extensions that are considered HTML or HTML-like so we
# should not alter them, this includes .xhtml through XHTM5.
HTML_EXTENSIONS = %w(
.html
.xhtml
.htm
).freeze
# rubocop:disable Metrics/AbcSize
# Initialize a new Page.
#
# site - The Site object.
# base - The String path to the source.
# dir - The String path between the source and the file.
# name - The String filename of the file.
def initialize(site, base, dir, name)
@site = site
@base = base
@dir = dir
@name = name
@path = if site.in_theme_dir(base) == base # we're in a theme
site.in_theme_dir(base, dir, name)
else
site.in_source_dir(base, dir, name)
end
process(name)
read_yaml(File.join(base, dir), name)
data.default_proc = proc do |_, key|
site.frontmatter_defaults.find(File.join(dir, name), type, key)
def initialize(*args)
if args.size == 2 # Initialized as Document
super
elsif args.size == 4 # Legacy Page support
Jekyll::Deprecator.deprecation_message "Pages are now Documents."
Jekyll::Deprecator.deprecation_message "Called by #{caller(1..1).first}."
@site, @base, @dir, @name = args
@path = if site.in_theme_dir(@base) == @base # we're in a theme
site.in_theme_dir(@base, @dir, @name)
else
site.in_source_dir(@base, @dir, @name)
end
@relative_path = File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).sub(%r!\A\/!, "")
super(@path, :collection => site.pages, :site => @site)
read
backwards_compatibilize
else
raise ArugmentError, "Expected 2 or 4 arguments, #{args.size} given"
end
Jekyll::Hooks.trigger :pages, :post_init, self
end
# The generated directory into which the page will be placed
# upon generation. This is derived from the permalink or, if
# permalink is absent, will be '/'
#
# Returns the String destination directory.
# rubocop:enable Metrics/AbcSize
# Backwards compatible shim to return the generated directory into which
# the page will be placed upon generation. This is derived from the
# permalink or, if permalink is absent, will be '/'
def dir
if url.end_with?("/")
url
@@ -70,116 +60,45 @@ module Jekyll
end
end
# The full path and filename of the post. Defined in the YAML of the post
# body.
#
# Returns the String permalink or nil if none has been set.
def permalink
data.nil? ? nil : data["permalink"]
end
# The template of the permalink.
#
# Returns the template String.
def template
def url_template
if !html?
"/:path/:basename:output_ext"
"/:path:output_ext"
elsif index?
"/:path/"
"/:relative_path_without_basename/"
else
Utils.add_permalink_suffix("/:path/:basename", site.permalink_style)
Utils.add_permalink_suffix("/:path", site.permalink_style)
end
end
alias_method :template, :url_template
# The generated relative url of this page. e.g. /about.html.
#
# Returns the String url.
def url
@url ||= URL.new(
:template => template,
:placeholders => url_placeholders,
:permalink => permalink
).to_s
end
# Returns a hash of URL placeholder names (as symbols) mapping to the
# desired placeholder replacements. For details see "url.rb"
def url_placeholders
{
:path => @dir,
:basename => basename,
:output_ext => output_ext,
}
end
# Extract information from the page filename.
#
# name - The String filename of the page file.
#
# Returns nothing.
def process(name)
self.ext = File.extname(name)
self.basename = name[0..-ext.length - 1]
end
# Add any necessary layouts to this post
# Backwards compatible shim to add any necessary layouts to this post
#
# layouts - The Hash of {"name" => "layout"}.
# site_payload - The site payload Hash.
#
# Returns String rendered page.
def render(layouts, site_payload)
site_payload["page"] = to_liquid
site_payload["paginator"] = pager.to_liquid
do_layout(site_payload, layouts)
def render(_, site_payload = nil)
Jekyll::Renderer.new(site, self, site_payload).run
end
# The path to the source file
#
# Returns the path to the source file
# To maintain backwards compataiblity, path is relative for Pages
# but absolute for documents. Use #absolute_path to get the absolute path
def path
data.fetch("path") { relative_path }
Jekyll::Deprecator.deprecation_message "Page#path is now Page#relative_path."
Jekyll::Deprecator.deprecation_message "Called by #{caller(1..1).first}."
relative_path
end
# The path to the page source file, relative to the site source
def relative_path
File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).sub(%r!\A\/!, "")
end
private
# Obtain destination path.
#
# dest - The String path to the destination dir.
#
# Returns the destination file path String.
def destination(dest)
path = site.in_dest_dir(dest, URL.unescape_path(url))
path = File.join(path, "index") if url.end_with?("/")
path << output_ext unless path.end_with? output_ext
path
end
# Returns the object as a debug String.
def inspect
"#<Jekyll::Page @name=#{name.inspect}>"
end
# Returns the Boolean of whether this Page is HTML or not.
def html?
HTML_EXTENSIONS.include?(output_ext)
end
# Returns the Boolean of whether this Page is an index file or not.
def index?
basename == "index"
end
def trigger_hooks(hook_name, *args)
Jekyll::Hooks.trigger :pages, hook_name, self, *args
end
def write?
true
def backwards_compatibilize
ATTRIBUTES_FOR_LIQUID.each do |key|
data[key] = public_send(key.to_sym)
end
@url = nil
end
end
end

View File

@@ -14,5 +14,21 @@ module Jekyll
def inspect
"#<Jekyll:PageWithoutAFile @name=#{name.inspect}>"
end
def draft?
!!data["draft"]
end
def do_nothing(*)
nil
end
alias_method :process, :do_nothing
alias_method :read, :do_nothing
alias_method :read_content, :do_nothing
alias_method :read_post_data, :do_nothing
alias_method :categories_from_path, :do_nothing
alias_method :populate_categories, :do_nothing
alias_method :populate_tags, :do_nothing
alias_method :backwards_compatibilize, :do_nothing
end
end

View File

@@ -23,7 +23,6 @@ module Jekyll
# Sorts posts, pages, and static files.
def sort_files!
site.collections.each_value { |c| c.docs.sort! }
site.pages.sort_by!(&:name)
site.static_files.sort_by!(&:relative_path)
end
@@ -88,7 +87,7 @@ module Jekyll
#
# Returns nothing.
def retrieve_pages(dir, dot_pages)
site.pages.concat(PageReader.new(site, dir).read(dot_pages))
site.pages.docs.concat(PageReader.new(site, dir).read(dot_pages))
end
# Retrieve all the static files from the current directory,

View File

@@ -2,7 +2,7 @@
module Jekyll
class CollectionReader
SPECIAL_COLLECTIONS = %w(posts data).freeze
SPECIAL_COLLECTIONS = %w(posts data pages).freeze
attr_reader :site, :content
def initialize(site)

View File

@@ -17,9 +17,11 @@ module Jekyll
# Returns an array of static pages.
def read(files)
files.map do |page|
@unfiltered_content << Page.new(@site, @site.source, @dir, page)
end
@unfiltered_content.select { |page| site.publisher.publish?(page) }
path = File.join @site.source, @dir, page
doc = Page.new(path, :collection => site.pages, :site => site)
doc.read
doc if site.publisher.publish?(doc)
end.compact
end
end
end

View File

@@ -164,14 +164,14 @@ module Jekyll
def regenerate_page?(document)
document.asset_file? || document.data["regenerate"] ||
source_modified_or_dest_missing?(
site.in_source_dir(document.relative_path), document.destination(@site.dest)
document.absolute_path, document.destination(@site.dest)
)
end
def regenerate_document?(document)
!document.write? || document.data["regenerate"] ||
source_modified_or_dest_missing?(
document.path, document.destination(@site.dest)
document.absolute_path, document.destination(@site.dest)
)
end

View File

@@ -76,7 +76,7 @@ module Jekyll
output = document.content
if document.render_with_liquid?
Jekyll.logger.debug "Rendering Liquid:", document.relative_path
output = render_liquid(output, payload, info, document.path)
output = render_liquid(output, payload, info, document.relative_path)
end
Jekyll.logger.debug "Rendering Markup:", document.relative_path
@@ -203,7 +203,7 @@ module Jekyll
def add_regenerator_dependencies(layout)
return unless document.write?
site.regenerator.add_dependency(
site.in_source_dir(document.path),
site.in_source_dir(document.relative_path),
layout.path
)
end

View File

@@ -3,7 +3,7 @@
module Jekyll
class Site
attr_reader :source, :dest, :config
attr_accessor :layouts, :pages, :static_files, :drafts,
attr_accessor :layouts, :static_files, :drafts,
:exclude, :include, :lsi, :highlighter, :permalink_style,
:time, :future, :unpublished, :safe, :plugins, :limit_posts,
:show_drafts, :keep_files, :baseurl, :data, :file_read_opts,
@@ -88,7 +88,6 @@ module Jekyll
Time.now
end
self.layouts = {}
self.pages = []
self.static_files = []
self.data = {}
@site_data = nil
@@ -131,11 +130,18 @@ module Jekyll
# If config['collections'] is set, a new instance is created
# for each item in the collection, a new hash is returned otherwise.
#
# Note: For backwards compatibility, we want Pages to be the last
# collection to render so other documents have output at render time
#
# Returns a Hash containing collection name-to-instance pairs.
def collections
@collections ||= Hash[collection_names.map do |coll|
[coll, Jekyll::Collection.new(self, coll)]
end]
@collections ||= begin
collections = Hash[collection_names.map do |coll|
[coll, Jekyll::Collection.new(self, coll)]
end]
collections["pages"] = collections.delete("pages")
collections
end
end
# The list of collection names.
@@ -187,7 +193,6 @@ module Jekyll
Jekyll::Hooks.trigger :site, :pre_render, self, payload
render_docs(payload)
render_pages(payload)
Jekyll::Hooks.trigger :site, :post_render, self, payload
end
@@ -214,6 +219,10 @@ module Jekyll
collections["posts"] ||= Collection.new(self, "posts")
end
def pages
collections["pages"] ||= Collection.new(self, "pages")
end
# Construct a Hash of Posts indexed by the specified Post attribute.
#
# post_attr - The String name of the Post attribute.
@@ -325,7 +334,7 @@ module Jekyll
end
def each_site_file
%w(pages static_files docs_to_write).each do |type|
%w(static_files docs_to_write).each do |type|
send(type).each do |item|
yield item
end
@@ -459,12 +468,6 @@ module Jekyll
end
end
def render_pages(payload)
pages.flatten.each do |page|
render_regenerated(page, payload)
end
end
def render_regenerated(document, payload)
return unless regenerator.regenerate?(document)
document.output = Jekyll::Renderer.new(self, document, payload).run

View File

@@ -19,6 +19,9 @@ def site_configuration(overrides = {})
"source" => source_dir,
"destination" => dest_dir
}, build_configs(overrides))
.fix_common_issues
.backwards_compatibilize
.add_default_collections
end
def dest_dir(*subdirs)

View File

@@ -27,13 +27,16 @@ class TestConfiguration < JekyllUnitTest
should "add default collections" do
result = Configuration.from({})
assert_equal(
result["collections"],
{
"posts" => {
"output" => true,
"permalink" => "/:categories/:year/:month/:day/:title:output_ext",
},
}
"pages" => {
"output" => true,
}
},
result["collections"],
)
end
@@ -72,7 +75,15 @@ class TestConfiguration < JekyllUnitTest
assert_instance_of Hash, result["collections"]
assert_equal(
result["collections"],
{ "posts" => { "output" => true }, "methods" => {} }
{
"posts" => {
"output" => true
},
"pages" => {
"output" => true
},
"methods" => {}
}
)
end
@@ -86,12 +97,25 @@ class TestConfiguration < JekyllUnitTest
"output" => true,
"permalink" => "/:categories/:year/:month/:day/:title/",
},
"pages" => {
"output" => true
}
}
)
result = Configuration[{ "permalink" => nil, "collections" => {} }]
.add_default_collections
assert_equal result["collections"], { "posts" => { "output" => true } }
assert_equal(
result["collections"],
{
"posts" => {
"output" => true
},
"pages" => {
"output" => true
}
}
)
end
should "forces posts to output" do
@@ -439,11 +463,14 @@ class TestConfiguration < JekyllUnitTest
end
assert_equal conf.add_default_collections, conf.merge({
"collections" => {
"docs" => {},
"posts" => {
"output" => true,
"permalink" => "/:categories/:year/:month/:day/:title:output_ext",
},
"pages" => {
"output" => true,
},
"docs" => {},
},
})
end
@@ -458,6 +485,9 @@ class TestConfiguration < JekyllUnitTest
"output" => true,
"permalink" => "/:categories/:year/:month/:day/:title:output_ext",
},
"pages" => {
"output" => true
},
},
})
end
@@ -470,24 +500,27 @@ class TestConfiguration < JekyllUnitTest
"output" => true,
"permalink" => "/:categories/:year/:month/:day/:title:output_ext",
},
"pages" => {
"output" => true
},
},
})
end
should "leave collections.posts.permalink alone if it is set" do
posts_permalink = "/:year/:title/"
conf = Configuration[default_configuration].tap do |c|
c["collections"] = {
"posts" => { "permalink" => posts_permalink },
}
end
conf = Configuration[default_configuration]
conf["collections"]["posts"] = { "permalink" => posts_permalink }
assert_equal conf.add_default_collections, conf.merge({
"collections" => {
"posts" => {
"output" => true,
"permalink" => posts_permalink,
"output" => true,
},
},
"pages" => {
"output" => true
}
}
})
end
end

View File

@@ -66,7 +66,7 @@ class TestPage < JekyllUnitTest
@page = setup_page("dynamic_page.php")
@dest_file = dest_dir("dynamic_page.php")
assert_equal ".php", @page.ext
assert_equal "dynamic_page", @page.basename
assert_equal "dynamic_page", @page.basename_without_ext
assert_equal "/dynamic_page.php", @page.url
assert_equal @dest_file, @page.destination(dest_dir)
end
@@ -75,7 +75,7 @@ class TestPage < JekyllUnitTest
@page = setup_page("deal.with.dots.html")
@dest_file = dest_dir("deal.with.dots.html")
assert_equal "deal.with.dots", @page.basename
assert_equal "deal.with.dots", @page.basename_without_ext
assert_equal @dest_file, @page.destination(dest_dir)
end
@@ -84,7 +84,7 @@ class TestPage < JekyllUnitTest
attrs = {
:content => "All the properties.\n",
:dir => "/properties/",
:excerpt => nil,
# :excerpt => nil,
:foo => "bar",
:layout => "default",
:name => "properties.html",

View File

@@ -34,7 +34,7 @@ class TestPageWithoutAFile < JekyllUnitTest
end
should "not have page-content and page-data defined within it" do
assert_equal "pages", @page.type.to_s
assert_equal "pages", @page.collection.label.to_s
assert_nil @page.content
assert_empty @page.data
end

View File

@@ -214,32 +214,34 @@ class TestSite < JekyllUnitTest
# exclude files in symlinked directories here and insert them in the
# following step when not on Windows.
sorted_pages = %w(
%#\ +.md
+/%#\ +.md
+/foo.md
.htaccess
about.html
application.coffee
bar.html
coffeescript.coffee
assets/application.coffee
contacts.html
contacts/bar.html
contacts/humans.txt
contacts/index.html
css/main.scss
deal.with.dots.html
dynamic_file.php
environment.html
exploit.md
foo.md
humans.txt
index.html
index.html
info.md
main.scss
js/coffeescript.coffee
properties.html
sitemap.xml
static_files.html
symlink-test/symlinked-dir/main.scss
symlink-test/symlinked-file
)
unless Utils::Platforms.really_windows?
# files in symlinked directories may appear twice
sorted_pages.push("main.scss", "symlinked-file").sort!
end
assert_equal sorted_pages, @site.pages.map(&:name)
assert_equal sorted_pages, @site.pages.docs.map(&:relative_path)
end
should "read posts" do