author | Lars Hjemli <hjemli@gmail.com> | 2006-12-11 15:55:07 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2006-12-11 15:55:33 (UTC) |
commit | 1418034e642fee67c981b31e4c3eb6e8ae14e303 (patch) (unidiff) | |
tree | 3addc880197706f2ddd24f35c5d886f1e885b276 | |
parent | 74620f12e4f7e91cb0a0b4ca731e07272d1b65f6 (diff) | |
download | cgit-1418034e642fee67c981b31e4c3eb6e8ae14e303.zip cgit-1418034e642fee67c981b31e4c3eb6e8ae14e303.tar.gz cgit-1418034e642fee67c981b31e4c3eb6e8ae14e303.tar.bz2 |
Move repo summary functions into ui-summary.c
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | cgit.c | 46 | ||||
-rw-r--r-- | cgit.h | 3 | ||||
-rw-r--r-- | ui-summary.c | 55 |
4 files changed, 59 insertions, 47 deletions
@@ -6,5 +6,5 @@ CACHE_ROOT = /var/cache/cgit | |||
6 | 6 | ||
7 | EXTLIBS = ../git/libgit.a ../git/xdiff/lib.a -lz -lcrypto | 7 | EXTLIBS = ../git/libgit.a ../git/xdiff/lib.a -lz -lcrypto |
8 | OBJECTS = parsing.o html.o cache.o ui-shared.o ui-repolist.o | 8 | OBJECTS = cache.o parsing.o html.o ui-shared.o ui-repolist.o ui-summary.o |
9 | 9 | ||
10 | CFLAGS += -Wall | 10 | CFLAGS += -Wall |
@@ -85,42 +85,4 @@ void cgit_querystring_cb(const char *name, const char *value) | |||
85 | } | 85 | } |
86 | 86 | ||
87 | static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, | ||
88 | int flags, void *cb_data) | ||
89 | { | ||
90 | struct commit *commit; | ||
91 | char buf[256], *url; | ||
92 | |||
93 | commit = lookup_commit(sha1); | ||
94 | if (commit && !parse_commit(commit)){ | ||
95 | html("<tr><td>"); | ||
96 | url = cgit_pageurl(cgit_query_repo, "log", | ||
97 | fmt("h=%s", refname)); | ||
98 | html_link_open(url, NULL, NULL); | ||
99 | strncpy(buf, refname, sizeof(buf)); | ||
100 | html_txt(buf); | ||
101 | html_link_close(); | ||
102 | html("</td><td>"); | ||
103 | pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0, buf, | ||
104 | sizeof(buf), 0, NULL, NULL, 0); | ||
105 | html_txt(buf); | ||
106 | html("</td></tr>\n"); | ||
107 | } else { | ||
108 | html("<tr><td>"); | ||
109 | html_txt(buf); | ||
110 | html("</td><td>"); | ||
111 | htmlf("*** bad ref %s", sha1_to_hex(sha1)); | ||
112 | html("</td></tr>\n"); | ||
113 | } | ||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | static void cgit_print_branches() | ||
118 | { | ||
119 | html("<table class='list'>"); | ||
120 | html("<tr><th>Branch name</th><th>Head commit</th></tr>\n"); | ||
121 | for_each_branch_ref(cgit_print_branch_cb, NULL); | ||
122 | html("</table>"); | ||
123 | } | ||
124 | |||
125 | static int get_one_line(char *txt) | 87 | static int get_one_line(char *txt) |
126 | { | 88 | { |
@@ -228,12 +190,4 @@ static void cgit_print_log(const char *tip, int ofs, int cnt) | |||
228 | } | 190 | } |
229 | 191 | ||
230 | static void cgit_print_repo_summary() | ||
231 | { | ||
232 | html("<h2>"); | ||
233 | html_txt("Repo summary page"); | ||
234 | html("</h2>"); | ||
235 | cgit_print_branches(); | ||
236 | } | ||
237 | |||
238 | static void cgit_print_object(char *hex) | 192 | static void cgit_print_object(char *hex) |
239 | { | 193 | { |
@@ -80,3 +80,6 @@ extern void cgit_print_repolist(struct cacheitem *item); | |||
80 | extern void cgit_repo_config_cb(const char *name, const char *value); | 80 | extern void cgit_repo_config_cb(const char *name, const char *value); |
81 | 81 | ||
82 | extern void cgit_print_repo_summary(); | ||
83 | |||
84 | |||
82 | #endif /* CGIT_H */ | 85 | #endif /* CGIT_H */ |
diff --git a/ui-summary.c b/ui-summary.c new file mode 100644 index 0000000..532ddbf --- a/dev/null +++ b/ui-summary.c | |||
@@ -0,0 +1,55 @@ | |||
1 | /* ui-summary.c: functions for generating repo summary page | ||
2 | * | ||
3 | * Copyright (C) 2006 Lars Hjemli | ||
4 | * | ||
5 | * Licensed under GNU General Public License v2 | ||
6 | * (see COPYING for full license text) | ||
7 | */ | ||
8 | |||
9 | #include "cgit.h" | ||
10 | |||
11 | static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, | ||
12 | int flags, void *cb_data) | ||
13 | { | ||
14 | struct commit *commit; | ||
15 | char buf[256], *url; | ||
16 | |||
17 | commit = lookup_commit(sha1); | ||
18 | if (commit && !parse_commit(commit)){ | ||
19 | html("<tr><td>"); | ||
20 | url = cgit_pageurl(cgit_query_repo, "log", | ||
21 | fmt("h=%s", refname)); | ||
22 | html_link_open(url, NULL, NULL); | ||
23 | strncpy(buf, refname, sizeof(buf)); | ||
24 | html_txt(buf); | ||
25 | html_link_close(); | ||
26 | html("</td><td>"); | ||
27 | pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0, buf, | ||
28 | sizeof(buf), 0, NULL, NULL, 0); | ||
29 | html_txt(buf); | ||
30 | html("</td></tr>\n"); | ||
31 | } else { | ||
32 | html("<tr><td>"); | ||
33 | html_txt(buf); | ||
34 | html("</td><td>"); | ||
35 | htmlf("*** bad ref %s", sha1_to_hex(sha1)); | ||
36 | html("</td></tr>\n"); | ||
37 | } | ||
38 | return 0; | ||
39 | } | ||
40 | |||
41 | static void cgit_print_branches() | ||
42 | { | ||
43 | html("<table class='list'>"); | ||
44 | html("<tr><th>Branch name</th><th>Head commit</th></tr>\n"); | ||
45 | for_each_branch_ref(cgit_print_branch_cb, NULL); | ||
46 | html("</table>"); | ||
47 | } | ||
48 | |||
49 | void cgit_print_repo_summary() | ||
50 | { | ||
51 | html("<h2>"); | ||
52 | html_txt("Repo summary page"); | ||
53 | html("</h2>"); | ||
54 | cgit_print_branches(); | ||
55 | } | ||