Author: Jason A. Donenfeld <Jason@zx2c4.com>
ui-shared: add homepage to tabs Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
cgit.c | 4 ++++ cgit.css | 5 +++++ cgit.h | 1 + cgitrc.5.txt | 13 ++++++++----- scan-tree.c | 2 ++ shared.c | 1 + ui-shared.c | 5 +++++
diff --git a/cgit.c b/cgit.c index 7f83a2dbb0985c614e129a41f7a5975feee9686d..fc482bee0c83d34a38159d94fe0fa8bc6a4e42f1 100644 --- a/cgit.c +++ b/cgit.c @@ -41,6 +41,8 @@ else if (!strcmp(name, "desc")) repo->desc = xstrdup(value); else if (!strcmp(name, "owner")) repo->owner = xstrdup(value); + else if (!strcmp(name, "homepage")) + repo->homepage = xstrdup(value); else if (!strcmp(name, "defbranch")) repo->defbranch = xstrdup(value); else if (!strcmp(name, "snapshots")) @@ -793,6 +795,8 @@ if (repo->module_link) fprintf(f, "repo.module-link=%s\n", repo->module_link); if (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) fprintf(f, "repo.clone-url=%s\n", repo->clone_url); fprintf(f, "repo.enable-commit-graph=%d\n", diff --git a/cgit.css b/cgit.css index 82c755cfeabe6d3bad303d4e0e1d540ad19956f1..50f65876e1dc750256b69e0611b8b2581ed18fe8 100644 --- a/cgit.css +++ b/cgit.css @@ -85,6 +85,11 @@ color: #000; 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 { text-align: right; } diff --git a/cgit.h b/cgit.h index d10c79972331db7f7fe0b9c9a283474ef75c9476..325432bae774e06f0e3490cb317f01f4debedb4b 100644 --- a/cgit.h +++ b/cgit.h @@ -81,6 +81,7 @@ char *name; char *path; char *desc; char *owner; + char *homepage; char *defbranch; char *module_link; struct string_list readme; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 47850a8003df969c38c78df067e7610dc37bb1ea..94901bd9f9276b46b8ba5a8783a9e257e59a4742 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -205,11 +205,11 @@ enable-git-config:: 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 "scan-path", and must be defined prior, to augment repo-specific - settings. The keys gitweb.owner, gitweb.category, and gitweb.description - will map to the cgit keys repo.owner, repo.section, and repo.desc, - respectively. All git config keys that begin with "cgit." will be mapped - to the corresponding "repo." key in cgit. Default value: "0". See also: - scan-path, section-from-path. + settings. The keys gitweb.owner, gitweb.category, gitweb.description, + and gitweb.homepage will map to the cgit keys repo.owner, repo.section, + repo.desc, and repo.homepage respectively. All git config keys that begin + with "cgit." will be mapped to the corresponding "repo." key in cgit. + Default value: "0". See also: scan-path, section-from-path. favicon:: Url used as link to a shortcut icon for cgit. It is suggested to use @@ -495,6 +495,9 @@ "master" if there is no suitable HEAD. repo.desc:: 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:: Override the default email-filter. Default value: none. See also: diff --git a/scan-tree.c b/scan-tree.c index b5a10ffa5cf491c6ec811413740db20ad0dfb583..2e87999b11b8f10fdbeab0c9b2b20e22b7b46184 100644 --- a/scan-tree.c +++ b/scan-tree.c @@ -61,6 +61,8 @@ else if (!strcmp(key, "gitweb.description")) config_fn(repo, "desc", value); else if (!strcmp(key, "gitweb.category")) config_fn(repo, "section", value); + else if (!strcmp(key, "gitweb.homepage")) + config_fn(repo, "homepage", value); else if (starts_with(key, "cgit.")) config_fn(repo, key + 5, value); diff --git a/shared.c b/shared.c index a078a27b1bcc2accf5982ae8d1af005f728bac4c..a63633b295578cc9302b9842722a0184e4e02792 100644 --- a/shared.c +++ b/shared.c @@ -54,6 +54,7 @@ ret->name = ret->url; ret->path = NULL; ret->desc = cgit_default_repo_desc; ret->owner = NULL; + ret->homepage = NULL; ret->section = ctx.cfg.section; ret->snapshots = ctx.cfg.snapshots; ret->enable_commit_graph = ctx.cfg.enable_commit_graph; diff --git a/ui-shared.c b/ui-shared.c index 03dcc0892626962300bb752b4a91083e23ce5041..2c91e75b0727f26f670e80546802d69b3012fc07 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -997,6 +997,11 @@ ctx.qry.sha1, ctx.qry.sha2, ctx.qry.vpath); if (ctx.repo->max_stats) cgit_stats_link("stats", NULL, hc("stats"), 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("<form class='right' method='get' action='"); if (ctx.cfg.virtual_root) {