{! static int get_num_commits(); static int get_num_branches(); static int get_num_tags(); !} {% block page_start %} {{ ctx.page.title }}{# ctx.page.title is usually set by prepare_repo_cmd #} {% endblock %} {% block repo_header %}
{# Repo header #}
{# Heroicons outline cube #}
{% endblock %} {% block repo_description_panel %}
{# Description panel #} {{ ctx.repo->desc }}
{% endblock %} {% block repo_summary_bar %} {% endblock %} {% block page_end %} {% endblock %} {! static int get_num_commits() { int num_commits = 0; // Based on ui-stats collect_stats struct rev_info rev; struct commit *commit; const char *argv[] = {NULL, ctx.qry.head}; int argc = 2; repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.commit_format = CMIT_FMT_DEFAULT; rev.max_parents = 1; rev.verbose_header = 1; rev.show_root_diff = 0; setup_revisions(argc, argv, &rev, NULL); prepare_revision_walk(&rev); while ((commit = get_revision(&rev)) != NULL) { // Process the commit num_commits++; // ?? This causes subsequent walks to return commits with index 0 //release_commit_memory(the_repository->parsed_objects, commit); //commit->parents = NULL; } reset_revision_walk(); return num_commits; } static int get_num_branches() { struct reflist list; list.refs = NULL; list.alloc = list.count = 0; refs_for_each_branch_ref(get_main_ref_store(the_repository), cgit_refs_cb, &list); int num_branches = list.count; cgit_free_reflist_inner(&list); return num_branches; } static int get_num_tags() { struct reflist list; list.refs = NULL; list.alloc = list.count = 0; refs_for_each_tag_ref(get_main_ref_store(the_repository), cgit_refs_cb, &list); int num_tags = list.count; cgit_free_reflist_inner(&list); return num_tags; } !} {! #include "mincrypt_sha256.h" static void gravatar_url(char *email) { // Trim email of whitespace, < and > while (isspace(*email) || *email == '<') email++; char* strend = email + strlen(email) - 1; while (isspace(*strend) || *strend == '>') strend--; // Now strend points to the last character // Email to lowercase size_t email_len = strend - email + 1; char *email_lower = malloc(email_len + 1); // +1 for null terminator for (int i = 0; i < email_len; i++) { email_lower[i] = tolower(email[i]); } email_lower[email_len] = '\0'; // For good measure // Compute hash and print Gravatar link uint8_t digest[32]; SHA256_hash(email, strend - email + 1, digest); htmlf( "https://gravatar.com/avatar/%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", digest[0], digest[1], digest[2], digest[3], digest[4], digest[5], digest[6], digest[7], digest[8], digest[9], digest[10], digest[11], digest[12], digest[13], digest[14], digest[15], digest[16], digest[17], digest[18], digest[19], digest[20], digest[21], digest[22], digest[23], digest[24], digest[25], digest[26], digest[27], digest[28], digest[29], digest[30], digest[31] ); free(email_lower); } !}