Coder Social home page Coder Social logo

asset_id's People

Contributors

moomerman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

asset_id's Issues

asset_id depends on mime-types >= 1.16

I'm preparing mime-types 2.0 for release, and it has some breaking API changes (not for most uses, but some esoteric features). The most important API change is that mime-types 2.0 no longer supports Ruby 1.8.

If this matters, the gemspec needs to be changed from >= 1.16 to ~> 1.16.

fixed - timestamp problem on changing url in css

I use a sprite plugin that appends the timestamp to the url in css:

url(/images/logo.png?194819891)

So if you just add url = url.split("?")[0], to the following method, it works great!

def replace_css_images!(options={})
  options[:prefix] ||= ''
  # adapted from https://github.com/blakink/asset_id
  data.gsub! /url\((?:"([^"]*)"|'([^']*)'|([^)]*))\)/mi do |match|
    begin
      # $1 is the double quoted string, $2 is single quoted, $3 is no quotes
      uri = ($1 || $2 || $3).to_s.strip
      uri.gsub!(/^\.\.\//, '/')

      # if the uri appears to begin with a protocol then the asset isn't on the local filesystem
      if uri =~ /[a-z]+:\/\//i
        "url(#{uri})"
      else
        url = url.split("?")[0]
        asset = Asset.new(uri)
        # TODO: Check the referenced asset is in the asset_paths
        puts "  - Changing CSS URI #{uri} to #{options[:prefix]}#{asset.fingerprint}" if @@debug
        "url(#{options[:prefix]}#{asset.fingerprint})"
      end
    rescue Errno::ENOENT => e
      puts "  - Warning: #{uri} not found" if @@debug
      "url(#{uri})"
    end
  end
end

Customisable s3 cred yaml file

It would be ideal if one could specify the location of the yml file holding the credentials for S3 to keep things DRY.

How to handle CSS url()

Hey, have you any good way to set a file path e.g. in CSS with url()...
I can hardcode url(http://static.host.com/images/pic.jpg) but then in development mode, maybe when I'm offline, I have the trouble.
And I think it's a stupid way to hardcode the full host address.
Maybe I will change the domain in the future and so on.

Daniel

Check for existing asset before uploading

Since asset_id inserts an md5 hash into the filename of each asset uploaded, wouldn't it be faster to check on s3 for the presence of the file before reuploading every resource every time?

compatibility with compass

Hi. first of all, thanks for putting asset_id together, it's very handy.

My project uses compass/sass, so I need to modify the output of the compass image-url method. compass has it's own asset_host specification system, it doesn't cleverly inherit from rails or anything.

Was just wondering if you've used asset_id with compass and how you achieved that. If not, I'll let you know what I put together.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.