Added HTML links to posts
This commit is contained in:
parent
482b2f5ffb
commit
035db98367
2 changed files with 11 additions and 1 deletions
|
|
@ -10,4 +10,14 @@ module StatusMessagesHelper
|
|||
return I18n.t('status_messages.helper.no_message_to_display')
|
||||
end
|
||||
end
|
||||
|
||||
def make_links(message)
|
||||
# If there should be some kind of bb-style markup, email/diaspora highlighting, it could go here.
|
||||
|
||||
# next line is important due to XSS! (h is rail's make_html_safe-function)
|
||||
message = h(message).html_safe
|
||||
message.gsub!(/( |^)(www\.[^ ]+\.[^ ])/, '\1http://\2');
|
||||
return message.gsub(/(http|ftp):\/\/([^ ]+)/, '<a target="_blank" href="\1://\2">\2</a>');
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
= render "shared/reshare", :post => post, :current_user => current_user
|
||||
= link_to t('.delete'), status_message_path(post), :confirm => t('.are_you_sure'), :method => :delete, :remote => true, :class => "delete"
|
||||
|
||||
= post.message
|
||||
= make_links(post.message)
|
||||
|
||||
.info
|
||||
%span.time= link_to(how_long_ago(post), object_path(post))
|
||||
|
|
|
|||
Loading…
Reference in a new issue