mashirozx/mastodon

View on GitHub
app/views/layouts/application.html.haml

Summary

Maintainability
Test Coverage
!!! 5
%html{ lang: I18n.locale }
  %head
    %meta{ charset: 'utf-8' }/
    %meta{ name: 'viewport', content: 'width=device-width, initial-scale=1' }/

    - if cdn_host?
      %link{ rel: 'dns-prefetch', href: cdn_host }/
      %meta{ name: 'cdn-host', content: cdn_host }/

    - if storage_host?
      %link{ rel: 'dns-prefetch', href: storage_host }/
    
    - if user_signed_in?
      - unless (not current_user.setting_enable_noto_serif) or current_user.setting_system_font_ui
        %link{ rel: 'preconnect', href: 'https://fonts.googleapis.com' }/
        %link{ rel: 'preconnect', href: 'https://fonts.gstatic.com', crossorigin: true }/

    %link{ rel: 'icon', href: "/favicon#{ENV['LOGO_PACK'] || ''}.ico", type: 'image/x-icon' }/

    - %w(16 32 48).each do |size|
      %link{ rel: 'icon', sizes: "#{size}x#{size}", href: asset_pack_path("media/icons/favicon-#{size}x#{size}#{ENV['LOGO_PACK'] || ''}.png"), type: 'image/png' }/

    - %w(57 60 72 76 114 120 144 152 167 180 1024).each do |size|
      %link{ rel: 'apple-touch-icon', sizes: "#{size}x#{size}", href: asset_pack_path("media/icons/apple-touch-icon-#{size}x#{size}#{ENV['LOGO_PACK'] || ''}.png") }/

    %link{ rel: 'mask-icon', href: asset_pack_path("media/images/logo-symbol-icon#{ENV['LOGO_PACK'] || ''}.svg"), color: '#6364FF' }/
    %link{ rel: 'manifest', href: manifest_path(format: :json) }/
    %meta{ name: 'theme-color', content: '#282c37' }/
    %meta{ name: 'apple-mobile-web-app-capable', content: 'yes' }/
    %meta{ name: 'apple-itunes-app', content: 'app-id=1571998974' }/

    %title= content_for?(:page_title) ? safe_join([yield(:page_title).chomp.html_safe, title], ' - ') : title

    = stylesheet_pack_tag 'common', media: 'all', crossorigin: 'anonymous'
    = stylesheet_pack_tag current_theme, media: 'all', crossorigin: 'anonymous'
    = javascript_pack_tag 'common', crossorigin: 'anonymous'
    = javascript_pack_tag "locale_#{I18n.locale}", crossorigin: 'anonymous'
    = csrf_meta_tags
    %meta{ name: 'style-nonce', content: request.content_security_policy_nonce }

    = stylesheet_link_tag '/inert.css', skip_pipeline: true, media: 'all', id: 'inert-style'

    - if Setting.custom_css.present? || Setting.custom_css.present?
      = stylesheet_link_tag custom_css_path(Digest::SHA1.hexdigest("#{Setting.custom_css if Setting.custom_css.present?}\n#{current_user.setting_custom_css if user_signed_in?}")), host: default_url_options[:host], media: 'all'


    -if user_signed_in? && current_user.setting_enable_snowfall
      = content_tag(:script, nil, src: full_asset_url('plugins/snow.js?v3', skip_pipeline: true), async: true)
      = stylesheet_link_tag '/plugins/snow.css', skip_pipeline: true, media: 'all', id: 'snow-plugin-style'


    - if ENV['PLAUSIBLE_ANALYTICS_HOST']
      = javascript_include_tag "//#{ ENV['PLAUSIBLE_ANALYTICS_HOST'] }/js/plausible.js", :defer => true, :async => 'async', :'data-domain' => ENV['PLAUSIBLE_ANALYTICS_SITE_DOMAIN'] || Rails.configuration.x.local_domain

    - if ENV['MATOMO_ANALYTICS_HOST']
      = javascript_pack_tag 'matomo', crossorigin: 'anonymous', 'data-matomo-host' => ENV['MATOMO_ANALYTICS_HOST'], 'data-matomo-site-id' => ENV['MATOMO_ANALYTICS_SITE_ID']

    = stylesheet_link_tag '/plugins/icon-mastodon-custom/iconfont.css?t=1656835877240', skip_pipeline: true, media: 'all', id: 'icon-mastodon-custom-style'

    - if user_signed_in?
      - unless (not current_user.setting_enable_noto_serif) or current_user.setting_system_font_ui
        - if ['zh-HK', 'zh-TW'].include? I18n.locale.to_s
          = stylesheet_link_tag zh_hans_font_url, skip_pipeline: true, media: 'all'
        - if ['ja'].include? I18n.locale.to_s
          = stylesheet_link_tag ja_font_url, skip_pipeline: true, media: 'all'
        - else
          = stylesheet_link_tag zh_hans_font_url, skip_pipeline: true, media: 'all'

      - if current_user.setting_icon_pack == 'forest'
        -# = stylesheet_link_tag 'https://at.alicdn.com/t/font_3453204_g1r9b59fnds.css', skip_pipeline: true, media: 'all'
        = stylesheet_link_tag forest_icon_pack_url, skip_pipeline: true, media: 'all', id: 'icon-forest-style'

    = yield :header_tags

  %body{ class: body_classes }
    = content_for?(:content) ? yield(:content) : yield

    .logo-resources{ 'tabindex' => '-1', 'inert' => true, 'aria-hidden' => true }
      = render_symbol :icon
      = render_symbol :wordmark
      = render_symbol :wordmark_with_sub