Skip to content

Commit 1601476

Browse files
committed
Add git information to the output HTML, closes #11
1 parent 8dab84e commit 1601476

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Makefile

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ TSCFLAGS=--strict \
88
--noUnusedParameters \
99
--noImplicitReturns \
1010
--noFallthroughCasesInSwitch
11+
GITHUB_PATH=$(shell ./scripts/github-path.sh)
12+
COMMIT_ID=$(shell git rev-parse HEAD)
1113

1214
all: remarks.html
1315

1416
remarks.html: remarks.tmpl.html LICENSE remarks.css remarks.js Makefile
15-
cpp $(CPPFLAGS) -P $< $@
17+
cpp $(CPPFLAGS) \
18+
-D"GITHUB_PATH=$(GITHUB_PATH)" \
19+
-D"GITHUB_HREF=\"https://github.com/$(GITHUB_PATH)\"" \
20+
-D"COMMIT_ID=$(COMMIT_ID)" \
21+
-D"COMMIT_HREF=\"https://github.com/$(GITHUB_PATH)/commit/$(COMMIT_ID)\"" \
22+
-P $< $@
1623

1724
remarks.js: remarks.ts Makefile
1825
tsc $(TSCFLAGS) $<

remarks.tmpl.html

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
</head>
1212
<body>
1313
<div id="judgements"></div>
14+
<div id="github">
15+
Made from <a href=GITHUB_HREF>GITHUB_PATH</a>, commit <a
16+
href=COMMIT_HREF>COMMIT_ID</a>.
17+
</div>
1418
<script type="text/javascript">
1519
#include "remarks.js"
1620
</script>

scripts/github-path.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
git remote get-url origin | \
6+
sed 's/^git@github.com:\(.*\)\.git$/\1/'

0 commit comments

Comments
 (0)