Sha256: 5aea39f0dbc73f035557609a931c52020d916acac5ab1ec135d402de8c70b52c

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

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

    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.2 entry_types/scrolled/app/helpers/pageflow_scrolled/entry_json_seed_helper.rb
pageflow-15.1.1 entry_types/scrolled/app/helpers/pageflow_scrolled/entry_json_seed_helper.rb
pageflow-15.1.0 entry_types/scrolled/app/helpers/pageflow_scrolled/entry_json_seed_helper.rb
pageflow-15.1.0.rc0 entry_types/scrolled/app/helpers/pageflow_scrolled/entry_json_seed_helper.rb