Sha256: d50995cedcd963ea16b198a8c6ed0c0d352c8934f1eb407d1b265b024f9c6494

Contents?: true

Size: 853 Bytes

Versions: 1

Compression:

Stored size: 853 Bytes

Contents

module Bigmouth
  module Admin::ApplicationHelper

    include Bigmouth::ApplicationHelper

    def uploaded_by(image)
      if image.user.present?
        image.user[Bigmouth.config.username_key.to_sym] || "Guest"
      else
        "Guest"
      end
    end

    def sidebar_activate(sidebar_link_url)
      current_url = request.headers["SCRIPT_NAME"] + request.headers["PATH_INFO"]
      current_url.match(sidebar_link_url) ? ' class="active"' : ""
    end

    def sidebar_list_items
      items = [
        { text: "Articles", path: admin_articles_path },
        { text: "Images", path: admin_images_path }
      ]

      html = ""
      items.each do |item|
        text = item[:text]
        path = item[:path]
        html += %(<li#{sidebar_activate(path)}><a href="#{path}">#{text}</a></li>)
      end

      html.html_safe
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bigmouth-0.0.2 app/helpers/bigmouth/admin/application_helper.rb