From 3cc47beb6e1f646baca64fdf56168e2f2e2bc726 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 9 Sep 2016 20:04:34 +0200 Subject: Refactored generation of unique tags, URIs and object URLs into own classes, as well as formatting of content --- app/views/accounts/_grid_card.html.haml | 2 +- app/views/accounts/show.atom.ruby | 2 +- app/views/api/accounts/show.rabl | 2 +- app/views/api/statuses/show.rabl | 6 +++--- app/views/notification_mailer/follow.text.erb | 2 +- app/views/notification_mailer/mention.text.erb | 2 +- app/views/stream_entries/_follow.html.haml | 2 +- app/views/stream_entries/_status.html.haml | 8 ++++---- app/views/xrd/webfinger.xml.ruby | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) (limited to 'app/views') diff --git a/app/views/accounts/_grid_card.html.haml b/app/views/accounts/_grid_card.html.haml index d107f5274..f65b78470 100644 --- a/app/views/accounts/_grid_card.html.haml +++ b/app/views/accounts/_grid_card.html.haml @@ -2,7 +2,7 @@ .account-grid-card__header .avatar= image_tag account.avatar.url(:medium) .name - = link_to url_for_target(account) do + = link_to TagManager.instance.url_for(account) do %span.display_name= display_name(account) %span.username= "@#{account.acct}" %p.note= truncate(strip_tags(account.note), length: 150) diff --git a/app/views/accounts/show.atom.ruby b/app/views/accounts/show.atom.ruby index 8a7bc1b92..d7b2201d4 100644 --- a/app/views/accounts/show.atom.ruby +++ b/app/views/accounts/show.atom.ruby @@ -10,7 +10,7 @@ Nokogiri::XML::Builder.new do |xml| include_author xml, @account end - link_alternate xml, url_for_target(@account) + link_alternate xml, TagManager.instance.url_for(@account) link_self xml, account_url(@account, format: 'atom') link_hub xml, Rails.configuration.x.hub_url link_salmon xml, api_salmon_url(@account.id) diff --git a/app/views/api/accounts/show.rabl b/app/views/api/accounts/show.rabl index 4f7cee680..d779393d1 100644 --- a/app/views/api/accounts/show.rabl +++ b/app/views/api/accounts/show.rabl @@ -2,7 +2,7 @@ object @account attributes :id, :username, :acct, :display_name, :note -node(:url) { |account| url_for_target(account) } +node(:url) { |account| TagManager.instance.url_for(account) } node(:avatar) { |account| full_asset_url(account.avatar.url(:large, false)) } node(:followers_count) { |account| account.followers.count } node(:following_count) { |account| account.following.count } diff --git a/app/views/api/statuses/show.rabl b/app/views/api/statuses/show.rabl index c7d028e14..047436b61 100644 --- a/app/views/api/statuses/show.rabl +++ b/app/views/api/statuses/show.rabl @@ -1,9 +1,9 @@ object @status attributes :id, :created_at, :in_reply_to_id -node(:uri) { |status| uri_for_target(status) } -node(:content) { |status| content_for_status(status) } -node(:url) { |status| url_for_target(status) } +node(:uri) { |status| TagManager.instance.uri_for(status) } +node(:content) { |status| Formatter.instance.format(status) } +node(:url) { |status| TagManager.instance.url_for(status) } node(:reblogs_count) { |status| status.reblogs_count } node(:favourites_count) { |status| status.favourites_count } node(:favourited) { |status| current_account.favourited?(status) } diff --git a/app/views/notification_mailer/follow.text.erb b/app/views/notification_mailer/follow.text.erb index 6f70c0d90..a13b6d7a9 100644 --- a/app/views/notification_mailer/follow.text.erb +++ b/app/views/notification_mailer/follow.text.erb @@ -2,4 +2,4 @@ <%= @account.acct %> is now following you! -<%= url_for_target(@account) %> +<%= TagManager.instance.url_for(@account) %> diff --git a/app/views/notification_mailer/mention.text.erb b/app/views/notification_mailer/mention.text.erb index b093f4ec0..f3582749d 100644 --- a/app/views/notification_mailer/mention.text.erb +++ b/app/views/notification_mailer/mention.text.erb @@ -4,4 +4,4 @@ You were mentioned by <%= @status.account.acct %> in: <%= strip_tags(@status.content) %> -<%= url_for_target(@status) %> +<%= TagManager.instance.url_for(@status) %> diff --git a/app/views/stream_entries/_follow.html.haml b/app/views/stream_entries/_follow.html.haml index f19e8783d..f6ec8c4f5 100644 --- a/app/views/stream_entries/_follow.html.haml +++ b/app/views/stream_entries/_follow.html.haml @@ -2,4 +2,4 @@ .content %strong= link_to follow.account.acct, account_path(follow.account) is now following - %strong= link_to follow.target_account.acct, url_for_target(follow.target_account) + %strong= link_to follow.target_account.acct, TagManager.instance.url_for(follow.target_account) diff --git a/app/views/stream_entries/_status.html.haml b/app/views/stream_entries/_status.html.haml index ece31d0e2..a0afccd39 100644 --- a/app/views/stream_entries/_status.html.haml +++ b/app/views/stream_entries/_status.html.haml @@ -12,7 +12,7 @@ .pre-header %i.fa.fa-retweet Shared by - = link_to display_name(status.account), url_for_target(status.account), class: 'name' + = link_to display_name(status.account), TagManager.instance.url_for(status.account), class: 'name' .entry__container .avatar @@ -21,10 +21,10 @@ .entry__container__container .header .header__left - = link_to url_for_target(proper_status(status).account), class: 'name' do + = link_to TagManager.instance.url_for(proper_status(status).account), class: 'name' do %strong= display_name(proper_status(status).account) = "@#{proper_status(status).account.acct}" - = link_to url_for_target(proper_status(status)), class: 'time' do + = link_to TagManager.instance.url_for(proper_status(status)), class: 'time' do %span{ title: proper_status(status).created_at } = relative_time(proper_status(status).created_at) @@ -36,7 +36,7 @@ %i.fa.fa-star %span.counter-number= proper_status(status).favourites_count - .content= content_for_status(proper_status(status)) + .content= Formatter.instance.format(proper_status(status)) %ul.media-attachments - status.media_attachments.each do |media| diff --git a/app/views/xrd/webfinger.xml.ruby b/app/views/xrd/webfinger.xml.ruby index 7c920b678..d633e3477 100644 --- a/app/views/xrd/webfinger.xml.ruby +++ b/app/views/xrd/webfinger.xml.ruby @@ -1,8 +1,8 @@ Nokogiri::XML::Builder.new do |xml| xml.XRD(xmlns: 'http://docs.oasis-open.org/ns/xri/xrd-1.0') do xml.Subject @canonical_account_uri - xml.Alias url_for_target(@account) - xml.Link(rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: url_for_target(@account)) + xml.Alias TagManager.instance.url_for(@account) + xml.Link(rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: TagManager.instance.url_for(@account)) xml.Link(rel: 'http://schemas.google.com/g/2010#updates-from', type: 'application/atom+xml', href: account_url(@account, format: 'atom')) xml.Link(rel: 'salmon', href: api_salmon_url(@account.id)) xml.Link(rel: 'magic-public-key', href: @magic_key) -- cgit