diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Clean up the whole tree
Diffstat (limited to 'source/ui-shared.c')
| -rw-r--r-- | source/ui-shared.c | 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 120 insertions, 198 deletions
diff --git a/source/ui-shared.c b/source/ui-shared.c index 2ec9d0e..58e7f03 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -73,8 +73,7 @@ static const char *root_url(void) return ctx.cfg.script_name; } -static void site_url(const char *page, const char *search, const char *sort, - int ofs, int always_root) +static void site_url(const char *page, const char *search, const char *sort, int ofs, int always_root) { const char *delim = "?"; @@ -109,8 +108,7 @@ static void site_url(const char *page, const char *search, const char *sort, } 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) + const char *class, const char *search, const char *sort, int ofs, int always_root) { html("<a"); if (title) { @@ -136,9 +134,8 @@ static void site_link(const char *page, const char *name, const char *title, * arguments and close. The return is the delimiter to put before the first of * those, which is still a question mark unless a query string has been opened. */ -static const char *repolink(const char *title, const char *class, - const char *page, const char *head, - const char *path) +static const char *repolink(const char *title, const char *class, const char *page, + const char *head, const char *path) { const char *delim = "?"; @@ -200,8 +197,7 @@ static const char *emit_rev_arg(const char *delim, const char *rev) } static void reporevlink(const char *page, const char *name, const char *title, - const char *class, const char *head, const char *rev, - const char *path) + const char *class, const char *head, const char *rev, const char *path) { const char *delim; @@ -236,8 +232,7 @@ static void emit_diff_args(const char *delim) } } -static struct string_list_item *lookup_path(struct string_list *list, - const char *path) +static struct string_list_item *lookup_path(struct string_list *list, const char *path) { struct string_list_item *item; @@ -307,8 +302,7 @@ static void print_abs_date(time_t t, int tz) html("</time>"); } -static void print_rel_date(time_t t, int tz, double count, const char *class, - const char *suffix) +static void print_rel_date(time_t t, int tz, double count, const char *class, const char *suffix) { htmlf("<time class='%s' datetime='", class); html_attr(show_date(t, tz, cgit_date_mode(DATE_ISO8601_STRICT))); @@ -407,7 +401,7 @@ static const struct object_id *pinned_oid(void) if (!ctx.repo || !ctx.qry.has_oid || !ctx.qry.oid || !ctx.qry.head) return NULL; if (repo_get_oid(the_repository, ctx.qry.oid, &oid) || - repo_get_oid(the_repository, ctx.qry.head, &head_oid)) + repo_get_oid(the_repository, ctx.qry.head, &head_oid)) return NULL; // A full hex id resolves without being looked up, so only peeling to a // commit proves the pin names history, and a tag pinned to the tip @@ -533,16 +527,13 @@ static void print_header(void) if (pinned) { const char *hex = oid_to_hex(pinned); - html_option(hex, cgit_fmt("%.*s (detached)", - SHORT_HASH_LEN, hex), hex); + html_option(hex, cgit_fmt("%.*s (detached)", SHORT_HASH_LEN, hex), hex); } else if (!head_is_listed_branch()) { print_detached_head_option(); } - refs_for_each_branch_ref(get_main_ref_store(the_repository), - print_branch_option, &opt); + refs_for_each_branch_ref(get_main_ref_store(the_repository), print_branch_option, &opt); if (ctx.repo->enable_remote_branches) - refs_for_each_remote_ref(get_main_ref_store(the_repository), - print_branch_option, &opt); + refs_for_each_remote_ref(get_main_ref_store(the_repository), print_branch_option, &opt); html("</select> "); html("<input type='submit' value='switch'>"); html("</form>\n"); @@ -572,8 +563,7 @@ static const char *tab_class(const char *page) return strcmp(ctx.qry.page, page) ? NULL : "active"; } -static const char *tab_title(const char *format, const char *fallback, - const char *path) +static const char *tab_title(const char *format, const char *fallback, const char *path) { if (!path || !*path || strlen(path) > MAX_TITLE_PATH_LEN) return fallback; @@ -587,47 +577,44 @@ static void print_repo_tabs(void) html("<ul>\n"); if (ctx.repo->readme.nr) { html("<li>"); - reporevlink("about", "about", "About this repository", - tab_class("about"), ctx.qry.head, NULL, NULL); + reporevlink("about", "about", "About this repository", tab_class("about"), ctx.qry.head, NULL, NULL); html("</li>\n"); } html("<li>"); - cgit_summary_link("summary", "Repository summary", tab_class("summary"), - ctx.qry.head); + cgit_summary_link("summary", "Repository summary", tab_class("summary"), ctx.qry.head); html("</li>\n<li>"); - cgit_refs_link("refs", "Branches and tags", tab_class("refs"), - ctx.qry.head, ctx.qry.oid, NULL); + cgit_refs_link("refs", "Branches and tags", tab_class("refs"), ctx.qry.head, ctx.qry.oid, NULL); html("</li>\n<li>"); - cgit_log_link("log", - tab_title("Commit history of %s", "Commit history", vpath), - tab_class("log"), ctx.qry.head, - NULL, ctx.qry.vpath, 0, NULL, NULL, - ctx.qry.showmsg, ctx.qry.follow); + cgit_log_link( + "log", tab_title("Commit history of %s", "Commit history", vpath), + tab_class("log"), ctx.qry.head, NULL, ctx.qry.vpath, 0, NULL, NULL, + ctx.qry.showmsg, ctx.qry.follow + ); html("</li>\n<li>"); if (ctx.qry.page && !strcmp(ctx.qry.page, "blame")) - cgit_blame_link("blame", - tab_title("Line-by-line blame of %s", "Blame", vpath), - tab_class("blame"), ctx.qry.head, - ctx.qry.oid, ctx.qry.vpath); + cgit_blame_link( + "blame", tab_title("Line-by-line blame of %s", "Blame", vpath), + tab_class("blame"), ctx.qry.head, ctx.qry.oid, ctx.qry.vpath + ); else - cgit_tree_link("tree", - tab_title("Browse the tree at %s", - "Browse the file tree", vpath), - tab_class("tree"), ctx.qry.head, - ctx.qry.oid, ctx.qry.vpath); + cgit_tree_link( + "tree", tab_title("Browse the tree at %s", "Browse the file tree", vpath), + tab_class("tree"), ctx.qry.head, ctx.qry.oid, ctx.qry.vpath + ); html("</li>\n<li>"); - cgit_commit_link("commit", "The current commit", tab_class("commit"), - ctx.qry.head, ctx.qry.oid, ctx.qry.vpath); + cgit_commit_link( + "commit", "The current commit", tab_class("commit"), + ctx.qry.head, ctx.qry.oid, ctx.qry.vpath + ); html("</li>\n<li>"); - cgit_diff_link("diff", - tab_title("Changes to %s", "Changes in the current commit", vpath), - tab_class("diff"), ctx.qry.head, - ctx.qry.oid, ctx.qry.oid2, ctx.qry.vpath); + cgit_diff_link( + "diff", tab_title("Changes to %s", "Changes in the current commit", vpath), + tab_class("diff"), ctx.qry.head, ctx.qry.oid, ctx.qry.oid2, ctx.qry.vpath + ); html("</li>\n"); if (ctx.repo->max_stats) { html("<li>"); - cgit_stats_link("stats", "Commit activity", tab_class("stats"), - ctx.qry.head, ctx.qry.vpath); + cgit_stats_link("stats", "Commit activity", tab_class("stats"), ctx.qry.head, ctx.qry.vpath); html("</li>\n"); } html("</ul>\n"); @@ -637,8 +624,7 @@ static void print_repo_search(void) { html("<form class='search' method='get' action='"); if (ctx.cfg.virtual_root) { - char *fileurl = cgit_fileurl(ctx.qry.repo, "log", - ctx.qry.vpath, NULL); + char *fileurl = cgit_fileurl(ctx.qry.repo, "log", ctx.qry.vpath, NULL); html_url_path(fileurl); free(fileurl); } @@ -660,13 +646,11 @@ static void print_repo_search(void) static void print_site_tabs(void) { html("<ul>\n<li>"); - site_link(NULL, "index", "Repository index", tab_class("repolist"), - NULL, NULL, 0, 1); + site_link(NULL, "index", "Repository index", tab_class("repolist"), NULL, NULL, 0, 1); html("</li>\n"); if (ctx.cfg.root_readme) { html("<li>"); - site_link("about", "about", "About this site", - tab_class("about"), NULL, NULL, 0, 1); + site_link("about", "about", "About this site", tab_class("about"), NULL, NULL, 0, 1); html("</li>\n"); } html("</ul>\n"); @@ -688,8 +672,7 @@ static void print_site_search(void) } static void snapshot_link(const char *name, const char *title, const char *class, - const char *head, const char *rev, - const char *archivename) + const char *head, const char *rev, const char *archivename) { reporevlink("snapshot", name, title, class, head, rev, archivename); } @@ -699,54 +682,35 @@ static void snapshot_link(const char *name, const char *title, const char *class static void self_link(const char *name, const char *title, const char *class) { if (!strcmp(ctx.qry.page, "repolist")) - cgit_index_link(name, title, class, ctx.qry.search, ctx.qry.sort, - ctx.qry.ofs, 1); + cgit_index_link(name, title, class, ctx.qry.search, ctx.qry.sort, ctx.qry.ofs, 1); else if (!strcmp(ctx.qry.page, "summary")) cgit_summary_link(name, title, class, ctx.qry.head); else if (!strcmp(ctx.qry.page, "tag")) - cgit_tag_link(name, title, class, ctx.qry.has_oid ? - ctx.qry.oid : ctx.qry.head); + cgit_tag_link(name, title, class, ctx.qry.has_oid ? ctx.qry.oid : ctx.qry.head); else if (!strcmp(ctx.qry.page, "tree")) - cgit_tree_link(name, title, class, ctx.qry.head, - ctx.qry.has_oid ? ctx.qry.oid : NULL, - ctx.qry.path); + cgit_tree_link(name, title, class, ctx.qry.head, ctx.qry.has_oid ? ctx.qry.oid : NULL, ctx.qry.path); else if (!strcmp(ctx.qry.page, "plain")) - cgit_plain_link(name, title, class, ctx.qry.head, - ctx.qry.has_oid ? ctx.qry.oid : NULL, - ctx.qry.path); + cgit_plain_link(name, title, class, ctx.qry.head, ctx.qry.has_oid ? ctx.qry.oid : NULL, ctx.qry.path); else if (!strcmp(ctx.qry.page, "blame")) - cgit_blame_link(name, title, class, ctx.qry.head, - ctx.qry.has_oid ? ctx.qry.oid : NULL, - ctx.qry.path); + cgit_blame_link(name, title, class, ctx.qry.head, ctx.qry.has_oid ? ctx.qry.oid : NULL, ctx.qry.path); else if (!strcmp(ctx.qry.page, "log")) - cgit_log_link(name, title, class, ctx.qry.head, - ctx.qry.has_oid ? ctx.qry.oid : NULL, - ctx.qry.path, ctx.qry.ofs, - ctx.qry.grep, ctx.qry.search, - ctx.qry.showmsg, ctx.qry.follow); + cgit_log_link( + name, title, class, ctx.qry.head, ctx.qry.has_oid ? ctx.qry.oid : NULL, + ctx.qry.path, ctx.qry.ofs, ctx.qry.grep, ctx.qry.search, + ctx.qry.showmsg, ctx.qry.follow + ); else if (!strcmp(ctx.qry.page, "commit")) - cgit_commit_link(name, title, class, ctx.qry.head, - ctx.qry.has_oid ? ctx.qry.oid : NULL, - ctx.qry.path); + cgit_commit_link(name, title, class, ctx.qry.head, ctx.qry.has_oid ? ctx.qry.oid : NULL, ctx.qry.path); else if (!strcmp(ctx.qry.page, "patch")) - cgit_patch_link(name, title, class, ctx.qry.head, - ctx.qry.has_oid ? ctx.qry.oid : NULL, - ctx.qry.path); + cgit_patch_link(name, title, class, ctx.qry.head, ctx.qry.has_oid ? ctx.qry.oid : NULL, ctx.qry.path); else if (!strcmp(ctx.qry.page, "refs")) - cgit_refs_link(name, title, class, ctx.qry.head, - ctx.qry.has_oid ? ctx.qry.oid : NULL, - ctx.qry.path); + cgit_refs_link(name, title, class, ctx.qry.head, ctx.qry.has_oid ? ctx.qry.oid : NULL, ctx.qry.path); else if (!strcmp(ctx.qry.page, "snapshot")) - snapshot_link(name, title, class, ctx.qry.head, - ctx.qry.has_oid ? ctx.qry.oid : NULL, - ctx.qry.path); + snapshot_link(name, title, class, ctx.qry.head, ctx.qry.has_oid ? ctx.qry.oid : NULL, ctx.qry.path); else if (!strcmp(ctx.qry.page, "diff")) - cgit_diff_link(name, title, class, ctx.qry.head, - ctx.qry.oid, ctx.qry.oid2, - ctx.qry.path); + cgit_diff_link(name, title, class, ctx.qry.head, ctx.qry.oid, ctx.qry.oid2, ctx.qry.path); else if (!strcmp(ctx.qry.page, "stats")) - cgit_stats_link(name, title, class, ctx.qry.head, - ctx.qry.path); + cgit_stats_link(name, title, class, ctx.qry.head, ctx.qry.path); else { // A page name this switch does not know still gets a plain // repolink, which covers any simple page added later. @@ -824,8 +788,7 @@ char *cgit_hosturl(void) return xstrdup(ctx.env.http_host); if (!ctx.env.server_name) return NULL; - if (!ctx.env.server_port || - atoi(ctx.env.server_port) == DEFAULT_HTTP_PORT) + if (!ctx.env.server_port || atoi(ctx.env.server_port) == DEFAULT_HTTP_PORT) return xstrdup(ctx.env.server_name); return cgit_fmtalloc("%s:%s", ctx.env.server_name, ctx.env.server_port); } @@ -895,8 +858,8 @@ char *cgit_repourl(const char *reponame) return cgit_fmtalloc("?r=%s", reponame); } -char *cgit_fileurl(const char *reponame, const char *pagename, - const char *filename, const char *query) +char *cgit_fileurl(const char *reponame, const char *pagename, const char *filename, + const char *query) { struct strbuf sb = STRBUF_INIT; const char *delim; @@ -904,12 +867,11 @@ char *cgit_fileurl(const char *reponame, const char *pagename, // The result is a raw URL, so the query joiner is a bare ampersand // and each sink escapes the whole string for wherever it lands. if (ctx.cfg.virtual_root) { - strbuf_addf(&sb, "%s%s/%s/%s", ctx.cfg.virtual_root, reponame, - pagename, (filename ? filename:"")); + strbuf_addf(&sb, "%s%s/%s/%s", ctx.cfg.virtual_root, reponame, pagename, + (filename ? filename:"")); delim = "?"; } else { - strbuf_addf(&sb, "?url=%s/%s/%s", reponame, pagename, - (filename ? filename : "")); + strbuf_addf(&sb, "?url=%s/%s/%s", reponame, pagename, (filename ? filename : "")); delim = "&"; } if (query) @@ -917,8 +879,7 @@ char *cgit_fileurl(const char *reponame, const char *pagename, return strbuf_detach(&sb, NULL); } -char *cgit_pageurl(const char *reponame, const char *pagename, - const char *query) +char *cgit_pageurl(const char *reponame, const char *pagename, const char *query) { return cgit_fileurl(reponame, pagename, NULL, query); } @@ -932,46 +893,42 @@ const char *cgit_snapshot_prefix(const struct cgit_repo *repo) } void cgit_index_link(const char *name, const char *title, const char *class, - const char *pattern, const char *sort, int ofs, - int always_root) + const char *pattern, const char *sort, int ofs, int always_root) { site_link(NULL, name, title, class, pattern, sort, ofs, always_root); } -void cgit_summary_link(const char *name, const char *title, const char *class, - const char *head) +void cgit_summary_link(const char *name, const char *title, const char *class, const char *head) { reporevlink(NULL, name, title, class, head, NULL, NULL); } -void cgit_tag_link(const char *name, const char *title, const char *class, - const char *tag) +void cgit_tag_link(const char *name, const char *title, const char *class, const char *tag) { reporevlink("tag", name, title, class, tag, NULL, NULL); } void cgit_tree_link(const char *name, const char *title, const char *class, - const char *head, const char *rev, const char *path) + const char *head, const char *rev, const char *path) { reporevlink("tree", name, title, class, head, rev, path); } void cgit_plain_link(const char *name, const char *title, const char *class, - const char *head, const char *rev, const char *path) + const char *head, const char *rev, const char *path) { reporevlink("plain", name, title, class, head, rev, path); } void cgit_blame_link(const char *name, const char *title, const char *class, - const char *head, const char *rev, const char *path) + const char *head, const char *rev, const char *path) { reporevlink("blame", name, title, class, head, rev, path); } void cgit_log_link(const char *name, const char *title, const char *class, - const char *head, const char *rev, const char *path, - int ofs, const char *grep, const char *pattern, int showmsg, - int follow) + const char *head, const char *rev, const char *path, int ofs, const char *grep, + const char *pattern, int showmsg, int follow) { const char *delim; @@ -1007,7 +964,7 @@ void cgit_log_link(const char *name, const char *title, const char *class, } void cgit_commit_link(const char *name, const char *title, const char *class, - const char *head, const char *rev, const char *path) + const char *head, const char *rev, const char *path) { const char *delim; @@ -1016,8 +973,7 @@ void cgit_commit_link(const char *name, const char *title, const char *class, emit_diff_args(delim); html("'>"); if (name && name[0] != '\0') { - if (ctx.cfg.max_msg_len >= MIN_TRUNCATE_LEN && - strlen(name) > (size_t)ctx.cfg.max_msg_len) { + if (ctx.cfg.max_msg_len >= MIN_TRUNCATE_LEN && strlen(name) > (size_t)ctx.cfg.max_msg_len) { html_ntxt(name, ctx.cfg.max_msg_len - ELLIPSIS_LEN); html("..."); } else @@ -1028,14 +984,13 @@ void cgit_commit_link(const char *name, const char *title, const char *class, } void cgit_refs_link(const char *name, const char *title, const char *class, - const char *head, const char *rev, const char *path) + const char *head, const char *rev, const char *path) { reporevlink("refs", name, title, class, head, rev, path); } void cgit_diff_link(const char *name, const char *title, const char *class, - const char *head, const char *new_rev, const char *old_rev, - const char *path) + const char *head, const char *new_rev, const char *old_rev, const char *path) { const char *delim; @@ -1054,13 +1009,13 @@ void cgit_diff_link(const char *name, const char *title, const char *class, } void cgit_patch_link(const char *name, const char *title, const char *class, - const char *head, const char *rev, const char *path) + const char *head, const char *rev, const char *path) { reporevlink("patch", name, title, class, head, rev, path); } void cgit_stats_link(const char *name, const char *title, const char *class, - const char *head, const char *path) + const char *head, const char *path) { reporevlink("stats", name, title, class, head, NULL, path); } @@ -1074,8 +1029,7 @@ void cgit_object_link(struct object *obj) shortrev = xstrdup(fullrev); shortrev[SHORT_HASH_LEN] = '\0'; if (obj->type == OBJ_COMMIT) { - cgit_commit_link(cgit_fmt("commit %s...", shortrev), NULL, NULL, - ctx.qry.head, fullrev, NULL); + cgit_commit_link(cgit_fmt("commit %s...", shortrev), NULL, NULL, ctx.qry.head, fullrev, NULL); return; } else if (obj->type == OBJ_TREE) page = "tree"; @@ -1128,18 +1082,19 @@ static char *submodule_url_path(const char *url) strbuf_release(&sb); return NULL; } - } else if (skip_prefix(url, "http://", &rest) || - skip_prefix(url, "https://", &rest) || - skip_prefix(url, "git://", &rest) || - skip_prefix(url, "ssh://", &rest)) { + } else if ( + skip_prefix(url, "http://", &rest) || + skip_prefix(url, "https://", &rest) || + skip_prefix(url, "git://", &rest) || + skip_prefix(url, "ssh://", &rest) + ) { rest = strchr(rest, '/'); if (!rest) return NULL; strbuf_addstr(&sb, rest); } else if (skip_prefix(url, "file://", &rest)) { strbuf_addstr(&sb, rest); - } else if ((colon = strchr(url, ':')) && - !memchr(url, '/', colon - url)) { + } else if ((colon = strchr(url, ':')) && !memchr(url, '/', colon - url)) { // scp syntax, user@host:path strbuf_addstr(&sb, colon + 1); } else { @@ -1216,8 +1171,7 @@ static const struct forge *forge_for_host(const char *host, size_t len) size_t i; for (i = 0; i < ARRAY_SIZE(forges); i++) - if (strlen(forges[i].host) == len && - !strncasecmp(forges[i].host, host, len)) + if (strlen(forges[i].host) == len && !strncasecmp(forges[i].host, host, len)) return &forges[i]; return NULL; } @@ -1228,9 +1182,8 @@ static const struct forge *forge_for_host(const char *host, size_t len) * relative urls still land on an internal page when their target is served * here, and a scheme cgit cannot vouch for is left unlinked as a tooltip. */ -static void gitmodules_link(const char *path, const char *rev, - char **module, char **commit, - const char **tooltip) +static void gitmodules_link(const char *path, const char *rev, char **module, + char **commit, const char **tooltip) { const struct object_id *treeish = page_treeish(); const struct submodule *sub; @@ -1256,8 +1209,7 @@ static void gitmodules_link(const char *path, const char *rev, return; } - if (skip_prefix(url, "http://", &rest) || - skip_prefix(url, "https://", &rest)) { + if (skip_prefix(url, "http://", &rest) || skip_prefix(url, "https://", &rest)) { *module = xstrdup(url); forge = forge_for_host(rest, strcspn(rest, "/")); if (forge) { @@ -1284,8 +1236,7 @@ static void gitmodules_link(const char *path, const char *rev, rest = colon + 1; while (*rest == '/') rest++; - strbuf_addf(&sb, "https://%.*s/%s", - (int)(colon - host), host, rest); + strbuf_addf(&sb, "https://%.*s/%s", (int)(colon - host), host, rest); while (sb.len && sb.buf[sb.len - 1] == '/') strbuf_setlen(&sb, sb.len - 1); if (!forge->keep_dot_git) @@ -1322,8 +1273,7 @@ void cgit_submodule_link(const char *class, char *path, const char *rev) } } - if (!item && !ctx.repo->module_link && - ctx.repo->enable_gitmodules_links) + if (!item && !ctx.repo->module_link && ctx.repo->enable_gitmodules_links) gitmodules_link(path, rev, &module, &commit, &tooltip); // The row shows the entry's own name, like every other row, while @@ -1398,39 +1348,32 @@ void cgit_print_age(time_t t, int tz, time_t max_relative) if (secs < 0) secs = 0; - if (!ctx.cfg.enable_relative_dates || - (secs > max_relative && max_relative >= 0)) { + if (!ctx.cfg.enable_relative_dates || (secs > max_relative && max_relative >= 0)) { print_abs_date(t, tz); return; } if (secs < SECONDS_PER_HOUR * 2) { - print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_MINUTE, - "age-mins", "min."); + print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_MINUTE, "age-mins", "min."); return; } if (secs < SECONDS_PER_DAY * 2) { - print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_HOUR, - "age-hours", "hours"); + print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_HOUR, "age-hours", "hours"); return; } if (secs < SECONDS_PER_WEEK * 2) { - print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_DAY, - "age-days", "days"); + print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_DAY, "age-days", "days"); return; } if (secs < SECONDS_PER_MONTH * 2) { - print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_WEEK, - "age-weeks", "weeks"); + print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_WEEK, "age-weeks", "weeks"); return; } if (secs < SECONDS_PER_YEAR * 2) { - print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_MONTH, - "age-months", "months"); + print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_MONTH, "age-months", "months"); return; } - print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_YEAR, - "age-years", "years"); + print_rel_date(t, tz, secs * 1.0 / SECONDS_PER_YEAR, "age-years", "years"); } void cgit_print_http_headers(void) @@ -1445,8 +1388,7 @@ void cgit_print_http_headers(void) else html("Status: 200 OK\n"); if (ctx.page.mimetype && ctx.page.charset) - htmlf("Content-Type: %s; charset=%s\n", ctx.page.mimetype, - ctx.page.charset); + htmlf("Content-Type: %s; charset=%s\n", ctx.page.mimetype, ctx.page.charset); else if (ctx.page.mimetype) htmlf("Content-Type: %s\n", ctx.page.mimetype); if (ctx.page.size) @@ -1475,8 +1417,7 @@ void cgit_print_http_headers(void) void cgit_redirect(const char *url, bool permanent) { - htmlf("Status: %d %s\n", permanent ? 301 : 302, - permanent ? "Moved Permanently" : "Found"); + htmlf("Status: %d %s\n", permanent ? 301 : 302, permanent ? "Moved Permanently" : "Found"); html("Location: "); html_url_path(url); html("\n\n"); @@ -1499,10 +1440,8 @@ void cgit_print_docstart(void) html("<meta charset='UTF-8'>\n"); html("<meta name='viewport' content='width=device-width, initial-scale=1'>\n"); html("<meta name='color-scheme' content='light dark'>\n"); - html("<meta name='theme-color' media='(prefers-color-scheme: light)'" - " content='#ffffff'>\n"); - html("<meta name='theme-color' media='(prefers-color-scheme: dark)'" - " content='#1b1b1b'>\n"); + html("<meta name='theme-color' media='(prefers-color-scheme: light)' content='#ffffff'>\n"); + html("<meta name='theme-color' media='(prefers-color-scheme: dark)' content='#1b1b1b'>\n"); html("<title>"); // An error page reached before a title was chosen still has to name // itself, since an empty title element is not valid. @@ -1514,8 +1453,7 @@ void cgit_print_docstart(void) html("</title>\n"); // The placeholder a scanned repository carries instead of a description // is left out, since it describes nothing. - if (ctx.repo && ctx.repo->desc && *ctx.repo->desc && - ctx.repo->desc != cgit_default_repo_desc) { + if (ctx.repo && ctx.repo->desc && *ctx.repo->desc && ctx.repo->desc != cgit_default_repo_desc) { html("<meta name='description' content='"); html_attr(ctx.repo->desc); html("'>\n"); @@ -1554,8 +1492,7 @@ void cgit_print_docstart(void) html("<link rel='alternate' title='Atom feed' href='"); html(cgit_httpscheme()); html_attr(host); - fileurl = cgit_fileurl(ctx.repo->url, "atom", ctx.qry.vpath, - sb.buf); + fileurl = cgit_fileurl(ctx.repo->url, "atom", ctx.qry.vpath, sb.buf); html_attr(fileurl); html("' type='application/atom+xml'>\n"); strbuf_release(&sb); @@ -1603,8 +1540,7 @@ void cgit_print_error_page(int code, const char *msg, const char *fmt, ...) va_end(ap); } -void cgit_vprint_error_page(int code, const char *msg, const char *fmt, - va_list ap) +void cgit_vprint_error_page(int code, const char *msg, const char *fmt, va_list ap) { // An error page describes a condition that may not outlast the slot // holding it. A request naming a commit not yet pushed would cache its @@ -1688,8 +1624,7 @@ void cgit_print_clone_row(const char *url, int colspan) free(fallback); } -void cgit_add_hidden_formfields(int incl_head, int incl_search, - const char *page) +void cgit_add_hidden_formfields(int incl_head, int incl_search, const char *page) { if (!ctx.cfg.virtual_root) { struct strbuf url = STRBUF_INIT; @@ -1701,8 +1636,7 @@ void cgit_add_hidden_formfields(int incl_head, int incl_search, strbuf_release(&url); } - if (incl_head && ctx.qry.head && ctx.repo->defbranch && - strcmp(ctx.qry.head, ctx.repo->defbranch)) + if (incl_head && ctx.qry.head && ctx.repo->defbranch && strcmp(ctx.qry.head, ctx.repo->defbranch)) html_hidden("h", ctx.qry.head); if (ctx.qry.oid) @@ -1734,8 +1668,7 @@ void cgit_print_pageheader(void) // Every other tab needs a commit to render and the search form // has nothing to search, so an empty repo gets summary alone. html("<ul>\n<li>"); - cgit_summary_link("summary", "Repository summary", - tab_class("summary"), ctx.qry.head); + cgit_summary_link("summary", "Repository summary", tab_class("summary"), ctx.qry.head); html("</li>\n</ul>\n"); } else if (ctx.env.authenticated && ctx.repo) { print_repo_tabs(); @@ -1749,8 +1682,7 @@ void cgit_print_pageheader(void) pinned = ctx.env.authenticated && ctx.repo ? pinned_oid() : NULL; // The commit and diff pages name the commit they show as their own // content, so the rev crumb would only repeat them. - if (pinned && ctx.qry.page && (!strcmp(ctx.qry.page, "commit") || - !strcmp(ctx.qry.page, "diff"))) + if (pinned && ctx.qry.page && (!strcmp(ctx.qry.page, "commit") || !strcmp(ctx.qry.page, "diff"))) pinned = NULL; if ((ctx.env.authenticated && ctx.repo && ctx.qry.vpath) || pinned) { html("<nav class='path' aria-label='"); @@ -1762,12 +1694,10 @@ void cgit_print_pageheader(void) // between them, so the run stays inline in a span. html("<span>path: "); print_path_crumbs(ctx.qry.vpath); - if (ctx.repo->enable_follow_links && - !strcmp(ctx.qry.page, "log")) { + if (ctx.repo->enable_follow_links && !strcmp(ctx.qry.page, "log")) { html(" ("); ctx.qry.follow = !ctx.qry.follow; - self_link(ctx.qry.follow ? "follow" : "unfollow", - NULL, NULL); + self_link(ctx.qry.follow ? "follow" : "unfollow", NULL, NULL); ctx.qry.follow = !ctx.qry.follow; html(")"); } @@ -1779,8 +1709,7 @@ void cgit_print_pageheader(void) html("<span class='rev'>rev: "); cgit_commit_link(cgit_fmt("%.*s", SHORT_HASH_LEN, hex), - NULL, NULL, ctx.qry.head, hex, - ctx.qry.vpath); + NULL, NULL, ctx.qry.head, hex, ctx.qry.vpath); html(" ("); // self_link reads the pin out of ctx.qry, so lifting // it is what makes the link land back on the tip of @@ -1812,8 +1741,7 @@ void cgit_print_filemode(unsigned short mode) html_fileperm(mode); } -static void compose_snapshot_prefix(struct strbuf *filename, const char *base, - const char *ref) +static void compose_snapshot_prefix(struct strbuf *filename, const char *base, const char *ref) { struct object_id oid; @@ -1831,8 +1759,7 @@ static void compose_snapshot_prefix(struct strbuf *filename, const char *base, strbuf_addf(filename, "%s-%s", base, ref); } -void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref, - const char *separator) +void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref, const char *separator) { const struct cgit_snapshot_format *f; struct strbuf filename = STRBUF_INIT; @@ -1851,25 +1778,20 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref, continue; strbuf_setlen(&filename, prefixlen); strbuf_addstr(&filename, f->suffix); - snapshot_link(filename.buf, NULL, NULL, NULL, NULL, - filename.buf); + snapshot_link(filename.buf, NULL, NULL, NULL, NULL, filename.buf); if (cgit_snapshot_get_sig(ref, f)) { strbuf_addstr(&filename, ".asc"); html(" ("); - snapshot_link("sig", NULL, NULL, NULL, NULL, - filename.buf); + snapshot_link("sig", NULL, NULL, NULL, NULL, filename.buf); html(")"); - } else if (starts_with(f->suffix, ".tar") && - cgit_snapshot_get_sig(ref, &cgit_snapshot_formats[0])) { + } else if (starts_with(f->suffix, ".tar") && cgit_snapshot_get_sig(ref, &cgit_snapshot_formats[0])) { // A compressed tarball offers the signature made for // the plain tar it expands to, which is the first // format in the table. - strbuf_setlen(&filename, - filename.len - strlen(f->suffix)); + strbuf_setlen(&filename, filename.len - strlen(f->suffix)); strbuf_addstr(&filename, ".tar.asc"); html(" ("); - snapshot_link("sig", NULL, NULL, NULL, NULL, - filename.buf); + snapshot_link("sig", NULL, NULL, NULL, NULL, filename.buf); html(")"); } html(separator); |
