Sha256: 384d690751eee7c0b9c6317e9a29e791dd5573b3845153c85ad34c120ff18052

Contents?: true

Size: 1.16 KB

Versions: 18

Compression:

Stored size: 1.16 KB

Contents

module ActionDispatch::Routing
  class Mapper

    def mount_push_type(options = {})
      opts = {
        path:   '/push_type',
        home:   PushType.config.home_slug,
        actions: {
          node:     'nodes_front_end#show',
          taxonomy: 'taxonomies_front_end#show',
        }
      }.deep_merge!(options)

      # Mount the PushType engine at the specified path.
      mount PushType::Core::Engine => opts[:path]

      # 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'

      # Taxonomies
      get ":taxonomy/*permalink" => opts[:actions][:taxonomy], as: 'taxonomy', constraints: ->(params, req) {
        PushType::Taxonomy.descendants(exposed: true).map(&:base_slug).include? params[:taxonomy]
      }

      # A catch-all root for the nodes
      get '*permalink' => opts[:actions][:node], as: 'node'
      root to: opts[:actions][:node], permalink: opts[:home]
    end
    
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
push_type_core-0.7.0 lib/push_type/rails/routes.rb
push_type_core-0.7.0.beta.1 lib/push_type/rails/routes.rb
push_type_core-0.6.0 lib/push_type/rails/routes.rb
push_type_core-0.6.0.beta.4 lib/push_type/rails/routes.rb
push_type_core-0.6.0.beta.3 lib/push_type/rails/routes.rb
push_type_core-0.6.0.beta.2 lib/push_type/rails/routes.rb
push_type_core-0.6.0.beta.1 lib/push_type/rails/routes.rb
push_type_core-0.5.3 lib/push_type/rails/routes.rb
push_type_core-0.5.2 lib/push_type/rails/routes.rb
push_type_core-0.5.1 lib/push_type/rails/routes.rb
push_type_core-0.5.0 lib/push_type/rails/routes.rb
push_type_core-0.5.0.alpha.5 lib/push_type/rails/routes.rb
push_type_core-0.5.0.alpha.4 lib/push_type/rails/routes.rb
push_type_core-0.5.0.alpha.3 lib/push_type/rails/routes.rb
push_type_core-0.5.0.alpha.2 lib/push_type/rails/routes.rb
push_type_core-0.5.0.alpha.1 lib/push_type/rails/routes.rb
push_type_core-0.4.0 lib/push_type/rails/routes.rb
push_type_core-0.4.0.beta.3 lib/push_type/rails/routes.rb