Sha256: f7954c76bf8b3d55ecc7f35e455a2d006831380e978f6df9a5d30dd19ca7bd9d

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

module Thredded
  module MessageboardHelper
    def link_or_text_to(messageboard)
      if can? :read, messageboard
        link_to messageboard.name, messageboard_topics_path(messageboard)
      else
        messageboard.name
      end
    end

    def meta_for(messageboard)
      topics = messageboard.topics_count
      posts  = messageboard.posts_count
      "#{number_to_human topics} topics,
        #{number_to_human posts} posts".downcase
    end

    def latest_thread_for(messageboard)
      topic = messageboard.topics.first

      if topic.present?
        abbr = content_tag :abbr, class: 'updated_at timeago', title: topic.updated_at.strftime('%Y-%m-%dT%H:%M:%S') do
          topic.updated_at.strftime('%b %d, %Y %I:%M:%S %Z')
        end

        if can? :read, messageboard
          link_to abbr , messageboard_topic_posts_path(messageboard, topic)
        else
          abbr
        end
      else
        ''
      end
    end

    def latest_user_for(messageboard)
      if messageboard.topics.first.present? && messageboard.topics.first.user.present?
        messageboard.topics.first.last_user.to_s
      else
        ''
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thredded-0.0.4 app/helpers/thredded/messageboard_helper.rb
thredded-0.0.3 app/helpers/thredded/messageboard_helper.rb