danielweinmann/unlock

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

Summary

Maintainability
Test Coverage
doctype html
html
  head
    meta charset="utf-8"
    meta name="robots" content="index, follow"
    meta name="viewport" content="initial-scale=1.0, width=device-width"
    - if content_for? :meta_tags
      / Page specific meta tags
      = yield :meta_tags
    - else
      / Meta tags for pages that don't have specific meta tags
      meta name="description" content=yield(:title)
      meta name="keywords" content="#{yield :title} Unlock"
      meta property="og:title" content=yield(:title)
      meta property="og:type" content="website"
      meta property="og:url" content=(content_for?(:url) ? yield(:url) : request.url)
      meta property="og:image" content=="#{request.protocol}#{request.host_with_port}#{image_path("logo_facebook.png")}"
      meta property="og:description" content=yield(:title)
      meta name="author" content="Larusso e Weinmann"
    / Metatags for every page
    meta property="og:site_name" content="Unlock"
    meta property="fb:app_id" content=ENV['FACEBOOK_APP_ID']
    meta property="fb:admins" content=ENV['FACEBOOK_ADMINS']
    title= "#{"#{yield :title} · " if content_for?(:title)}Unlock"
    - if content_for? :external_js
      = yield :external_js
    = stylesheet_link_tag "application"
    link rel="shortcut icon" href==image_path('favicon.png')
    javascript:
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

      ga('create', 'UA-43352814-4', 'unlock.fund');
    = javascript_include_tag "application" 
    = csrf_meta_tags 
  body[data-namespace="#{namespace}" data-controller="#{controller_name}" data-action="#{action_name}" data-locale="#{I18n.locale}" data-facebook_app_id="#{ENV['FACEBOOK_APP_ID']}"]
    - if Rails.env.production?
      javascript:
        ga('send', 'pageview');
    div#fb-root
    #flash
      - for key, msg in flash
        - unless key == :timedout
          div class="#{key}" = msg
    #pre_header_wrapper
      header
        - if add_logo?
          .logo= link_to :root do
            h1= image_tag 'logo.png', alt: "Unlock", title: "Unlock"
        - if current_user
          .menu.user
            a.open href="#"
              = truncate current_user.name, length: 18
              span ▾
            nav
              = link_to t('my_contributions'), my_contributions_path
              = link_to t('my_initiatives'), my_initiatives_path
              = link_to t('profile'), edit_user_registration_path
              hr
              = link_to t('logout'), destroy_user_session_path, method: :delete
        - else
          nav.sign_in
            = link_to t('devise.shared.links.sign_up'), new_user_registration_path
            = link_to t('devise.shared.links.sign_in'), new_user_session_path
          / .menu.locales
          /   a.open href="#"
          /     = I18n.locale
          /     span ▾
          /   nav
          /     - I18n.available_locales.select{ |locale| locale != I18n.locale }.map(&:to_s).sort.each do |locale|
          /       = link_to params.merge(locale: locale) do
          /         = locale
      = yield :pre_header
    - if content_for?(:header)
      #header_wrapper
        header= yield :header
    - if content_for?(:post_header)
      #post_header_wrapper
        header= yield :post_header
    #content_wrapper
      #content
        - if add_headline_and_article?
          article
            - if content_for?(:title)
              h2= yield :title
            = yield
        - else
          = yield
    #footer_wrapper
      footer
        section.user
          nav
            - if current_user
              = link_to t('my_contributions'), my_contributions_path
              = link_to t('my_initiatives'), my_initiatives_path
              = link_to t('profile'), edit_user_registration_path
              = link_to t('logout'), destroy_user_session_path, method: :delete
            - elsif namespace != "devise"
              = link_to t('devise.shared.links.sign_up'), new_user_registration_path
              = link_to t('devise.shared.links.sign_in'), new_user_session_path
        section.links
          h5
            a href='https://unlock.fund/unlock' target='_blank'= t('about')
          h5
            a href='https://www.facebook.com/groups/unlock.fund/' target='_blank'= t('help')
          h5
            a href='https://unlock.fund/pages/terms' target='_blank'= t('terms')
        section.credits
          h4
            = link_to :root do
              = image_tag 'logo_footer.png', alt: "Unlock", title: "Unlock"
          h5== t('.love')
          h5== t('.by')
        - if request.method == "GET" && I18n.available_locales.size > 1
          = flag_list 32 do
            - I18n.available_locales.map(&:to_s).sort.each do |locale|
              - if locale_country(locale)
                = link_to params.merge(locale: locale) do
                  = flag(locale_country(locale), :title => t("languages.#{locale}"))