Skip to content

Commit

Permalink
Add analytics via EndTRACKER
Browse files Browse the repository at this point in the history
  • Loading branch information
jmmv committed Oct 7, 2023
1 parent a7fb94d commit 2b6ba2c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- run: sudo apt-get install -y mandoc pandoc
- run: autoreconf -isv
- run: ./configure
- run: make site
- run: make site SITE_ID=238881e4-4c6d-4bcf-87df-d0fd12afd2ce
- uses: JamesIves/github-pages-deploy-action@4.1.4
with:
folder: site-out
Expand Down
4 changes: 3 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -319,5 +319,7 @@ site/build: $(srcdir)/site/build.sh shtk
$(AM_V_GEN)$(TESTS_ENVIRONMENT) ./shtk build -o $@ $<

PHONY_TARGETS += site
SITE_ID = 00000000-0000-0000-0000-000000000000
site: all site/build
@$(TESTS_ENVIRONMENT) ./site/build -o site-out "-v$(PACKAGE_VERSION)"
@$(TESTS_ENVIRONMENT) ./site/build \
-o site-out "-s$(SITE_ID)" "-v$(PACKAGE_VERSION)"
19 changes: 16 additions & 3 deletions site/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ build_docs() {
build_fragments() {
local outdir="${1}"; shift
local version="${1}"; shift
local site_id="${1}"; shift

shtk_cli_info "Processing fragments..."
for src in "${outdir}"/*.frag; do
Expand All @@ -66,23 +67,35 @@ build_fragments() {
*/install.html*) install_active="active" ;;
*) docs_active="active" ;;
esac

local name="${dest#${outdir}/}"
local page_id="$(echo "https://shtk.jmmv.dev/${name}" | base64 -w0)"

cat site/header.html.in "${src}" site/footer.html.in \
| sed -e "s,@DOCS_ACTIVE@,${docs_active},g" \
-e "s,@INSTALL_ACTIVE@,${install_active},g" >"${dest}" \
-e "s,@SHTK_VERSION@,${version},g" >"${dest}"
-e "s,@SHTK_VERSION@,${version},g" \
-e "s,@SITE_ID@,${site_id},g" \
-e "s,@PAGE_ID@,${page_id},g" \
>"${dest}"
done
}

main() {
local site_id=
local outdir=site-out
local version=0.0

while getopts ':o:v:' arg "${@}"; do
while getopts ':o:s:v:' arg "${@}"; do
case "${arg}" in
o) # Output directory.
outdir="${OPTARG}"
;;

s) # Site id for analytics.
site_id="${OPTARG}"
;;

v) # Version to embed in the documentation.
version="${OPTARG}"
;;
Expand Down Expand Up @@ -111,7 +124,7 @@ main() {

build_docs "${outdir}"

build_fragments "${outdir}" "${version}"
build_fragments "${outdir}" "${version}" "${site_id}"

rm "${outdir}"/*.frag
}
2 changes: 2 additions & 0 deletions site/footer.html.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
<script src="main.js"></script>

<img src="https://hugo-dynamic.jmmv.dev/api/sites/@SITE_ID@/pages/@PAGE_ID@/stamp.gif" style="display: none;" />
</body>
</html>

0 comments on commit 2b6ba2c

Please sign in to comment.