# encoding: utf-8 # # = Pivotal Tracker Helpers # # pivotal_vote_controls:: Cute little controls for voting stories up or down. # pivotal_story:: Display a single story. # pivotal_comment:: Display a single comment (for use within a story). # ################################################################################ module ApplicationHelper::PivotalTracker def pivotal_vote_controls(story) current_vote = story.user_vote(@user) result = '' result += if @user && current_vote < PIVOTAL_MAX_VOTE link_to_function(image_tag('vote_up_hot.png'), "vote_on_story(#{story.id}, #{@user.id}, #{current_vote+1})") else image_tag('vote_up_cold.png') end result += '' + story.score.to_s + '' result += if @user && current_vote > PIVOTAL_MIN_VOTE link_to_function(image_tag('vote_down_hot.png'), "vote_on_story(#{story.id}, #{@user.id}, #{current_vote-1})") else image_tag('vote_down_cold.png') end return result end def pivotal_story(story) result = '' result += '

' + :DESCRIPTION.l + ':

' result += story.description.tp if story.user.instance_of?(User) result += '

' + :pivotal_posted_by.l + ': ' result += user_link(story.user) + '

' end result += '

' + :COMMENTS.l + ':

' result += '
' num = 0 for comment in story.comments num += 1 result += pivotal_comment(comment, num) end result += '
' result += '
' result += '
' result += '' result += '
' return result end def pivotal_comment(comment, num) result = '' result += '
' result += '

' result += :CREATED.t + ': ' + comment.time.to_s + '
' result += :BY.t + ': ' + user_link(comment.user) + '
' result += '

' result += comment.text.to_s.tp result += '
' return result end end