Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Rails plugin for uploading images as resources, with support for resizing, text stamping, and other special effects. Working with RAILS 3 - need to remove warning on rmagick and mimetype
Ruby
branch: master

This branch is 28 commits behind tvdeyen:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
CHANGELOG.rdoc
MIT-LICENSE
README.rdoc
Rakefile
VERSION
autotest.rb
init.rb
tvdeyen-fleximage.gemspec

README.rdoc

For all istructions refers to git://github.com/Squeegy/fleximage. I add a rails3_view.rb to manage template in rails3.

#rails3_view.rb

module ActionView

module TemplateHandlers
  class Rails3View < TemplateHandler
    include Compilable
    class TemplateDidNotReturnImage < RuntimeError #:nodoc:
    end

    def compile(template)
      <<-CODE
      @template_format = :flexi
      controller.response.content_type ||= Mime::JPG    
      result = #{template.source}
      requested_format = (params[:format] || :jpg).to_sym
      begin
        # Raise an error if object returned from template is not an image record
        unless result.class.include?(Fleximage::Model::InstanceMethods)
          raise TemplateDidNotReturnImage, ".flexi template was expected to return a model instance that acts_as_fleximage, but got an instance of instead."
        end
        # Figure out the proper format
        raise 'Image must be requested with an image type format.  jpg, gif and png only are supported.' unless [:jpg, :gif, :png].include?(requested_format)
        result.output_image(:format => requested_format)
      rescue Exception => e
        e
      end
      CODE
    ensure
      GC.start
    end
  end
end

end

Something went wrong with that request. Please try again.