Sha256: f6859e2973919ca64f19ba898a36e736c0f0355fd302f4e6ab6a21d937df15f7

Contents?: true

Size: 1.2 KB

Versions: 12

Compression:

Stored size: 1.2 KB

Contents

format :html do
  def show view, args
    capture_the_freak do
      content = send show_method, view, args
      show_full_page? ? wrap_with_html_page(content) : content
    end
  end

  def show_method
    "show_#{show_layout? ? :with : :without}_page_layout"
  end

  def show_without_page_layout view, args
    @main = true if params[:is_main] || args[:main]
    args.delete(:layout)
    view ||= args[:home_view] || :open # default_nest_view
    render! view, args
  end

  def show_full_page?
    !Env.ajax?
  end

  wrapper :html_page do
    <<-HTML.strip_heredoc
      <!DOCTYPE HTML>
      <html class="h-100">
        <head>
          #{head_content}
        </head>
        #{interior}
      </html>
    HTML
  end

  def head_content
    nest card.rule_card(:head), view: :head_content
  end

  private

  # this is a temporary fix to try to debug a recurring encoding-related error
  # TODO: remove the following after tracking down wikirate encoding bug
  def capture_the_freak
    yield
  rescue Card::Error::ServerError => e
    if e.message.match?(/invalid byte sequence/)
      Card::Lexicon.cache.reset
      Rails.logger.info "reset name cache to prevent encoding freakiness"
    end
    raise e
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
card-mod-format-0.13.2 set/all/html_show.rb
card-mod-format-0.13.1 set/all/html_show.rb
card-mod-format-0.13.0 set/all/html_show.rb
card-mod-format-0.11.7 set/all/html_show.rb
card-mod-format-0.12.0 set/all/html_show.rb
card-mod-format-0.11.6 set/all/html_show.rb
card-mod-format-0.11.5 set/all/html_show.rb
card-mod-format-0.11.4 set/all/html_show.rb
card-mod-format-0.11.3 set/all/html_show.rb
card-mod-format-0.11.2 set/all/html_show.rb
card-mod-format-0.11.1 set/all/html_show.rb
card-mod-format-0.11.0 set/all/html_show.rb