main.html 6.83 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 branding import api as branding_api
17
from django.core.urlresolvers import reverse
18 19
from django.utils.http import urlquote_plus
from django.utils.translation import ugettext as _
David Baumgold committed
20
from django.utils.translation import get_language_bidi
21
from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_string
22
from pipeline_mako import render_require_js_path_overrides
23

24
%>
25
<!DOCTYPE html>
26 27
<!--[if lte IE 9]><html class="ie ie9 lte9" lang="${LANGUAGE_CODE}"><![endif]-->
<!--[if !IE]><!--><html lang="${LANGUAGE_CODE}"><!--<![endif]-->
28
<head dir="${static.dir_rtl()}">
29 30
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
31
    <meta name="viewport" content="width=device-width, initial-scale=1">
32 33 34 35 36

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

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

46 47 48 49 50 51 52 53 54 55
  % 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
56

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

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

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

65
  <%static:css group='style-vendor'/>
66 67 68 69 70
  % if uses_bootstrap:
    <link rel="stylesheet" href="${static.url(self.attr.main_css)}" type="text/css" media="all" />
  % else:
    <%static:css group='${self.attr.main_css}'/>
  % endif
71

72
  % if disable_courseware_js or uses_pattern_library:
73
    <%static:js group='base_vendor'/>
Andy Armstrong committed
74
    <%static:js group='base_application'/>
75 76 77
  % else:
    <%static:js group='main_vendor'/>
    <%static:js group='application'/>
78 79
  % endif

80
  % if uses_bootstrap:
81
    <%static:js group='lms_bootstrap'/>
82 83
  % endif

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

97 98 99 100
  % if not disable_courseware_js:
    <%static:js group='module-js'/>
  % endif

101
  <%block name="headextra"/>
102
  <%block name="head_extra"/>
103

104
  <%include file="/courseware/experiments.html"/>
105
  <%static:optional_include_mako file="head-extra.html" is_theming_enabled="True" />
106

Renzo Lucioni committed
107
  <%include file="widgets/optimizely.html" />
108
  <%include file="widgets/segment-io.html" />
Renzo Lucioni committed
109

110
  <meta name="path_prefix" content="${EDX_ROOT_URL}">
111
  <meta name="google-site-verification" content="_mipQ4AtZQDNmbtOkwehQDOgCxUUV2fb_C0b6wbiRHY" />
112

113
<% ga_acct = static.get_value("GOOGLE_ANALYTICS_ACCOUNT", settings.GOOGLE_ANALYTICS_ACCOUNT) %>
114 115 116
% if ga_acct:
    <script type="text/javascript">
    var _gaq = _gaq || [];
117
    _gaq.push(['_setAccount', '${ga_acct | n, js_escaped_string}']);
118 119 120 121 122 123 124 125
    _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>
126
% endif
127

pmitros committed
128
</head>
Kyle Fiedler committed
129

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

132
<%static:optional_include_mako file="body-initial.html" is_theming_enabled="True" />
133
<div id="page-prompt"></div>
134
% if not disable_window_wrap:
135
  <div class="window-wrap" dir="${static.dir_rtl()}">
136
% endif
137
    <a class="nav-skip sr-only sr-only-focusable" href="#main">${_("Skip to main content")}</a>
138

139
    % if not disable_header:
140
        <%include file="${static.get_template_path('header.html')}" args="online_help_token=online_help_token" />
141
        <%include file="/preview_menu.html" />
142
    % endif
143

144
    <div class="content-wrapper ${"container-fluid" if uses_bootstrap else "container" } main-container" id="content">
145 146 147
      ${self.body()}
      <%block name="bodyextra"/>
    </div>
148

149
    % if not disable_footer:
150
        <%include file="${static.get_template_path('footer.html')}" />
151
    % endif
152

153
% if not disable_window_wrap:
154
  </div>
155
% endif
156

157
  <%block name="footer_extra"/>
Matthew Mongeau committed
158
  <%block name="js_extra"/>
159

160
  <%include file="widgets/segment-io-footer.html" />
161
  <script type="text/javascript" src="${static.url('js/vendor/noreferrer.js')}" charset="utf-8"></script>
162
  <script type="text/javascript" src="${static.url('js/utils/navigation.js')}" charset="utf-8"></script>
163
  <%static:optional_include_mako file="body-extra.html" is_theming_enabled="True" />
pmitros committed
164 165
</body>
</html>
166 167

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

171
<!-- Performance beacon for onload times -->
172 173 174
% if settings.FEATURES.get('ENABLE_ONLOAD_BEACON', False):
<script>
  (function () {
175
    var sample_rate = ${settings.ONLOAD_BEACON_SAMPLE_RATE | n, dump_js_escaped_json};
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
    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