1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-27 06:38:30 -04:00

revert Access-Control-Allow-Origin: * header

This commit is contained in:
Jake Jarvis 2020-04-26 23:43:10 -04:00
parent 374a822ad4
commit c52a357e29
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39
5 changed files with 26 additions and 33 deletions

View File

@ -13,32 +13,31 @@
let pref = localStorage.getItem('dark_mode_pref');
// keep track of current state (light by default)
let activated = false;
let dark = false;
// dynamically switch utteranc.es's theme
let utterancesInit = false;
const setUtterances = function() {
let theme = activated ? 'github-dark' : 'github-light';
// load utteranc.es with proper theme and dynamically switch it
let utterancesLoaded = false;
const setUtterancesTheme = function(theme) {
const container = document.querySelector('div#comments');
// don't do any of this if we're not on a page with comments enabled
if (container) {
if (!utterancesInit) {
if (!utterancesLoaded) {
const script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.defer = true;
script.src = 'https://utteranc.es/client.js';
script.crossorigin = true;
script.crossOrigin = 'anonymous';
script.setAttribute('data-repo', '{{ .Site.Params.github | safeJS }}');
script.setAttribute('data-label', 'comments');
script.setAttribute('data-issue-term', 'og:title');
script.setAttribute('data-theme', theme);
script.setAttribute('data-label', 'comments');
container.appendChild(script);
utterancesInit = true;
utterancesLoaded = true;
} else {
const frame = document.querySelector('.utterances-frame');
const frame = document.querySelector('iframe.utterances-frame');
// be extra sure frame exists
if (frame) {
@ -46,7 +45,7 @@
frame.contentWindow.postMessage({
type: 'set-theme',
theme: theme
}, '*');
}, 'https://utteranc.es');
}
}
}
@ -56,18 +55,18 @@
document.body.classList.remove('light');
document.body.classList.add('dark');
activated = true;
dark = true;
setUtterances();
setUtterancesTheme('github-dark');
};
const activateLightMode = function() {
document.body.classList.remove('dark');
document.body.classList.add('light');
activated = false;
dark = false;
setUtterances();
setUtterancesTheme('github-light');
};
// if user already explicitly toggled in the past, restore their preference.
@ -93,7 +92,7 @@
// handle lightbulb click
toggle.addEventListener('click', function() {
// switch to the opposite theme & save preference in local storage
if (!activated) {
if (!dark) {
activateDarkMode();
localStorage.setItem('dark_mode_pref', 'true');
} else {

View File

@ -1,11 +1,11 @@
/* jshint indent: 2, browser: true, bitwise: true, plusplus: true */
/*!
*
* Copyright Twitter Inc. and other contributors. Licensed under MIT.
* https://github.com/twitter/twemoji/blob/gh-pages/LICENSE
*
*/
*
* Copyright Twitter Inc. and other contributors. Licensed under MIT.
* https://github.com/twitter/twemoji/blob/gh-pages/LICENSE
*
*/
(function (

View File

@ -30,6 +30,7 @@ disableAliases = true
defaultImage = "img/me_large.jpg"
github = "jakejarvis/jarv.is"
facebookAppID = "3357248167622283"
webmention = "jarv.is"
copyrightFirstYear = "2001"
license = "CC-BY-4.0"
licenseFull = "Creative Commons Attribution 4.0 International"
@ -157,9 +158,3 @@ disableAliases = true
lineNumbersInTable = true
noClasses = true
tabWidth = 4
[server]
[[server.headers]]
for = "/**"
[server.headers.values]
Access-Control-Allow-Origin = "*"

View File

@ -1,2 +1,4 @@
<link rel="pingback" href="https://webmention.io/jarv.is/xmlrpc">
<link rel="webmention" href="https://webmention.io/jarv.is/webmention">
{{ with .Site.Params.webmention }}
<link rel="pingback" href="https://webmention.io/{{ . }}/xmlrpc">
<link rel="webmention" href="https://webmention.io/{{ . }}/webmention">
{{ end }}

View File

@ -44,10 +44,7 @@
[[headers]]
for = "/*"
[headers.values]
# Needed to fix utteranc.es + CORS issues.
# Cringey but not a huge deal for this site.
Access-Control-Allow-Origin = "*"
# 🐄🐄🐄
# 🐄
X-Got-Milk = "2%"
# PGP file: open in browser, download correctly