web/tools/pv.sh

27 lines
527 B
Bash
Raw Normal View History

2019-09-30 15:38:41 +03:00
#!/bin/bash
#
# Fetch Google Analytics Pageviews reporting cache
# and save as 'assets/data/pagevies.json'
#
# Requirement:
# - jq
# - wget
#
2020-01-02 16:17:49 +03:00
# v2.0
# https://github.com/cotes2020/jekyll-theme-chirpy
2019-09-30 15:38:41 +03:00
# © 2019 Cotes Chung
# MIT Licensed
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"