0
0
Fork 0

Adding hashtag model

This commit is contained in:
Eugen Rochko 2016-11-04 19:12:59 +01:00
parent 6471a548fe
commit 62292797ec
11 changed files with 60 additions and 9 deletions

View file

@ -14,6 +14,7 @@ class Formatter
html = simple_format(html, sanitize: false)
html = link_urls(html)
html = link_mentions(html, status.mentions)
html = link_hashtags(html)
html.html_safe
end
@ -43,6 +44,17 @@ class Formatter
end
end
def link_hashtags(html)
html.gsub(Tag::HASHTAG_RE) do |match|
hashtag_html(match)
end
end
def hashtag_html(match)
prefix, affix = match.split('#')
"#{prefix}<a href=\"#\" class=\"mention hashtag\">#<span>#{affix}</span></a>"
end
def mention_html(match, account)
"#{match.split('@').first}<a href=\"#{TagManager.instance.url_for(account)}\" class=\"mention\">@<span>#{account.username}</span></a>"
end