the repository which powers this website
Template-based home page
RunasSudo 10 months ago
parent e750dd6 · commit 5776aeb
-rw-r--r--themed/index.html63
-rw-r--r--ui-repolist.c12
-rw-r--r--ui-repolist.h3
-rw-r--r--ui-shared.c5
-rw-r--r--ui-shared.h2
5 files changed, 84 insertions, 1 deletions
diff --git a/themed/index.html b/themed/index.html
new file mode 100644
index 00000000..03c01692
--- /dev/null
+++ b/themed/index.html
@@ -0,0 +1,63 @@
+{! int cgit_repolist_is_visible(struct cgit_repo *repo); !}
+{! void cgit_repolist_print_modtime(struct cgit_repo *repo); !}
+{! void cgit_shared_site_url(const char *page, const char *search, const char *sort, int ofs, int always_root); !}
+
+{% page cgit_print_repolist %}
+{! ctx.page.title = ctx.cfg.root_title; !}
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>{{ ctx.cfg.root_title }}</title>
+ <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="/style.css">
+ </head>
+ <body class="text-gray-900">
+ <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">
+ <a href="{! cgit_shared_site_url(NULL, NULL, NULL, 0, 1); !}" class="text-lg hover:underline">{{ ctx.cfg.root_title }}</a>
+ </div>
+ </header>
+ <main class="max-w-[1280px] mx-auto py-4">
+ {# Main content #}
+ <form method="GET" action="{! cgit_shared_site_url(NULL, NULL, NULL, 0, 1); !}" class="flex text-sm mb-4 outline-1 outline-gray-300 rounded-lg has-[input:focus-within]:outline-2 has-[input:focus-within]:outline-blue-600">
+ {# Search box #}
+ <input name="q" value="{{ ctx.qry.search|attr }}" type="text" placeholder="Search repos&hellip;" class="flex-1 py-1.5 pl-2 text-sm focus:outline-none">
+ <button class="py-1.5 px-2 cursor-pointer" action="submit" value="search">
+ {# Heroicons micro magnifying-glass #}
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="text-gray-700 size-4"><path fill-rule="evenodd" d="M9.965 11.026a5 5 0 1 1 1.06-1.06l2.755 2.754a.75.75 0 1 1-1.06 1.06l-2.755-2.754ZM10.5 7a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0Z" clip-rule="evenodd" /></svg>
+ </button>
+ </form>
+ <div class="grid grid-cols-[auto_1fr]">
+ {# Repo list #}
+ {! for (int i = 0; i < cgit_repolist.count; i++) { !}
+ {! ctx.repo = &cgit_repolist.repos[i]; !}
+ {! if (!cgit_repolist_is_visible(ctx.repo)) { continue; } !}
+ <div>
+ {# 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>
+ <div class="pl-2">
+ {! char *repourl = cgit_repourl(ctx.repo->url); !}
+ <div><a href="{{ repourl|attr }}" class="text-lg font-semibold text-blue-500 hover:text-blue-600 hover:underline">{{ ctx.repo->name }}</a></div>
+ {! free(repourl); !}
+ <div class="text-gray-500">{{ ctx.repo->desc }}</div>
+ <div class="text-gray-500">Updated {! cgit_repolist_print_modtime(ctx.repo); !} ago</div>
+ </div>
+ {! } !}
+ </div>
+ </main>
+ <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>
+{% endpage %}
diff --git a/ui-repolist.c b/ui-repolist.c
index d12e3dd3..01f1fb51 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -82,6 +82,11 @@ static void print_modtime(struct cgit_repo *repo)
cgit_print_age(t, 0, -1);
}
+void cgit_repolist_print_modtime(struct cgit_repo *repo)
+{
+ print_modtime(repo);
+}
+
static int is_match(struct cgit_repo *repo)
{
if (!ctx.qry.search)
@@ -115,6 +120,11 @@ static int is_visible(struct cgit_repo *repo)
return 1;
}
+int cgit_repolist_is_visible(struct cgit_repo *repo)
+{
+ return is_visible(repo);
+}
+
static int any_repos_visible(void)
{
int i;
@@ -265,7 +275,7 @@ static int sort_repolist(char *field)
}
-void cgit_print_repolist(void)
+void _orig_cgit_print_repolist(void)
{
int i, columns = 3, hits = 0, header = 0;
char *last_section = NULL;
diff --git a/ui-repolist.h b/ui-repolist.h
index 1b6b3227..f62cd3e0 100644
--- a/ui-repolist.h
+++ b/ui-repolist.h
@@ -1,6 +1,9 @@
#ifndef UI_REPOLIST_H
#define UI_REPOLIST_H
+extern int cgit_repolist_is_visible(struct cgit_repo *repo);
+extern void cgit_repolist_print_modtime(struct cgit_repo *repo);
+
extern void cgit_print_repolist(void);
extern void cgit_print_site_readme(void);
diff --git a/ui-shared.c b/ui-shared.c
index 4250b890..5853a969 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -235,6 +235,11 @@ static void site_url(const char *page, const char *search, const char *sort, int
}
}
+void cgit_shared_site_url(const char *page, const char *search, const char *sort, int ofs, int always_root)
+{
+ site_url(page, search, sort, ofs, always_root);
+}
+
static void site_link(const char *page, const char *name, const char *title,
const char *class, const char *search, const char *sort, int ofs, int always_root)
{
diff --git a/ui-shared.h b/ui-shared.h
index f12fa994..ce05a9b5 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -1,6 +1,8 @@
#ifndef UI_SHARED_H
#define UI_SHARED_H
+extern void cgit_shared_site_url(const char *page, const char *search, const char *sort, int ofs, int always_root);
+
extern const char *cgit_httpscheme(void);
extern char *cgit_hosturl(void);
extern const char *cgit_rooturl(void);