Sha256: 5b9309377ef7d294f751bca940d0a0fa226f13be21f4c66235c22d19a32f1431

Contents?: true

Size: 1.85 KB

Versions: 4

Compression:

Stored size: 1.85 KB

Contents

# stdlib
require 'ostruct'


module Jekyll
  module AssetsPlugin
    # Plugin configuration class.
    #
    #
    # ##### sources
    #
    # Pathnames where to find assets relative to the root of the site.
    #
    # Default: ['_assets/javascripts', '_assets/stylesheets', '_assets/images']
    #
    #
    # ##### compress
    #
    # Sets compressors for the specific types of file: `js`, or `css`.
    #
    # Possible variants:
    #
    #     css  => 'yui', 'sass', nil
    #     js   => 'yui', 'uglifier', nil
    #
    # Default: { 'css' => nil, 'js' => nil } (no compression at all)
    #
    #
    # ##### dirname
    #
    # Pathname of the destination of generated (bundled) assets relative to the
    # destination of the root.
    #
    # Default: 'assets'
    #
    #
    # ##### baseurl
    #
    # Base URL for assets paths. By default equals dirname surrunded with
    # slashes. You ight want to change it if your blog has baseurl configuration
    # and served not from the root of the server, or if you want to keep your
    # assets on CDN.
    #
    class Configuration < OpenStruct
      @@defaults = {
        :dirname  => 'assets',
        :sources  => %w{_assets/javascripts _assets/stylesheets _assets/images},
        :compress => { :css => nil, :js => nil }
      }

      def initialize config = {}
        super @@defaults.merge(config)

        self.sources  = [ self.sources ] if self.sources.is_a? String
        self.compress = OpenStruct.new(self.compress)
        self.dirname  = self.dirname.gsub(/^\/+|\/+$/, '')

        # if baseurl not given - autoguess base on dirname
        self.baseurl ||= "/#{self.dirname}/".squeeze '/'
      end

      def js_compressor
        return compress.js.to_sym if compress.js
        false
      end

      def css_compressor
        return compress.css.to_sym if compress.css
        false
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jekyll-assets-0.2.3 lib/jekyll/assets_plugin/configuration.rb
jekyll-assets-0.2.2 lib/jekyll/assets_plugin/configuration.rb
jekyll-assets-0.2.1 lib/jekyll/assets_plugin/configuration.rb
jekyll-assets-0.2.0 lib/jekyll/assets_plugin/configuration.rb