Mon, 19 May 2025 13:58:19 +0200
make charts identifiable with a query - fixes #608
src/html.cpp | file | annotate | diff | comparison | revisions | |
src/html.h | file | annotate | diff | comparison | revisions | |
src/main.cpp | file | annotate | diff | comparison | revisions |
--- a/src/html.cpp Mon May 19 13:30:18 2025 +0200 +++ b/src/html.cpp Mon May 19 13:58:19 2025 +0200 @@ -134,9 +134,21 @@ } } +void html::chart_begin(const std::string& repo, const std::string& author) { + indent(); + printf("<div class=\"chart\" data-repo=\"%s\" data-author=\"%s\">\n", + encode(repo).c_str(), encode(author).c_str()); + indentation++; +} + +void html::chart_end() { + indent(-1); + puts("</div>"); +} + void html::heading_repo(const std::string& repo) { indent(); - printf("<h1>%s</h1>\n", encode(repo).c_str()); + printf("<h1 data-repo=\"%s\">%1$s</h1>\n", encode(repo).c_str()); } void html::heading_author(const std::string& author, unsigned int total_commits) { @@ -179,8 +191,7 @@ } void html::table_end() { - indentation--; - indent(); + indent(-1); puts("</table>"); }
--- a/src/html.h Mon May 19 13:30:18 2025 +0200 +++ b/src/html.h Mon May 19 13:58:19 2025 +0200 @@ -36,6 +36,8 @@ void open(bool fragment); void close(bool fragment); + void chart_begin(const std::string& repo, const std::string& author); + void chart_end(); void heading_repo(const std::string& repo); void heading_author(const std::string& author, unsigned int total_commits); void table_begin(std::chrono::year y, const std::array<unsigned int, 12> &commits_per_month);
--- a/src/main.cpp Mon May 19 13:30:18 2025 +0200 +++ b/src/main.cpp Mon May 19 13:58:19 2025 +0200 @@ -271,6 +271,7 @@ html::heading_repo(repo); h1_rendered = true; } + html::chart_begin(repo, author); const auto commits_per_month = heatmap.commits_per_month(repo, author, report_year); const auto total_commits = std::accumulate(commits_per_month.begin(), commits_per_month.end(), 0u); @@ -280,7 +281,7 @@ // initialize counters unsigned column = 0, row = 0; - // initialize first day (which must be a Monday, possibly the year before) + // initialize the first day (which must be a Monday, possibly the year before) sys_days day_to_check = January / Monday[1] / report_year; if (year_month_day{day_to_check}.day() != 1d) { day_to_check -= days{7}; @@ -289,7 +290,7 @@ // remember the starting point auto start = day_to_check; - // now add all entries for Monday, Tuesdays, etc. always starting back in january + // now add all entries for Monday, Tuesdays, etc. always starting back in January while (true) { html::row_begin(row); @@ -330,6 +331,7 @@ } html::table_end(); + html::chart_end(); } } html::close(settings.fragment);