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

## 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.
34

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

43 44 45 46 47 48 49 50 51 52
  % 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
53

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

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

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

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

65 66
  % if disable_courseware_js:
    <%static:js group='base_vendor'/>
67
    <%static:js group='base_application'/>
68
  % else:
69
    <%static:js group='main_vendor'/>
70
    <%static:js group='application'/>
71 72 73 74 75 76
  % endif

  <script>
    window.baseUrl = "${settings.STATIC_URL}";
    (function (require) {
      require.config({
77
          baseUrl: window.baseUrl
78 79 80
      });
    }).call(this, require || RequireJS.require);
  </script>
81
  <script type="text/javascript" src="${static.url("lms/js/require-config.js")}"></script>
82
  <%block name="js_overrides">
83
    ${render_require_js_path_overrides(settings.REQUIRE_JS_PATH_OVERRIDES)}
84 85
  </%block>

86 87 88 89
  % if not disable_courseware_js:
    <%static:js group='module-js'/>
  % endif

90
  <%block name="headextra"/>
91

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

Renzo Lucioni committed
94
  <%include file="widgets/optimizely.html" />
95
  <%include file="widgets/segment-io.html" />
Renzo Lucioni committed
96

97
  <meta name="path_prefix" content="${EDX_ROOT_URL}">
98
  <meta name="google-site-verification" content="_mipQ4AtZQDNmbtOkwehQDOgCxUUV2fb_C0b6wbiRHY" />
99

100
<% ga_acct = static.get_value("GOOGLE_ANALYTICS_ACCOUNT", settings.GOOGLE_ANALYTICS_ACCOUNT) %>
101 102 103 104 105 106 107 108 109 110 111 112
% 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>
113
% endif
114

pmitros committed
115
</head>
Kyle Fiedler committed
116

117
<body class="${static.dir_rtl()} <%block name='bodyclass'/> lang_${LANGUAGE_CODE}">
118
<%static:optional_include_mako file="body-initial.html" is_theming_enabled="True" />
119
<div id="page-prompt"></div>
120
% if not disable_window_wrap:
121
  <div class="window-wrap" dir="${static.dir_rtl()}">
122
% endif
123
    <a class="nav-skip" href="<%block name="nav_skip">#content</%block>">${_("Skip to main content")}</a>
124

125
    % if not disable_header:
126
        <%include file="${static.get_template_path('header.html')}" />
127
    % endif
128

129
    <div role="main" class="content-wrapper" id="content" tabindex="-1">
130 131 132
      ${self.body()}
      <%block name="bodyextra"/>
    </div>
133

134
    % if not disable_footer:
135
        <%include file="themable-footer.html" />
136
    % endif
137

138
% if not disable_window_wrap:
139
  </div>
140
% endif
141

Matthew Mongeau committed
142
  <%block name="js_extra"/>
143
  <%include file="widgets/segment-io-footer.html" />
144
  <script type="text/javascript" src="${static.url('js/vendor/noreferrer.js')}" charset="utf-8"></script>
145
  <script type="text/javascript" src="${static.url('js/utils/navigation.js')}" charset="utf-8"></script>
146
  <%static:optional_include_mako file="body-extra.html" is_theming_enabled="True" />
pmitros committed
147 148
</body>
</html>
149 150

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

154
<!-- Performance beacon for onload times -->
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
% 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