<%
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
# This program is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free Software
# Foundation; either version 3.0 of the License, or (at your option) any later
# version.
#
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
%>

<!DOCTYPE html>
<html>
  <head>
    <title><%= t("bigbluebutton") %></title>
    <%= csrf_meta_tags %>

    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">

    <!-- Global javascript variables and helpers. -->
    <script type="text/javascript">
      window.GreenLight = {};
      window.GreenLight.WEBSOCKET_HOST = "<%= ENV['WEBSOCKET_HOST'] %>"
      window.GreenLight.RELATIVE_ROOT = "<%= relative_root %>"
    </script>

    <link href="https://fonts.googleapis.com/css?family=Roboto:400,500" rel="stylesheet">

    <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>


    <!-- Because of turbolinks, this will only load once -->
    <%= stylesheet_link_tag    "https://cdn.jsdelivr.net/npm/@simonwep/pickr/dist/themes/monolith.min.css" %>
    <%= javascript_include_tag "https://cdn.jsdelivr.net/npm/@simonwep/pickr/dist/pickr.min.js" %>

    <!-- Primary color styling -->
    <%= stylesheet_link_tag themes_primary_path %>

    <script type="text/javascript">
      // Rail-ish function to translate a string, according to the Rails locales
      window.t = function t(key) {
        if (!key) {
          return "";
        }

        var keys = key.split('.');
        var value = <%= current_translations.to_json.html_safe %>; // Add I18n variables

        keys.forEach(key => {
          if (value) {
            value = value[key];
          }
        });

        return value ? value : "";
      }
    </script>
  </head>

  <body class="app-background" data-controller="<%= params[:controller] %>" data-action="<%= params[:action] %>" data-relative-root="<%= Rails.configuration.relative_url_root || "/" %>">
    <%= render "shared/header" %>

    <div class="wrapper">
      <% if bigbluebutton_endpoint_default? %>
        <div class="alert alert-icon alert-danger text-center mb-0">
          <div class="flash alert d-inline">
            <i class="fas fa-exclamation-triangle"></i>
            <p class="d-inline"><%= t("test_install",
              href: link_to(t("docs").downcase, "http://docs.bigbluebutton.org/install/greenlight-v2.html#2-install-greenlight", target: "_blank")
            ).html_safe %>
          </div>
        </div>
      <% end %>

      <% unless Rails.configuration.banner_message.blank? %>
        <div class="alert alert-icon alert-danger text-center mb-0">
          <div class="flash alert d-inline">
            <p class="d-inline"><%= Rails.configuration.banner_message %></p>
          </div>
        </div>
      <% end %>

      <%= render 'shared/flash_messages' unless flash.empty? %>

      <%= yield %>
    </div>

    <%= render "shared/footer" %>
  </body>
</html>
