Merge pull request #2075 from jekyll/expose-static-files
This commit is contained in:
commit
27be7e2e6a
|
@ -310,6 +310,7 @@ module Jekyll
|
|||
"time" => self.time,
|
||||
"posts" => self.posts.sort { |a, b| b <=> a },
|
||||
"pages" => self.pages,
|
||||
"static_files" => self.static_files.sort { |a, b| a.relative_path <=> b.relative_path },
|
||||
"html_pages" => self.pages.reject { |page| !page.html? },
|
||||
"categories" => post_attr_hash('categories'),
|
||||
"tags" => post_attr_hash('tags'),
|
||||
|
|
|
@ -21,6 +21,11 @@ module Jekyll
|
|||
File.join(@base, @dir, @name)
|
||||
end
|
||||
|
||||
# Returns the source file path relative to the site source
|
||||
def relative_path
|
||||
@relative_path ||= path.sub(/\A#{@site.source}/, '')
|
||||
end
|
||||
|
||||
# Obtain destination path.
|
||||
#
|
||||
# dest - The String path to the destination dir.
|
||||
|
@ -66,5 +71,13 @@ module Jekyll
|
|||
@@mtimes = Hash.new
|
||||
nil
|
||||
end
|
||||
|
||||
def to_liquid
|
||||
{
|
||||
"path" => relative_path,
|
||||
"modified_time" => mtime.to_s,
|
||||
"extname" => File.extname(relative_path)
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -112,6 +112,16 @@ following is a reference of the available data.
|
|||
|
||||
</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p><code>site.static_files</code></p></td>
|
||||
<td><p>
|
||||
|
||||
A list of all static files (i.e. files not processed by Jekyll's
|
||||
converters or the Liquid renderer). Each file has two properties:
|
||||
<code>path</code>, <code>modified_time</code> and <code>extname</code>.
|
||||
|
||||
</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p><code>site.categories.CATEGORY</code></p></td>
|
||||
<td><p>
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
---
|
||||
{% for file in site.static_files %}
|
||||
- {{ file.path }} last edited at {{ file.modified_time }} with extname {{ file.extname }}{% endfor %}
|
|
@ -131,7 +131,7 @@ class TestFilters < Test::Unit::TestCase
|
|||
assert_equal 2, g["items"].size
|
||||
when ""
|
||||
assert g["items"].is_a?(Array), "The list of grouped items for '' is not an Array."
|
||||
assert_equal 9, g["items"].size
|
||||
assert_equal 10, g["items"].size
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,6 +44,15 @@ class TestGeneratedSite < Test::Unit::TestCase
|
|||
assert File.exists?(dest_dir('/about/index.html'))
|
||||
assert File.exists?(dest_dir('/contacts.html'))
|
||||
end
|
||||
|
||||
should "print a nice list of static files" do
|
||||
expected_output = Regexp.new <<-OUTPUT
|
||||
- /css/screen.css last edited at \\d+ with extname .css
|
||||
- /products.yml last edited at \\d+ with extname .yml
|
||||
- /symlink-test/symlinked-dir/screen.css last edited at \\d+ with extname .css
|
||||
OUTPUT
|
||||
assert_match expected_output, File.read(dest_dir('static_files.html'))
|
||||
end
|
||||
end
|
||||
|
||||
context "generating limited posts" do
|
||||
|
|
|
@ -158,7 +158,24 @@ class TestSite < Test::Unit::TestCase
|
|||
stub.proxy(Dir).entries { |entries| entries.reverse }
|
||||
@site.process
|
||||
# files in symlinked directories may appear twice
|
||||
sorted_pages = %w(.htaccess about.html bar.html coffeescript.coffee contacts.html deal.with.dots.html exploit.md foo.md index.html index.html main.scss main.scss properties.html sitemap.xml symlinked-file)
|
||||
sorted_pages = %w(
|
||||
.htaccess
|
||||
about.html
|
||||
bar.html
|
||||
coffeescript.coffee
|
||||
contacts.html
|
||||
deal.with.dots.html
|
||||
exploit.md
|
||||
foo.md
|
||||
index.html
|
||||
index.html
|
||||
main.scss
|
||||
main.scss
|
||||
properties.html
|
||||
sitemap.xml
|
||||
static_files.html
|
||||
symlinked-file
|
||||
)
|
||||
assert_equal sorted_pages, @site.pages.map(&:name)
|
||||
end
|
||||
|
||||
|
@ -169,6 +186,14 @@ class TestSite < Test::Unit::TestCase
|
|||
assert_equal posts.size - @num_invalid_posts, @site.posts.size
|
||||
end
|
||||
|
||||
should "expose jekyll version to site payload" do
|
||||
assert_equal Jekyll::VERSION, @site.site_payload['jekyll']['version']
|
||||
end
|
||||
|
||||
should "expose list of static files to site payload" do
|
||||
assert_equal @site.static_files, @site.site_payload['site']['static_files']
|
||||
end
|
||||
|
||||
should "deploy payload" do
|
||||
clear_dest
|
||||
@site.process
|
||||
|
|
Loading…
Reference in New Issue