Skip to content

@gugu /staticurl.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
sass-staticurl-plugin
require "rubypython"
ENV["DJANGO_SETTINGS_MODULE"] = "settings"
ENV["PYTHONPATH"] = "."
RubyPython.start(:python_exe => ENV["PYTHON_EXECUTABLE_NAME"])
RubyPython.import('imp').load_source("activate_this",File.join(File.dirname(RubyPython::Runtime.python), "activate_this.py"))
$versioning = RubyPython.import("staticutils.versioning")
$settings = RubyPython.import("django.conf").settings
$storage = RubyPython.import("django.core.files.storage")
$fs_storage = $storage.FileSystemStorage(location=$settings.VERSIONED_STATIC_ROOT)
module Sass::Script::Functions
def staticurl(url)
assert_type url, :String
path, hash = url.value.split('#')
version = $versioning.get_file_version(path, $fs_storage)
prefixed_path = $versioning.get_versioned_path(path, version)
Sass::Script::String.new('url(/static/' + prefixed_path.rubify + (hash ? '#' + hash : '') + ')')
end
declare :staticurl, :args => [:string]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.