author | Lars Hjemli <hjemli@gmail.com> | 2007-05-18 20:48:22 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-05-18 20:51:18 (UTC) |
commit | 5877c49f68b1e1bef94b4867f22c336f0e1605b6 (patch) (unidiff) | |
tree | 4e628096d9f189b7ef5ff9dcda40a07a5f7b21d0 /ui-repolist.c | |
parent | 08cc2e5f0e24773dad81d38bd6b689e36afe9dda (diff) | |
download | cgit-5877c49f68b1e1bef94b4867f22c336f0e1605b6.zip cgit-5877c49f68b1e1bef94b4867f22c336f0e1605b6.tar.gz cgit-5877c49f68b1e1bef94b4867f22c336f0e1605b6.tar.bz2 |
Teach cgit how to group repositories by category
The new parameter 'repo.group' is used to set the repository group
for the following repositores. Whenever this parameter changes value,
a subheading is generated in the index page (printing the current value
of repo.group).
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-repolist.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ui-repolist.c b/ui-repolist.c index d7311e4..a884c20 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -9,12 +9,13 @@ | |||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | 10 | ||
11 | void cgit_print_repolist(struct cacheitem *item) | 11 | void cgit_print_repolist(struct cacheitem *item) |
12 | { | 12 | { |
13 | struct repoinfo *repo; | 13 | struct repoinfo *repo; |
14 | int i; | 14 | int i; |
15 | char *last_group = NULL; | ||
15 | 16 | ||
16 | cgit_print_docstart(cgit_root_title, item); | 17 | cgit_print_docstart(cgit_root_title, item); |
17 | cgit_print_pageheader(cgit_root_title, 0); | 18 | cgit_print_pageheader(cgit_root_title, 0); |
18 | 19 | ||
19 | html("<table class='list nowrap'>"); | 20 | html("<table class='list nowrap'>"); |
20 | html("<tr class='nohover'>" | 21 | html("<tr class='nohover'>" |
@@ -22,12 +23,21 @@ void cgit_print_repolist(struct cacheitem *item) | |||
22 | "<th class='left'>Description</th>" | 23 | "<th class='left'>Description</th>" |
23 | "<th class='left'>Owner</th>" | 24 | "<th class='left'>Owner</th>" |
24 | "<th class='left'>Links</th></tr>\n"); | 25 | "<th class='left'>Links</th></tr>\n"); |
25 | 26 | ||
26 | for (i=0; i<cgit_repolist.count; i++) { | 27 | for (i=0; i<cgit_repolist.count; i++) { |
27 | repo = &cgit_repolist.repos[i]; | 28 | repo = &cgit_repolist.repos[i]; |
29 | if ((last_group == NULL && repo->group != NULL) || | ||
30 | (last_group != NULL && repo->group == NULL) || | ||
31 | (last_group != NULL && repo->group!= NULL && | ||
32 | strcmp(repo->group, last_group))) { | ||
33 | html("<tr><td colspan='4' class='repogroup'>"); | ||
34 | html_txt(repo->group); | ||
35 | html("</td></tr>"); | ||
36 | last_group = repo->group; | ||
37 | } | ||
28 | html("<tr><td>"); | 38 | html("<tr><td>"); |
29 | html_link_open(cgit_repourl(repo->url), NULL, NULL); | 39 | html_link_open(cgit_repourl(repo->url), NULL, NULL); |
30 | html_txt(repo->name); | 40 | html_txt(repo->name); |
31 | html_link_close(); | 41 | html_link_close(); |
32 | html("</td><td>"); | 42 | html("</td><td>"); |
33 | html_ntxt(cgit_max_repodesc_len, repo->desc); | 43 | html_ntxt(cgit_max_repodesc_len, repo->desc); |