diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-01-07 08:00:11 -0600 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-05-21 03:16:21 -0500 |
commit | fa7e6b5a63c0ba584e0e2f457c41fece72c7f8ed (patch) | |
tree | 6e368d979a8556bb19e76276bb08dd579367066e /app | |
parent | 5c6a14ca68c3fba3ee778588c080c77a92d53e66 (diff) |
Add pseudomentions to various hosts
Diffstat (limited to 'app')
-rw-r--r-- | app/lib/formatter.rb | 96 |
1 files changed, 95 insertions, 1 deletions
diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index 78a0e9f25..cb9ca8336 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -186,7 +186,8 @@ class Formatter elsif entity[:hashtag] link_to_hashtag(entity) elsif entity[:screen_name] - link_to_mention(entity, accounts) + link = link_to_pseudo(entity[:screen_name]) + link.nil? ? link_to_mention(entity, accounts) : link end end end @@ -384,4 +385,97 @@ class Formatter def mention_html(account) "<span class=\"h-card\"><a href=\"#{encode(TagManager.instance.url_for(account))}\" class=\"u-url mention\">@<span>#{encode(account.username)}</span></a></span>" end + + def link_to_pseudo(acct) + username, domain = acct.split('@') + + case domain + when 'twitter.com' + return link_to_twitter(username) + when 'tumblr.com' + return link_to_tumblr(username) + when 'weasyl.com' + return link_to_weasyl(username) + when 'furaffinity.net' + return link_to_furaffinity(username) + when 'furrynetwork.com', 'beta.furrynetwork.com' + return link_to_furrynetwork(username) + when 'sofurry.com' + return link_to_sofurry(username) + when 'inkbunny.net' + return link_to_inkbunny(username) + when 'e621.net' + return link_to_e621(username) + when 'e926.net' + return link_to_e926(username) + when 'f-list.net' + return link_to_flist(username) + when 'deviantart.com' + return link_to_deviantart(username) + when 'artstation.com' + return link_to_artstation(username) + when 'github.com' + return link_to_github(username) + when 'gitlab.com' + return link_to_gitlab(username) + else + return nil + end + end + + def link_to_twitter(username) + "<span class=\"h-card\"><a href=\"https://twitter.com/#{username}\" target=\"blank\" rel=\"noopener noreferrer\" class=\"u-url mention\">@<span>#{username}@twitter.com</span></a></span>" + end + + def link_to_tumblr(username) + "<span class=\"h-card\"><a href=\"https://#{username}.tumblr.com\" target=\"blank\" rel=\"noopener noreferrer\" class=\"u-url mention\">@<span>#{username}@tumblr.com</span></a></span>" + end + + def link_to_weasyl(username) + "<span class=\"h-card\"><a href=\"https://weasyl.com/~#{username}\" target=\"blank\" rel=\"noopener noreferrer\" class=\"u-url mention\">@<span>#{username}@weasyl.com</span></a></span>" + end + + def link_to_furaffinity(username) + "<span class=\"h-card\"><a href=\"https://furaffinity.net/user/#{username}\" target=\"blank\" rel=\"noopener noreferrer\" class=\"u-url mention\">@<span>#{username}@furaffinity.net</span></a></span>" + end + + def link_to_furrynetwork(username) + "<span class=\"h-card\"><a href=\"https://furrynetwork.com/#{username}\" target=\"blank\" rel=\"noopener noreferrer\" class=\"u-url mention\">@<span>#{username}@furrynetwork.com</span></a></span>" + end + + def link_to_inkbunny(username) + "<span class=\"h-card\"><a href=\"https://inkbunny.net/#{username}\" target=\"blank\" rel=\"noopener noreferrer\" class=\"u-url mention\">@<span>#{username}@inkbunny.net</span></a></span>" + end + + def link_to_sofurry(username) + "<span class=\"h-card\"><a href=\"https://#{username}.sofurry.com\" target=\"blank\" rel=\"noopener noreferrer\" class=\"u-url mention\">@<span>#{username}@sofurry.com</span></a></span>" + end + + def link_to_e621(username) + "<span class=\"h-card\"><a href=\"https://e621.net/user/show/#{username}\" target=\"blank\" rel=\"noopener noreferrer\" class=\"u-url mention\">@<span>#{username}@e621.net</span></a></span>" + end + + def link_to_e926(username) + "<span class=\"h-card\"><a href=\"https://e926.net/user/show/#{username}\" target=\"blank\" rel=\"noopener noreferrer\" class=\"u-url mention\">@<span>#{username}@e926.net</span></a></span>" + end + + def link_to_flist(username) + "<span class=\"h-card\"><a href=\"https://f-list.net/c/#{username}\" target=\"blank\" rel=\"noopener noreferrer\" class=\"u-url mention\">@<span>#{username}@f-list.net</span></a></span>" + end + + def link_to_deviantart(username) + "<span class=\"h-card\"><a href=\"https://#{username}.deviantart.com\" target=\"blank\" rel=\"noopener noreferrer\" class=\"u-url mention\">@<span>#{username}@deviantart.com</span></a></span>" + end + + def link_to_artstation(username) + "<span class=\"h-card\"><a href=\"https://www.artstation.com/#{username}\" target=\"blank\" rel=\"noopener noreferrer\" class=\"u-url mention\">@<span>#{username}@artstation.com</span></a></span>" + end + + def link_to_github(username) + "<span class=\"h-card\"><a href=\"https://github.com/#{username}\" target=\"blank\" rel=\"noopener noreferrer\" class=\"u-url mention\">@<span>#{username}@github.com</span></a></span>" + end + + def link_to_gitlab(username) + "<span class=\"h-card\"><a href=\"https://gitlab.com/#{username}\" target=\"blank\" rel=\"noopener noreferrer\" class=\"u-url mention\">@<span>#{username}@gitlab.com</span></a></span>" + end end |