diff options
author | Lars Hjemli | 2007-12-03 01:49:38 +0100 |
---|---|---|
committer | Lars Hjemli | 2007-12-03 01:49:38 +0100 |
commit | afcdd083dab81afef744e261d81a452698188c30 (patch) | |
tree | 0ca43a6b87567af70c802a25124702c7c7891c9a | |
parent | Merge branch 'stable' (diff) | |
download | cgit-afcdd083dab81afef744e261d81a452698188c30.tar.gz cgit-afcdd083dab81afef744e261d81a452698188c30.zip |
Add support for automatic and custom clone urls
This adds support for two new parameters to cgitrc: clone-prefix and repo.clone-url. If clone-prefix is specified, all repos will get a clone url printed in the sidebar; the url is generated by clone-prefix + repo.url. Additionally, each repo can specify repo.clone-url which will override any such auto-generated url. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | cgitrc | 7 | ||||
-rw-r--r-- | shared.c | 5 | ||||
-rw-r--r-- | ui-shared.c | 17 |
4 files changed, 31 insertions, 0 deletions
diff --git a/cgit.h b/cgit.h index ab0efeb..f223dbc 100644 --- a/cgit.h +++ b/cgit.h | |||
@@ -75,6 +75,7 @@ struct repoinfo { | |||
75 | char *group; | 75 | char *group; |
76 | char *module_link; | 76 | char *module_link; |
77 | char *readme; | 77 | char *readme; |
78 | char *clone_url; | ||
78 | int snapshots; | 79 | int snapshots; |
79 | int enable_log_filecount; | 80 | int enable_log_filecount; |
80 | int enable_log_linecount; | 81 | int enable_log_linecount; |
@@ -140,6 +141,7 @@ extern char *cgit_script_name; | |||
140 | extern char *cgit_cache_root; | 141 | extern char *cgit_cache_root; |
141 | extern char *cgit_repo_group; | 142 | extern char *cgit_repo_group; |
142 | extern char *cgit_robots; | 143 | extern char *cgit_robots; |
144 | extern char *cgit_clone_prefix; | ||
143 | 145 | ||
144 | extern int cgit_nocache; | 146 | extern int cgit_nocache; |
145 | extern int cgit_snapshots; | 147 | extern int cgit_snapshots; |
diff --git a/cgitrc b/cgitrc index 8c616e0..ce0c01b 100644 --- a/cgitrc +++ b/cgitrc | |||
@@ -116,6 +116,11 @@ | |||
116 | #module-link=./?repo=%s&page=commit&id=%s | 116 | #module-link=./?repo=%s&page=commit&id=%s |
117 | 117 | ||
118 | 118 | ||
119 | ## Shared prefix which, when combined with repo url, becomes the url used | ||
120 | ## to clone the repo | ||
121 | #clone-prefix= | ||
122 | |||
123 | |||
119 | ## Number of chars shown of repo description (in repolist view) | 124 | ## Number of chars shown of repo description (in repolist view) |
120 | #max-repodesc-length=60 | 125 | #max-repodesc-length=60 |
121 | 126 | ||
@@ -167,12 +172,14 @@ | |||
167 | #repo.enable-log-linecount=0 ## override the default linecount setting | 172 | #repo.enable-log-linecount=0 ## override the default linecount setting |
168 | #repo.module-link=/git/%s/commit/?id=%s ## override the standard module-link | 173 | #repo.module-link=/git/%s/commit/?id=%s ## override the standard module-link |
169 | #repo.readme=info/web/readme ## specify a file to include on summary page | 174 | #repo.readme=info/web/readme ## specify a file to include on summary page |
175 | #repo.clone-url=git://hjemli.net/pub/git/cgit | ||
170 | 176 | ||
171 | ## Additional repositories grouped under "mirrors" | 177 | ## Additional repositories grouped under "mirrors" |
172 | #repo.group=mirrors | 178 | #repo.group=mirrors |
173 | 179 | ||
174 | #repo.url=git | 180 | #repo.url=git |
175 | #repo.path=/pub/git/git | 181 | #repo.path=/pub/git/git |
182 | #repo.clone-url=git://hjemli.net/pub/git/git | ||
176 | # | 183 | # |
177 | #repo.url=linux | 184 | #repo.url=linux |
178 | #repo.path=/pub/git/linux | 185 | #repo.path=/pub/git/linux |
diff --git a/shared.c b/shared.c index fd8b1e3..2c309f5 100644 --- a/shared.c +++ b/shared.c | |||
@@ -27,6 +27,7 @@ char *cgit_script_name = CGIT_SCRIPT_NAME; | |||
27 | char *cgit_cache_root = CGIT_CACHE_ROOT; | 27 | char *cgit_cache_root = CGIT_CACHE_ROOT; |
28 | char *cgit_repo_group = NULL; | 28 | char *cgit_repo_group = NULL; |
29 | char *cgit_robots = "index, nofollow"; | 29 | char *cgit_robots = "index, nofollow"; |
30 | char *cgit_clone_prefix = NULL; | ||
30 | 31 | ||
31 | int cgit_nocache = 0; | 32 | int cgit_nocache = 0; |
32 | int cgit_snapshots = 0; | 33 | int cgit_snapshots = 0; |
@@ -200,6 +201,8 @@ void cgit_global_config_cb(const char *name, const char *value) | |||
200 | cgit_renamelimit = atoi(value); | 201 | cgit_renamelimit = atoi(value); |
201 | else if (!strcmp(name, "robots")) | 202 | else if (!strcmp(name, "robots")) |
202 | cgit_robots = xstrdup(value); | 203 | cgit_robots = xstrdup(value); |
204 | else if (!strcmp(name, "clone-prefix")) | ||
205 | cgit_clone_prefix = xstrdup(value); | ||
203 | else if (!strcmp(name, "repo.group")) | 206 | else if (!strcmp(name, "repo.group")) |
204 | cgit_repo_group = xstrdup(value); | 207 | cgit_repo_group = xstrdup(value); |
205 | else if (!strcmp(name, "repo.url")) | 208 | else if (!strcmp(name, "repo.url")) |
@@ -208,6 +211,8 @@ void cgit_global_config_cb(const char *name, const char *value) | |||
208 | cgit_repo->name = xstrdup(value); | 211 | cgit_repo->name = xstrdup(value); |
209 | else if (cgit_repo && !strcmp(name, "repo.path")) | 212 | else if (cgit_repo && !strcmp(name, "repo.path")) |
210 | cgit_repo->path = trim_end(value, '/'); | 213 | cgit_repo->path = trim_end(value, '/'); |
214 | else if (cgit_repo && !strcmp(name, "repo.clone-url")) | ||
215 | cgit_repo->clone_url = xstrdup(value); | ||
211 | else if (cgit_repo && !strcmp(name, "repo.desc")) | 216 | else if (cgit_repo && !strcmp(name, "repo.desc")) |
212 | cgit_repo->desc = xstrdup(value); | 217 | cgit_repo->desc = xstrdup(value); |
213 | else if (cgit_repo && !strcmp(name, "repo.owner")) | 218 | else if (cgit_repo && !strcmp(name, "repo.owner")) |
diff --git a/ui-shared.c b/ui-shared.c index 3e13c86..ece041c 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -460,6 +460,7 @@ void cgit_print_pageheader(char *title, int show_search) | |||
460 | { | 460 | { |
461 | static const char *default_info = "This is cgit, a fast webinterface for git repositories"; | 461 | static const char *default_info = "This is cgit, a fast webinterface for git repositories"; |
462 | int header = 0; | 462 | int header = 0; |
463 | char *url; | ||
463 | 464 | ||
464 | html("<table id='layout' summary=''>\n"); | 465 | html("<table id='layout' summary=''>\n"); |
465 | html("<tr><td id='sidebar'>\n"); | 466 | html("<tr><td id='sidebar'>\n"); |
@@ -492,6 +493,22 @@ void cgit_print_pageheader(char *title, int show_search) | |||
492 | 493 | ||
493 | for_each_ref(print_archive_ref, &header); | 494 | for_each_ref(print_archive_ref, &header); |
494 | 495 | ||
496 | if (cgit_repo->clone_url || cgit_clone_prefix) { | ||
497 | html("<h1>clone</h1>\n"); | ||
498 | if (cgit_repo->clone_url) | ||
499 | url = cgit_repo->clone_url; | ||
500 | else | ||
501 | url = fmt("%s%s", cgit_clone_prefix, | ||
502 | cgit_repo->url); | ||
503 | html("<a class='menu' href='"); | ||
504 | html_attr(url); | ||
505 | html("' title='"); | ||
506 | html_attr(url); | ||
507 | html("'>\n"); | ||
508 | html_txt(strrpart(url, 20)); | ||
509 | html("</a>\n"); | ||
510 | } | ||
511 | |||
495 | html("<h1>branch</h1>\n"); | 512 | html("<h1>branch</h1>\n"); |
496 | html("<form method='get' action=''>\n"); | 513 | html("<form method='get' action=''>\n"); |
497 | add_hidden_formfields(0, 1, cgit_query_page); | 514 | add_hidden_formfields(0, 1, cgit_query_page); |