Sha256: b941324d74117b5e176181bf0bd7b1abaa168ab1ff1f65e55ad54137d1ac8f9f

Contents?: true

Size: 849 Bytes

Versions: 2

Compression:

Stored size: 849 Bytes

Contents

module Stylish
  module AssetBrowser
    extend ActiveSupport::Concern

    included do
      get "/browse/assets" do
        {
          path: path,
          action: "browse/assets",
          entries: []
        }.to_json
      end

      get "/browse/assets/*" do |path|
        asset = Stylish.sprockets.find_asset(path) rescue nil

        response = if asset
          {
            realpath: asset.pathname.expand_path.to_s,
            content: asset.pathname.read,
            rendered: asset.to_s,
            logical_path: asset.logical_path,
            digest: asset.digest,
            id: Digest::MD5.hexdigest(asset.pathname.to_s)
          }
        else
          {
            path: path,
            action: "browse/assets",
            entries: []
          }
        end

        response.to_json
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stylish-0.3.1 lib/stylish/api/asset_browser.rb
stylish-0.3.0 lib/stylish/api/asset_browser.rb