Quick best practice cleanup of views/helpers (#1546)

* Remove trailing whitespace

* Use query methods instead of explicit .blank? checks
main
Matt Jankowski 2017-04-12 12:24:18 -04:00 committed by Eugen
parent aa90798386
commit c44a700252
10 changed files with 16 additions and 19 deletions

View File

@ -2,7 +2,7 @@
module StreamEntriesHelper module StreamEntriesHelper
def display_name(account) def display_name(account)
account.display_name.blank? ? account.username : account.display_name account.display_name.presence || account.username
end end
def stream_link_target def stream_link_target

View File

@ -26,8 +26,8 @@ class AtomSerializer
append_element(author, 'link', nil, rel: :avatar, type: account.avatar_content_type, 'media:width': 120, 'media:height': 120, href: full_asset_url(account.avatar.url(:original))) append_element(author, 'link', nil, rel: :avatar, type: account.avatar_content_type, 'media:width': 120, 'media:height': 120, href: full_asset_url(account.avatar.url(:original)))
append_element(author, 'link', nil, rel: :header, type: account.header_content_type, 'media:width': 700, 'media:height': 335, href: full_asset_url(account.header.url(:original))) append_element(author, 'link', nil, rel: :header, type: account.header_content_type, 'media:width': 700, 'media:height': 335, href: full_asset_url(account.header.url(:original)))
append_element(author, 'poco:preferredUsername', account.username) append_element(author, 'poco:preferredUsername', account.username)
append_element(author, 'poco:displayName', account.display_name) unless account.display_name.blank? append_element(author, 'poco:displayName', account.display_name) if account.display_name?
append_element(author, 'poco:note', Formatter.instance.simplified_format(account).to_str) unless account.note.blank? append_element(author, 'poco:note', Formatter.instance.simplified_format(account).to_str) if account.note?
append_element(author, 'mastodon:scope', account.locked? ? :private : :public) append_element(author, 'mastodon:scope', account.locked? ? :private : :public)
author author
@ -327,7 +327,7 @@ class AtomSerializer
end end
def serialize_status_attributes(entry, status) def serialize_status_attributes(entry, status)
append_element(entry, 'summary', status.spoiler_text) unless status.spoiler_text.blank? append_element(entry, 'summary', status.spoiler_text) if status.spoiler_text?
append_element(entry, 'content', Formatter.instance.format(status.proper).to_str, type: 'html') append_element(entry, 'content', Formatter.instance.format(status.proper).to_str, type: 'html')
status.mentions.each do |mentioned| status.mentions.each do |mentioned|

View File

@ -21,9 +21,9 @@
%i.fa.fa-check %i.fa.fa-check
%td= distance_of_time_in_words(Time.now, subscription.expires_at) %td= distance_of_time_in_words(Time.now, subscription.expires_at)
%td %td
- if subscription.last_successful_delivery_at.nil? - if subscription.last_successful_delivery_at?
%i.fa.fa-times
- else
= l subscription.last_successful_delivery_at = l subscription.last_successful_delivery_at
- else
%i.fa.fa-times
= paginate @subscriptions = paginate @subscriptions

View File

@ -12,10 +12,7 @@
%p %p
%strong= t('reports.comment.label') %strong= t('reports.comment.label')
\: \:
- if @report.comment.blank? = @report.comment.presence || t('reports.comment.none')
= t('reports.comment.none')
- else
= @report.comment
- unless @statuses.empty? - unless @statuses.empty?
%hr/ %hr/

View File

@ -7,5 +7,5 @@
%strong.emojify= display_name(account) %strong.emojify= display_name(account)
%span= "@#{account.acct}" %span= "@#{account.acct}"
- unless account.note.blank? - if account.note?
.account__header__content.emojify= Formatter.instance.simplified_format(account) .account__header__content.emojify= Formatter.instance.simplified_format(account)

View File

@ -8,11 +8,11 @@
%span.p-nickname= acct(status.account) %span.p-nickname= acct(status.account)
.status__content.e-content.p-name.emojify< .status__content.e-content.p-name.emojify<
- unless status.spoiler_text.blank? - if status.spoiler_text?
%p{ style: 'margin-bottom: 0' }< %p{ style: 'margin-bottom: 0' }<
%span>= "#{status.spoiler_text} " %span>= "#{status.spoiler_text} "
%a.status__content__spoiler-link{ href: '#' }= t('statuses.show_more') %a.status__content__spoiler-link{ href: '#' }= t('statuses.show_more')
%div{ style: "display: #{status.spoiler_text.blank? ? 'block' : 'none'}; direction: #{rtl?(status.content) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status) %div{ style: "display: #{status.spoiler_text? ? 'none' : 'block'}; direction: #{rtl?(status.content) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status)
- unless status.media_attachments.empty? - unless status.media_attachments.empty?
- if status.media_attachments.first.video? - if status.media_attachments.first.video?

View File

@ -13,11 +13,11 @@
%span.p-nickname= acct(status.account) %span.p-nickname= acct(status.account)
.status__content.e-content.p-name.emojify< .status__content.e-content.p-name.emojify<
- unless status.spoiler_text.blank? - if status.spoiler_text?
%p{ style: 'margin-bottom: 0' }< %p{ style: 'margin-bottom: 0' }<
%span>= "#{status.spoiler_text} " %span>= "#{status.spoiler_text} "
%a.status__content__spoiler-link{ href: '#' }= t('statuses.show_more') %a.status__content__spoiler-link{ href: '#' }= t('statuses.show_more')
%div{ style: "display: #{status.spoiler_text.blank? ? 'block' : 'none'}; direction: #{rtl?(status.content) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status) %div{ style: "display: #{status.spoiler_text? ? 'none' : 'block'}; direction: #{rtl?(status.content) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status)
- unless status.media_attachments.empty? - unless status.media_attachments.empty?
.status__attachments .status__attachments

View File

@ -19,7 +19,7 @@ class Pubsubhubbub::DeliveryWorker
headers['User-Agent'] = 'Mastodon/PubSubHubbub' headers['User-Agent'] = 'Mastodon/PubSubHubbub'
headers['Link'] = LinkHeader.new([[api_push_url, [%w(rel hub)]], [account_url(subscription.account, format: :atom), [%w(rel self)]]]).to_s headers['Link'] = LinkHeader.new([[api_push_url, [%w(rel hub)]], [account_url(subscription.account, format: :atom), [%w(rel self)]]]).to_s
headers['X-Hub-Signature'] = signature(subscription.secret, payload) unless subscription.secret.blank? headers['X-Hub-Signature'] = signature(subscription.secret, payload) if subscription.secret?
response = HTTP.timeout(:per_operation, write: 50, connect: 20, read: 50) response = HTTP.timeout(:per_operation, write: 50, connect: 20, read: 50)
.headers(headers) .headers(headers)