web/tools/pv.sh

21 lines
437 B
Bash
Raw Normal View History

2021-01-25 01:20:51 +03:00
#!/usr/bin/env bash
2019-09-30 15:38:41 +03:00
#
# Fetch Google Analytics Pageviews reporting cache
# and save as 'assets/data/pagevies.json'
#
# Requirement:
# - jq
# - wget
set -eu
WORK_DIR="$(dirname "$(dirname "$(realpath "$0")")")"
2020-08-19 12:05:58 +03:00
URL_FILE="${WORK_DIR}/_config.yml"
PV_CACHE="${WORK_DIR}/assets/js/data/pageviews.json"
2020-01-01 20:21:43 +03:00
2020-08-19 12:05:58 +03:00
PROXY_URL="$(grep "proxy_endpoint:" "$URL_FILE" | sed "s/.*: '//g;s/'.*//")"
2019-09-30 15:38:41 +03:00
2020-08-19 12:05:58 +03:00
wget "$PROXY_URL" -O "$PV_CACHE"
2020-07-24 19:49:13 +03:00
echo "ls $PV_CACHE"