about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--cgit.c10
-rw-r--r--cgit.h3
-rw-r--r--cgitrc.5.txt11
-rw-r--r--cmd.c6
-rw-r--r--shared.c1
-rw-r--r--ui-shared.c24
-rw-r--r--ui-shared.h2
7 files changed, 51 insertions, 6 deletions
diff --git a/cgit.c b/cgit.c index dd28a79..0c5ccab 100644 --- a/cgit.c +++ b/cgit.c
@@ -56,6 +56,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va
56 repo->homepage = xstrdup(value); 56 repo->homepage = xstrdup(value);
57 else if (!strcmp(name, "defbranch")) 57 else if (!strcmp(name, "defbranch"))
58 repo->defbranch = xstrdup(value); 58 repo->defbranch = xstrdup(value);
59 else if (!strcmp(name, "default-tab"))
60 repo->default_tab = xstrdup(value);
59 else if (!strcmp(name, "extra-head-content")) 61 else if (!strcmp(name, "extra-head-content"))
60 repo->extra_head_content = xstrdup(value); 62 repo->extra_head_content = xstrdup(value);
61 else if (!strcmp(name, "snapshots")) 63 else if (!strcmp(name, "snapshots"))
@@ -285,6 +287,10 @@ static void config_cb(const char *name, const char *value)
285 ctx.cfg.clone_url = xstrdup(value); 287 ctx.cfg.clone_url = xstrdup(value);
286 else if (!strcmp(name, "local-time")) 288 else if (!strcmp(name, "local-time"))
287 ctx.cfg.local_time = atoi(value); 289 ctx.cfg.local_time = atoi(value);
290 else if (!strcmp(name, "default-tab"))
291 ctx.cfg.default_tab = xstrdup(value);
292 else if (!strcmp(name, "root-default-tab"))
293 ctx.cfg.root_default_tab = xstrdup(value);
288 else if (!strcmp(name, "commit-sort")) { 294 else if (!strcmp(name, "commit-sort")) {
289 if (!strcmp(value, "date")) 295 if (!strcmp(value, "date"))
290 ctx.cfg.commit_sort = 1; 296 ctx.cfg.commit_sort = 1;
@@ -373,6 +379,8 @@ static void prepare_context(void)
373 ctx.cfg.cache_scanrc_ttl = 15; 379 ctx.cfg.cache_scanrc_ttl = 15;
374 ctx.cfg.cache_dynamic_ttl = 5; 380 ctx.cfg.cache_dynamic_ttl = 5;
375 ctx.cfg.cache_static_ttl = -1; 381 ctx.cfg.cache_static_ttl = -1;
382 ctx.cfg.default_tab = "summary";
383 ctx.cfg.root_default_tab = "repolist";
376 ctx.cfg.case_sensitive_sort = 1; 384 ctx.cfg.case_sensitive_sort = 1;
377 ctx.cfg.branch_sort = 0; 385 ctx.cfg.branch_sort = 0;
378 ctx.cfg.commit_sort = 0; 386 ctx.cfg.commit_sort = 0;
@@ -818,6 +826,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
818 fprintf(f, "repo.homepage=%s\n", repo->homepage); 826 fprintf(f, "repo.homepage=%s\n", repo->homepage);
819 if (repo->clone_url) 827 if (repo->clone_url)
820 fprintf(f, "repo.clone-url=%s\n", repo->clone_url); 828 fprintf(f, "repo.clone-url=%s\n", repo->clone_url);
829 if (repo->default_tab)
830 fprintf(f, "repo.default-tab=%s\n", repo->default_tab);
821 fprintf(f, "repo.enable-blame=%d\n", 831 fprintf(f, "repo.enable-blame=%d\n",
822 repo->enable_blame); 832 repo->enable_blame);
823 fprintf(f, "repo.enable-commit-graph=%d\n", 833 fprintf(f, "repo.enable-commit-graph=%d\n",
diff --git a/cgit.h b/cgit.h index 72fcd84..4cd5fc3 100644 --- a/cgit.h +++ b/cgit.h
@@ -86,6 +86,7 @@ struct cgit_repo {
86 char *owner; 86 char *owner;
87 char *homepage; 87 char *homepage;
88 char *defbranch; 88 char *defbranch;
89 char *default_tab;
89 char *module_link; 90 char *module_link;
90 struct string_list readme; 91 struct string_list readme;
91 char *section; 92 char *section;
@@ -215,6 +216,8 @@ struct cgit_config {
215 char *repository_sort; 216 char *repository_sort;
216 char *virtual_root; /* Always ends with '/'. */ 217 char *virtual_root; /* Always ends with '/'. */
217 char *strict_export; 218 char *strict_export;
219 char *default_tab;
220 char *root_default_tab;
218 int cache_size; 221 int cache_size;
219 int cache_dynamic_ttl; 222 int cache_dynamic_ttl;
220 int cache_max_create_time; 223 int cache_max_create_time;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index cafb535..e9ebae5 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt
@@ -128,6 +128,10 @@ css::
128 Url which specifies the css document to include in all cgit pages. 128 Url which specifies the css document to include in all cgit pages.
129 Default value: "/cgit.css". 129 Default value: "/cgit.css".
130 130
131default-tab::
132 Specifies the tab to automatically load in the root page of a repository.
133 Default value: "summary". See also: root-default-tab, repo.default-tab.
134
131email-filter:: 135email-filter::
132 Specifies a command which will be invoked to format names and email 136 Specifies a command which will be invoked to format names and email
133 address of committers, authors, and taggers, as represented in various 137 address of committers, authors, and taggers, as represented in various
@@ -352,6 +356,10 @@ robots::
352 Text used as content for the "robots" meta-tag. Default value: 356 Text used as content for the "robots" meta-tag. Default value:
353 "index, nofollow". 357 "index, nofollow".
354 358
359root-default-tab::
360 Specifies the tab to automatically load as the root index page.
361 Default value: "repolist". See also: default-tab, repo.default-tab.
362
355root-desc:: 363root-desc::
356 Text printed below the heading on the repository index page. Default 364 Text printed below the heading on the repository index page. Default
357 value: "a fast webinterface for the git dscm". 365 value: "a fast webinterface for the git dscm".
@@ -481,6 +489,9 @@ repo.defbranch::
481 as default instead. Default value: branch pointed to by HEAD, or 489 as default instead. Default value: branch pointed to by HEAD, or
482 "master" if there is no suitable HEAD. 490 "master" if there is no suitable HEAD.
483 491
492repo.default-tab::
493 Override the global default-tab. Default value: none.
494
484repo.desc:: 495repo.desc::
485 The value to show as repository description. Default value: none. 496 The value to show as repository description. Default value: none.
486 497
diff --git a/cmd.c b/cmd.c index 0eb75b1..64f6639 100644 --- a/cmd.c +++ b/cmd.c
@@ -55,7 +55,7 @@ static void about_fn(void)
55 cgit_redirect(ctx.repo->homepage, false); 55 cgit_redirect(ctx.repo->homepage, false);
56 else { 56 else {
57 char *currenturl = cgit_currenturl(); 57 char *currenturl = cgit_currenturl();
58 char *redirect = fmtalloc("%s../", currenturl); 58 char *redirect = cgit_pageurl(ctx.repo->url, "summary", NULL);
59 cgit_redirect(redirect, false); 59 cgit_redirect(redirect, false);
60 free(currenturl); 60 free(currenturl);
61 free(redirect); 61 free(redirect);
@@ -196,9 +196,9 @@ struct cgit_cmd *cgit_get_cmd(void)
196 196
197 if (ctx.qry.page == NULL) { 197 if (ctx.qry.page == NULL) {
198 if (ctx.repo) 198 if (ctx.repo)
199 ctx.qry.page = "summary"; 199 ctx.qry.page = ctx.repo->default_tab;
200 else 200 else
201 ctx.qry.page = "repolist"; 201 ctx.qry.page = ctx.cfg.root_default_tab;
202 } 202 }
203 203
204 for (i = 0; i < sizeof(cmds)/sizeof(*cmds); i++) 204 for (i = 0; i < sizeof(cmds)/sizeof(*cmds); i++)
diff --git a/shared.c b/shared.c index 0bceb98..f60b8d4 100644 --- a/shared.c +++ b/shared.c
@@ -79,6 +79,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
79 ret->clone_url = ctx.cfg.clone_url; 79 ret->clone_url = ctx.cfg.clone_url;
80 ret->submodules.strdup_strings = 1; 80 ret->submodules.strdup_strings = 1;
81 ret->hide = ret->ignore = 0; 81 ret->hide = ret->ignore = 0;
82 ret->default_tab = ctx.cfg.default_tab;
82 return ret; 83 return ret;
83} 84}
84 85
diff --git a/ui-shared.c b/ui-shared.c index 72a1505..0b7937c 100644 --- a/ui-shared.c +++ b/ui-shared.c
@@ -203,6 +203,9 @@ static void site_url(const char *page, const char *search, const char *sort, int
203{ 203{
204 char *delim = "?"; 204 char *delim = "?";
205 205
206 if (!strcmp(page ? page : "", ctx.cfg.root_default_tab))
207 page = NULL;
208
206 if (always_root || page) 209 if (always_root || page)
207 html_attr(cgit_rooturl()); 210 html_attr(cgit_rooturl());
208 else { 211 else {
@@ -257,7 +260,7 @@ static void site_link(const char *page, const char *name, const char *title,
257void cgit_index_link(const char *name, const char *title, const char *class, 260void cgit_index_link(const char *name, const char *title, const char *class,
258 const char *pattern, const char *sort, int ofs, int always_root) 261 const char *pattern, const char *sort, int ofs, int always_root)
259{ 262{
260 site_link(NULL, name, title, class, pattern, sort, ofs, always_root); 263 site_link("repolist", name, title, class, pattern, sort, ofs, always_root);
261} 264}
262 265
263static char *repolink(const char *title, const char *class, const char *page, 266static char *repolink(const char *title, const char *class, const char *page,
@@ -317,6 +320,14 @@ static void reporevlink(const char *page, const char *name, const char *title,
317{ 320{
318 char *delim; 321 char *delim;
319 322
323 if (!strcmp(page
324 ? page
325 : "",
326 ctx.repo
327 ? ctx.repo->default_tab
328 : ctx.cfg.root_default_tab))
329 page = NULL;
330
320 delim = repolink(title, class, page, head, path); 331 delim = repolink(title, class, page, head, path);
321 if (rev && ctx.qry.head != NULL && strcmp(rev, ctx.qry.head)) { 332 if (rev && ctx.qry.head != NULL && strcmp(rev, ctx.qry.head)) {
322 html(delim); 333 html(delim);
@@ -328,10 +339,17 @@ static void reporevlink(const char *page, const char *name, const char *title,
328 html("</a>"); 339 html("</a>");
329} 340}
330 341
342void cgit_repo_link(const char *name, const char *title, const char *class,
343 const char *head)
344{
345 reporevlink(NULL, name, title, class, head, NULL, NULL);
346}
347
348
331void cgit_summary_link(const char *name, const char *title, const char *class, 349void cgit_summary_link(const char *name, const char *title, const char *class,
332 const char *head) 350 const char *head)
333{ 351{
334 reporevlink(NULL, name, title, class, head, NULL, NULL); 352 reporevlink("summary", name, title, class, head, NULL, NULL);
335} 353}
336 354
337void cgit_tag_link(const char *name, const char *title, const char *class, 355void cgit_tag_link(const char *name, const char *title, const char *class,
@@ -1111,7 +1129,7 @@ void cgit_print_pageheader(void)
1111 html("</form>\n"); 1129 html("</form>\n");
1112 } else if (ctx.env.authenticated) { 1130 } else if (ctx.env.authenticated) {
1113 char *currenturl = cgit_currenturl(); 1131 char *currenturl = cgit_currenturl();
1114 site_link(NULL, "index", NULL, hc("repolist"), NULL, NULL, 0, 1); 1132 site_link("repolist", "index", NULL, hc("repolist"), NULL, NULL, 0, 1);
1115 if (ctx.cfg.root_readme) 1133 if (ctx.cfg.root_readme)
1116 site_link("about", "about", NULL, hc("about"), 1134 site_link("about", "about", NULL, hc("about"),
1117 NULL, NULL, 0, 1); 1135 NULL, NULL, 0, 1);
diff --git a/ui-shared.h b/ui-shared.h index 6964873..9faf2ba 100644 --- a/ui-shared.h +++ b/ui-shared.h
@@ -17,6 +17,8 @@ extern void cgit_add_clone_urls(void (*fn)(const char *));
17 17
18extern void cgit_index_link(const char *name, const char *title, 18extern void cgit_index_link(const char *name, const char *title,
19 const char *class, const char *pattern, const char *sort, int ofs, int always_root); 19 const char *class, const char *pattern, const char *sort, int ofs, int always_root);
20extern void cgit_repo_link(const char *name, const char *title,
21 const char *class, const char *head);
20extern void cgit_summary_link(const char *name, const char *title, 22extern void cgit_summary_link(const char *name, const char *title,
21 const char *class, const char *head); 23 const char *class, const char *head);
22extern void cgit_tag_link(const char *name, const char *title, 24extern void cgit_tag_link(const char *name, const char *title,