Sha256: 4e73dba3aa37155a621986a1fb68875f0fe451660a372d1886418696922be9c5

Contents?: true

Size: 1.4 KB

Versions: 11

Compression:

Stored size: 1.4 KB

Contents

module MyForum
  module ForumsHelper

    def forum_status_img(forum)
      unread  = 'lada_logo_unread.jpg'
      read    = 'lada_logo.jpg'

      display_as = read
      display_as = unread if forum.has_unread_posts?(current_user)

      image_tag(display_as, width: '66px')
    end

    def forum_name(forum)
      html  = content_tag :strong, link_to(forum.name, forum_path(forum))
      html += content_tag :div, forum.description
      html.html_safe
    end

    def forum_stat(forum)
      html  = content_tag(:div, t('.topics_count', topics_count: forum.topics_count))
      html += content_tag(:div, t('.messages_count', messages_count: forum.posts_count))
      html.html_safe
    end

    def forum_last_message_info(forum)
      topic = forum.topics.order('latest_post_created_at DESC').first

      html  = content_tag(:div, topic ? (t('.last_answer_from') + topic.latest_post_login) : '-' )
      html += content_tag(:div, topic ? (link_to((t('.in_forum') + topic.name), forum_topic_path(topic.forum_id, topic.id))) : '-' )
      html += content_tag(:div, topic ? forum_time(topic.latest_post_created_at) : '-' )

      html.html_safe
    end

    def new_topic_button
      return unless current_user
      return unless @forum
      content_tag :div, class: 'buttons_for_new_topic' do
        link_to t('my_forum.create_new_topic'), new_forum_topic_path(@forum), class: 'btn btn-primary'
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
my_forum-0.0.2.4 app/helpers/my_forum/forums_helper.rb
my_forum-0.0.2.3 app/helpers/my_forum/forums_helper.rb
my_forum-0.0.2.2 app/helpers/my_forum/forums_helper.rb
my_forum-0.0.2.1 app/helpers/my_forum/forums_helper.rb
my_forum-0.0.2 app/helpers/my_forum/forums_helper.rb
my_forum-0.0.1.beta60 app/helpers/my_forum/forums_helper.rb
my_forum-0.0.1.beta59 app/helpers/my_forum/forums_helper.rb
my_forum-0.0.1.beta58 app/helpers/my_forum/forums_helper.rb
my_forum-0.0.1.beta57 app/helpers/my_forum/forums_helper.rb
my_forum-0.0.1.beta56 app/helpers/my_forum/forums_helper.rb
my_forum-0.0.1.beta55 app/helpers/my_forum/forums_helper.rb