main.html 6.42 KB
Newer Older
1
## coding=utf-8
2 3 4 5 6 7 8 9 10 11 12

## This is the main Mako template that all page templates should include.
## Note: there are a handful of pages that use Django Templates and which
## instead include main_django.html. It is important that these two files
## remain in sync, so changes made in one should be applied to the other.

## Pages currently use v1 styling by default. Once the Pattern Library
## rollout has been completed, this default can be switched to v2.
<%! main_css = "style-main-v1" %>


13
<%namespace name='static' file='static_content.html'/>
14
<% online_help_token = self.online_help_token() if hasattr(self, 'online_help_token') else None %>
15
<%!
16
from django.core.urlresolvers import reverse
17 18
from django.utils.http import urlquote_plus
from django.utils.translation import ugettext as _
David Baumgold committed
19
from django.utils.translation import get_language_bidi
20
from branding import api as branding_api
21
from pipeline_mako import render_require_js_path_overrides
22
%>
23
<!DOCTYPE html>
24 25
<!--[if lte IE 9]><html class="ie ie9 lte9" lang="${LANGUAGE_CODE}"><![endif]-->
<!--[if !IE]><!--><html lang="${LANGUAGE_CODE}"><!--<![endif]-->
26
<head dir="${static.dir_rtl()}">
27 28
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
29
    <meta name="viewport" content="width=device-width, initial-scale=1">
30 31 32 33 34

## Define a couple of helper functions to make life easier when
## embedding theme conditionals into templates. All inheriting
## templates have access to these functions, and we can import these
## into non-inheriting templates via the %namespace tag.
35

36 37
## this needs to be here to prevent the title from mysteriously appearing in the body, in one case
<%def name="pagetitle()" />
38
  <%block name="title">
39
      <title>
40
       ${static.get_page_title_breadcrumbs(self.pagetitle())}
41
      </title>
42
  </%block>
43

44 45 46 47 48 49 50 51 52 53
  % if not allow_iframing:
      <script type="text/javascript">
        /* immediately break out of an iframe if coming from the marketing website */
        (function(window) {
          if (window.location !== window.top.location) {
            window.top.location = window.location;
          }
        })(this);
      </script>
  % endif
54

55 56 57 58 59
  <%
    jsi18n_path = "js/i18n/{language}/djangojs.js".format(language=LANGUAGE_CODE)
  %>

  <script type="text/javascript" src="${static.url(jsi18n_path)}"></script>
60

61
  <link rel="icon" type="image/x-icon" href="${static.url(static.get_value('favicon_path', settings.FAVICON_PATH))}" />
62

63
  <%static:css group='style-vendor'/>
64
  <%static:css group='${self.attr.main_css}'/>
65

66 67 68 69 70 71 72 73
  % if not uses_pattern_library:
    % if disable_courseware_js:
      <%static:js group='base_vendor'/>
      <%static:js group='base_application'/>
    % else:
      <%static:js group='main_vendor'/>
      <%static:js group='application'/>
    % endif
74
  % else:
75 76 77
    ## TODO: Update to only bring in RequireJS
    ## https://openedx.atlassian.net/browse/FEDX-140
    <%static:js group='base_vendor'/>
Andy Armstrong committed
78
    <%static:js group='base_application'/>
79 80 81 82 83 84
  % endif

  <script>
    window.baseUrl = "${settings.STATIC_URL}";
    (function (require) {
      require.config({
85
          baseUrl: window.baseUrl
86 87 88
      });
    }).call(this, require || RequireJS.require);
  </script>
89
  <script type="text/javascript" src="${static.url("lms/js/require-config.js")}"></script>
90
  <%block name="js_overrides">
91
    ${render_require_js_path_overrides(settings.REQUIRE_JS_PATH_OVERRIDES)}
92 93
  </%block>

94 95 96 97
  % if not disable_courseware_js:
    <%static:js group='module-js'/>
  % endif

98
  <%block name="headextra"/>
99

100
  <%static:optional_include_mako file="head-extra.html" is_theming_enabled="True" />
101

Renzo Lucioni committed
102
  <%include file="widgets/optimizely.html" />
103
  <%include file="widgets/segment-io.html" />
Renzo Lucioni committed
104

105
  <meta name="path_prefix" content="${EDX_ROOT_URL}">
106
  <meta name="google-site-verification" content="_mipQ4AtZQDNmbtOkwehQDOgCxUUV2fb_C0b6wbiRHY" />
107

108
<% ga_acct = static.get_value("GOOGLE_ANALYTICS_ACCOUNT", settings.GOOGLE_ANALYTICS_ACCOUNT) %>
109 110 111 112 113 114 115 116 117 118 119 120
% if ga_acct:
    <script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', '${ga_acct}']);
    _gaq.push(['_trackPageview']);

    (function() {
      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
    </script>
121
% endif
122

pmitros committed
123
</head>
Kyle Fiedler committed
124

125
<body class="${static.dir_rtl()} <%block name='bodyclass'/> lang_${LANGUAGE_CODE}">
126

127
<%static:optional_include_mako file="body-initial.html" is_theming_enabled="True" />
128
<div id="page-prompt"></div>
129
% if not disable_window_wrap:
130
  <div class="window-wrap" dir="${static.dir_rtl()}">
131
% endif
132
    <a class="nav-skip" href="#main">${_("Skip to main content")}</a>
133

134
    % if not disable_header:
135
        <%include file="${static.get_template_path('header.html')}" args="online_help_token=online_help_token" />
136
    % endif
137

138
    <div class="content-wrapper" id="content">
139 140 141
      ${self.body()}
      <%block name="bodyextra"/>
    </div>
142

143
    % if not disable_footer:
144
        <%include file="${static.get_template_path('footer.html')}" />
145
    % endif
146

147
% if not disable_window_wrap:
148
  </div>
149
% endif
150

Matthew Mongeau committed
151
  <%block name="js_extra"/>
152

153
  <%include file="widgets/segment-io-footer.html" />
154
  <script type="text/javascript" src="${static.url('js/vendor/noreferrer.js')}" charset="utf-8"></script>
155
  <script type="text/javascript" src="${static.url('js/utils/navigation.js')}" charset="utf-8"></script>
156
  <%static:optional_include_mako file="body-extra.html" is_theming_enabled="True" />
pmitros committed
157 158
</body>
</html>
159 160

<%def name="login_query()">${
161
  u"?next={0}".format(urlquote_plus(login_redirect_url)) if login_redirect_url else ""
162
}</%def>
163

164
<!-- Performance beacon for onload times -->
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
% if settings.FEATURES.get('ENABLE_ONLOAD_BEACON', False):
<script>
  (function () {
    var sample_rate = ${settings.ONLOAD_BEACON_SAMPLE_RATE};
    var roll = Math.floor(Math.random() * 100)/100;
    var onloadBeaconSent = false;

    if(roll < sample_rate){
      $(window).load(function() {
        setTimeout(function(){
          var t = window.performance.timing;

          var data = {
            event: "onload",
            value: t.loadEventEnd - t.navigationStart,
            page: window.location.href,
          };

          if (!onloadBeaconSent) {
            $.ajax({method: "POST", url: "/performance", data: data});
          }
          onloadBeaconSent = true;
        }, 0);
      });
    }
  }());
</script>
% endif