author | Lars Hjemli <hjemli@gmail.com> | 2007-06-18 22:56:40 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-06-18 22:56:40 (UTC) |
commit | 0d05bca502f4a5347fa629045aca97ba9b404acc (patch) (unidiff) | |
tree | e11b6a3e183aab02824f83c51759b5d426a64a67 | |
parent | a215bf4620113fcefb8dd3442bf3501bd648c463 (diff) | |
download | cgit-0d05bca502f4a5347fa629045aca97ba9b404acc.zip cgit-0d05bca502f4a5347fa629045aca97ba9b404acc.tar.gz cgit-0d05bca502f4a5347fa629045aca97ba9b404acc.tar.bz2 |
Add setting to enable/disable extra links on index page
The summary/log/tree links displayed for each repository on the index
page lost some of their purpose when the header menu was added, so this
commit introduces the parameter 'enable-index-links' which must be set
to 1 to enable these links.
Suggested-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | cgitrc | 4 | ||||
-rw-r--r-- | shared.c | 3 | ||||
-rw-r--r-- | ui-repolist.c | 35 |
4 files changed, 31 insertions, 12 deletions
@@ -115,12 +115,13 @@ extern char *cgit_virtual_root; | |||
115 | extern char *cgit_script_name; | 115 | extern char *cgit_script_name; |
116 | extern char *cgit_cache_root; | 116 | extern char *cgit_cache_root; |
117 | extern char *cgit_repo_group; | 117 | extern char *cgit_repo_group; |
118 | 118 | ||
119 | extern int cgit_nocache; | 119 | extern int cgit_nocache; |
120 | extern int cgit_snapshots; | 120 | extern int cgit_snapshots; |
121 | extern int cgit_enable_index_links; | ||
121 | extern int cgit_enable_log_filecount; | 122 | extern int cgit_enable_log_filecount; |
122 | extern int cgit_enable_log_linecount; | 123 | extern int cgit_enable_log_linecount; |
123 | extern int cgit_max_lock_attempts; | 124 | extern int cgit_max_lock_attempts; |
124 | extern int cgit_cache_root_ttl; | 125 | extern int cgit_cache_root_ttl; |
125 | extern int cgit_cache_repo_ttl; | 126 | extern int cgit_cache_repo_ttl; |
126 | extern int cgit_cache_dynamic_ttl; | 127 | extern int cgit_cache_dynamic_ttl; |
@@ -9,12 +9,16 @@ | |||
9 | 9 | ||
10 | 10 | ||
11 | ## Enable/disable snapshots by default. This can be overridden per repo | 11 | ## Enable/disable snapshots by default. This can be overridden per repo |
12 | #snapshots=0 | 12 | #snapshots=0 |
13 | 13 | ||
14 | 14 | ||
15 | ## Enable/disable extra links to summary/log/tree per repo on index page | ||
16 | #enable-index-links=0 | ||
17 | |||
18 | |||
15 | ## Enable/disable display of 'number of files changed' in log view | 19 | ## Enable/disable display of 'number of files changed' in log view |
16 | #enable-log-filecount=0 | 20 | #enable-log-filecount=0 |
17 | 21 | ||
18 | 22 | ||
19 | ## Enable/disable display of 'number of lines changed' in log view | 23 | ## Enable/disable display of 'number of lines changed' in log view |
20 | #enable-log-linecount=0 | 24 | #enable-log-linecount=0 |
@@ -23,12 +23,13 @@ char *cgit_virtual_root = NULL; | |||
23 | char *cgit_script_name = CGIT_SCRIPT_NAME; | 23 | char *cgit_script_name = CGIT_SCRIPT_NAME; |
24 | char *cgit_cache_root = "/var/cache/cgit"; | 24 | char *cgit_cache_root = "/var/cache/cgit"; |
25 | char *cgit_repo_group = NULL; | 25 | char *cgit_repo_group = NULL; |
26 | 26 | ||
27 | int cgit_nocache = 0; | 27 | int cgit_nocache = 0; |
28 | int cgit_snapshots = 0; | 28 | int cgit_snapshots = 0; |
29 | int cgit_enable_index_links = 0; | ||
29 | int cgit_enable_log_filecount = 0; | 30 | int cgit_enable_log_filecount = 0; |
30 | int cgit_enable_log_linecount = 0; | 31 | int cgit_enable_log_linecount = 0; |
31 | int cgit_max_lock_attempts = 5; | 32 | int cgit_max_lock_attempts = 5; |
32 | int cgit_cache_root_ttl = 5; | 33 | int cgit_cache_root_ttl = 5; |
33 | int cgit_cache_repo_ttl = 5; | 34 | int cgit_cache_repo_ttl = 5; |
34 | int cgit_cache_dynamic_ttl = 5; | 35 | int cgit_cache_dynamic_ttl = 5; |
@@ -143,12 +144,14 @@ void cgit_global_config_cb(const char *name, const char *value) | |||
143 | else if (!strcmp(name, "virtual-root")) | 144 | else if (!strcmp(name, "virtual-root")) |
144 | cgit_virtual_root = xstrdup(value); | 145 | cgit_virtual_root = xstrdup(value); |
145 | else if (!strcmp(name, "nocache")) | 146 | else if (!strcmp(name, "nocache")) |
146 | cgit_nocache = atoi(value); | 147 | cgit_nocache = atoi(value); |
147 | else if (!strcmp(name, "snapshots")) | 148 | else if (!strcmp(name, "snapshots")) |
148 | cgit_snapshots = atoi(value); | 149 | cgit_snapshots = atoi(value); |
150 | else if (!strcmp(name, "enable-index-links")) | ||
151 | cgit_enable_index_links = atoi(value); | ||
149 | else if (!strcmp(name, "enable-log-filecount")) | 152 | else if (!strcmp(name, "enable-log-filecount")) |
150 | cgit_enable_log_filecount = atoi(value); | 153 | cgit_enable_log_filecount = atoi(value); |
151 | else if (!strcmp(name, "enable-log-linecount")) | 154 | else if (!strcmp(name, "enable-log-linecount")) |
152 | cgit_enable_log_linecount = atoi(value); | 155 | cgit_enable_log_linecount = atoi(value); |
153 | else if (!strcmp(name, "cache-root")) | 156 | else if (!strcmp(name, "cache-root")) |
154 | cgit_cache_root = xstrdup(value); | 157 | cgit_cache_root = xstrdup(value); |
diff --git a/ui-repolist.c b/ui-repolist.c index 4f820a8..c735368 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -41,38 +41,45 @@ static void print_modtime(struct repoinfo *repo) | |||
41 | return; | 41 | return; |
42 | cgit_print_age(s.st_mtime, -1, NULL); | 42 | cgit_print_age(s.st_mtime, -1, NULL); |
43 | } | 43 | } |
44 | 44 | ||
45 | void cgit_print_repolist(struct cacheitem *item) | 45 | void cgit_print_repolist(struct cacheitem *item) |
46 | { | 46 | { |
47 | int i; | 47 | int i, columns = 4; |
48 | char *last_group = NULL; | 48 | char *last_group = NULL; |
49 | 49 | ||
50 | if (cgit_enable_index_links) | ||
51 | columns++; | ||
52 | |||
50 | cgit_print_docstart(cgit_root_title, item); | 53 | cgit_print_docstart(cgit_root_title, item); |
51 | cgit_print_pageheader(cgit_root_title, 0); | 54 | cgit_print_pageheader(cgit_root_title, 0); |
52 | 55 | ||
53 | html("<table class='list nowrap'>"); | 56 | html("<table class='list nowrap'>"); |
54 | if (cgit_index_header) { | 57 | if (cgit_index_header) { |
55 | html("<tr class='nohover'><td colspan='5' class='include-block'>"); | 58 | htmlf("<tr class='nohover'><td colspan='%d' class='include-block'>", |
59 | columns); | ||
56 | html_include(cgit_index_header); | 60 | html_include(cgit_index_header); |
57 | html("</td></tr>"); | 61 | html("</td></tr>"); |
58 | } | 62 | } |
59 | html("<tr class='nohover'>" | 63 | html("<tr class='nohover'>" |
60 | "<th class='left'>Name</th>" | 64 | "<th class='left'>Name</th>" |
61 | "<th class='left'>Description</th>" | 65 | "<th class='left'>Description</th>" |
62 | "<th class='left'>Owner</th>" | 66 | "<th class='left'>Owner</th>" |
63 | "<th class='left'>Idle</th>" | 67 | "<th class='left'>Idle</th>"); |
64 | "<th>Links</th></tr>\n"); | 68 | if (cgit_enable_index_links) |
69 | html("<th>Links</th>"); | ||
70 | html("</tr>\n"); | ||
65 | 71 | ||
66 | for (i=0; i<cgit_repolist.count; i++) { | 72 | for (i=0; i<cgit_repolist.count; i++) { |
67 | cgit_repo = &cgit_repolist.repos[i]; | 73 | cgit_repo = &cgit_repolist.repos[i]; |
68 | if ((last_group == NULL && cgit_repo->group != NULL) || | 74 | if ((last_group == NULL && cgit_repo->group != NULL) || |
69 | (last_group != NULL && cgit_repo->group == NULL) || | 75 | (last_group != NULL && cgit_repo->group == NULL) || |
70 | (last_group != NULL && cgit_repo->group != NULL && | 76 | (last_group != NULL && cgit_repo->group != NULL && |
71 | strcmp(cgit_repo->group, last_group))) { | 77 | strcmp(cgit_repo->group, last_group))) { |
72 | html("<tr class='nohover'><td colspan='4' class='repogroup'>"); | 78 | htmlf("<tr class='nohover'><td colspan='%d' class='repogroup'>", |
79 | columns); | ||
73 | html_txt(cgit_repo->group); | 80 | html_txt(cgit_repo->group); |
74 | html("</td></tr>"); | 81 | html("</td></tr>"); |
75 | last_group = cgit_repo->group; | 82 | last_group = cgit_repo->group; |
76 | } | 83 | } |
77 | htmlf("<tr><td class='%s'>", | 84 | htmlf("<tr><td class='%s'>", |
78 | cgit_repo->group ? "sublevel-repo" : "toplevel-repo"); | 85 | cgit_repo->group ? "sublevel-repo" : "toplevel-repo"); |
@@ -82,17 +89,21 @@ void cgit_print_repolist(struct cacheitem *item) | |||
82 | html("</td><td>"); | 89 | html("</td><td>"); |
83 | html_ntxt(cgit_max_repodesc_len, cgit_repo->desc); | 90 | html_ntxt(cgit_max_repodesc_len, cgit_repo->desc); |
84 | html("</td><td>"); | 91 | html("</td><td>"); |
85 | html_txt(cgit_repo->owner); | 92 | html_txt(cgit_repo->owner); |
86 | html("</td><td>"); | 93 | html("</td><td>"); |
87 | print_modtime(cgit_repo); | 94 | print_modtime(cgit_repo); |
88 | html("</td><td>"); | 95 | html("</td>"); |
89 | html_link_open(cgit_repourl(cgit_repo->url), | 96 | if (cgit_enable_index_links) { |
90 | NULL, "button"); | 97 | html("<td>"); |
91 | html("summary</a>"); | 98 | html_link_open(cgit_repourl(cgit_repo->url), |
92 | cgit_log_link("log", NULL, "button", NULL, NULL, NULL); | 99 | NULL, "button"); |
93 | cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL); | 100 | html("summary</a>"); |
94 | html("</td></tr>\n"); | 101 | cgit_log_link("log", NULL, "button", NULL, NULL, NULL); |
102 | cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL); | ||
103 | html("</td>"); | ||
104 | } | ||
105 | html("</tr>\n"); | ||
95 | } | 106 | } |
96 | html("</table>"); | 107 | html("</table>"); |
97 | cgit_print_docend(); | 108 | cgit_print_docend(); |
98 | } | 109 | } |