ui-shared: add homepage to tabs

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2016-02-22 16:04:15 +01:00
parent 75298209bf
commit 5f2664f13c
7 changed files with 26 additions and 5 deletions

4
cgit.c
View File

@ -41,6 +41,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va
repo->desc = xstrdup(value); repo->desc = xstrdup(value);
else if (!strcmp(name, "owner")) else if (!strcmp(name, "owner"))
repo->owner = xstrdup(value); repo->owner = xstrdup(value);
else if (!strcmp(name, "homepage"))
repo->homepage = xstrdup(value);
else if (!strcmp(name, "defbranch")) else if (!strcmp(name, "defbranch"))
repo->defbranch = xstrdup(value); repo->defbranch = xstrdup(value);
else if (!strcmp(name, "snapshots")) else if (!strcmp(name, "snapshots"))
@ -793,6 +795,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
fprintf(f, "repo.module-link=%s\n", repo->module_link); fprintf(f, "repo.module-link=%s\n", repo->module_link);
if (repo->section) if (repo->section)
fprintf(f, "repo.section=%s\n", repo->section); fprintf(f, "repo.section=%s\n", repo->section);
if (repo->homepage)
fprintf(f, "repo.homepage=%s\n", repo->homepage);
if (repo->clone_url) if (repo->clone_url)
fprintf(f, "repo.clone-url=%s\n", repo->clone_url); fprintf(f, "repo.clone-url=%s\n", repo->clone_url);
fprintf(f, "repo.enable-commit-graph=%d\n", fprintf(f, "repo.enable-commit-graph=%d\n",

View File

@ -85,6 +85,11 @@ div#cgit table.tabs td a.active {
background-color: #ccc; background-color: #ccc;
} }
div#cgit table.tabs a[href^="http://"]:after, div#cgit table.tabs a[href^="https://"]:after {
content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAAnNCSVQICFXsRgQAAAAJcEhZcwAAABQAAAAUAVyMgXwAAAAZdEVYdFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAAAeklEQVQI12NoYCu3q3ABwXL98vTy/0D4jaF8XXldRRoYejAwlu8BCTOU72SAg4q08j/le0GC22BC5anlfyrSGBiBGCZYllz+pywLJg8WLOMtf1GeCjRgI5IgSBhMboUIHq40r1CCQrfyDRAV6uXdZTMhsKKlVIIBFwAAVeg4KFYK95cAAAAASUVORK5CYII=);
margin: 0 0 0 5px;
}
div#cgit table.tabs td.form { div#cgit table.tabs td.form {
text-align: right; text-align: right;
} }

1
cgit.h
View File

@ -81,6 +81,7 @@ struct cgit_repo {
char *path; char *path;
char *desc; char *desc;
char *owner; char *owner;
char *homepage;
char *defbranch; char *defbranch;
char *module_link; char *module_link;
struct string_list readme; struct string_list readme;

View File

@ -205,11 +205,11 @@ enable-git-config::
Flag which, when set to "1", will allow cgit to use git config to set Flag which, when set to "1", will allow cgit to use git config to set
any repo specific settings. This option is used in conjunction with any repo specific settings. This option is used in conjunction with
"scan-path", and must be defined prior, to augment repo-specific "scan-path", and must be defined prior, to augment repo-specific
settings. The keys gitweb.owner, gitweb.category, and gitweb.description settings. The keys gitweb.owner, gitweb.category, gitweb.description,
will map to the cgit keys repo.owner, repo.section, and repo.desc, and gitweb.homepage will map to the cgit keys repo.owner, repo.section,
respectively. All git config keys that begin with "cgit." will be mapped repo.desc, and repo.homepage respectively. All git config keys that begin
to the corresponding "repo." key in cgit. Default value: "0". See also: with "cgit." will be mapped to the corresponding "repo." key in cgit.
scan-path, section-from-path. Default value: "0". See also: scan-path, section-from-path.
favicon:: favicon::
Url used as link to a shortcut icon for cgit. It is suggested to use Url used as link to a shortcut icon for cgit. It is suggested to use
@ -496,6 +496,9 @@ repo.defbranch::
repo.desc:: repo.desc::
The value to show as repository description. Default value: none. The value to show as repository description. Default value: none.
repo.homepage::
The value to show as repository homepage. Default value: none.
repo.email-filter:: repo.email-filter::
Override the default email-filter. Default value: none. See also: Override the default email-filter. Default value: none. See also:
"enable-filter-overrides". See also: "FILTER API". "enable-filter-overrides". See also: "FILTER API".

View File

@ -61,6 +61,8 @@ static int gitconfig_config(const char *key, const char *value, void *cb)
config_fn(repo, "desc", value); config_fn(repo, "desc", value);
else if (!strcmp(key, "gitweb.category")) else if (!strcmp(key, "gitweb.category"))
config_fn(repo, "section", value); config_fn(repo, "section", value);
else if (!strcmp(key, "gitweb.homepage"))
config_fn(repo, "homepage", value);
else if (starts_with(key, "cgit.")) else if (starts_with(key, "cgit."))
config_fn(repo, key + 5, value); config_fn(repo, key + 5, value);

View File

@ -54,6 +54,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
ret->path = NULL; ret->path = NULL;
ret->desc = cgit_default_repo_desc; ret->desc = cgit_default_repo_desc;
ret->owner = NULL; ret->owner = NULL;
ret->homepage = NULL;
ret->section = ctx.cfg.section; ret->section = ctx.cfg.section;
ret->snapshots = ctx.cfg.snapshots; ret->snapshots = ctx.cfg.snapshots;
ret->enable_commit_graph = ctx.cfg.enable_commit_graph; ret->enable_commit_graph = ctx.cfg.enable_commit_graph;

View File

@ -997,6 +997,11 @@ void cgit_print_pageheader(void)
if (ctx.repo->max_stats) if (ctx.repo->max_stats)
cgit_stats_link("stats", NULL, hc("stats"), cgit_stats_link("stats", NULL, hc("stats"),
ctx.qry.head, ctx.qry.vpath); ctx.qry.head, ctx.qry.vpath);
if (ctx.repo->homepage) {
html("<a href='");
html_attr(ctx.repo->homepage);
html("' target='_blank'>homepage</a>");
}
html("</td><td class='form'>"); html("</td><td class='form'>");
html("<form class='right' method='get' action='"); html("<form class='right' method='get' action='");
if (ctx.cfg.virtual_root) { if (ctx.cfg.virtual_root) {