Sha256: 36ab8ab71f90f6708e4052bcd449b6be446883428da5f687e90f0440867ce18c

Contents?: true

Size: 1.5 KB

Versions: 6

Compression:

Stored size: 1.5 KB

Contents

module ApplicationHelper
  def admin_navigation
    return unless signed_in?
    render 'sessions/navigation'
  end

  def title_tag(title = 'Ecrire')
    content_tag :title do
      if block_given?
        yield
      elsif !@post.nil?
        @post.title
      else
        title
      end
    end
  end

  def assets_tags
    [
      stylesheet_link_tag("application", "base", media: "all", "data-turbolinks-track" => true),
      javascript_include_tag("application", "base", "data-turbolinks-track" => true)
    ].join.html_safe
  end

  def meta_informations_tags
    [
      content_tag(:link, nil, rel: 'alternate', type: 'application/rss+xml', title: 'RSS', href: '/feed'),
      content_tag(:link, nil, rel: %w(shortcut icon), href: asset_url('favicon.ico')),
      csrf_meta_tags
    ].join.html_safe
  end

  def description_meta_tag
    if Rails.application.secrets.fetch(:meta, {}).has_key?(:description)
      content_tag :meta, nil, name: 'description', content: Rails.application.secrets[:meta][:description]
    end
  end

  def open_graph_type
    if @post.nil?
      'website'
    else
      'article'
    end
  end

  def body_tag(html_options = {}, &block)
    html_options[:id] ||= [controller_name, action_name].map(&:capitalize).join
    content_tag :body, html_options, &block
  end


  def flash_messages
    return if flash.empty?

    flash.map do |name, msg|
      content_tag :div, class: %W(flash #{name}) do
        content_tag(:span, h(msg), class: %w(message))
      end
    end.join.html_safe
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ecrire-0.24.1 lib/ecrire/app/helpers/application_helper.rb
ecrire-0.24.0 lib/ecrire/app/helpers/application_helper.rb
ecrire-0.23.0 lib/ecrire/app/helpers/application_helper.rb
ecrire-0.22.1 lib/ecrire/app/helpers/application_helper.rb
ecrire-0.21.0 lib/ecrire/app/helpers/application_helper.rb
ecrire-0.20.0 lib/ecrire/app/helpers/application_helper.rb