Sha256: 4221cd118d5a689b3103cb385174620360cea2b1cdf13971c6cb35db931d69c8
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
module Middleman module AutomaticClowncar class ThumbnailResource < ::Middleman::Sitemap::Resource require 'mini_magick' attr_accessor :output def initialize(store, path, dimensions, origin, root_path, build_dir, source_dir) @dimensions = dimensions @origin = origin @root_path = root_path @build_dir = build_dir @source_dir = source_dir super(store, path) end def template? false end def source_file nil end #def source_file #output_dir = File.join(@root_path,@build_dir) #dest_path = File.join(output_dir,@path) #source_path = File.join(@root_path,@source_dir) #if Utils.timestamp_current?(@source_dir,@build_dir,@origin) && File.exist?(dest_path) #File.join(@build_dir,@path) #else #@origin #end #end def render(*args, &block) output_dir = File.join(@root_path,@build_dir) dest_path = File.join(output_dir,@path) source_path = File.join(@source_dir,@origin) img = nil if Utils.timestamp_current?(@source_dir,@build_dir,@origin) && File.exist?(dest_path) img = MiniMagick::Image.open(dest_path) else img = MiniMagick::Image.open(@origin) img.resize(@dimensions) unless @dimensions.blank? end img.to_blob end # def request_path # @request_path # end def binary? false end def raw_data {} end def ignored? false end def metadata @local_metadata.dup end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
middleman-automatic-clowncar-0.0.4 | lib/middleman-automatic-clowncar/thumbnail-resource.rb |
middleman-automatic-clowncar-0.0.3 | lib/middleman-automatic-clowncar/thumbnail-resource.rb |