Module: MyForum::ForumsHelper

Defined in:
app/helpers/my_forum/forums_helper.rb

Instance Method Summary collapse

Instance Method Details

#forum_last_message_info(forum) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'app/helpers/my_forum/forums_helper.rb', line 26

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

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

  html.html_safe
end

#forum_name(forum) ⇒ Object



14
15
16
17
18
# File 'app/helpers/my_forum/forums_helper.rb', line 14

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

#forum_stat(forum) ⇒ Object



20
21
22
23
24
# File 'app/helpers/my_forum/forums_helper.rb', line 20

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

#forum_status_img(forum) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'app/helpers/my_forum/forums_helper.rb', line 4

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

#new_topic_buttonObject



36
37
38
39
40
41
42
# File 'app/helpers/my_forum/forums_helper.rb', line 36

def new_topic_button
  return unless current_user
  return unless @forum
   :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