diff -r 1040ba37d4c9 -r d0f77dd2da42 src/html.cpp
--- a/src/html.cpp Fri Jan 31 22:27:28 2025 +0100
+++ b/src/html.cpp Fri Jan 31 22:48:43 2025 +0100
@@ -26,10 +26,11 @@
#include
-#include
namespace chrono = std::chrono;
namespace html {
+ static constexpr const char* weekdays[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
+
static unsigned indentation;
static const char *tabs = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
static void indent(int change = 0) {
@@ -89,6 +90,30 @@
table.heatmap td.out-of-range {
background-color: gray;
}
+
+ table.heatmap td.zero-commits {
+ background-color: white;
+ }
+
+ table.heatmap td.one-commit {
+ background-color: #80E7A0;
+ }
+
+ table.heatmap td.up-to-5-commits {
+ background-color: #30D350;
+ }
+
+ table.heatmap td.up-to-10-commits {
+ background-color: #00BF00;
+ }
+
+ table.heatmap td.up-to-20-commits {
+ background-color: #00A300;
+ }
+
+ table.heatmap td.commit-spam {
+ background-color: #008000;
+ }
)");
@@ -151,7 +176,6 @@
}
void html::row_begin(unsigned int row) {
- static constexpr const char* weekdays[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
indent();
puts("");
indent(1);
@@ -168,8 +192,27 @@
puts(" | ");
}
-void html::cell(unsigned commits) {
+void html::cell(std::chrono::year_month_day ymd, unsigned commits) {
+ const char *color_class;
+ if (commits == 0) {
+ color_class = "zero-commits";
+ } else if (commits == 1) {
+ color_class = "one-commit";
+ } else if (commits <= 5) {
+ color_class = "up-to-5-commits";
+ } else if (commits <= 10) {
+ color_class = "up-to-10-commits";
+ } else if (commits <= 20) {
+ color_class = "up-to-20-commits";
+ } else {
+ color_class = "commit-spam";
+ }
indent();
- // TODO: use nice coloring and tooltips instead of printing the commits
- printf("%u | \n", commits);
+ printf(" | \n",
+ color_class,
+ weekdays[chrono::weekday(ymd).iso_encoding() - 1],
+ static_cast(ymd.year()),
+ static_cast(ymd.month()),
+ static_cast(ymd.day()),
+ commits);
}