<!DOCTYPE html>
<html lang="<%= I18n.locale %>" ng-app="application" class="app">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="">
  <meta name="author" content="">

  <title><%=Setting.find_by(name: 'fablab_name').value%></title>

  <% if ENV['DEFAULT_HOST'] == 'fablab.lacasemate.fr' %>
    <script type="text/javascript" src="//use.typekit.net/rih5zfr.js"></script>
    <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
  <% else %>
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,400italic,600,600italic,700,800,700italic' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700,300italic' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Loved+by+the+King' rel='stylesheet' type='text/css'>
  <% end %>
  <script type="text/javascript" src="https://js.stripe.com/v2/"></script>
  <script type="text/javascript">
      Stripe.setPublishableKey('<%= Rails.application.secrets.stripe_publishable_key %>');

      var Fablab = Fablab || {};

      Fablab.withoutPlans = ('<%= Rails.application.secrets.fablab_without_plans %>' == 'true');
      Fablab.withoutSpaces = ('<%= Rails.application.secrets.fablab_without_spaces %>' != 'false');
      Fablab.disqusShortname = "<%= Rails.application.secrets.disqus_shortname %>";
      Fablab.defaultHost = "<%= Rails.application.secrets.default_host %>";
      Fablab.gaId = "<%= Rails.application.secrets.google_analytics_id %>";

      // i18n stuff
      Fablab.locale = "<%= I18n.locale %>";
      Fablab.moment_locale = "<%= Rails.application.secrets.moment_locale %>";
      Fablab.summernote_locale = "<%= Rails.application.secrets.summernote_locale %>";
      Fablab.fullcalendar_locale = "<%= Rails.application.secrets.fullcalendar_locale %>";
      Fablab.timezone = "<%= Time.zone.tzinfo.name %>";
      Fablab.translations = {
        app: {
          shared: {
            buttons: <%= I18n.t('app.shared.buttons').to_json.html_safe %>,
            messages: <%= I18n.t('app.shared.messages').to_json.html_safe %>
          }
        }
      };
      Fablab.weekStartingDay = <%= Date.parse(Rails.application.secrets.week_starting_day).strftime('%w') %>;
      Fablab.d3DateFormat = "<%= Rails.application.secrets.d3_date_format %>";
      Fablab.uibDateFormat = "<%= Rails.application.secrets.uib_date_format %>";
      Fablab.openlabProjectsActive = <%= Rails.application.secrets.openlab_app_secret.present? %>;
      <% if Rails.application.secrets.openlab_app_id.present? %>
      Fablab.openlabAppId = "<%= Rails.application.secrets.openlab_app_id %>";
      <% else %>
      Fablab.openlabAppId = null;
      <% end %>
  </script>

  <%= stylesheet_link_tag 'application', media: 'all' %>
  <%= stylesheet_link_tag 'app.printer', media: 'print' %>
  <% if !Stylesheet.first.nil? %>
    <link rel="stylesheet" media="all" href="<%= stylesheet_path(Stylesheet.first.id) %>-<%=Stylesheet.first.updated_at.to_i.to_s%>.css" />
  <% end %>
  <base href="/"></base>

  <% if CustomAsset.get_url('favicon-file') %>
    <link rel="shortcut icon" type="image/x-icon" href="<%= CustomAsset.get_url('favicon-file') %>">
    <link rel="shortcut icon" type="image/ico" href="<%= CustomAsset.get_url('favicon-file') %>">
  <% end %>

  <!-- RSS -->
  <link rel="alternate" type="application/rss+xml" title="RSS: <%= t('app.public.projects_list.the_fablab_projects') %>" href="<%= rss_projects_path %>.xml">
  <link rel="alternate" type="application/rss+xml" title="RSS: <%= t('app.public.events_list.the_fablab_s_events') %>" href="<%= rss_events_path %>.xml">

  <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>

<body ng-controller="ApplicationController" ng-init="setCurrentUser(<%= current_user ? current_user.to_builder.target! : 'null' %>)" ng-cloak>
  <div growl></div>

  <%= flash_messages %>

  <section class="vbox">

    <header class="header header-md navbar navbar-fixed-top-xs">
      <div ui-view="header"></div>
    </header>

    <section ui-view="content">
      <section class="hbox stretch">
        <aside id="nav" class="aside-md bg-red hidden-print" ui-view="leftnav"></aside>

        <section id="content">
          <section class="vbox">
            <section id="content-main" class="scrollable" ui-view="main">
            </section>
          </section>
        </section>


      </section> <!-- /.hbox -->
    </section>

  </section> <!-- /.vbox -->

  <div class="app-generator">
    <span class="app-version" ng-if="currentUser && currentUser.role == 'admin'" uib-tooltip="{{'version' | translate}} {{version.version}}">
      <i class="fa fa-question-circle" aria-label="Version ?"></i>
    </span>
    <span class="text-sm">Powered by <a href="http://www.fab-manager.com" target="_blank">Fab Manager</a></span>
  </div>

<%= javascript_include_tag 'application' %>

<!-- i18n of external libraries -->
<script type="text/javascript" src="<%= asset_path "angular-i18n/angular-locale_#{Rails.application.secrets.angular_locale}.js" %>"></script>
<script type="text/javascript" src="<%= asset_path "messageformat/locale/#{Rails.application.secrets.messageformat_locale}.js" %>"></script>

<!-- if required locale does not exist, use the default "en" -->
<% if Rails.application.assets.find_asset "moment/locale/#{Rails.application.secrets.moment_locale}.js" %>
  <script type="text/javascript" src="<%= asset_path "moment/locale/#{Rails.application.secrets.moment_locale}.js" %>"></script>
<%
  elsif Rails.application.secrets.moment_locale != 'en'
    raise LoadError, "moment/locale/#{Rails.application.secrets.moment_locale}.js does not exists"
  end
%>
<!-- if required locale does not exist, use the default "en-US" -->
<% if Rails.application.assets.find_asset "summernote/lang/summernote-#{Rails.application.secrets.summernote_locale}.js" %>
  <script type="text/javascript" src="<%= asset_path "summernote/lang/summernote-#{Rails.application.secrets.summernote_locale}.js" %>"></script>
<%
  elsif Rails.application.secrets.summernote_locale != 'en-US'
    raise LoadError, "summernote/lang/summernote-#{Rails.application.secrets.summernote_locale}.js does not exists"
  end
%>
<!-- if required locale does not exist, use the default "en" -->
<% if Rails.application.assets.find_asset "fullcalendar/dist/lang/#{Rails.application.secrets.fullcalendar_locale}.js" %>
  <script type="text/javascript" src="<%= asset_path "fullcalendar/dist/lang/#{Rails.application.secrets.fullcalendar_locale}.js" %>"></script>
<%
  elsif Rails.application.secrets.fullcalendar_locale != 'en'
    raise LoadError, "fullcalendar/dist/lang/#{Rails.application.secrets.fullcalendar_locale}.js does not exists"
  end
%>
</body>
</html>
