Fix asset paths in partials
This commit is contained in:
parent
b14ef9be32
commit
9ffbaa101c
@ -1,5 +1,5 @@
|
|||||||
Gem::Specification.new do |spec|
|
Gem::Specification.new do |spec|
|
||||||
spec.version = "0.1.2"
|
spec.version = "0.1.3"
|
||||||
spec.homepage = "http://github.com/abemedia/jekyll-pdf/"
|
spec.homepage = "http://github.com/abemedia/jekyll-pdf/"
|
||||||
spec.authors = ["Adam Bouqdib"]
|
spec.authors = ["Adam Bouqdib"]
|
||||||
spec.email = ["adam@abemedia.co.uk"]
|
spec.email = ["adam@abemedia.co.uk"]
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
try_require "jekyll-assets" do
|
try_require "jekyll-assets" do
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
module PDF
|
module PDF
|
||||||
class AssetsTag < Jekyll::Assets::Liquid::Tag
|
class AssetsTag < Jekyll::Assets::Liquid::Tag
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# Tags that we allow our users to use.
|
# Tags that we allow our users to use.
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
@ -18,29 +18,29 @@ try_require "jekyll-assets" do
|
|||||||
pdf_css
|
pdf_css
|
||||||
pdf_js
|
pdf_js
|
||||||
).freeze
|
).freeze
|
||||||
|
|
||||||
def initialize(tag, args, tokens)
|
def initialize(tag, args, tokens)
|
||||||
tag = tag.to_s.sub!("pdf_", "")
|
tag = tag.to_s.sub!("pdf_", "")
|
||||||
super(tag, args, tokens)
|
super(tag, args, tokens)
|
||||||
end
|
end
|
||||||
|
|
||||||
def render(context)
|
def render(context)
|
||||||
@path_prefix = "file://" + context.registers[:site].dest
|
@path_prefix = "file://" + context.registers[:site].dest
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def build_html(args, sprockets, asset, path = get_path(sprockets, asset))
|
def build_html(args, sprockets, asset, path = get_path(sprockets, asset))
|
||||||
data = @path_prefix + (args.key?(:data) && args[:data].key?(:uri) ? asset.data_uri : path)
|
data = @path_prefix + (args.key?(:data) && args[:data].key?(:uri) ? asset.data_uri : path)
|
||||||
format(Jekyll::Assets::Liquid::Tag::Tags[@tag], data, args.to_html)
|
format(Jekyll::Assets::Liquid::Tag::Tags[@tag], data, args.to_html)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Jekyll::PDF::AssetsTag::AcceptableTags.each do |tag|
|
Jekyll::PDF::AssetsTag::AcceptableTags.each do |tag|
|
||||||
Liquid::Template.register_tag tag, Jekyll::PDF::AssetsTag
|
Liquid::Template.register_tag tag, Jekyll::PDF::AssetsTag
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -5,6 +5,7 @@ module Jekyll
|
|||||||
module PDF
|
module PDF
|
||||||
class Partial
|
class Partial
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
|
include Helper
|
||||||
|
|
||||||
attr_accessor :doc
|
attr_accessor :doc
|
||||||
attr_accessor :partial
|
attr_accessor :partial
|
||||||
@ -76,6 +77,7 @@ module Jekyll
|
|||||||
tempfile = File.absolute_path(File.join(dir, id))
|
tempfile = File.absolute_path(File.join(dir, id))
|
||||||
unless File.exist?(tempfile)
|
unless File.exist?(tempfile)
|
||||||
FileUtils.mkdir_p(File.dirname(tempfile)) unless File.exist?(File.dirname(tempfile))
|
FileUtils.mkdir_p(File.dirname(tempfile)) unless File.exist?(File.dirname(tempfile))
|
||||||
|
fix_relative_paths
|
||||||
File.open(tempfile, 'w') {|f| f.write(to_s) }
|
File.open(tempfile, 'w') {|f| f.write(to_s) }
|
||||||
end
|
end
|
||||||
@output = tempfile
|
@output = tempfile
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user