115 lines
4.2 KiB
HTML

{% block page_start %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{ ctx.page.title }}</title>{# ctx.page.title is usually set by prepare_repo_cmd #}
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap">
<link rel="stylesheet" href="/themed.css">
</head>
<body class="text-gray-900">
{% endblock %}
{% block repo_header %}
<header class="bg-gray-50 border-b border-gray-300">{# Repo header #}
<div class="max-w-[1280px] mx-auto py-4 flex gap-x-1">
{# Heroicons outline cube #}
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6"><path stroke-linecap="round" stroke-linejoin="round" d="m21 7.5-9-5.25L3 7.5m18 0-9 5.25m9-5.25v9l-9 5.25M3 7.5l9 5.25M3 7.5v9l9 5.25m0-9v9" /></svg>
<div class="text-lg"><a href="{{ cgit_rooturl()|attr }}" class="hover:text-blue-600 hover:underline">index</a> / <a href="{! cgit_shared_repolink_url(NULL, NULL, NULL); !}" class="font-semibold hover:text-blue-600 hover:underline">{{ ctx.repo->name }}</a></div>
</div>
</header>
{% endblock %}
{% block page_end %}
<footer class="border-t border-gray-300">
{# Footer panel #}
<div class="max-w-[1280px] mx-auto py-4">
<div class="text-sm text-gray-500">
{# cgit footer #}
generated by <a href="https://git.zx2c4.com/cgit/about/" class="hover:text-blue-600 hover:underline">cgit {{ cgit_version }}</a> (<a href="https://git-scm.com/" class="hover:text-blue-600 hover:underline">git {{ git_version_string }}</a>) at
{{ show_date(time(NULL), 0, cgit_date_mode(DATE_ISO8601)) }}
</div>
</div>
</footer>
</body>
</html>
{% 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++;
release_commit_memory(the_repository->parsed_objects, commit);
commit->parents = NULL;
}
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);
}
!}