hashtags module now in comments. not sure how to pull back relevant posts on tags/show from here...

This commit is contained in:
danielgrippi 2011-07-06 20:58:32 -07:00
parent b8d70393f4
commit 310b9969f3
9 changed files with 21 additions and 9 deletions

View file

@ -13,6 +13,11 @@ class Comment < ActiveRecord::Base
include Diaspora::Relayable
include Diaspora::Socketable
include Diaspora::Taggable
acts_as_taggable_on :tags
extract_tags_from :text
before_create :build_tags
xml_attr :text
xml_attr :diaspora_handle

View file

@ -43,7 +43,7 @@ class StatusMessage < Post
escaped_message = opts[:plain_text] ? self.raw_message: ERB::Util.h(self.raw_message)
mentioned_message = self.format_mentions(escaped_message, opts)
self.format_tags(mentioned_message, opts)
Diaspora::Taggable.format_tags(mentioned_message, opts)
end
def format_mentions(text, opts = {})

View file

@ -12,7 +12,7 @@
= person_link(comment.author, :class => "hovercardable")
%span{:class => direction_for(comment.text)}
= markdownify(comment.text, :youtube_maps => comment.youtube_titles)
= markdownify(Diaspora::Taggable.format_tags(comment.text), :youtube_maps => comment.youtube_titles)
%br
%time.timeago{:datetime => comment.created_at}

View file

@ -15,5 +15,5 @@
=person_link(person)
.info
= person.profile.format_tags(person.profile.tag_string)
= Diaspora::Taggable.format_tags(person.profile.tag_string)

View file

@ -47,7 +47,7 @@
= @person.diaspora_handle
.description
- if !@person.profile.tag_string.blank?
= @person.profile.format_tags(@person.profile.tag_string)
= Diapsora::Taggable.format_tags(@person.profile.tag_string)
- if user_signed_in? && @person == current_user.person
%span.hover_edit
= link_to t('people.show.edit'), edit_profile_path

View file

@ -38,7 +38,7 @@
.description
- if !@person.profile.tag_string.blank? && user_signed_in? && (@contact.persisted? || @person == current_user.person || @incoming_request)
= @person.profile.format_tags(@person.profile.tag_string)
= Diaspora::Taggable.format_tags(@person.profile.tag_string)
- if user_signed_in? && @person == current_user.person
%span.hover_edit
= link_to t('.edit'), edit_profile_path

View file

@ -36,7 +36,7 @@ module Diaspora
unique_matches.values
end
def format_tags(text, opts={})
def self.format_tags(text, opts={})
return text if opts[:plain_text]
regex = /(^|\s)#(#{VALID_TAG_BODY})/
form_message = text.gsub(regex) do |matched_string|

View file

@ -126,4 +126,11 @@ describe Comment do
it_should_behave_like 'it is relayable'
end
describe 'tags' do
before do
@object = Factory.build(:comment)
end
it_should_behave_like 'it is taggable'
end
end

View file

@ -12,7 +12,7 @@ describe Diaspora::Taggable do
def controller
end
describe '#format_tags' do
describe '.format_tags' do
before do
@str = '#what #hey #vöglein'
@object.send(@object.class.field_with_tags_setter, @str)
@ -21,10 +21,10 @@ describe Diaspora::Taggable do
end
it 'links the tag to /p' do
link = link_to('#vöglein', '/tags/vöglein', :class => 'tag')
@object.format_tags(@str).should include(link)
Diaspora::Taggable.format_tags(@str).should include(link)
end
it 'responds to plain_text' do
@object.format_tags(@str, :plain_text => true).should == @str
Diaspora::Taggable.format_tags(@str, :plain_text => true).should == @str
end
end
describe '#build_tags' do