slackbuilds

My Slackbuilds
git clone git://git.server.ky/slackcoder/slackbuilds
Log | Files | Refs | README

0001-UI-Add-support-for-project-sponsor-page.patch (3487B)


      1 From a6cb50a01bcd2b45c44336cc85f2a3d5d602a856 Mon Sep 17 00:00:00 2001
      2 From: Slack Coder <slackcoder@server.ky>
      3 Date: Tue, 29 Oct 2024 11:43:48 -0500
      4 Subject: [PATCH] UI: Add support for project sponsor page
      5 
      6 Add an extra configuration parameter repo.sponsor-page to link to a project's
      7 sponsorship page.
      8 ---
      9  cgit.c       | 4 ++++
     10  cgit.h       | 1 +
     11  cgitrc.5.txt | 3 +++
     12  scan-tree.c  | 2 ++
     13  shared.c     | 1 +
     14  ui-shared.c  | 5 +++++
     15  6 files changed, 16 insertions(+)
     16 
     17 diff --git a/cgit.c b/cgit.c
     18 index c4320f0..e19b9c1 100644
     19 --- a/cgit.c
     20 +++ b/cgit.c
     21 @@ -54,6 +54,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va
     22  		repo->owner = xstrdup(value);
     23  	else if (!strcmp(name, "homepage"))
     24  		repo->homepage = xstrdup(value);
     25 +	else if (!strcmp(name, "sponsor-page"))
     26 +		repo->sponsor_page = xstrdup(value);
     27  	else if (!strcmp(name, "defbranch"))
     28  		repo->defbranch = xstrdup(value);
     29  	else if (!strcmp(name, "extra-head-content"))
     30 @@ -814,6 +816,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
     31  		fprintf(f, "repo.section=%s\n", repo->section);
     32  	if (repo->homepage)
     33  		fprintf(f, "repo.homepage=%s\n", repo->homepage);
     34 +	if (repo->sponsor_page)
     35 +		fprintf(f, "repo.sponsor-page=%s\n", repo->sponsor_page);
     36  	if (repo->clone_url)
     37  		fprintf(f, "repo.clone-url=%s\n", repo->clone_url);
     38  	fprintf(f, "repo.enable-blame=%d\n",
     39 diff --git a/cgit.h b/cgit.h
     40 index 7ec46b4..0136ea6 100644
     41 --- a/cgit.h
     42 +++ b/cgit.h
     43 @@ -85,6 +85,7 @@ struct cgit_repo {
     44  	char *extra_head_content;
     45  	char *owner;
     46  	char *homepage;
     47 +	char *sponsor_page;
     48  	char *defbranch;
     49  	char *module_link;
     50  	struct string_list readme;
     51 diff --git a/cgitrc.5.txt b/cgitrc.5.txt
     52 index 33a6a8c..d1429c5 100644
     53 --- a/cgitrc.5.txt
     54 +++ b/cgitrc.5.txt
     55 @@ -528,6 +528,9 @@ repo.hide::
     56  repo.homepage::
     57  	The value to show as repository homepage. Default value: none.
     58  
     59 +repo.sponsor-page::
     60 +	The value to show as repository sponsor page. Default value: none.
     61 +
     62  repo.ignore::
     63  	Flag which, when set to "1", ignores the repository. The repository
     64  	is not shown in the index and cannot be accessed by providing a direct
     65 diff --git a/scan-tree.c b/scan-tree.c
     66 index 6a2f65a..bdd3e70 100644
     67 --- a/scan-tree.c
     68 +++ b/scan-tree.c
     69 @@ -66,6 +66,8 @@ static int gitconfig_config(const char *key, const char *value, void *cb)
     70  		config_fn(repo, "section", value);
     71  	else if (!strcmp(key, "gitweb.homepage"))
     72  		config_fn(repo, "homepage", value);
     73 +	else if (!strcmp(key, "gitweb.sponsor-page"))
     74 +		config_fn(repo, "sponsor-page", value);
     75  	else if (skip_prefix(key, "cgit.", &name))
     76  		config_fn(repo, name, value);
     77  
     78 diff --git a/shared.c b/shared.c
     79 index 8115469..099a3b9 100644
     80 --- a/shared.c
     81 +++ b/shared.c
     82 @@ -56,6 +56,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
     83  	ret->extra_head_content = NULL;
     84  	ret->owner = NULL;
     85  	ret->homepage = NULL;
     86 +	ret->sponsor_page = NULL;
     87  	ret->section = ctx.cfg.section;
     88  	ret->snapshots = ctx.cfg.snapshots;
     89  	ret->enable_blame = ctx.cfg.enable_blame;
     90 diff --git a/ui-shared.c b/ui-shared.c
     91 index d2358f2..4d2d94e 100644
     92 --- a/ui-shared.c
     93 +++ b/ui-shared.c
     94 @@ -1060,6 +1060,11 @@ void cgit_print_pageheader(void)
     95  			html_attr(ctx.repo->homepage);
     96  			html("'>homepage</a>");
     97  		}
     98 +		if (ctx.repo->sponsor_page) {
     99 +			html("<a href='");
    100 +			html_attr(ctx.repo->sponsor_page);
    101 +			html("'>sponsor</a>");
    102 +		}
    103  		html("</td><td class='form'>");
    104  		html("<form class='right' method='get' action='");
    105  		if (ctx.cfg.virtual_root) {
    106 -- 
    107 2.46.2
    108