Sha256: 61bf79143100599e3a86f52f59d0b49a22907db8fd0c59cd90b653465a1950e1

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 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'

        get '/node/preview/:id' => 'front_end#preview', as: 'preview_node'
        get '*permalink'    => 'front_end#show',    as: 'node'
        get '/' => 'front_end#show', as: 'home_node', 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

13 entries across 13 versions & 1 rubygems

Version Path
push_type_core-0.12.1 lib/push_type/rails/routes.rb
push_type_core-0.12.0 lib/push_type/rails/routes.rb
push_type_core-0.12.0.beta.1 lib/push_type/rails/routes.rb
push_type_core-0.11.2 lib/push_type/rails/routes.rb
push_type_core-0.11.1 lib/push_type/rails/routes.rb
push_type_core-0.11.0.beta.2 lib/push_type/rails/routes.rb
push_type_core-0.11.0.beta.1 lib/push_type/rails/routes.rb
push_type_core-0.10.4 lib/push_type/rails/routes.rb
push_type_core-0.10.3 lib/push_type/rails/routes.rb
push_type_core-0.10.2 lib/push_type/rails/routes.rb
push_type_core-0.10.1 lib/push_type/rails/routes.rb
push_type_core-0.10.0 lib/push_type/rails/routes.rb
push_type_core-0.10.0.beta.5 lib/push_type/rails/routes.rb