mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-07-03 14:06:40 -04: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
|
||||
with:
|
||||
node-version: 12.x
|
||||
- uses: actions/setup-go@v2-beta
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.14.x
|
||||
# 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) */
|
||||
// https://github.com/simpleanalytics/scripts/blob/6bf58f785134134196cde293d6c9e215a670a4d1/src/default.js
|
||||
/*! Simple Analytics - Privacy friendly analytics (docs.simpleanalytics.com/script; 2020-06-19; 8601) */
|
||||
// https://github.com/simpleanalytics/scripts/blob/eac9823da1fe92c0bca65a041df1f005ff860f1f/src/default.js
|
||||
|
||||
(function (window, baseUrl) {
|
||||
if (!window) return;
|
||||
@ -10,7 +10,6 @@
|
||||
// need multiple scripts. The minified version stays small.
|
||||
var https = "https:";
|
||||
var pageviewsText = "pageview";
|
||||
var errorText = "error";
|
||||
var protocol = https + "//";
|
||||
var con = window.console;
|
||||
var slash = "/";
|
||||
@ -27,7 +26,6 @@
|
||||
var addEventListenerFunc = window.addEventListener;
|
||||
var fullApiUrl = protocol + baseUrl;
|
||||
var undefinedVar = undefined;
|
||||
var functionName = "sa_event";
|
||||
var documentElement = doc.documentElement || {};
|
||||
var language = "language";
|
||||
var Height = "Height";
|
||||
@ -38,15 +36,9 @@
|
||||
var clientHeight = "client" + Height;
|
||||
var clientWidth = "client" + Width;
|
||||
var screen = window.screen;
|
||||
var functionName = "sa_event";
|
||||
|
||||
var bot =
|
||||
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 bot = /(bot|spider|crawl)/i.test(userAgent);
|
||||
|
||||
var payload = {
|
||||
version: 3,
|
||||
@ -123,7 +115,7 @@
|
||||
}
|
||||
image.src =
|
||||
fullApiUrl +
|
||||
"/send.gif?" +
|
||||
"/send?" +
|
||||
Object.keys(data)
|
||||
.filter(function (key) {
|
||||
return data[key] != undefinedVar;
|
||||
@ -134,29 +126,6 @@
|
||||
.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 **/
|
||||
var duration = "duration";
|
||||
var start = now();
|
||||
@ -180,8 +149,8 @@
|
||||
|
||||
/** unless testing **/
|
||||
// Don't track when localhost or when it's an IP address
|
||||
// if (locationHostname.indexOf(".") == -1 || /^[0-9]+$/.test(locationHostname.replace(/\./g, "")))
|
||||
// return warn(notSending + "from " + locationHostname);
|
||||
if (locationHostname.indexOf(".") == -1 || /^[0-9]+$/.test(locationHostname.replace(/\./g, "")))
|
||||
return warn(notSending + "from " + locationHostname);
|
||||
/** endunless **/
|
||||
|
||||
var page = {};
|
||||
@ -303,7 +272,6 @@
|
||||
{
|
||||
https: loc.protocol == https,
|
||||
timezone: timezone,
|
||||
width: window.innerWidth,
|
||||
type: pageviewsText,
|
||||
}
|
||||
)
|
||||
@ -394,7 +362,7 @@
|
||||
|
||||
if (event)
|
||||
sendData(
|
||||
assign(source, {
|
||||
assign(source, bot ? { bot: true } : {}, {
|
||||
type: "event",
|
||||
event: event,
|
||||
page_id: page.id,
|
||||
@ -423,6 +391,6 @@
|
||||
for (var event in queue) sendEvent(queue[event]);
|
||||
/** endif **/
|
||||
} catch (e) {
|
||||
sendError(e);
|
||||
warn(e);
|
||||
}
|
||||
})(window, "{{ (urls.Parse .Site.BaseURL).Host }}/sa");
|
||||
|
@ -47,8 +47,6 @@
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
{{ partialCached "head/favicons" (dict "pngSizes" "192 48 32 16" "icoSizes" "16 32 48") }}
|
||||
</head>
|
||||
<body>
|
||||
<div id="message">
|
||||
|
@ -4,9 +4,9 @@
|
||||
{{ $bundle := slice $darkmode $twemoji }}
|
||||
|
||||
{{/* 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" . }}
|
||||
{{ $bundle = slice $darkmode $twemoji $analytics }}
|
||||
{{ end }}
|
||||
@ -15,6 +15,6 @@
|
||||
<script async defer src="{{ $js.Permalink }}"></script>
|
||||
|
||||
{{/* proxy to simple analytics noscript on production */}}
|
||||
{{ if $useAnalytics }}
|
||||
<noscript><img src="{{ "sa/noscript.gif" | absURL }}" alt=""></noscript>
|
||||
{{ if $includeAnalytics }}
|
||||
<noscript><img src="{{ "sa/manual.gif" | absURL }}" alt=""></noscript>
|
||||
{{ end }}
|
||||
|
@ -15,7 +15,7 @@
|
||||
<p class="image">
|
||||
{{ 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 }}"
|
||||
{{- with .Get "alt" }} alt="{{ . | safeHTML }}" title="{{ . | safeHTML }}"{{ end }}>
|
||||
{{- with .Get "alt" }} alt="{{ . | safeHTML }}" title="{{ . | safeHTML }}"{{ end }}>
|
||||
{{ if .Get "link" }}</a>{{ end }}
|
||||
</p>
|
||||
{{- 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
|
||||
[dev]
|
||||
framework = "#custom"
|
||||
command = "yarn start --baseURL=/ --appendPort=false"
|
||||
command = "yarn start --baseURL=/ --appendPort=false --disableLiveReload"
|
||||
port = 1338
|
||||
targetPort = 1337
|
||||
publish = "public"
|
||||
@ -133,16 +133,16 @@
|
||||
from = "/keybase.txt"
|
||||
to = "/.well-known/keybase.txt"
|
||||
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]]
|
||||
from = "/sa/send.gif*"
|
||||
from = "/sa/send*"
|
||||
to = "https://queue.simpleanalyticscdn.com/simple.gif:splat"
|
||||
status = 200
|
||||
[[redirects]]
|
||||
from = "/sa/noscript.gif*"
|
||||
to = "https://queue.simpleanalyticscdn.com/noscript.gif:splat"
|
||||
status = 200
|
||||
[[redirects]]
|
||||
from = "/sa/append*"
|
||||
to = "https://queue.simpleanalyticscdn.com/append:splat"
|
||||
@ -151,6 +151,17 @@
|
||||
from = "/sa/post*"
|
||||
to = "https://api.simpleanalytics.io/post:splat"
|
||||
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
|
||||
# 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"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rimraf public/ resources/ builds/ && hugo mod clean",
|
||||
"build": "run-s hugo:mods hugo minify",
|
||||
"build:preview": "run-s hugo:mods hugo:dev",
|
||||
"clean": "rimraf public/ resources/ builds/ _vendor/ && hugo mod clean",
|
||||
"build": "run-s hugo:vendor hugo minify",
|
||||
"build:preview": "run-s hugo:vendor hugo:preview",
|
||||
"hugo": "hugo --gc --cleanDestinationDir --verbose",
|
||||
"hugo:dev": "hugo --environment development --baseURL ${DEPLOY_PRIME_URL:-/} --buildDrafts --buildFuture --gc --cleanDestinationDir --verbose",
|
||||
"hugo:mods": "hugo mod vendor",
|
||||
"hugo:preview": "hugo --environment development --baseURL ${DEPLOY_PRIME_URL:-/} --buildDrafts --buildFuture --gc --cleanDestinationDir --verbose",
|
||||
"hugo:vendor": "hugo mod vendor",
|
||||
"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:live": "netlify dev --live",
|
||||
"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: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:prettier": "prettier --check .",
|
||||
"index": "run-s clean hugo index:**",
|
||||
"index:algolia": "npx atomic-algolia",
|
||||
"live": "netlify dev --live"
|
||||
"index:algolia": "npx atomic-algolia"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
|
12
yarn.lock
12
yarn.lock
@ -1229,9 +1229,9 @@ duplexer3@^0.1.4:
|
||||
integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=
|
||||
|
||||
electron-to-chromium@^1.3.413:
|
||||
version "1.3.475"
|
||||
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.475.tgz#67688cc82c342f39594a412286e975eda45d8412"
|
||||
integrity sha512-vcTeLpPm4+ccoYFXnepvkFt0KujdyrBU19KNEO40Pnkhta6mUi2K0Dn7NmpRcNz7BvysnSqeuIYScP003HWuYg==
|
||||
version "1.3.478"
|
||||
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.478.tgz#cfa0f2f0d3012463438a3bc81f50f2d109aca450"
|
||||
integrity sha512-pt9GUDD52uEO9ZXWcG4UuW/HwE8T+a8iFP7K2qqWrHB5wUxbbvCIXGBVpQDDQwSR766Nn4AkmLYxOUNd4Ji5Dw==
|
||||
|
||||
emoji-regex@^7.0.1:
|
||||
version "7.0.3"
|
||||
@ -3212,9 +3212,9 @@ object-assign@^4.0.1, object-assign@^4.1.0:
|
||||
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
|
||||
|
||||
object-inspect@^1.7.0:
|
||||
version "1.7.0"
|
||||
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67"
|
||||
integrity sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==
|
||||
version "1.8.0"
|
||||
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0"
|
||||
integrity sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==
|
||||
|
||||
object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1:
|
||||
version "1.1.1"
|
||||
|
Reference in New Issue
Block a user