Sha256: 6a08d1c6c7f5f61a81286eb6bd547251dfb23659a1bb85728b92894d376ae3fa

Contents?: true

Size: 1.85 KB

Versions: 2

Compression:

Stored size: 1.85 KB

Contents

module Octopress
  module Ink
    module Assets
      class Sass < Stylesheet
        def initialize(plugin, type, file, media)
          @plugin = plugin
          @type = type
          @file = file
          @media = media || 'all'
          @root = plugin.assets_path
          @dir = File.join(plugin.slug, type)
          @exists = {}
          file_check
        end

        def tag
          "<link href='#{Filters.expand_url(File.join(@dir, @file))}' media='#{media}' rel='stylesheet' type='text/css'>"
        end

        # TODO: see if this is done TODO: choose user path before local path.
        def user_load_path
          File.join(Plugins.site.source, Plugins.custom_dir, @dir, File.dirname(@file)).sub /\/\.$/, ''
        end

        def theme_load_path
          File.expand_path(File.join(@root, @type))
        end

        def compile
          unless @compiled
            options = Plugins.sass_options
            if @plugin.type == 'local_plugin'
              @compiled = Plugins.compile_sass_file(path.to_s, options)
            else
              # If the plugin isn't a local plugin, add source paths to allow overrieds on @imports.
              #
              options[:load_paths] = [user_load_path, theme_load_path]
              @compiled = Plugins.compile_sass(path.read, options)
            end
          end
          @compiled
        end

        def user_override_path
          # Allow Sass overrides to use either syntax
          if @file =~ /s[ac]ss$/
            [File.join(user_dir, @file), File.join(user_dir, alt_syntax_file)]
          else
            File.join user_dir, @file
          end
        end

        def destination
          File.join(@dir, @file.sub(/s.ss/, 'css'))
        end

        def copy
          Plugins.site.static_files << StaticFileContent.new(compile, destination)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
octopress-ink-1.0.0.alpha.33 lib/octopress-ink/assets/sass.rb
octopress-ink-1.0.0.alpha.32 lib/octopress-ink/assets/sass.rb