Sha256: 00d4892d559c4520c6219c3a4d6e35a87d1d6513f789b4590e03df009f4a080b

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module ActionDispatch::Routing
  class Mapper

    def mount_push_type(opts = {})
      # Mount the registered PushType engines at the specified path.
      PushType.rails_engines.each do |k, (mod, default_path)|
        key  = push_type_engine_keys[k] || k
        path = opts[key] || default_path
        mount mod::Engine => path
      end

      scope path: opts[:front_end] do
        # Use a Dragonfly endpoint to provide better URLs for accessing assets
        get 'media/*file_uid' => Dragonfly.app.endpoint { |params, app|
          file_name = [ params[:file_uid], params[:format] ].join('.')
          asset = PushType::Asset.find_by_file_uid! file_name
          asset.media params[:style]
        }, as: 'media'

        # A catch-all root for the nodes
        get '*permalink' => 'front_end#show', as: 'node'
        get '/' => 'front_end#show', as: 'home', permalink: PushType.config.home_slug if PushType.config.home_slug.present?
      end
    end

    private

    def push_type_engine_keys
      {
        push_type_api:    :api,
        push_type_admin:  :admin
      }
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
push_type_core-0.10.0.beta.3 lib/push_type/rails/routes.rb