commit - 345ec100b5ccad3d06f76def8bf4ad10e19bf36e
commit + 465b5e047c1c3c664fedb9f1d8ac15a7c87e427b
blob - 8b52a96285c3f5641afc0b80af3319368dde1c03
blob + 997f31d25d163cb25bb799bd71b700d31e59318c
--- index.html
+++ index.html
<section>
<h2>Contributions</h2>
<picture>
+ <source srcset="/static/contrib-half-dark.svg?v=6" media="(max-width: 600px) and (prefers-color-scheme: dark)" width="334" height="112">
+ <source srcset="/static/contrib-half.svg?v=6" media="(max-width: 600px)" width="334" height="112">
<source srcset="/static/contrib-dark.svg?v=6" media="(prefers-color-scheme: dark)">
<img class="contrib" src="/static/contrib.svg?v=6" loading="lazy" alt="Contribution graph for the last year across Got, sourcehut and GitHub" width="658" height="112">
</picture>
blob - /dev/null
blob + 5af78a44cfe82e3c9c74aaa5f3a54aaf6ecb5606 (mode 644)
--- /dev/null
+++ static/contrib-half-dark.svg
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 334 112" width="334" height="112">
+<style>text{fill:#8f8c84;font:9px Charter,"Bitstream Charter","Sitka Text",Cambria,Georgia,serif}.l0{fill:#23221f}.l1{fill:#35402c}.l2{fill:#4f633b}.l3{fill:#728c51}.l4{fill:#a2bb7c}</style>
+<text x="24" y="8">Apr</text>
+<text x="72" y="8">May</text>
+<text x="132" y="8">Jun</text>
+<text x="180" y="8">Jul</text>
+<text x="228" y="8">Aug</text>
+<text x="288" y="8">Sep</text>
+<text x="0" y="35">Mon</text><text x="0" y="59">Wed</text><text x="0" y="83">Fri</text>
+<defs><pattern id="g" x="24" y="15" width="12" height="12" patternUnits="userSpaceOnUse"><rect class="l0" width="10" height="10" rx="2"/></pattern></defs>
+<rect fill="url(#g)" x="24" y="15" width="298" height="82"/>
+<rect fill="url(#g)" x="324" y="15" width="10" height="34"/>
+<rect class="l1" x="24" y="75" width="10" height="10" rx="2"/>
+<rect class="l1" x="48" y="87" width="10" height="10" rx="2"/>
+<rect class="l1" x="72" y="39" width="10" height="10" rx="2"/>
+<rect class="l1" x="72" y="51" width="10" height="10" rx="2"/>
+<rect class="l2" x="144" y="63" width="10" height="10" rx="2"/>
+<rect class="l1" x="144" y="75" width="10" height="10" rx="2"/>
+<rect class="l1" x="168" y="15" width="10" height="10" rx="2"/>
+<rect class="l4" x="168" y="27" width="10" height="10" rx="2"/>
+<rect class="l4" x="168" y="39" width="10" height="10" rx="2"/>
+<rect class="l1" x="168" y="75" width="10" height="10" rx="2"/>
+<rect class="l1" x="168" y="87" width="10" height="10" rx="2"/>
+<rect class="l1" x="204" y="63" width="10" height="10" rx="2"/>
+<rect class="l2" x="264" y="63" width="10" height="10" rx="2"/>
+<rect class="l2" x="288" y="63" width="10" height="10" rx="2"/>
+<rect class="l2" x="300" y="63" width="10" height="10" rx="2"/>
+<rect class="l1" x="300" y="75" width="10" height="10" rx="2"/>
+<rect class="l1" x="300" y="87" width="10" height="10" rx="2"/>
+<rect class="l1" x="312" y="15" width="10" height="10" rx="2"/>
+<rect class="l4" x="312" y="63" width="10" height="10" rx="2"/>
+<rect class="l4" x="324" y="39" width="10" height="10" rx="2"/>
+<text x="24" y="110" style="font-style:italic;font-size:10px">111 contributions in the last six months</text>
+</svg>
blob - /dev/null
blob + 7f12e056a05588daea8fdf5dbe4ed7a646e216a4 (mode 644)
--- /dev/null
+++ static/contrib-half.svg
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 334 112" width="334" height="112">
+<style>text{fill:#75726b;font:9px Charter,"Bitstream Charter","Sitka Text",Cambria,Georgia,serif}.l0{fill:#e6e2d8}.l1{fill:#b9c99a}.l2{fill:#88a263}.l3{fill:#5a7a40}.l4{fill:#36502a}</style>
+<text x="24" y="8">Apr</text>
+<text x="72" y="8">May</text>
+<text x="132" y="8">Jun</text>
+<text x="180" y="8">Jul</text>
+<text x="228" y="8">Aug</text>
+<text x="288" y="8">Sep</text>
+<text x="0" y="35">Mon</text><text x="0" y="59">Wed</text><text x="0" y="83">Fri</text>
+<defs><pattern id="g" x="24" y="15" width="12" height="12" patternUnits="userSpaceOnUse"><rect class="l0" width="10" height="10" rx="2"/></pattern></defs>
+<rect fill="url(#g)" x="24" y="15" width="298" height="82"/>
+<rect fill="url(#g)" x="324" y="15" width="10" height="34"/>
+<rect class="l1" x="24" y="75" width="10" height="10" rx="2"/>
+<rect class="l1" x="48" y="87" width="10" height="10" rx="2"/>
+<rect class="l1" x="72" y="39" width="10" height="10" rx="2"/>
+<rect class="l1" x="72" y="51" width="10" height="10" rx="2"/>
+<rect class="l2" x="144" y="63" width="10" height="10" rx="2"/>
+<rect class="l1" x="144" y="75" width="10" height="10" rx="2"/>
+<rect class="l1" x="168" y="15" width="10" height="10" rx="2"/>
+<rect class="l4" x="168" y="27" width="10" height="10" rx="2"/>
+<rect class="l4" x="168" y="39" width="10" height="10" rx="2"/>
+<rect class="l1" x="168" y="75" width="10" height="10" rx="2"/>
+<rect class="l1" x="168" y="87" width="10" height="10" rx="2"/>
+<rect class="l1" x="204" y="63" width="10" height="10" rx="2"/>
+<rect class="l2" x="264" y="63" width="10" height="10" rx="2"/>
+<rect class="l2" x="288" y="63" width="10" height="10" rx="2"/>
+<rect class="l2" x="300" y="63" width="10" height="10" rx="2"/>
+<rect class="l1" x="300" y="75" width="10" height="10" rx="2"/>
+<rect class="l1" x="300" y="87" width="10" height="10" rx="2"/>
+<rect class="l1" x="312" y="15" width="10" height="10" rx="2"/>
+<rect class="l4" x="312" y="63" width="10" height="10" rx="2"/>
+<rect class="l4" x="324" y="39" width="10" height="10" rx="2"/>
+<text x="24" y="110" style="font-style:italic;font-size:10px">111 contributions in the last six months</text>
+</svg>
blob - 874827df3a2ec9591f84cd5c344889bcadd91980
blob + 326a1d7af1d1d14ff904d6f08fd59e98c52be391
--- tools/contrib.sh
+++ tools/contrib.sh
# SKIP repo names (without .git) that are also pushed to GitHub, so
# their commits are not counted twice
# OUT output SVG path (default static/contrib.svg);
-# a dark version is written next to it as NAME-dark.svg
+# a dark version is written next to it as NAME-dark.svg, and a
+# half-year chart for phones as NAME-half.svg and NAME-half-dark.svg
set -eu
fi
fi
-awk -v today="$(date +%Y-%m-%d)" '
+# chart WEEKS: the last WEEKS columns of days as an SVG, style left as @STYLE@
+chart() {
+awk -v today="$(date +%Y-%m-%d)" -v weeks="$1" '
# days since 1970-01-01 (proleptic Gregorian)
function days(s, p, y, m, d, era, yoe, doy) {
split(s, p, "-"); y = p[1] + 0; m = p[2] + 0; d = p[3] + 0
split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", mon, " ")
end = days(today)
dow = (end + 4) % 7 # 0 = Sunday
- start = end - dow - 52 * 7 # Sunday, 53 columns
+ start = end - dow - (weeks - 1) * 7 # Sunday, one column per week
# shade with the level boundaries GitHub uses, so GitHub days match ghchart;
# without GitHub data, fall back to quartiles of the non-zero days
if (lvmax[1] && lvmax[2] && lvmax[3]) {
}
step = 12; left = 24; top = 15
- w = left + 53 * step - 2; h = top + 7 * step + 13
+ w = left + weeks * step - 2; h = top + 7 * step + 13
printf "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 %d %d\" width=\"%d\" height=\"%d\">\n", w, h, w, h
print "<style>@STYLE@</style>"
# month labels where a new month starts within a column
last = -1
- for (c = 0; c < 53; c++) {
+ for (c = 0; c < weeks; c++) {
civil(start + c * 7)
- if (CM != last && CD <= 7 && c < 52) printf "<text x=\"%d\" y=\"8\">%s</text>\n", left + c * step, mon[CM]
+ if (CM != last && CD <= 7 && c < weeks - 1) printf "<text x=\"%d\" y=\"8\">%s</text>\n", left + c * step, mon[CM]
last = CM
}
printf "<text x=\"0\" y=\"%d\">Mon</text><text x=\"0\" y=\"%d\">Wed</text><text x=\"0\" y=\"%d\">Fri</text>\n", top + 20, top + 44, top + 68
# empty days are a tiled pattern; only active days get their own square
printf "<defs><pattern id=\"g\" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" patternUnits=\"userSpaceOnUse\"><rect class=\"l0\" width=\"10\" height=\"10\" rx=\"2\"/></pattern></defs>\n", left, top, step, step
- printf "<rect fill=\"url(#g)\" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\"/>\n", left, top, 52 * step - 2, 7 * step - 2
- printf "<rect fill=\"url(#g)\" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\"/>\n", left + 52 * step, top, step - 2, (dow + 1) * step - 2
+ printf "<rect fill=\"url(#g)\" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\"/>\n", left, top, (weeks - 1) * step - 2, 7 * step - 2
+ printf "<rect fill=\"url(#g)\" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\"/>\n", left + (weeks - 1) * step, top, step - 2, (dow + 1) * step - 2
total = 0
for (n = start; n <= end; n++) {
v = cnt[n] + 0
l = v <= q1 ? 1 : v <= q2 ? 2 : v <= q3 ? 3 : 4
printf "<rect class=\"l%d\" x=\"%d\" y=\"%d\" width=\"10\" height=\"10\" rx=\"2\"/>\n", l, left + int(i / 7) * step, top + i % 7 * step
}
- printf "<text x=\"%d\" y=\"%d\" style=\"font-style:italic;font-size:10px\">%d contribution%s in the last year</text>\n", left, h - 2, total, (total == 1 ? "" : "s")
+ printf "<text x=\"%d\" y=\"%d\" style=\"font-style:italic;font-size:10px\">%d contribution%s in the last %s</text>\n", left, h - 2, total, (total == 1 ? "" : "s"), (weeks > 26 ? "year" : "six months")
print "</svg>"
-}' "$tmp/days" > "$tmp/chart"
+}' "$tmp/days"
+}
-sed "s|@STYLE@|$LIGHT|" "$tmp/chart" > "$tmp/light.svg"
-sed "s|@STYLE@|$DARK|" "$tmp/chart" > "$tmp/dark.svg"
-mv "$tmp/light.svg" "$OUT"
-mv "$tmp/dark.svg" "${OUT%.svg}-dark.svg"
+# write NAME CHART: light and dark versions of CHART as NAME.svg and NAME-dark.svg
+write() {
+ sed "s|@STYLE@|$LIGHT|" "$2" > "$tmp/light.svg"
+ sed "s|@STYLE@|$DARK|" "$2" > "$tmp/dark.svg"
+ mv "$tmp/light.svg" "$1.svg"
+ mv "$tmp/dark.svg" "$1-dark.svg"
+}
+
+chart 53 > "$tmp/year"
+chart 26 > "$tmp/half"
+write "${OUT%.svg}" "$tmp/year"
+write "${OUT%.svg}-half" "$tmp/half"