Sha256: 4f6a4ec842bd000cfd0612c876eb4ca284d8bee62d4e954b4251deb8c3b7d7ca

Contents?: true

Size: 1.62 KB

Versions: 46

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

require "alchemy/admin/preview_url"

module Alchemy
  YAML_WHITELIST_CLASSES = %w(Symbol Date Regexp)

  # Define page preview sources
  #
  # A preview source is a Ruby class returning an URL
  # that is used as source for the preview frame in the
  # admin UI.
  #
  # == Example
  #
  #     # lib/acme/preview_source.rb
  #     class Acme::PreviewSource < Alchemy::Admin::PreviewUrl
  #       def url_for(page)
  #         if page.site.name == "Next"
  #           "https://user:#{ENV['PREVIEW_HTTP_PASS']}@next.acme.com"
  #         else
  #           "https://www.acme.com"
  #         end
  #       end
  #     end
  #
  #     # config/initializers/alchemy.rb
  #     require "acme/preview_source"
  #     Alchemy.preview_sources << Acme::PreviewSource
  #
  #     # config/locales/de.yml
  #     de:
  #       activemodel:
  #         models:
  #           acme/preview_source: Acme Vorschau
  #
  def self.preview_sources
    @_preview_sources ||= begin
      Set.new << Alchemy::Admin::PreviewUrl
    end
  end

  # Define page publish targets
  #
  # A publish target is a ActiveJob that gets performed
  # whenever a user clicks the publish page button.
  #
  # Use this to trigger deployment hooks of external
  # services in an asychronous way.
  #
  # == Example
  #
  #     # app/jobs/publish_job.rb
  #     class PublishJob < ApplicationJob
  #       def perform(page)
  #         RestClient.post(ENV['BUILD_HOOK_URL'])
  #       end
  #     end
  #
  #     # config/initializers/alchemy.rb
  #     Alchemy.publish_targets << PublishJob
  #
  def self.publish_targets
    @_publish_targets ||= Set.new
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
alchemy_cms-5.3.8 lib/alchemy.rb
alchemy_cms-5.3.7 lib/alchemy.rb
alchemy_cms-5.3.6 lib/alchemy.rb
alchemy_cms-5.3.5 lib/alchemy.rb
alchemy_cms-6.0.0 lib/alchemy.rb
alchemy_cms-5.3.4 lib/alchemy.rb
alchemy_cms-6.0.0.pre.rc7 lib/alchemy.rb
alchemy_cms-5.3.3 lib/alchemy.rb
alchemy_cms-5.3.2 lib/alchemy.rb
alchemy_cms-5.3.1 lib/alchemy.rb
alchemy_cms-5.3.0 lib/alchemy.rb
alchemy_cms-6.0.0.pre.rc6 lib/alchemy.rb
alchemy_cms-5.2.7 lib/alchemy.rb
alchemy_cms-5.2.6 lib/alchemy.rb
alchemy_cms-5.1.10 lib/alchemy.rb
alchemy_cms-6.0.0.pre.rc5 lib/alchemy.rb
alchemy_cms-6.0.0.pre.rc4 lib/alchemy.rb
alchemy_cms-6.0.0.pre.rc3 lib/alchemy.rb
alchemy_cms-5.2.5 lib/alchemy.rb
alchemy_cms-5.1.9 lib/alchemy.rb