- title_service_name = "#{@current_community.full_name(I18n.locale)}"

- if content_for?(:title)
  - title = "#{content_for(:title)} - #{title_service_name}"
- else
  - title = "#{title_service_name} - #{community_slogan}"

- if content_for?(:keywords)
  - keywords = content_for(:keywords)
- else
  - keywords = StringUtils.keywords(community_slogan)

- if content_for?(:meta_author)
  - meta_author = content_for(:meta_author)
- else
  - meta_author = @current_community.name(I18n.locale)

- full_url = "#{@current_community.full_url}#{request.fullpath}"

- if content_for?(:meta_description)
  - meta_description = "#{content_for(:meta_description)}"
- else
  - meta_description = "#{community_description(false)} - #{community_slogan}"

- if content_for?(:meta_image)
  - meta_image = content_for(:meta_image)
  - meta_image_width = content_for(:meta_image_width)
  - meta_image_height = content_for(:meta_image_height)
- else
  - if @current_community.logo?
    - meta_image = @current_community.logo.url(:original)
  - else
    - meta_image = image_path("sharetribe_icon.png")

%title= title
%meta{ :property => "og:title", :content => title}
%meta{ :name => "twitter:title", :content => title}
%meta{ :name => "author", :content=> meta_author }
%meta{ :name => "keywords", :content => keywords }
%meta{ :property => "og:url", :content => full_url}
%meta{ :name => "identifier-url", :content => "#{@current_community.full_domain(with_protocol: true)}"}
%meta{ :name => "copyright", :content => "#{@current_community.name(I18n.locale)}"}
%meta{ :name => "twitter:url", :content => full_url}
%meta{ :property => "og:site_name", :content =>"#{@current_community.full_name(locale)}"}
%meta{ :name => "description", :content => strip_tags(meta_description).html_safe}
%meta{ :property => "og:description", :content => strip_tags(meta_description).html_safe}
%meta{ :name => "twitter:description", :content => strip_tags(meta_description).html_safe}
%meta{ :property => "og:image", :content => meta_image}
- if meta_image_width && meta_image_height
  %meta{ :property => "og:image:width", :content => meta_image_width}
  %meta{ :property => "og:image:height", :content => meta_image_height}
%meta{ :name => "twitter:image", :content => meta_image}
%link{:rel => "canonical", :href => full_url}
- if @facebook_locale_code
  %meta{ :property => "og:locale", :content => @facebook_locale_code}

- if @current_community.twitter_handle.present?
  %meta{ :name => "twitter:site", :content => "@#{@current_community.twitter_handle}"}

- if @current_community.facebook_connect_id
  %meta{ :property => "fb:app_id", :content => "#{@current_community.facebook_connect_id}" }

/ CSS
= stylesheet_link_tag "application"

- if @current_community.has_customizations?
  = render partial: "layouts/style_overrides", locals: MarketplaceHelper.style_customizations_map(@current_community)

= stylesheet_link_tag "app-bundle"

/ Modernizr, in the head tag, right after stylesheets, for best performance:
= javascript_include_tag "modernizr.min"

/ Detect if JS is enabled. duplicate of what Modernizr is doing, but we plan to get rid of Modernizr at some point.
:javascript
  document.documentElement.className += ' js-enabled';


/ Android pre Jellybean has an ugly bug, which prevents font-size 0 technique from
/ removing the spaces between inline-blocks. Remove this piece of code when pre Jellybean becomes unsupported
:javascript
  Modernizr.addTest('androidPreJellybean', function(){
    var ua = navigator.userAgent;
    if( ua.indexOf("Android") >= 0 ) {
      var androidversion = parseFloat(ua.slice(ua.indexOf("Android")+8));
      return androidversion < 4.1
    }
  });

= csrf_meta_tag

%link{:rel => "image_src", :href => meta_image}

%link{:rel => "shortcut icon", :href => @current_community.favicon }

%link{:rel => "apple-touch-icon-precomposed",:href => @current_community.logo.url(:apple_touch)}

= auto_discovery_link_tag(:atom, atom_feed_url )

- unless on_admin?
  = @current_community.custom_head_script.try(:html_safe)
