10000 Backport #5871 for v3.4.x: Convert StaticFile liquid representation to a Drop & add front matter defaults support to StaticFiles by parkr · Pull Request #5940 · jekyll/jekyll · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Backport #5871 for v3.4.x: Convert StaticFile liquid representation to a Drop & add front matter defaults support to StaticFiles #5940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions History.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.4.1 / 2017-03-02

* Backport #5920 for v3.4.x: Allow abbreviated post dates (#5924)

## 3.4.0 / 2016-01-27

### Minor Enhancements
Expand Down
6 changes: 6 additions & 0 deletions docs/_docs/history.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ permalink: "/docs/history/"
note: This file is autogenerated. Edit /History.markdown instead.
---

## 3.4.1 / 2017-03-02
{: #v3-4-1}

- Backport [#5920]({{ site.repository }}/issues/5920) for v3.4.x: Allow abbreviated post dates ([#5924]({{ site.repository }}/issues/5924))


## 3.4.0 / 2016-01-27
{: #v3-4-0}

Expand Down
2 changes: 1 addition & 1 deletion docs/latest_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.0
3.4.1
11 changes: 11 additions & 0 deletions lib/jekyll/drops/static_file_drop.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Jekyll
module Drops
class StaticFileDrop < Drop
extend Forwardable
def_delegators :@obj, :name, :extname, :modified_time, :basename
def_delegator :@obj, :relative_path, :path
def_delegator :@obj, :data, :fallback_data
def_delegator :@obj, :type, :collection
end
end
end
20 changes: 13 additions & 7 deletions lib/jekyll/static_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def initialize(site, base, dir, name, collection = nil)
@collection = collection
@relative_path = File.join(*[@dir, @name].compact)
@extname = File.extname(@name)

data.default_proc = proc do |_, key|
site.frontmatter_defaults.find(relative_path, type, key)
end
end
# rubocop: enable ParameterLists

Expand Down Expand Up @@ -96,13 +100,15 @@ def write(dest)
end

def to_liquid
{
"basename" => File.basename(name, extname),
"name" => name,
"extname" => extname,
"modified_time" => modified_time,
"path" => File.join("", relative_path),
}
@to_liquid ||= Drops::StaticFileDrop.new(self)
end

def data
@data ||= {}
end

def basename
File.basename(name, extname)
end

def placeholders
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Jekyll
VERSION = "3.4.0".freeze
VERSION = "3.4.1".freeze
end
3 changes: 2 additions & 1 deletion test/test_static_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ def setup_static_file_with_defaults(base, dir, name, defaults)
"extname" => ".txt",
"modified_time" => @static_file.modified_time,
"path" => "/static_file.txt",
"collection" => nil
}
assert_equal expected, @static_file.to_liquid
assert_equal expected, @static_file.to_liquid.to_h
end
end
end
0