Sha256: ac178d311f30e5bb2c263e11e8e8409498384f46aab8bb1924e8ed7177cbea66

Contents?: true

Size: 1.93 KB

Versions: 10

Compression:

Stored size: 1.93 KB

Contents

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

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

        def read
          @compiled ||= compile
        end

        def add
          unless file =~ /^_/
            Plugins.add_css_tag tag
            Plugins.static_files << StaticFileContent.new(read, destination)
          end
        end

        def content
          render
        end

        def ext
          path.extname
        end

        def load_paths
          [user_load_path, theme_load_path]
        end

        def disabled?
          is_disabled('sass', filename) || is_disabled('stylesheets', filename)
        end

        private

        def compile
          PluginAssetPipeline.compile_sass(self)
        end

        def user_load_path
          File.join(Ink.site.source, Plugins.custom_dir, dir, File.dirname(file)).sub /\/\.$/, ''
        end

        def theme_load_path
          File.expand_path(File.join(root, base))
        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 alt_syntax_file
          ext = File.extname(file)
          alt_ext = (ext == '.scss' ? '.sass' : '.scss')
          file.sub(ext, alt_ext)
        end

        def destination
          File.join(base, plugin.slug, file.sub(/@(.+?)\./,'.').sub(/s.ss/, 'css'))
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
octopress-ink-1.0.0.rc.11 lib/octopress-ink/assets/sass.rb
octopress-ink-1.0.0.rc.10 lib/octopress-ink/assets/sass.rb
octopress-ink-1.0.0.rc.9 lib/octopress-ink/assets/sass.rb
octopress-ink-1.0.0.rc.8 lib/octopress-ink/assets/sass.rb
octopress-ink-1.0.0.rc.7 lib/octopress-ink/assets/sass.rb
octopress-ink-1.0.0.rc.6 lib/octopress-ink/assets/sass.rb
octopress-ink-1.0.0.rc.5 lib/octopress-ink/assets/sass.rb
octopress-ink-1.0.0.rc.3 lib/octopress-ink/assets/sass.rb
octopress-ink-1.0.0.rc.2 lib/octopress-ink/assets/sass.rb
octopress-ink-1.0.0.rc.1 lib/octopress-ink/assets/sass.rb