Sha256: 97cad5c37cc50feebd353500328b75edd47539fa4f76080bf68c0d5a91624807

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

module PageflowScrolled
  # Render seed data for published scrolled entries.
  #
  # @api private
  module EntryJsonSeedHelper
    include Pageflow::ConfigHelper
    include Pageflow::RenderJsonHelper
    include Pageflow::FilesHelper

    def scrolled_entry_json_seed_script_tag(scrolled_entry, options = {})
      seed_json = render_json do |json|
        scrolled_entry_json_seed(json, scrolled_entry, options)
      end

      content_tag(:script, <<-JS.html_safe)
        var pageflowScrolledSeed = #{sanitize_json(seed_json)};
      JS
    end

    def scrolled_entry_json_seed(json, scrolled_entry, options = {})
      main_storyline = Storyline.all_for_revision(scrolled_entry.revision).first
      main_storyline ||= Storyline.new

      json.partial!('pageflow_scrolled/entry_json_seed/entry',
                    chapters: main_storyline.chapters,
                    entry: scrolled_entry,
                    entry_config: Pageflow.config_for(scrolled_entry),
                    sections: main_storyline.sections,
                    content_elements: main_storyline.content_elements,
                    options: options)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pageflow-15.1.0.beta6 entry_types/scrolled/app/helpers/pageflow_scrolled/entry_json_seed_helper.rb
pageflow-15.1.0.beta5 entry_types/scrolled/app/helpers/pageflow_scrolled/entry_json_seed_helper.rb
pageflow-15.1.0.beta4 entry_types/scrolled/app/helpers/pageflow_scrolled/entry_json_seed_helper.rb
pageflow-15.1.0.beta3 entry_types/scrolled/app/helpers/pageflow_scrolled/entry_json_seed_helper.rb