Skip to content

Commit

Permalink
Sanatize and auto_link IRC messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Byron committed Oct 1, 2011
1 parent b54fe49 commit 5345f25
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
14 changes: 11 additions & 3 deletions app/helpers/chat/messages_helper.rb
Expand Up @@ -8,10 +8,10 @@ def last_message_timestamp_for_channel(channel)
'No Messages'
end
end
def message_date(message)

def message_date(message)
params[:last_date] = @since.to_date if @since && params[:last_date].nil?

if params[:last_date].nil? || params[:last_date] != message.recorded_at.to_date
params[:last_date] = message.recorded_at.to_date
message.recorded_at.strftime("%A, %B %d, %Y")
Expand All @@ -21,4 +21,12 @@ def message_date(message)
def message_time(message)
message.recorded_at.strftime("%I:%M %p")
end

def message_body(message, highlight=nil)
body = sanitize(message.body)

body = highlight(body, highlight) if highlight

auto_link(body, :html => { :target => '_blank' }).html_safe
end
end
2 changes: 1 addition & 1 deletion app/views/chat/_recent.html.haml
Expand Up @@ -8,4 +8,4 @@
.message
.handle= "#{message.handle.name}:"
.body{:class => (defined?(full_body) ? 'full' : '')}
= auto_link(message.body, :html => { :target => '_blank' })
= message_body(message)
2 changes: 1 addition & 1 deletion app/views/chat/messages/_display.html.haml
Expand Up @@ -5,5 +5,5 @@
%tr.message
%td.handle= "#{message.handle.name}:"
%td.body{ :class => ('action' if message.action?)}
= auto_link(highlight(message.body,params[:highlight].try(:split)), :html => { :target => '_blank' })
= message_body(message, params[:highlight].try(:split))
%td.recorded_at= message_time message
2 changes: 1 addition & 1 deletion app/views/chat/messages/_search_result.html.haml
@@ -1,5 +1,5 @@
%tr.message
%td.handle= "#{message.handle.name}:"
%td.body{ :class => ('action' if message.action?)}
= auto_link(highlight(message.body,params[:search].split), :html => { :target => '_blank' })
= message_body(message, params[:search].split)
%td.recorded_at= message_time message

0 comments on commit 5345f25

Please sign in to comment.