summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-repolist.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/ui-repolist.c b/ui-repolist.c
index 573c730..e5c6c20 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -1,104 +1,103 @@
1/* ui-repolist.c: functions for generating the repolist page 1/* ui-repolist.c: functions for generating the repolist page
2 * 2 *
3 * Copyright (C) 2006 Lars Hjemli 3 * Copyright (C) 2006 Lars Hjemli
4 * 4 *
5 * Licensed under GNU General Public License v2 5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text) 6 * (see COPYING for full license text)
7 */ 7 */
8 8
9#include "cgit.h" 9#include "cgit.h"
10#include <time.h> 10#include <time.h>
11 11
12 12
13time_t read_agefile(char *path) 13time_t read_agefile(char *path)
14{ 14{
15 FILE *f; 15 FILE *f;
16 static char buf[64], buf2[64]; 16 static char buf[64], buf2[64];
17 struct tm tm;
18 17
19 if (!(f = fopen(path, "r"))) 18 if (!(f = fopen(path, "r")))
20 return -1; 19 return -1;
21 fgets(buf, sizeof(buf), f); 20 fgets(buf, sizeof(buf), f);
22 fclose(f); 21 fclose(f);
23 if (parse_date(buf, buf2, sizeof(buf2))) 22 if (parse_date(buf, buf2, sizeof(buf2)))
24 return strtoul(buf2, NULL, 10); 23 return strtoul(buf2, NULL, 10);
25 else 24 else
26 return 0; 25 return 0;
27} 26}
28 27
29static void print_modtime(struct repoinfo *repo) 28static void print_modtime(struct repoinfo *repo)
30{ 29{
31 char *path; 30 char *path;
32 struct stat s; 31 struct stat s;
33 32
34 path = fmt("%s/%s", repo->path, cgit_agefile); 33 path = fmt("%s/%s", repo->path, cgit_agefile);
35 if (stat(path, &s) == 0) { 34 if (stat(path, &s) == 0) {
36 cgit_print_age(read_agefile(path), -1, NULL); 35 cgit_print_age(read_agefile(path), -1, NULL);
37 return; 36 return;
38 } 37 }
39 38
40 path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch); 39 path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch);
41 if (stat(path, &s) != 0) 40 if (stat(path, &s) != 0)
42 return; 41 return;
43 cgit_print_age(s.st_mtime, -1, NULL); 42 cgit_print_age(s.st_mtime, -1, NULL);
44} 43}
45 44
46void cgit_print_repolist(struct cacheitem *item) 45void cgit_print_repolist(struct cacheitem *item)
47{ 46{
48 struct repoinfo *repo; 47 struct repoinfo *repo;
49 int i; 48 int i;
50 char *last_group = NULL; 49 char *last_group = NULL;
51 50
52 cgit_print_docstart(cgit_root_title, item); 51 cgit_print_docstart(cgit_root_title, item);
53 cgit_print_pageheader(cgit_root_title, 0); 52 cgit_print_pageheader(cgit_root_title, 0);
54 53
55 html("<table class='list nowrap'>"); 54 html("<table class='list nowrap'>");
56 if (cgit_index_header) { 55 if (cgit_index_header) {
57 html("<tr class='nohover'><td colspan='5' class='include-block'>"); 56 html("<tr class='nohover'><td colspan='5' class='include-block'>");
58 html_include(cgit_index_header); 57 html_include(cgit_index_header);
59 html("</td></tr>"); 58 html("</td></tr>");
60 } 59 }
61 html("<tr class='nohover'>" 60 html("<tr class='nohover'>"
62 "<th class='left'>Name</th>" 61 "<th class='left'>Name</th>"
63 "<th class='left'>Description</th>" 62 "<th class='left'>Description</th>"
64 "<th class='left'>Owner</th>" 63 "<th class='left'>Owner</th>"
65 "<th class='left'>Idle</th>" 64 "<th class='left'>Idle</th>"
66 "<th>Links</th></tr>\n"); 65 "<th>Links</th></tr>\n");
67 66
68 for (i=0; i<cgit_repolist.count; i++) { 67 for (i=0; i<cgit_repolist.count; i++) {
69 repo = &cgit_repolist.repos[i]; 68 repo = &cgit_repolist.repos[i];
70 if ((last_group == NULL && repo->group != NULL) || 69 if ((last_group == NULL && repo->group != NULL) ||
71 (last_group != NULL && repo->group == NULL) || 70 (last_group != NULL && repo->group == NULL) ||
72 (last_group != NULL && repo->group!= NULL && 71 (last_group != NULL && repo->group!= NULL &&
73 strcmp(repo->group, last_group))) { 72 strcmp(repo->group, last_group))) {
74 html("<tr class='nohover'><td colspan='4' class='repogroup'>"); 73 html("<tr class='nohover'><td colspan='4' class='repogroup'>");
75 html_txt(repo->group); 74 html_txt(repo->group);
76 html("</td></tr>"); 75 html("</td></tr>");
77 last_group = repo->group; 76 last_group = repo->group;
78 } 77 }
79 htmlf("<tr><td class='%s'>", 78 htmlf("<tr><td class='%s'>",
80 repo->group ? "sublevel-repo" : "toplevel-repo"); 79 repo->group ? "sublevel-repo" : "toplevel-repo");
81 html_link_open(cgit_repourl(repo->url), repo->desc, NULL); 80 html_link_open(cgit_repourl(repo->url), repo->desc, NULL);
82 html_txt(repo->name); 81 html_txt(repo->name);
83 html_link_close(); 82 html_link_close();
84 html("</td><td>"); 83 html("</td><td>");
85 html_ntxt(cgit_max_repodesc_len, repo->desc); 84 html_ntxt(cgit_max_repodesc_len, repo->desc);
86 html("</td><td>"); 85 html("</td><td>");
87 html_txt(repo->owner); 86 html_txt(repo->owner);
88 html("</td><td>"); 87 html("</td><td>");
89 print_modtime(repo); 88 print_modtime(repo);
90 html("</td><td>"); 89 html("</td><td>");
91 html_link_open(cgit_repourl(repo->url), 90 html_link_open(cgit_repourl(repo->url),
92 "Summary", "button"); 91 "Summary", "button");
93 html("S</a>"); 92 html("S</a>");
94 html_link_open(cgit_pageurl(repo->name, "log", NULL), 93 html_link_open(cgit_pageurl(repo->name, "log", NULL),
95 "Log", "button"); 94 "Log", "button");
96 html("L</a>"); 95 html("L</a>");
97 html_link_open(cgit_pageurl(repo->name, "tree", NULL), 96 html_link_open(cgit_pageurl(repo->name, "tree", NULL),
98 "Files", "button"); 97 "Files", "button");
99 html("F</a>"); 98 html("F</a>");
100 html("</td></tr>\n"); 99 html("</td></tr>\n");
101 } 100 }
102 html("</table>"); 101 html("</table>");
103 cgit_print_docend(); 102 cgit_print_docend();
104} 103}