1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
{! #include "../ui-blob.h" !}
{!
int ls_item(const struct object_id *oid, struct strbuf *base, const char *pathname, unsigned mode, void *cbdata) {
tree_listing_item(oid, base, pathname, mode, true); /* from tree_common.html */
return 0;
}
!}
{% block cgit_print_summary_impl %}
{! page_start(ctx.repo->name, ctx.repo->desc); !}
{! repo_header(); !}
<main class="max-w-7xl mx-auto py-4 pl-2 pr-2">{# Main content #}
{! repo_description_panel(); !}
{! repo_summary_bar(); !}
<div class="grid grid-cols-[auto_1fr_auto_auto] border border-[#333A45] rounded-md mb-4">
{# Latest commit panel (specify rounded-t-md so background does not cover border) #}
{!
char *hex = ctx.qry.oid;
if (!hex) { hex = ctx.qry.head; }
struct object_id oid;
if (repo_get_oid(the_repository, hex, &oid)) {
die("Bad object id");
}
struct commit *commit = lookup_commit_reference(the_repository, &oid);
if (!commit) {
die("Bad commit reference");
}
struct commitinfo *info = cgit_parse_commit(commit);
!}
<div class="col-span-4 rounded-t-md bg-[#262F3F] px-3 py-2 flex gap-x-1 items-center">
<img class="gravatar" src="{! gravatar_url(info->author_email); !}?s=32">
<span class="font-semibold">{{ info->author }}</span>
<a href="{! cgit_shared_reporevlink_url("commit", ctx.qry.head, oid_to_hex(&commit->object.oid), ctx.qry.vpath); !}" class="ml-2 text-[#a3a29c] hover:text-[#73D0FF] hover:underline">{{ info->subject }}</a>
<div class="flex-1"></div>
<span class="text-[#a3a29c]">
<a href="{! cgit_shared_reporevlink_url("commit", ctx.qry.head, oid_to_hex(&commit->object.oid), ctx.qry.vpath); !}" class="font-mono hover:text-[#73D0FF] hover:underline">
{! short_commit_id(oid_to_hex(&commit->object.oid)); !}
</a>
·
{! cgit_print_age_themed(info->committer_date, info->committer_tz, TM_MONTH * 12); !}
</span>
<a href="{! cgit_shared_repolink_url("log", ctx.qry.head, NULL); !}" class="flex gap-x-1 py-1.5 px-3 ml-3 rounded-md hover:bg-[#333A45]">
{# Heroicons micro clock #}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4 self-center text-[#a3a29c]"><path fill-rule="evenodd" d="M1 8a7 7 0 1 1 14 0A7 7 0 0 1 1 8Zm7.75-4.25a.75.75 0 0 0-1.5 0V8c0 .414.336.75.75.75h3.25a.75.75 0 0 0 0-1.5h-2.5v-3.5Z" clip-rule="evenodd" /></svg>
{! int num_commits = get_num_commits(); !}
<span class="font-semibold">{{ num_commits|%d }}</span><span class="font-semibold text-[#a3a29c]">Commit{% if num_commits != 1 %}s{% endif %}</span>
</a>
</div>
{! cgit_free_commitinfo(info); !}
{# Files #}
{!
const struct object_id *tree_oid = get_commit_tree_oid(commit);
struct tree *tree = parse_tree_indirect(tree_oid);
struct pathspec paths = {
.nr = 0
};
read_tree(the_repository, tree, &paths, ls_item, NULL);
!}
</div>
{% if ctx.repo->readme.nr > 0 %}
{!
char *filename = ctx.repo->readme.items[0].string;
char *ref = ctx.repo->readme.items[0].util;
!}
<div class="readme flex flex-col border border-[#333A45] rounded-md">
{# Readme panel #}
<div class="rounded-t-md bg-[#262F3F] px-3 py-2 flex gap-x-1 items-center">
{# Heroicons micro book-open #}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4"><path d="M7.25 3.688a8.035 8.035 0 0 0-4.872-.523A.48.48 0 0 0 2 3.64v7.994c0 .345.342.588.679.512a6.02 6.02 0 0 1 4.571.81V3.688ZM8.75 12.956a6.02 6.02 0 0 1 4.571-.81c.337.075.679-.167.679-.512V3.64a.48.48 0 0 0-.378-.475 8.034 8.034 0 0 0-4.872.523v9.268Z" /></svg>
<span class="font-semibold text-sm">{{ filename }}</span>
{# Readme content #}
</div>
<div class="rendered-file p-1 border-t border-[#333A45] text-[#CCCAC2]">
{!
cgit_open_filter(ctx.repo->about_filter, filename);
if (ref) {
cgit_print_file(filename, ref, 1);
} else {
html_include(filename);
}
cgit_close_filter(ctx.repo->about_filter);
!}
</div>
</div>
<!-- {% endif %} -->
</main>
{! page_end(); !}
{% endblock %}
{% page cgit_print_summary %}
{! cgit_print_summary_impl(); !}
{% endpage %}
|