aboutsummaryrefslogtreecommitdiffstats
path: root/ui-repolist.c
diff options
context:
space:
mode:
authorLars Hjemli2008-04-08 21:29:21 +0200
committerLars Hjemli2008-04-08 21:29:21 +0200
commit23296ad648c0e2a9e3cf40a3de322b10ad25cce3 (patch)
tree136493d8228b0ff4971feb06b0e8aee296367b00 /ui-repolist.c
parente2a44cf0923398396b7a321d5ce894ad3bf6f580 (diff)
parentc6f747649ace1a92ed5dfaae9cc1ea3affe0bf51 (diff)
downloadcgit-23296ad648c0e2a9e3cf40a3de322b10ad25cce3.tar.gz
cgit-23296ad648c0e2a9e3cf40a3de322b10ad25cce3.tar.bz2
cgit-23296ad648c0e2a9e3cf40a3de322b10ad25cce3.zip
Merge branch 'lh/cleanup'
* lh/cleanup: (21 commits) Reset ctx.repo to NULL when the config parser is finished Move cgit_parse_query() from parsing.c to html.c as http_parse_querystring() Move function for configfile parsing into configfile.[ch] Add cache.h Remove global and obsolete cgit_cmd Makefile: copy the QUIET constructs from the Makefile in git.git Move cgit_version from shared.c to cgit.c Makefile: autobuild dependency rules Initial Makefile cleanup Move non-generic functions from shared.c to cgit.c Add ui-shared.h Add separate header-files for each page/view Refactor snapshot support Add command dispatcher Remove obsolete cacheitem parameter to ui-functions Add struct cgit_page to cgit_context Introduce html.h Improve initialization of git directory Move cgit_repo into cgit_context Add all config variables into struct cgit_context ...
Diffstat (limited to 'ui-repolist.c')
-rw-r--r--ui-repolist.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/ui-repolist.c b/ui-repolist.c
index 3e97ca9..eeeaf3d 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -6,9 +6,11 @@
6 * (see COPYING for full license text) 6 * (see COPYING for full license text)
7 */ 7 */
8 8
9#include "cgit.h"
10#include <time.h> 9#include <time.h>
11 10
11#include "cgit.h"
12#include "html.h"
13#include "ui-shared.h"
12 14
13time_t read_agefile(char *path) 15time_t read_agefile(char *path)
14{ 16{
@@ -25,12 +27,12 @@ time_t read_agefile(char *path)
25 return 0; 27 return 0;
26} 28}
27 29
28static void print_modtime(struct repoinfo *repo) 30static void print_modtime(struct cgit_repo *repo)
29{ 31{
30 char *path; 32 char *path;
31 struct stat s; 33 struct stat s;
32 34
33 path = fmt("%s/%s", repo->path, cgit_agefile); 35 path = fmt("%s/%s", repo->path, ctx.cfg.agefile);
34 if (stat(path, &s) == 0) { 36 if (stat(path, &s) == 0) {
35 cgit_print_age(read_agefile(path), -1, NULL); 37 cgit_print_age(read_agefile(path), -1, NULL);
36 return; 38 return;
@@ -42,22 +44,24 @@ static void print_modtime(struct repoinfo *repo)
42 cgit_print_age(s.st_mtime, -1, NULL); 44 cgit_print_age(s.st_mtime, -1, NULL);
43} 45}
44 46
45void cgit_print_repolist(struct cacheitem *item) 47void cgit_print_repolist()
46{ 48{
47 int i, columns = 4; 49 int i, columns = 4;
48 char *last_group = NULL; 50 char *last_group = NULL;
49 51
50 if (cgit_enable_index_links) 52 if (ctx.cfg.enable_index_links)
51 columns++; 53 columns++;
52 54
53 cgit_print_docstart(cgit_root_title, item); 55 ctx.page.title = ctx.cfg.root_title;
54 cgit_print_pageheader(cgit_root_title, 0); 56 cgit_print_http_headers(&ctx);
57 cgit_print_docstart(&ctx);
58 cgit_print_pageheader(&ctx);
55 59
56 html("<table summary='repository list' class='list nowrap'>"); 60 html("<table summary='repository list' class='list nowrap'>");
57 if (cgit_index_header) { 61 if (ctx.cfg.index_header) {
58 htmlf("<tr class='nohover'><td colspan='%d' class='include-block'>", 62 htmlf("<tr class='nohover'><td colspan='%d' class='include-block'>",
59 columns); 63 columns);
60 html_include(cgit_index_header); 64 html_include(ctx.cfg.index_header);
61 html("</td></tr>"); 65 html("</td></tr>");
62 } 66 }
63 html("<tr class='nohover'>" 67 html("<tr class='nohover'>"
@@ -65,37 +69,37 @@ void cgit_print_repolist(struct cacheitem *item)
65 "<th class='left'>Description</th>" 69 "<th class='left'>Description</th>"
66 "<th class='left'>Owner</th>" 70 "<th class='left'>Owner</th>"
67 "<th class='left'>Idle</th>"); 71 "<th class='left'>Idle</th>");
68 if (cgit_enable_index_links) 72 if (ctx.cfg.enable_index_links)
69 html("<th>Links</th>"); 73 html("<th>Links</th>");
70 html("</tr>\n"); 74 html("</tr>\n");
71 75
72 for (i=0; i<cgit_repolist.count; i++) { 76 for (i=0; i<cgit_repolist.count; i++) {
73 cgit_repo = &cgit_repolist.repos[i]; 77 ctx.repo = &cgit_repolist.repos[i];
74 if ((last_group == NULL && cgit_repo->group != NULL) || 78 if ((last_group == NULL && ctx.repo->group != NULL) ||
75 (last_group != NULL && cgit_repo->group == NULL) || 79 (last_group != NULL && ctx.repo->group == NULL) ||
76 (last_group != NULL && cgit_repo->group != NULL && 80 (last_group != NULL && ctx.repo->group != NULL &&
77 strcmp(cgit_repo->group, last_group))) { 81 strcmp(ctx.repo->group, last_group))) {
78 htmlf("<tr class='nohover'><td colspan='%d' class='repogroup'>", 82 htmlf("<tr class='nohover'><td colspan='%d' class='repogroup'>",
79 columns); 83 columns);
80 html_txt(cgit_repo->group); 84 html_txt(ctx.repo->group);
81 html("</td></tr>"); 85 html("</td></tr>");
82 last_group = cgit_repo->group; 86 last_group = ctx.repo->group;
83 } 87 }
84 htmlf("<tr><td class='%s'>", 88 htmlf("<tr><td class='%s'>",
85 cgit_repo->group ? "sublevel-repo" : "toplevel-repo"); 89 ctx.repo->group ? "sublevel-repo" : "toplevel-repo");
86 html_link_open(cgit_repourl(cgit_repo->url), NULL, NULL); 90 html_link_open(cgit_repourl(ctx.repo->url), NULL, NULL);
87 html_txt(cgit_repo->name); 91 html_txt(ctx.repo->name);
88 html_link_close(); 92 html_link_close();
89 html("</td><td>"); 93 html("</td><td>");
90 html_ntxt(cgit_max_repodesc_len, cgit_repo->desc); 94 html_ntxt(ctx.cfg.max_repodesc_len, ctx.repo->desc);
91 html("</td><td>"); 95 html("</td><td>");
92 html_txt(cgit_repo->owner); 96 html_txt(ctx.repo->owner);
93 html("</td><td>"); 97 html("</td><td>");
94 print_modtime(cgit_repo); 98 print_modtime(ctx.repo);
95 html("</td>"); 99 html("</td>");
96 if (cgit_enable_index_links) { 100 if (ctx.cfg.enable_index_links) {
97 html("<td>"); 101 html("<td>");
98 html_link_open(cgit_repourl(cgit_repo->url), 102 html_link_open(cgit_repourl(ctx.repo->url),
99 NULL, "button"); 103 NULL, "button");
100 html("summary</a>"); 104 html("summary</a>");
101 cgit_log_link("log", NULL, "button", NULL, NULL, NULL, 105 cgit_log_link("log", NULL, "button", NULL, NULL, NULL,