mirror of https://github.com/Siphonay/mastodon
Instance helper to replace site title helper (#2038)
* Move site title helper to instance helper (name change only) * Remove newline in <title> tag * Add site_hostname helper method to wrap up local_domain value * Use site_hostname helper in places that need local_domain value
This commit is contained in:
parent
e1e15adf1d
commit
389f8f8249
|
@ -0,0 +1,11 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module InstanceHelper
|
||||||
|
def site_title
|
||||||
|
Setting.site_title.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
def site_hostname
|
||||||
|
Rails.configuration.x.local_domain
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,7 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module SiteTitleHelper
|
|
||||||
def site_title
|
|
||||||
Setting.site_title.to_s
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -3,4 +3,5 @@
|
||||||
class ApplicationMailer < ActionMailer::Base
|
class ApplicationMailer < ActionMailer::Base
|
||||||
default from: ENV.fetch('SMTP_FROM_ADDRESS') { 'notifications@localhost' }
|
default from: ENV.fetch('SMTP_FROM_ADDRESS') { 'notifications@localhost' }
|
||||||
layout 'mailer'
|
layout 'mailer'
|
||||||
|
helper :instance
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,8 @@ class UserMailer < Devise::Mailer
|
||||||
default from: ENV.fetch('SMTP_FROM_ADDRESS') { 'notifications@localhost' }
|
default from: ENV.fetch('SMTP_FROM_ADDRESS') { 'notifications@localhost' }
|
||||||
layout 'mailer'
|
layout 'mailer'
|
||||||
|
|
||||||
|
helper :instance
|
||||||
|
|
||||||
def confirmation_instructions(user, token, _opts = {})
|
def confirmation_instructions(user, token, _opts = {})
|
||||||
@resource = user
|
@resource = user
|
||||||
@token = token
|
@token = token
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
#{Rails.configuration.x.local_domain}
|
= site_hostname
|
||||||
|
|
||||||
.wrapper.thicc
|
.wrapper.thicc
|
||||||
.sidebar-layout
|
.sidebar-layout
|
||||||
.main
|
.main
|
||||||
.panel
|
.panel
|
||||||
%h2= Rails.configuration.x.local_domain
|
%h2= site_hostname
|
||||||
|
|
||||||
- unless @instance_presenter.site_description.blank?
|
- unless @instance_presenter.site_description.blank?
|
||||||
%p= @instance_presenter.site_description.html_safe
|
%p= @instance_presenter.site_description.html_safe
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
= javascript_include_tag 'application_public', integrity: true
|
= javascript_include_tag 'application_public', integrity: true
|
||||||
|
|
||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
= Rails.configuration.x.local_domain
|
= site_hostname
|
||||||
|
|
||||||
- content_for :header_tags do
|
- content_for :header_tags do
|
||||||
%meta{ property: 'og:site_name', content: site_title }/
|
%meta{ property: 'og:site_name', content: site_title }/
|
||||||
%meta{ property: 'og:type', content: 'website' }/
|
%meta{ property: 'og:type', content: 'website' }/
|
||||||
%meta{ property: 'og:title', content: Rails.configuration.x.local_domain }/
|
%meta{ property: 'og:title', content: site_hostname }/
|
||||||
%meta{ property: 'og:description', content: strip_tags(@instance_presenter.site_description.presence || t('about.about_mastodon')) }/
|
%meta{ property: 'og:description', content: strip_tags(@instance_presenter.site_description.presence || t('about.about_mastodon')) }/
|
||||||
%meta{ property: 'og:image', content: asset_url('mastodon_small.jpg') }/
|
%meta{ property: 'og:image', content: asset_url('mastodon_small.jpg') }/
|
||||||
%meta{ property: 'og:image:width', content: '400' }/
|
%meta{ property: 'og:image:width', content: '400' }/
|
||||||
|
@ -72,7 +72,7 @@
|
||||||
= t 'about.features.api'
|
= t 'about.features.api'
|
||||||
|
|
||||||
- unless @instance_presenter.site_description.blank?
|
- unless @instance_presenter.site_description.blank?
|
||||||
%h3= t('about.description_headline', domain: Rails.configuration.x.local_domain)
|
%h3= t('about.description_headline', domain: site_hostname)
|
||||||
%p= @instance_presenter.site_description.html_safe
|
%p= @instance_presenter.site_description.html_safe
|
||||||
|
|
||||||
.actions
|
.actions
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
#{Rails.configuration.x.local_domain} Terms of Service and Privacy Policy
|
#{site_hostname} Terms of Service and Privacy Policy
|
||||||
|
|
||||||
.wrapper
|
.wrapper
|
||||||
%h2 Privacy Policy
|
%h2 Privacy Policy
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
#{Rails.configuration.x.local_domain} Personvern og villkår for bruk av nettstedet
|
#{site_hostname} Personvern og villkår for bruk av nettstedet
|
||||||
|
|
||||||
.wrapper
|
.wrapper
|
||||||
%h2 Personvernserklæring
|
%h2 Personvernserklæring
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
%meta{ property: 'og:site_name', content: site_title }/
|
%meta{ property: 'og:site_name', content: site_title }/
|
||||||
%meta{ property: 'og:type', content: 'profile' }/
|
%meta{ property: 'og:type', content: 'profile' }/
|
||||||
%meta{ property: 'og:title', content: "#{@account.username} on #{Rails.configuration.x.local_domain}" }/
|
%meta{ property: 'og:title', content: "#{@account.username} on #{site_hostname}" }/
|
||||||
%meta{ property: 'og:description', content: @account.note }/
|
%meta{ property: 'og:description', content: @account.note }/
|
||||||
%meta{ property: 'og:image', content: full_asset_url(@account.avatar.url(:original)) }/
|
%meta{ property: 'og:image', content: full_asset_url(@account.avatar.url(:original)) }/
|
||||||
%meta{ property: 'og:image:width', content: '120' }/
|
%meta{ property: 'og:image:width', content: '120' }/
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
= render partial: 'shared/landing_strip', locals: { account: @account }
|
= render partial: 'shared/landing_strip', locals: { account: @account }
|
||||||
|
|
||||||
.h-feed
|
.h-feed
|
||||||
%data.p-name{ value: "#{@account.username} on #{Rails.configuration.x.local_domain}" }/
|
%data.p-name{ value: "#{@account.username} on #{site_hostname}" }/
|
||||||
|
|
||||||
= render 'header', account: @account
|
= render 'header', account: @account
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ node(:version) { '1.0' }
|
||||||
node(:title, &:title)
|
node(:title, &:title)
|
||||||
node(:author_name) { |entry| entry.account.display_name.blank? ? entry.account.username : entry.account.display_name }
|
node(:author_name) { |entry| entry.account.display_name.blank? ? entry.account.username : entry.account.display_name }
|
||||||
node(:author_url) { |entry| account_url(entry.account) }
|
node(:author_url) { |entry| account_url(entry.account) }
|
||||||
node(:provider_name) { Rails.configuration.x.local_domain }
|
node(:provider_name) { site_hostname }
|
||||||
node(:provider_url) { root_url }
|
node(:provider_url) { root_url }
|
||||||
node(:cache_age) { 86_400 }
|
node(:cache_age) { 86_400 }
|
||||||
node(:html) { |entry| "<iframe src=\"#{embed_account_stream_entry_url(entry.account, entry)}\" style=\"width: 100%; overflow: hidden\" frameborder=\"0\" width=\"#{@width}\" height=\"#{@height}\" scrolling=\"no\"></iframe>" }
|
node(:html) { |entry| "<iframe src=\"#{embed_account_stream_entry_url(entry.account, entry)}\" style=\"width: 100%; overflow: hidden\" frameborder=\"0\" width=\"#{@width}\" height=\"#{@height}\" scrolling=\"no\"></iframe>" }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
object false
|
object false
|
||||||
|
|
||||||
node(:uri) { Rails.configuration.x.local_domain }
|
node(:uri) { site_hostname }
|
||||||
node(:title) { Setting.site_title }
|
node(:title) { Setting.site_title }
|
||||||
node(:description) { Setting.site_description }
|
node(:description) { Setting.site_description }
|
||||||
node(:email) { Setting.site_contact_email }
|
node(:email) { Setting.site_contact_email }
|
||||||
|
|
|
@ -5,7 +5,7 @@ node(:meta) do
|
||||||
streaming_api_base_url: @streaming_api_base_url,
|
streaming_api_base_url: @streaming_api_base_url,
|
||||||
access_token: @token,
|
access_token: @token,
|
||||||
locale: I18n.locale,
|
locale: I18n.locale,
|
||||||
domain: Rails.configuration.x.local_domain,
|
domain: site_hostname,
|
||||||
me: current_account.id,
|
me: current_account.id,
|
||||||
admin: @admin.try(:id),
|
admin: @admin.try(:id),
|
||||||
boost_modal: current_account.user.setting_boost_modal,
|
boost_modal: current_account.user.setting_boost_modal,
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
%title<
|
%title<
|
||||||
- if content_for?(:page_title)
|
- if content_for?(:page_title)
|
||||||
= yield(:page_title)
|
= yield(:page_title).strip
|
||||||
= ' - '
|
= ' - '
|
||||||
= site_title
|
= site_title
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
---
|
---
|
||||||
|
|
||||||
<%= t('application_mailer.signature', instance: Rails.configuration.x.local_domain) %>
|
<%= t('application_mailer.signature', instance: site_hostname) %>
|
||||||
<%= t('application_mailer.settings', link: settings_preferences_url) %>
|
<%= t('application_mailer.settings', link: settings_preferences_url) %>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
- content_for :content do
|
- content_for :content do
|
||||||
.container= yield
|
.container= yield
|
||||||
.footer
|
.footer
|
||||||
%span.domain= link_to Rails.configuration.x.local_domain, root_path
|
%span.domain= link_to site_hostname, root_path
|
||||||
%span.powered-by
|
%span.powered-by
|
||||||
= t('generic.powered_by', link: link_to('Mastodon', 'https://github.com/tootsuite/mastodon')).html_safe
|
= t('generic.powered_by', link: link_to('Mastodon', 'https://github.com/tootsuite/mastodon')).html_safe
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.landing-strip
|
.landing-strip
|
||||||
= t('landing_strip_html',
|
= t('landing_strip_html',
|
||||||
name: content_tag(:span, display_name(account), class: :emojify),
|
name: content_tag(:span, display_name(account), class: :emojify),
|
||||||
domain: Rails.configuration.x.local_domain,
|
domain: site_hostname,
|
||||||
sign_up_path: new_user_registration_path)
|
sign_up_path: new_user_registration_path)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
%meta{ property: 'og:site_name', content: site_title }/
|
%meta{ property: 'og:site_name', content: site_title }/
|
||||||
%meta{ property: 'og:type', content: 'article' }/
|
%meta{ property: 'og:type', content: 'article' }/
|
||||||
%meta{ property: 'og:title', content: "#{@account.username} on #{Rails.configuration.x.local_domain}" }/
|
%meta{ property: 'og:title', content: "#{@account.username} on #{site_hostname}" }/
|
||||||
|
|
||||||
= render 'stream_entries/og_description', activity: @stream_entry.activity
|
= render 'stream_entries/og_description', activity: @stream_entry.activity
|
||||||
= render 'stream_entries/og_image', activity: @stream_entry.activity, account: @account
|
= render 'stream_entries/og_image', activity: @stream_entry.activity, account: @account
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
describe InstanceHelper do
|
||||||
|
describe 'site_title' do
|
||||||
|
it 'Uses the Setting.site_title value when it exists' do
|
||||||
|
Setting.site_title = 'New site title'
|
||||||
|
|
||||||
|
expect(helper.site_title).to eq 'New site title'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns empty string when Setting.site_title is nil' do
|
||||||
|
Setting.site_title = nil
|
||||||
|
|
||||||
|
expect(helper.site_title).to eq ''
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'site_hostname' do
|
||||||
|
around(:each) do |example|
|
||||||
|
before = Rails.configuration.x.local_domain
|
||||||
|
example.run
|
||||||
|
Rails.configuration.x.local_domain = before
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns the local domain value' do
|
||||||
|
Rails.configuration.x.local_domain = 'example.com'
|
||||||
|
|
||||||
|
expect(helper.site_hostname).to eq 'example.com'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,15 +0,0 @@
|
||||||
require "rails_helper"
|
|
||||||
|
|
||||||
describe "site_title" do
|
|
||||||
it "Uses the Setting.site_title value when it exists" do
|
|
||||||
Setting.site_title = "New site title"
|
|
||||||
|
|
||||||
expect(helper.site_title).to eq "New site title"
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns empty string when Setting.site_title is nil" do
|
|
||||||
Setting.site_title = nil
|
|
||||||
|
|
||||||
expect(helper.site_title).to eq ""
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in New Issue