diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index ed55598f..b39041e6 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -307,13 +307,14 @@ module Jekyll def site_payload {"jekyll" => { "version" => Jekyll::VERSION }, "site" => self.config.merge({ - "time" => self.time, - "posts" => self.posts.sort { |a, b| b <=> a }, - "pages" => self.pages, - "html_pages" => self.pages.reject { |page| !page.html? }, - "categories" => post_attr_hash('categories'), - "tags" => post_attr_hash('tags'), - "data" => site_data})} + "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'), + "data" => site_data})} end # Filter out any files/directories that are hidden or backup files (start diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index 3d863ca7..dba66739 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -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 diff --git a/site/docs/variables.md b/site/docs/variables.md index 96578311..32b96693 100644 --- a/site/docs/variables.md +++ b/site/docs/variables.md @@ -112,6 +112,16 @@ following is a reference of the available data.
+site.static_files
+
+ A list of all static files (i.e. files not processed by Jekyll's
+ converters or the Liquid renderer). Each file has two properties:
+ path
, modified_time
and extname
.
+
+
site.categories.CATEGORY
diff --git a/test/source/static_files.html b/test/source/static_files.html new file mode 100644 index 00000000..878b7ebe --- /dev/null +++ b/test/source/static_files.html @@ -0,0 +1,4 @@ +--- +--- +{% for file in site.static_files %} +- {{ file.path }} last edited at {{ file.modified_time }} with extname {{ file.extname }}{% endfor %} diff --git a/test/test_filters.rb b/test/test_filters.rb index 1959e6f9..9a514229 100644 --- a/test/test_filters.rb +++ b/test/test_filters.rb @@ -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 diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index ea20a15f..5059dd12 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -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 diff --git a/test/test_site.rb b/test/test_site.rb index 7e593c86..c7ba23f9 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -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