mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-11-18 01:10:49 -05:00
re-tool/clean up scripts and redirects
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -67,7 +67,7 @@ jobs:
|
|||||||
- uses: actions/setup-node@v1
|
- uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 12.x
|
node-version: 12.x
|
||||||
- uses: actions/setup-go@v2-beta
|
- uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.14.x
|
go-version: 1.14.x
|
||||||
# https://github.com/actions/cache/blob/master/examples.md#node---yarn
|
# https://github.com/actions/cache/blob/master/examples.md#node---yarn
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*! Simple Analytics - Privacy friendly analytics (docs.simpleanalytics.com/script; 2020-06-17; dfcf) */
|
/*! Simple Analytics - Privacy friendly analytics (docs.simpleanalytics.com/script; 2020-06-19; 8601) */
|
||||||
// https://github.com/simpleanalytics/scripts/blob/6bf58f785134134196cde293d6c9e215a670a4d1/src/default.js
|
// https://github.com/simpleanalytics/scripts/blob/eac9823da1fe92c0bca65a041df1f005ff860f1f/src/default.js
|
||||||
|
|
||||||
(function (window, baseUrl) {
|
(function (window, baseUrl) {
|
||||||
if (!window) return;
|
if (!window) return;
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
// need multiple scripts. The minified version stays small.
|
// need multiple scripts. The minified version stays small.
|
||||||
var https = "https:";
|
var https = "https:";
|
||||||
var pageviewsText = "pageview";
|
var pageviewsText = "pageview";
|
||||||
var errorText = "error";
|
|
||||||
var protocol = https + "//";
|
var protocol = https + "//";
|
||||||
var con = window.console;
|
var con = window.console;
|
||||||
var slash = "/";
|
var slash = "/";
|
||||||
@@ -27,7 +26,6 @@
|
|||||||
var addEventListenerFunc = window.addEventListener;
|
var addEventListenerFunc = window.addEventListener;
|
||||||
var fullApiUrl = protocol + baseUrl;
|
var fullApiUrl = protocol + baseUrl;
|
||||||
var undefinedVar = undefined;
|
var undefinedVar = undefined;
|
||||||
var functionName = "sa_event";
|
|
||||||
var documentElement = doc.documentElement || {};
|
var documentElement = doc.documentElement || {};
|
||||||
var language = "language";
|
var language = "language";
|
||||||
var Height = "Height";
|
var Height = "Height";
|
||||||
@@ -38,15 +36,9 @@
|
|||||||
var clientHeight = "client" + Height;
|
var clientHeight = "client" + Height;
|
||||||
var clientWidth = "client" + Width;
|
var clientWidth = "client" + Width;
|
||||||
var screen = window.screen;
|
var screen = window.screen;
|
||||||
|
var functionName = "sa_event";
|
||||||
|
|
||||||
var bot =
|
var bot = /(bot|spider|crawl)/i.test(userAgent);
|
||||||
nav.webdriver ||
|
|
||||||
window.__nightmare ||
|
|
||||||
"callPhantom" in window ||
|
|
||||||
"_phantom" in window ||
|
|
||||||
"phantom" in window ||
|
|
||||||
/(bot|spider|crawl)/i.test(userAgent) ||
|
|
||||||
(window.chrome && (nav.languages === "" || !nav.plugins.length || !(nav.plugins instanceof PluginArray)));
|
|
||||||
|
|
||||||
var payload = {
|
var payload = {
|
||||||
version: 3,
|
version: 3,
|
||||||
@@ -123,7 +115,7 @@
|
|||||||
}
|
}
|
||||||
image.src =
|
image.src =
|
||||||
fullApiUrl +
|
fullApiUrl +
|
||||||
"/send.gif?" +
|
"/send?" +
|
||||||
Object.keys(data)
|
Object.keys(data)
|
||||||
.filter(function (key) {
|
.filter(function (key) {
|
||||||
return data[key] != undefinedVar;
|
return data[key] != undefinedVar;
|
||||||
@@ -134,29 +126,6 @@
|
|||||||
.join("&");
|
.join("&");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send errors
|
|
||||||
function sendError(errorOrMessage) {
|
|
||||||
errorOrMessage = errorOrMessage.message || errorOrMessage;
|
|
||||||
warn(errorOrMessage);
|
|
||||||
sendData({
|
|
||||||
type: errorText,
|
|
||||||
error: errorOrMessage,
|
|
||||||
url: options.hostname + loc.pathname,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// We listen for the error events and only send errors that are
|
|
||||||
// from our script (checked by filename) to our server.
|
|
||||||
addEventListenerFunc(
|
|
||||||
errorText,
|
|
||||||
function (event) {
|
|
||||||
if (event.filename && event.filename.indexOf(baseUrl) > -1) {
|
|
||||||
sendError(event.message);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
/** if duration **/
|
/** if duration **/
|
||||||
var duration = "duration";
|
var duration = "duration";
|
||||||
var start = now();
|
var start = now();
|
||||||
@@ -180,8 +149,8 @@
|
|||||||
|
|
||||||
/** unless testing **/
|
/** unless testing **/
|
||||||
// Don't track when localhost or when it's an IP address
|
// Don't track when localhost or when it's an IP address
|
||||||
// if (locationHostname.indexOf(".") == -1 || /^[0-9]+$/.test(locationHostname.replace(/\./g, "")))
|
if (locationHostname.indexOf(".") == -1 || /^[0-9]+$/.test(locationHostname.replace(/\./g, "")))
|
||||||
// return warn(notSending + "from " + locationHostname);
|
return warn(notSending + "from " + locationHostname);
|
||||||
/** endunless **/
|
/** endunless **/
|
||||||
|
|
||||||
var page = {};
|
var page = {};
|
||||||
@@ -303,7 +272,6 @@
|
|||||||
{
|
{
|
||||||
https: loc.protocol == https,
|
https: loc.protocol == https,
|
||||||
timezone: timezone,
|
timezone: timezone,
|
||||||
width: window.innerWidth,
|
|
||||||
type: pageviewsText,
|
type: pageviewsText,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -394,7 +362,7 @@
|
|||||||
|
|
||||||
if (event)
|
if (event)
|
||||||
sendData(
|
sendData(
|
||||||
assign(source, {
|
assign(source, bot ? { bot: true } : {}, {
|
||||||
type: "event",
|
type: "event",
|
||||||
event: event,
|
event: event,
|
||||||
page_id: page.id,
|
page_id: page.id,
|
||||||
@@ -423,6 +391,6 @@
|
|||||||
for (var event in queue) sendEvent(queue[event]);
|
for (var event in queue) sendEvent(queue[event]);
|
||||||
/** endif **/
|
/** endif **/
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendError(e);
|
warn(e);
|
||||||
}
|
}
|
||||||
})(window, "{{ (urls.Parse .Site.BaseURL).Host }}/sa");
|
})(window, "{{ (urls.Parse .Site.BaseURL).Host }}/sa");
|
||||||
|
|||||||
@@ -47,8 +47,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
{{ partialCached "head/favicons" (dict "pngSizes" "192 48 32 16" "icoSizes" "16 32 48") }}
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="message">
|
<div id="message">
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
{{ $bundle := slice $darkmode $twemoji }}
|
{{ $bundle := slice $darkmode $twemoji }}
|
||||||
|
|
||||||
{{/* only parse and append analytics script on production site */}}
|
{{/* only parse and append analytics script on production site */}}
|
||||||
{{ $useAnalytics := eq hugo.Environment "production" }}
|
{{ $includeAnalytics := eq hugo.Environment "production" }}
|
||||||
|
|
||||||
{{ if $useAnalytics }}
|
{{ if $includeAnalytics }}
|
||||||
{{ $analytics := resources.Get "js/simple-analytics.js" | resources.ExecuteAsTemplate "js/simple-analytics.js" . }}
|
{{ $analytics := resources.Get "js/simple-analytics.js" | resources.ExecuteAsTemplate "js/simple-analytics.js" . }}
|
||||||
{{ $bundle = slice $darkmode $twemoji $analytics }}
|
{{ $bundle = slice $darkmode $twemoji $analytics }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
@@ -15,6 +15,6 @@
|
|||||||
<script async defer src="{{ $js.Permalink }}"></script>
|
<script async defer src="{{ $js.Permalink }}"></script>
|
||||||
|
|
||||||
{{/* proxy to simple analytics noscript on production */}}
|
{{/* proxy to simple analytics noscript on production */}}
|
||||||
{{ if $useAnalytics }}
|
{{ if $includeAnalytics }}
|
||||||
<noscript><img src="{{ "sa/noscript.gif" | absURL }}" alt=""></noscript>
|
<noscript><img src="{{ "sa/manual.gif" | absURL }}" alt=""></noscript>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<p class="image">
|
<p class="image">
|
||||||
{{ with .Get "link" }}<a class="no-underline" href="{{ . }}"{{ if strings.HasPrefix . "http" }} target="_blank" rel="noopener"{{ end }}>{{ end }}
|
{{ with .Get "link" }}<a class="no-underline" href="{{ . }}"{{ if strings.HasPrefix . "http" }} target="_blank" rel="noopener"{{ end }}>{{ end }}
|
||||||
<img src="{{ $optimized.Permalink }}" width="{{ $optimized.Width }}" height="{{ $optimized.Height }}"
|
<img src="{{ $optimized.Permalink }}" width="{{ $optimized.Width }}" height="{{ $optimized.Height }}"
|
||||||
{{- with .Get "alt" }} alt="{{ . | safeHTML }}" title="{{ . | safeHTML }}"{{ end }}>
|
{{- with .Get "alt" }} alt="{{ . | safeHTML }}" title="{{ . | safeHTML }}"{{ end }}>
|
||||||
{{ if .Get "link" }}</a>{{ end }}
|
{{ if .Get "link" }}</a>{{ end }}
|
||||||
</p>
|
</p>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
25
netlify.toml
25
netlify.toml
@@ -31,7 +31,7 @@
|
|||||||
# https://github.com/netlify/cli/blob/master/docs/netlify-dev.md#netlifytoml-dev-block
|
# https://github.com/netlify/cli/blob/master/docs/netlify-dev.md#netlifytoml-dev-block
|
||||||
[dev]
|
[dev]
|
||||||
framework = "#custom"
|
framework = "#custom"
|
||||||
command = "yarn start --baseURL=/ --appendPort=false"
|
command = "yarn start --baseURL=/ --appendPort=false --disableLiveReload"
|
||||||
port = 1338
|
port = 1338
|
||||||
targetPort = 1337
|
targetPort = 1337
|
||||||
publish = "public"
|
publish = "public"
|
||||||
@@ -133,16 +133,16 @@
|
|||||||
from = "/keybase.txt"
|
from = "/keybase.txt"
|
||||||
to = "/.well-known/keybase.txt"
|
to = "/.well-known/keybase.txt"
|
||||||
status = 301
|
status = 301
|
||||||
|
[[redirects]]
|
||||||
|
from = "/twemoji/svg/*"
|
||||||
|
to = "/vendor/emoji/svg/:splat"
|
||||||
|
status = 301
|
||||||
|
|
||||||
# Proxy data to Simple Analytics endpoint:
|
# Proxy data to Simple Analytics endpoints:
|
||||||
[[redirects]]
|
[[redirects]]
|
||||||
from = "/sa/send.gif*"
|
from = "/sa/send*"
|
||||||
to = "https://queue.simpleanalyticscdn.com/simple.gif:splat"
|
to = "https://queue.simpleanalyticscdn.com/simple.gif:splat"
|
||||||
status = 200
|
status = 200
|
||||||
[[redirects]]
|
|
||||||
from = "/sa/noscript.gif*"
|
|
||||||
to = "https://queue.simpleanalyticscdn.com/noscript.gif:splat"
|
|
||||||
status = 200
|
|
||||||
[[redirects]]
|
[[redirects]]
|
||||||
from = "/sa/append*"
|
from = "/sa/append*"
|
||||||
to = "https://queue.simpleanalyticscdn.com/append:splat"
|
to = "https://queue.simpleanalyticscdn.com/append:splat"
|
||||||
@@ -151,6 +151,17 @@
|
|||||||
from = "/sa/post*"
|
from = "/sa/post*"
|
||||||
to = "https://api.simpleanalytics.io/post:splat"
|
to = "https://api.simpleanalytics.io/post:splat"
|
||||||
status = 200
|
status = 200
|
||||||
|
[[redirects]]
|
||||||
|
# this noscript pixel needs to pass unknown arguments along for AMP pages
|
||||||
|
# https://amp.dev/documentation/components/amp-pixel/
|
||||||
|
from = "/sa/noscript.gif*"
|
||||||
|
to = "https://queue.simpleanalyticscdn.com/noscript.gif:splat"
|
||||||
|
status = 200
|
||||||
|
[[redirects]]
|
||||||
|
# same noscript img as above but with no arguments, except `ignore-dnt`
|
||||||
|
from = "/sa/manual.gif"
|
||||||
|
to = "https://queue.simpleanalyticscdn.com/noscript.gif?ignore-dnt=true"
|
||||||
|
status = 200
|
||||||
|
|
||||||
# Mirror these directories from elsewhere to mimic GitHub Pages behavior and
|
# Mirror these directories from elsewhere to mimic GitHub Pages behavior and
|
||||||
# keep this main repository squeaky clean.
|
# keep this main repository squeaky clean.
|
||||||
|
|||||||
14
package.json
14
package.json
@@ -14,14 +14,15 @@
|
|||||||
"url": "git+https://github.com/jakejarvis/jarv.is.git"
|
"url": "git+https://github.com/jakejarvis/jarv.is.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "rimraf public/ resources/ builds/ && hugo mod clean",
|
"clean": "rimraf public/ resources/ builds/ _vendor/ && hugo mod clean",
|
||||||
"build": "run-s hugo:mods hugo minify",
|
"build": "run-s hugo:vendor hugo minify",
|
||||||
"build:preview": "run-s hugo:mods hugo:dev",
|
"build:preview": "run-s hugo:vendor hugo:preview",
|
||||||
"hugo": "hugo --gc --cleanDestinationDir --verbose",
|
"hugo": "hugo --gc --cleanDestinationDir --verbose",
|
||||||
"hugo:dev": "hugo --environment development --baseURL ${DEPLOY_PRIME_URL:-/} --buildDrafts --buildFuture --gc --cleanDestinationDir --verbose",
|
"hugo:preview": "hugo --environment development --baseURL ${DEPLOY_PRIME_URL:-/} --buildDrafts --buildFuture --gc --cleanDestinationDir --verbose",
|
||||||
"hugo:mods": "hugo mod vendor",
|
"hugo:vendor": "hugo mod vendor",
|
||||||
"start": "hugo server --disableFastRender --buildDrafts --buildFuture --port 1337 --bind 0.0.0.0 --verbose",
|
"start": "hugo server --disableFastRender --buildDrafts --buildFuture --port 1337 --bind 0.0.0.0 --verbose",
|
||||||
"start:docker": "docker run --rm -v $(pwd):/src -p 1337:1337 $(docker build --no-cache -q .)",
|
"start:docker": "docker run --rm -v $(pwd):/src -p 1337:1337 $(docker build --no-cache -q .)",
|
||||||
|
"start:live": "netlify dev --live",
|
||||||
"minify": "run-s minify:**",
|
"minify": "run-s minify:**",
|
||||||
"minify:html": "html-minifier --html5 --collapse-whitespace --collapse-boolean-attributes --preserve-line-breaks --minify-css --remove-comments --file-ext html --input-dir public --output-dir public **/*.html",
|
"minify:html": "html-minifier --html5 --collapse-whitespace --collapse-boolean-attributes --preserve-line-breaks --minify-css --remove-comments --file-ext html --input-dir public --output-dir public **/*.html",
|
||||||
"minify:js": "terser --compress passes=3,negate_iife=false,keep_fargs=false,sequences=false,reduce_vars=false --mangle reserved=['sa','sa_event'] --output public/js/app.js -- public/js/app.js",
|
"minify:js": "terser --compress passes=3,negate_iife=false,keep_fargs=false,sequences=false,reduce_vars=false --mangle reserved=['sa','sa_event'] --output public/js/app.js -- public/js/app.js",
|
||||||
@@ -32,8 +33,7 @@
|
|||||||
"lint:md": "markdownlint 'content/**/*.md'",
|
"lint:md": "markdownlint 'content/**/*.md'",
|
||||||
"lint:prettier": "prettier --check .",
|
"lint:prettier": "prettier --check .",
|
||||||
"index": "run-s clean hugo index:**",
|
"index": "run-s clean hugo index:**",
|
||||||
"index:algolia": "npx atomic-algolia",
|
"index:algolia": "npx atomic-algolia"
|
||||||
"live": "netlify dev --live"
|
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
12
yarn.lock
12
yarn.lock
@@ -1229,9 +1229,9 @@ duplexer3@^0.1.4:
|
|||||||
integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=
|
integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=
|
||||||
|
|
||||||
electron-to-chromium@^1.3.413:
|
electron-to-chromium@^1.3.413:
|
||||||
version "1.3.475"
|
version "1.3.478"
|
||||||
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.475.tgz#67688cc82c342f39594a412286e975eda45d8412"
|
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.478.tgz#cfa0f2f0d3012463438a3bc81f50f2d109aca450"
|
||||||
integrity sha512-vcTeLpPm4+ccoYFXnepvkFt0KujdyrBU19KNEO40Pnkhta6mUi2K0Dn7NmpRcNz7BvysnSqeuIYScP003HWuYg==
|
integrity sha512-pt9GUDD52uEO9ZXWcG4UuW/HwE8T+a8iFP7K2qqWrHB5wUxbbvCIXGBVpQDDQwSR766Nn4AkmLYxOUNd4Ji5Dw==
|
||||||
|
|
||||||
emoji-regex@^7.0.1:
|
emoji-regex@^7.0.1:
|
||||||
version "7.0.3"
|
version "7.0.3"
|
||||||
@@ -3212,9 +3212,9 @@ object-assign@^4.0.1, object-assign@^4.1.0:
|
|||||||
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
|
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
|
||||||
|
|
||||||
object-inspect@^1.7.0:
|
object-inspect@^1.7.0:
|
||||||
version "1.7.0"
|
version "1.8.0"
|
||||||
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67"
|
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0"
|
||||||
integrity sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==
|
integrity sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==
|
||||||
|
|
||||||
object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1:
|
object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1:
|
||||||
version "1.1.1"
|
version "1.1.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user