X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/f3c1a187fe2bc33f8423cd535d5045899699995b..502865a5ec40fed5f1f865cb34002aecaab8405e:/ui-shared.c diff --git a/ui-shared.c b/ui-shared.c index 2596023..6f83d2a 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -7,6 +7,7 @@ */ #include "cgit.h" +#include "cmd.h" #include "html.h" const char cgit_doctype[] = @@ -113,6 +114,60 @@ char *cgit_currurl() return fmt("%s/", ctx.cfg.virtual_root); } +static void site_url(char *page, char *search, int ofs) +{ + char *delim = "?"; + + if (ctx.cfg.virtual_root) { + html_attr(ctx.cfg.virtual_root); + if (ctx.cfg.virtual_root[strlen(ctx.cfg.virtual_root) - 1] != '/') + html("/"); + } else + html(ctx.cfg.script_name); + + if (page) { + htmlf("?p=%s", page); + delim = "&"; + } + if (search) { + html(delim); + html("q="); + html_attr(search); + delim = "&"; + } + if (ofs) { + html(delim); + htmlf("ofs=%d", ofs); + } +} + +static void site_link(char *page, char *name, char *title, char *class, + char *search, int ofs) +{ + html(""); + html_txt(name); + html(""); +} + +void cgit_index_link(char *name, char *title, char *class, char *pattern, + int ofs) +{ + site_link(NULL, name, title, class, pattern, ofs); +} + static char *repolink(char *title, char *class, char *page, char *head, char *path) { @@ -382,13 +437,27 @@ void cgit_print_docstart(struct cgit_context *ctx) html("\n"); + if (ctx->cfg.favicon) { + html("\n"); + } html("\n"); html("\n"); } void cgit_print_docend() { - html("\n\n\n\n\n"); + html(""); + if (ctx.cfg.footer) + html_include(ctx.cfg.footer); + else { + html("\n"); + } + html("\n\n"); } int print_branch_option(const char *refname, const unsigned char *sha1, @@ -465,75 +534,77 @@ void add_hidden_formfields(int incl_head, int incl_search, char *page) } } +char *hc(struct cgit_cmd *cmd, const char *page) +{ + return (strcmp(cmd->name, page) ? NULL : "active"); +} + void cgit_print_pageheader(struct cgit_context *ctx) { - static const char *default_info = "This is cgit, a fast webinterface for git repositories"; - int header = 0; - char *url; + struct cgit_cmd *cmd = cgit_get_cmd(ctx); - html("\n"); - html("\n"); - - html("
\n"); + html("
\n"); + html("
"); } void cgit_print_filemode(unsigned short mode) @@ -573,4 +654,19 @@ void cgit_print_filemode(unsigned short mode) html_fileperm(mode); } -/* vim:set sw=8: */ +void cgit_print_snapshot_links(const char *repo, const char *head, + const char *hex, int snapshots) +{ + const struct cgit_snapshot_format* f; + char *filename; + + for (f = cgit_snapshot_formats; f->suffix; f++) { + if (!(snapshots & f->bit)) + continue; + filename = fmt("%s-%s%s", cgit_repobasename(repo), hex, + f->suffix); + cgit_snapshot_link(filename, NULL, NULL, (char *)head, + (char *)hex, filename); + html("
"); + } +}