Unified · Split
| @@ -199,6 +199,8 @@ page.track = (fn) -> · 198 unmodified lines | |||
| 199 | return | 199 | return |
| 200 | 200 | ||
| 201 | track = -> | 201 | track = -> |
| 202 | return unless app.config.env == 'production' | ||
| 203 | |||
| 202 | consentGiven = Cookies.get('analyticsConsent') | 204 | consentGiven = Cookies.get('analyticsConsent') |
| 203 | consentAsked = Cookies.get('analyticsConsentAsked') | 205 | consentAsked = Cookies.get('analyticsConsentAsked') |
| 204 | 206 | ||
| @@ -19,7 +19,7 @@ app.templates.settingsPage = (settings) -> """ · 18 unmodified lines | |||
| 19 | <input type="checkbox" form="settings" name="autoInstall" value="_auto-install"#{if settings.autoInstall then ' checked' else ''}>Automatically download documentation for offline use | 19 | <input type="checkbox" form="settings" name="autoInstall" value="_auto-install"#{if settings.autoInstall then ' checked' else ''}>Automatically download documentation for offline use |
| 20 | <small>Only enable this when bandwidth isn't a concern to you.</small> | 20 | <small>Only enable this when bandwidth isn't a concern to you.</small> |
| 21 | </label> | 21 | </label> |
| 22 | <label class="_settings-label"> | 22 | <label class="_settings-label _hide-in-development"> |
| 23 | <input type="checkbox" form="settings" name="analyticsConsent"#{if settings.analyticsConsent then ' checked' else ''}>Enable tracking cookies | 23 | <input type="checkbox" form="settings" name="analyticsConsent"#{if settings.analyticsConsent then ' checked' else ''}>Enable tracking cookies |
| 24 | <small>With this checked, we enable Google Analytics and Gauges to collect anonymous traffic information.</small> | 24 | <small>With this checked, we enable Google Analytics and Gauges to collect anonymous traffic information.</small> |
| 25 | </label> | 25 | </label> |
| @@ -29,7 +29,8 @@ · 28 unmodified lines | |||
| 29 | 'components/path', | 29 | 'components/path', |
| 30 | 'components/notice', | 30 | 'components/notice', |
| 31 | 'components/prism', | 31 | 'components/prism', |
| 32 | 'components/mobile'; | 32 | 'components/mobile', |
| 33 | 'components/environment'; | ||
| 33 | 34 | ||
| 34 | @import 'pages/simple', | 35 | @import 'pages/simple', |
| 35 | 'pages/angular', | 36 | 'pages/angular', |
| @@ -0,0 +1,3 @@ | |||
| 1 | ._hide-in-development { | ||
| 2 | <%= App.environment != :production ? 'display: none;' : '' %> | ||
| 3 | } | ||
| @@ -11,34 +11,6 @@ const urlsToCache = [ · 10 unmodified lines | |||
| 11 | '<%= doc_index_urls.join "',\n '" %>', | 11 | '<%= doc_index_urls.join "',\n '" %>', |
| 12 | ]; | 12 | ]; |
| 13 | 13 | ||
| 14 | <%# Clone a request with the mode set to 'cors' %> | ||
| 15 | function corsify(request) { | ||
| 16 | const options = { | ||
| 17 | mode: 'cors', | ||
| 18 | }; | ||
| 19 | |||
| 20 | const keys = [ | ||
| 21 | 'body', | ||
| 22 | 'cache', | ||
| 23 | 'credentials', | ||
| 24 | 'headers', | ||
| 25 | 'integrity', | ||
| 26 | 'keepalive', | ||
| 27 | 'method', | ||
| 28 | 'redirect', | ||
| 29 | 'referrer', | ||
| 30 | 'referrerPolicy', | ||
| 31 | 'signal', | ||
| 32 | 'window', | ||
| 33 | ]; | ||
| 34 | |||
| 35 | for (const key of keys) { | ||
| 36 | options[key] = request[key]; | ||
| 37 | } | ||
| 38 | |||
| 39 | return new Request(request.url, options); | ||
| 40 | } | ||
| 41 | |||
| 42 | <%# Set-up the cache %> | 14 | <%# Set-up the cache %> |
| 43 | self.addEventListener('install', event => { | 15 | self.addEventListener('install', event => { |
| 44 | self.skipWaiting(); | 16 | self.skipWaiting(); |
| @@ -64,14 +36,7 @@ self.addEventListener('fetch', event => { · 19 unmodified lines | |||
| 64 | if (cachedResponse) return cachedResponse; | 36 | if (cachedResponse) return cachedResponse; |
| 65 | 37 | ||
| 66 | try { | 38 | try { |
| 67 | const response = await fetch(corsify(event.request)); | 39 | const response = await fetch(event.request); |
| 68 | |||
| 69 | <%# If the status code is 0 it means the response is opaque %> | ||
| 70 | <%# If the response is opaque it's not possible to read whether it is successful or not, so we assume it is %> | ||
| 71 | if (!response.ok && response.status !== 0) { | ||
| 72 | throw new Error(`The HTTP request failed with status code ${response.status}`); | ||
| 73 | } | ||
| 74 | |||
| 75 | return response; | 40 | return response; |
| 76 | } catch (err) { | 41 | } catch (err) { |
| 77 | const url = new URL(event.request.url); | 42 | const url = new URL(event.request.url); |