Sha256: f3333f144f3ec7efb714a4b99b6415862508527f8bcab440435f4d88c1b5079e

Contents?: true

Size: 1.95 KB

Versions: 12

Compression:

Stored size: 1.95 KB

Contents

# frozen_string_literal: true

# rubocop:disable Metrics/BlockLength
Maglev::Engine.routes.draw do
  # API
  constraints format: :json do
    namespace :api do
      root to: proc { [200, {}, ['{}']] }
      resource :site, only: :show
      resources :pages do
        resources :clones, controller: :page_clones, only: :create
      end
      resources :assets
      resource :publication, only: %i[show create]
      scope 'collections/:collection_id' do
        get '/', to: 'collection_items#index', as: :collection_items
      end
    end
  end

  root to: redirect { Maglev::Engine.routes.url_helpers.admin_root_path }

  # JS client lib for a headless use of Maglev
  get 'live-preview-client.js', to: (redirect(status: 302) do |_, request|
    manifest = ::Maglev::Engine.vite_ruby.manifest
    entries = manifest.resolve_entries(*%w[live-preview-rails-client], type: :javascript)
    [
      request.base_url,
      *entries.fetch(:scripts).flatten.uniq
    ].join
  end), as: :live_preview_client_js

  # Admin
  namespace :admin do
    root to: 'dashboard#index'
    resource :theme, only: %i[index show]
    namespace :sections, path: 'sections/:id' do
      get :preview, to: 'previews#show'
      get :preview_in_frame, to: 'previews#iframe_show'
      resources :screenshots, only: [:create]
    end
  end

  # Editor + Preview
  get 'editor', to: 'editor#show', as: :base_editor
  get 'editor/:locale/(*path)', to: 'editor#show', as: :editor
  get 'leave_editor', to: 'editor#destroy', as: :leave_editor
  get 'preview/(*path)', to: 'page_preview#index',
                         defaults: { path: 'index', rendering_mode: :editor },
                         constraints: Maglev::PreviewConstraint.new,
                         as: :site_preview
  post 'preview/(*path)', to: 'page_preview#create', defaults: { path: 'index', rendering_mode: :editor }

  # Public Assets
  get 'assets/:id(/:filename)', to: 'assets#show', as: :public_asset
end
# rubocop:enable Metrics/BlockLength

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
maglevcms-1.7.3 config/routes.rb
maglevcms-1.7.2 config/routes.rb
maglevcms-1.7.1 config/routes.rb
maglevcms-1.7.0 config/routes.rb
maglevcms-1.6.1 config/routes.rb
maglevcms-1.6.0 config/routes.rb
maglevcms-1.5.1 config/routes.rb
maglevcms-1.4.0 config/routes.rb
maglevcms-1.3.0 config/routes.rb
maglevcms-1.2.2 config/routes.rb
maglevcms-1.2.1 config/routes.rb
maglevcms-1.2.0 config/routes.rb