Sha256: 226f2cdd706c04a4f6948b86371f8824c9e6043ee5b9942147ac537e2483d07d

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

# Frozen-string-literal: true
# Copyright: 2012 - 2017 - MIT License
# Encoding: utf-8

require "jekyll/assets"

module Jekyll
  module Assets
    class Default
      class Video < Default
        content_types "video/avi"
        content_types "video/webm"
        content_types "video/mp4"

        # --
        def set_src
          dpath = asset.digest_path
          return args[:src] = asset.url if asset.is_a?(Url)
          return args[:src] = env.prefix_url(dpath) unless args[:inline]
          # This is insanity, but who am I to judge you, and what you do.
          args[:src] = asset.data_uri
        end

        # --
        def set_controls
          return if args.key?(:controls)

          args[:controls] = true
          unless args.key?(:controlsList) || args.key?(:controlslist)
            args[:controlList] = "nodownload"
          end
        end

        # --
        def set_integrity
          return unless integrity?

          args[:integrity] = asset.integrity
          unless args.key?(:crossorigin)
            args[:crossorigin] = "anonymous"
          end
        end

        # --
        def integrity?
          config[:integrity] && !asset.is_a?(Url) &&
            !args.key?(:integrity)
        end
      end
    end
  end
end

# --
Jekyll::Assets::Hook.register :config, :before_merge do |c|
  c.deep_merge!({
    defaults: {
      video: {
        integrity: Jekyll.production?,
      },
    },
  })
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jekyll-assets-3.0.3 lib/jekyll/assets/plugins/html/defaults/vid.rb
jekyll-assets-3.0.2 lib/jekyll/assets/plugins/html/defaults/vid.rb
jekyll-assets-3.0.1 lib/jekyll/assets/plugins/html/defaults/vid.rb
jekyll-assets-3.0.0 lib/jekyll/assets/plugins/html/defaults/vid.rb