1
0
mirror of https://gitlab.com/timvisee/send.git synced 2024-11-10 05:02:45 +01:00

add a dynamic js script for page config

This commit is contained in:
Danny Coates 2017-07-19 14:00:10 -07:00
parent 262322b9e8
commit 85a7be01cb
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
5 changed files with 15 additions and 28 deletions

View File

@ -69,9 +69,15 @@ app.use('/l20n', express.static(L20N));
app.use('/locales', express.static(LOCALES));
app.get('/', (req, res) => {
res.render('index', {
res.render('index');
});
app.get('/jsconfig.js', (req, res) => {
res.set('Content-Type', 'application/javascript');
res.render('jsconfig', {
trackerId: conf.analytics_id,
dsn: conf.sentry_id
dsn: conf.sentry_id,
layout: false
});
});

View File

@ -0,0 +1,6 @@
{{#if dsn}}
window.dsn = '{{{dsn}}}';
{{/if}}
{{#if trackerId}}
window.trackerId = '{{{trackerId}}}';
{{/if}}

View File

@ -2,15 +2,10 @@
<html>
<head>
<title>Firefox Send</title>
{{#if dsn}}
{{> sentry dsn=dsn}}
{{/if}}
<script src="/jsconfig.js"></script>
<script src="/bundle.js"></script>
<link rel="stylesheet" type="text/css" href="/main.css" />
<link rel="stylesheet" href="https://code.cdn.mozilla.net/fonts/fira.css">
{{#if trackerId}}
{{> analytics trackerId=trackerId}}
{{/if}}
<meta name="defaultLanguage" content="en-US">
<meta name="availableLanguages" content="en-US">

View File

@ -1,17 +0,0 @@
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', '{{{trackerId}}}', 'auto');
if (window.URL && document.referrer) {
ga("set", "referrer", (new URL(document.referrer)).origin);
} else {
ga("set", "referrer", "");
}
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
</script>

View File

@ -1,3 +0,0 @@
<script>
window.dsn = '{{{dsn}}}';
</script>