Merge remote-tracking branch 'origin/master' into gs-master
Conflicts: .travis.yml Gemfile.lock README.md app/controllers/settings/follower_domains_controller.rb app/controllers/statuses_controller.rb app/javascript/mastodon/locales/ja.json app/lib/feed_manager.rb app/models/media_attachment.rb app/models/mute.rb app/models/status.rb app/services/mute_service.rb app/views/home/index.html.haml app/views/stream_entries/_simple_status.html.haml config/locales/ca.yml config/locales/en.yml config/locales/es.yml config/locales/fr.yml config/locales/nl.yml config/locales/pl.yml config/locales/pt-BR.yml config/themes.yml
This commit is contained in:
@@ -1,4 +1,20 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin::AccountModerationNotesHelper
|
||||
def admin_account_link_to(account)
|
||||
link_to admin_account_path(account.id), class: name_tag_classes(account) do
|
||||
safe_join([
|
||||
image_tag(account.avatar.url, width: 15, height: 15, alt: display_name(account), class: 'avatar'),
|
||||
content_tag(:span, account.acct, class: 'username'),
|
||||
], ' ')
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def name_tag_classes(account)
|
||||
classes = ['name-tag']
|
||||
classes << 'suspended' if account.suspended?
|
||||
classes.join(' ')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -63,4 +63,8 @@ module ApplicationHelper
|
||||
def opengraph(property, content)
|
||||
tag(:meta, content: content, property: property)
|
||||
end
|
||||
|
||||
def react_component(name, props = {})
|
||||
content_tag(:div, nil, data: { component: name.to_s.camelcase, props: Oj.dump(props) })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,6 +5,10 @@ module JsonLdHelper
|
||||
haystack.is_a?(Array) ? haystack.include?(needle) : haystack == needle
|
||||
end
|
||||
|
||||
def equals_or_includes_any?(haystack, needles)
|
||||
needles.any? { |needle| equals_or_includes?(haystack, needle) }
|
||||
end
|
||||
|
||||
def first_of_value(value)
|
||||
value.is_a?(Array) ? value.first : value
|
||||
end
|
||||
@@ -44,7 +48,7 @@ module JsonLdHelper
|
||||
end
|
||||
|
||||
def canonicalize(json)
|
||||
graph = RDF::Graph.new << JSON::LD::API.toRdf(json)
|
||||
graph = RDF::Graph.new << JSON::LD::API.toRdf(json, documentLoader: method(:load_jsonld_context))
|
||||
graph.dump(:normalize)
|
||||
end
|
||||
|
||||
@@ -86,4 +90,19 @@ module JsonLdHelper
|
||||
request.add_headers('Accept' => 'application/activity+json, application/ld+json')
|
||||
request
|
||||
end
|
||||
|
||||
def load_jsonld_context(url, _options = {}, &_block)
|
||||
json = Rails.cache.fetch("jsonld:context:#{url}", expires_in: 30.days, raw: true) do
|
||||
request = Request.new(:get, url)
|
||||
request.add_headers('Accept' => 'application/ld+json')
|
||||
|
||||
request.perform do |res|
|
||||
raise JSON::LD::JsonLdError::LoadingDocumentFailed unless res.code == 200 && res.mime_type == 'application/ld+json'
|
||||
res.body_with_limit
|
||||
end
|
||||
end
|
||||
|
||||
doc = JSON::LD::API::RemoteDocument.new(url, json)
|
||||
block_given? ? yield(doc) : doc
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,12 +7,14 @@ module SettingsHelper
|
||||
bg: 'Български',
|
||||
ca: 'Català',
|
||||
de: 'Deutsch',
|
||||
el: 'Ελληνικά',
|
||||
eo: 'Esperanto',
|
||||
es: 'Español',
|
||||
eu: 'Euskara',
|
||||
fa: 'فارسی',
|
||||
gl: 'Galego',
|
||||
fi: 'Suomi',
|
||||
fr: 'Français',
|
||||
gl: 'Galego',
|
||||
he: 'עברית',
|
||||
hr: 'Hrvatski',
|
||||
hu: 'Magyar',
|
||||
@@ -33,6 +35,7 @@ module SettingsHelper
|
||||
sr: 'Српски',
|
||||
'sr-Latn': 'Srpski (latinica)',
|
||||
sv: 'Svenska',
|
||||
te: 'తెలుగు',
|
||||
th: 'ภาษาไทย',
|
||||
tr: 'Türkçe',
|
||||
uk: 'Українська',
|
||||
|
||||
@@ -12,17 +12,17 @@ module StreamEntriesHelper
|
||||
prepend_str = [
|
||||
[
|
||||
number_to_human(account.statuses_count, strip_insignificant_zeros: true),
|
||||
t('accounts.posts'),
|
||||
I18n.t('accounts.posts'),
|
||||
].join(' '),
|
||||
|
||||
[
|
||||
number_to_human(account.following_count, strip_insignificant_zeros: true),
|
||||
t('accounts.following'),
|
||||
I18n.t('accounts.following'),
|
||||
].join(' '),
|
||||
|
||||
[
|
||||
number_to_human(account.followers_count, strip_insignificant_zeros: true),
|
||||
t('accounts.followers'),
|
||||
I18n.t('accounts.followers'),
|
||||
].join(' '),
|
||||
].join(', ')
|
||||
|
||||
@@ -40,16 +40,16 @@ module StreamEntriesHelper
|
||||
end
|
||||
end
|
||||
|
||||
text = attachments.to_a.reject { |_, value| value.zero? }.map { |key, value| t("statuses.attached.#{key}", count: value) }.join(' · ')
|
||||
text = attachments.to_a.reject { |_, value| value.zero? }.map { |key, value| I18n.t("statuses.attached.#{key}", count: value) }.join(' · ')
|
||||
|
||||
return if text.blank?
|
||||
|
||||
t('statuses.attached.description', attached: text)
|
||||
I18n.t('statuses.attached.description', attached: text)
|
||||
end
|
||||
|
||||
def status_text_summary(status)
|
||||
return if status.spoiler_text.blank?
|
||||
t('statuses.content_warning', warning: status.spoiler_text)
|
||||
I18n.t('statuses.content_warning', warning: status.spoiler_text)
|
||||
end
|
||||
|
||||
def status_description(status)
|
||||
@@ -113,6 +113,19 @@ module StreamEntriesHelper
|
||||
end
|
||||
end
|
||||
|
||||
def fa_visibility_icon(status)
|
||||
case status.visibility
|
||||
when 'public'
|
||||
fa_icon 'globe fw'
|
||||
when 'unlisted'
|
||||
fa_icon 'unlock-alt fw'
|
||||
when 'private'
|
||||
fa_icon 'lock fw'
|
||||
when 'direct'
|
||||
fa_icon 'envelope fw'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def simplified_text(text)
|
||||
|
||||
Reference in New Issue
Block a user