Fixed grab_images handling.
This commit is contained in:
parent
0f51c81cfa
commit
886b9740f2
|
@ -10,6 +10,7 @@ module Jekyll
|
||||||
module Tumblr
|
module Tumblr
|
||||||
def self.process(url, format = "html", grab_images = false,
|
def self.process(url, format = "html", grab_images = false,
|
||||||
add_highlights = false, rewrite_urls = true)
|
add_highlights = false, rewrite_urls = true)
|
||||||
|
@grab_images = grab_images
|
||||||
FileUtils.mkdir_p "_posts/tumblr"
|
FileUtils.mkdir_p "_posts/tumblr"
|
||||||
url += "/api/read/json/"
|
url += "/api/read/json/"
|
||||||
per_page = 50
|
per_page = 50
|
||||||
|
@ -55,7 +56,7 @@ module Jekyll
|
||||||
end
|
end
|
||||||
when "photo"
|
when "photo"
|
||||||
title = post["photo-caption"]
|
title = post["photo-caption"]
|
||||||
content = "<img src=\"#{save_file(post["photo-url"], grab_images)}\"/>"
|
content = "<img src=\"#{save_file(post["photo-url"])}\"/>"
|
||||||
unless post["photo-link-url"].nil?
|
unless post["photo-link-url"].nil?
|
||||||
content = "<a href=\"#{post["photo-link-url"]}\">#{content}</a>"
|
content = "<a href=\"#{post["photo-link-url"]}\">#{content}</a>"
|
||||||
end
|
end
|
||||||
|
@ -170,16 +171,15 @@ module Jekyll
|
||||||
lines.join("\n")
|
lines.join("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.save_file(url, grab_image = false)
|
def self.save_file(url)
|
||||||
unless grab_image == false
|
if @grab_images
|
||||||
FileUtils.mkdir_p "tumblr_files"
|
FileUtils.mkdir_p "tumblr_files"
|
||||||
File.open("tumblr_files/#{url.split('/').last}", "w") do |f|
|
File.open("tumblr_files/#{url.split('/').last}", "w") do |f|
|
||||||
f.write(open(url).read)
|
f.write(open(url).read)
|
||||||
end
|
end
|
||||||
return "/tumblr_files/#{url.split('/').last}"
|
url = "/tumblr_files/#{url.split('/').last}"
|
||||||
else
|
|
||||||
return url
|
|
||||||
end
|
end
|
||||||
|
url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue