Skip to content

Commit 972d940

Browse files
author
Ed Costello
committed
DOCS-375 implement custom 404 page (and related pages)
layout.html modified to add logic to alter Google Analytics code depending on whether it's an error page being generated or a normal page. The .htaccess file needs to be dropped in the root directory of the manual (or appended to the one for the site). Sphinx ignores the .htaccess file and does not copy it to the built html directory.
1 parent e13dd00 commit 972d940

File tree

6 files changed

+49
-12
lines changed

6 files changed

+49
-12
lines changed

source/.htaccess

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Note: this must be manually copied, sphinx does not process it
2+
ErrorDocument 401 /manual/meta/401.html
3+
ErrorDocument 403 /manual/meta/403.html
4+
ErrorDocument 404 /manual/meta/404.html
5+
ErrorDocument 410 /manual/meta/410.html

source/meta/401.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
:orphan:
2+
3+
=======================
4+
Authentication Required
5+
=======================
6+
7+
You must log in to access the URL you requested.

source/meta/403.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
:orphan:
2+
3+
=============
4+
Access Denied
5+
=============
6+
7+
You do not have access to the URL you requested.

source/meta/404.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
:orphan:
2+
3+
==============
4+
File not found
5+
==============
6+
7+
The URL you requested does not exist or has been removed.

source/meta/410.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
:orphan:
2+
3+
============
4+
File Deleted
5+
============
6+
7+
The URL you requested has been deleted.

themes/mongodb/layout.html

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -222,21 +222,25 @@ <h3>{{ _('Navigation') }}</h3>
222222
</div>
223223
{%- endblock %}
224224

225-
{%- block analytics%}
225+
{%- block analytics %}
226226
<script type="text/javascript">
227-
var _gaq = _gaq || [];
228-
_gaq.push(['_setAccount', 'UA-7301842-8']);
229-
_gaq.push(['_setDomainName', 'mongodb.org']);
230-
_gaq.push(['_trackPageview']);
231-
(function() {
232-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
233-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
234-
var s = document.getElementsByTagName('script')[0];
235-
s.parentNode.insertBefore(ga, s);
236-
})();
227+
var _gaq = _gaq || [];
228+
_gaq.push(['_setAccount', 'UA-7301842-8']);
229+
_gaq.push(['_setDomainName', 'mongodb.org']);
230+
{%- if (pagename == "meta/401") or (pagename == "meta/403") or (pagename == "meta/404") or (pagename == "meta/410") %}
231+
_gaq.push(['_trackPageview', '/manual/{{pagename}}.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer]);
232+
{%- else %}
233+
_gaq.push(['_trackPageview']);
234+
{%- endif %}
235+
236+
(function() {
237+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
238+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
239+
var s = document.getElementsByTagName('script')[0];
240+
s.parentNode.insertBefore(ga, s);
241+
})();
237242
</script>
238243
{%- endblock %}
239-
240244
{%- block marketo %}
241245
<script type="text/javascript">
242246
document.write(unescape("%3Cscript src='" + document.location.protocol + "//munchkin.marketo.net/munchkin.js' type='text/javascript'%3E%3C/script%3E"));

0 commit comments

Comments
 (0)