-rw-r--r-- | cgit.css | 2 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | html.c | 28 | ||||
-rw-r--r-- | ui-log.c | 4 | ||||
-rw-r--r-- | ui-summary.c | 4 |
5 files changed, 34 insertions, 5 deletions
@@ -55,97 +55,97 @@ div#header { | |||
55 | font-size: 150%; | 55 | font-size: 150%; |
56 | font-weight: bold; | 56 | font-weight: bold; |
57 | border: solid 1px #ccc; | 57 | border: solid 1px #ccc; |
58 | vertical-align: middle; | 58 | vertical-align: middle; |
59 | } | 59 | } |
60 | div#header img#logo { | 60 | div#header img#logo { |
61 | float: right; | 61 | float: right; |
62 | } | 62 | } |
63 | div#header a { | 63 | div#header a { |
64 | color: black; | 64 | color: black; |
65 | } | 65 | } |
66 | 66 | ||
67 | div#content { | 67 | div#content { |
68 | margin: 0.5em 0.5em; | 68 | margin: 0.5em 0.5em; |
69 | } | 69 | } |
70 | 70 | ||
71 | div#blob { | 71 | div#blob { |
72 | border: solid 1px black; | 72 | border: solid 1px black; |
73 | } | 73 | } |
74 | 74 | ||
75 | div.error { | 75 | div.error { |
76 | color: red; | 76 | color: red; |
77 | font-weight: bold; | 77 | font-weight: bold; |
78 | margin: 1em 2em; | 78 | margin: 1em 2em; |
79 | } | 79 | } |
80 | div.ls-blob, div.ls-dir { | 80 | div.ls-blob, div.ls-dir { |
81 | font-family: monospace; | 81 | font-family: monospace; |
82 | } | 82 | } |
83 | div.ls-dir a { | 83 | div.ls-dir a { |
84 | font-weight: bold; | 84 | font-weight: bold; |
85 | } | 85 | } |
86 | th.filesize, td.filesize { | 86 | th.filesize, td.filesize { |
87 | text-align: right; | 87 | text-align: right; |
88 | } | 88 | } |
89 | td.filesize { | 89 | td.filesize { |
90 | font-family: monospace; | 90 | font-family: monospace; |
91 | } | 91 | } |
92 | td.filemode { | 92 | td.filemode { |
93 | font-family: monospace; | 93 | font-family: monospace; |
94 | } | 94 | } |
95 | 95 | ||
96 | td.blob { | 96 | td.blob { |
97 | white-space: pre; | 97 | white-space: pre; |
98 | font-family: courier; | 98 | font-family: courier; |
99 | font-size: 100%; | 99 | font-size: 100%; |
100 | background-color: white; | 100 | background-color: white; |
101 | } | 101 | } |
102 | 102 | ||
103 | table.log td { | 103 | table.nowrap td { |
104 | white-space: nowrap; | 104 | white-space: nowrap; |
105 | } | 105 | } |
106 | 106 | ||
107 | table.commit-info { | 107 | table.commit-info { |
108 | border-collapse: collapse; | 108 | border-collapse: collapse; |
109 | margin-top: 1.5em; | 109 | margin-top: 1.5em; |
110 | } | 110 | } |
111 | table.commit-info th { | 111 | table.commit-info th { |
112 | text-align: left; | 112 | text-align: left; |
113 | font-weight: normal; | 113 | font-weight: normal; |
114 | padding: 0.1em 1em 0.1em 0.1em; | 114 | padding: 0.1em 1em 0.1em 0.1em; |
115 | } | 115 | } |
116 | table.commit-info td { | 116 | table.commit-info td { |
117 | font-weight: normal; | 117 | font-weight: normal; |
118 | padding: 0.1em 1em 0.1em 0.1em; | 118 | padding: 0.1em 1em 0.1em 0.1em; |
119 | } | 119 | } |
120 | div.commit-subject { | 120 | div.commit-subject { |
121 | font-weight: bold; | 121 | font-weight: bold; |
122 | font-size: 125%; | 122 | font-size: 125%; |
123 | margin: 1.5em 0em 0.5em 0em; | 123 | margin: 1.5em 0em 0.5em 0em; |
124 | padding: 0em; | 124 | padding: 0em; |
125 | } | 125 | } |
126 | div.commit-msg { | 126 | div.commit-msg { |
127 | white-space: pre; | 127 | white-space: pre; |
128 | font-family: monospace; | 128 | font-family: monospace; |
129 | } | 129 | } |
130 | table.diffstat { | 130 | table.diffstat { |
131 | border-collapse: collapse; | 131 | border-collapse: collapse; |
132 | margin-top: 1.5em; | 132 | margin-top: 1.5em; |
133 | } | 133 | } |
134 | table.diffstat th { | 134 | table.diffstat th { |
135 | font-weight: normal; | 135 | font-weight: normal; |
136 | text-align: left; | 136 | text-align: left; |
137 | text-decoration: underline; | 137 | text-decoration: underline; |
138 | padding: 0.1em 1em 0.1em 0.1em; | 138 | padding: 0.1em 1em 0.1em 0.1em; |
139 | font-size: 100%; | 139 | font-size: 100%; |
140 | } | 140 | } |
141 | table.diffstat td { | 141 | table.diffstat td { |
142 | padding: 0.1em 1em 0.1em 0.1em; | 142 | padding: 0.1em 1em 0.1em 0.1em; |
143 | font-size: 100%; | 143 | font-size: 100%; |
144 | } | 144 | } |
145 | table.diffstat td span.modechange { | 145 | table.diffstat td span.modechange { |
146 | padding-left: 1em; | 146 | padding-left: 1em; |
147 | color: red; | 147 | color: red; |
148 | } | 148 | } |
149 | table.diffstat td.add a { | 149 | table.diffstat td.add a { |
150 | color: green; | 150 | color: green; |
151 | } | 151 | } |
@@ -28,83 +28,84 @@ struct commitinfo { | |||
28 | }; | 28 | }; |
29 | 29 | ||
30 | extern const char cgit_version[]; | 30 | extern const char cgit_version[]; |
31 | 31 | ||
32 | extern char *cgit_root; | 32 | extern char *cgit_root; |
33 | extern char *cgit_root_title; | 33 | extern char *cgit_root_title; |
34 | extern char *cgit_css; | 34 | extern char *cgit_css; |
35 | extern char *cgit_logo; | 35 | extern char *cgit_logo; |
36 | extern char *cgit_logo_link; | 36 | extern char *cgit_logo_link; |
37 | extern char *cgit_virtual_root; | 37 | extern char *cgit_virtual_root; |
38 | extern char *cgit_cache_root; | 38 | extern char *cgit_cache_root; |
39 | 39 | ||
40 | extern int cgit_nocache; | 40 | extern int cgit_nocache; |
41 | extern int cgit_max_lock_attempts; | 41 | extern int cgit_max_lock_attempts; |
42 | extern int cgit_cache_root_ttl; | 42 | extern int cgit_cache_root_ttl; |
43 | extern int cgit_cache_repo_ttl; | 43 | extern int cgit_cache_repo_ttl; |
44 | extern int cgit_cache_dynamic_ttl; | 44 | extern int cgit_cache_dynamic_ttl; |
45 | extern int cgit_cache_static_ttl; | 45 | extern int cgit_cache_static_ttl; |
46 | extern int cgit_cache_max_create_time; | 46 | extern int cgit_cache_max_create_time; |
47 | 47 | ||
48 | extern char *cgit_repo_name; | 48 | extern char *cgit_repo_name; |
49 | extern char *cgit_repo_desc; | 49 | extern char *cgit_repo_desc; |
50 | extern char *cgit_repo_owner; | 50 | extern char *cgit_repo_owner; |
51 | 51 | ||
52 | extern int cgit_query_has_symref; | 52 | extern int cgit_query_has_symref; |
53 | extern int cgit_query_has_sha1; | 53 | extern int cgit_query_has_sha1; |
54 | 54 | ||
55 | extern char *cgit_querystring; | 55 | extern char *cgit_querystring; |
56 | extern char *cgit_query_repo; | 56 | extern char *cgit_query_repo; |
57 | extern char *cgit_query_page; | 57 | extern char *cgit_query_page; |
58 | extern char *cgit_query_head; | 58 | extern char *cgit_query_head; |
59 | extern char *cgit_query_sha1; | 59 | extern char *cgit_query_sha1; |
60 | extern char *cgit_query_sha2; | 60 | extern char *cgit_query_sha2; |
61 | extern int cgit_query_ofs; | 61 | extern int cgit_query_ofs; |
62 | 62 | ||
63 | extern int htmlfd; | 63 | extern int htmlfd; |
64 | 64 | ||
65 | extern void cgit_global_config_cb(const char *name, const char *value); | 65 | extern void cgit_global_config_cb(const char *name, const char *value); |
66 | extern void cgit_repo_config_cb(const char *name, const char *value); | 66 | extern void cgit_repo_config_cb(const char *name, const char *value); |
67 | extern void cgit_querystring_cb(const char *name, const char *value); | 67 | extern void cgit_querystring_cb(const char *name, const char *value); |
68 | 68 | ||
69 | extern void *cgit_free_commitinfo(struct commitinfo *info); | 69 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
70 | 70 | ||
71 | extern char *fmt(const char *format,...); | 71 | extern char *fmt(const char *format,...); |
72 | 72 | ||
73 | extern void html(const char *txt); | 73 | extern void html(const char *txt); |
74 | extern void htmlf(const char *format,...); | 74 | extern void htmlf(const char *format,...); |
75 | extern void html_txt(char *txt); | 75 | extern void html_txt(char *txt); |
76 | extern void html_ntxt(int len, char *txt); | ||
76 | extern void html_attr(char *txt); | 77 | extern void html_attr(char *txt); |
77 | extern void html_link_open(char *url, char *title, char *class); | 78 | extern void html_link_open(char *url, char *title, char *class); |
78 | extern void html_link_close(void); | 79 | extern void html_link_close(void); |
79 | extern void html_filemode(unsigned short mode); | 80 | extern void html_filemode(unsigned short mode); |
80 | 81 | ||
81 | extern int cgit_read_config(const char *filename, configfn fn); | 82 | extern int cgit_read_config(const char *filename, configfn fn); |
82 | extern int cgit_parse_query(char *txt, configfn fn); | 83 | extern int cgit_parse_query(char *txt, configfn fn); |
83 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 84 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
84 | 85 | ||
85 | extern void cache_prepare(struct cacheitem *item); | 86 | extern void cache_prepare(struct cacheitem *item); |
86 | extern int cache_lock(struct cacheitem *item); | 87 | extern int cache_lock(struct cacheitem *item); |
87 | extern int cache_unlock(struct cacheitem *item); | 88 | extern int cache_unlock(struct cacheitem *item); |
88 | extern int cache_cancel_lock(struct cacheitem *item); | 89 | extern int cache_cancel_lock(struct cacheitem *item); |
89 | extern int cache_exist(struct cacheitem *item); | 90 | extern int cache_exist(struct cacheitem *item); |
90 | extern int cache_expired(struct cacheitem *item); | 91 | extern int cache_expired(struct cacheitem *item); |
91 | 92 | ||
92 | extern char *cgit_repourl(const char *reponame); | 93 | extern char *cgit_repourl(const char *reponame); |
93 | extern char *cgit_pageurl(const char *reponame, const char *pagename, | 94 | extern char *cgit_pageurl(const char *reponame, const char *pagename, |
94 | const char *query); | 95 | const char *query); |
95 | 96 | ||
96 | extern void cgit_print_error(char *msg); | 97 | extern void cgit_print_error(char *msg); |
97 | extern void cgit_print_date(unsigned long secs); | 98 | extern void cgit_print_date(unsigned long secs); |
98 | extern void cgit_print_docstart(char *title, struct cacheitem *item); | 99 | extern void cgit_print_docstart(char *title, struct cacheitem *item); |
99 | extern void cgit_print_docend(); | 100 | extern void cgit_print_docend(); |
100 | extern void cgit_print_pageheader(char *title); | 101 | extern void cgit_print_pageheader(char *title); |
101 | 102 | ||
102 | extern void cgit_print_repolist(struct cacheitem *item); | 103 | extern void cgit_print_repolist(struct cacheitem *item); |
103 | extern void cgit_print_summary(); | 104 | extern void cgit_print_summary(); |
104 | extern void cgit_print_log(const char *tip, int ofs, int cnt); | 105 | extern void cgit_print_log(const char *tip, int ofs, int cnt); |
105 | extern void cgit_print_view(const char *hex); | 106 | extern void cgit_print_view(const char *hex); |
106 | extern void cgit_print_tree(const char *hex); | 107 | extern void cgit_print_tree(const char *hex); |
107 | extern void cgit_print_commit(const char *hex); | 108 | extern void cgit_print_commit(const char *hex); |
108 | extern void cgit_print_diff(const char *old_hex, const char *new_hex); | 109 | extern void cgit_print_diff(const char *old_hex, const char *new_hex); |
109 | 110 | ||
110 | #endif /* CGIT_H */ | 111 | #endif /* CGIT_H */ |
@@ -20,96 +20,124 @@ char *fmt(const char *format, ...) | |||
20 | 20 | ||
21 | va_start(args, format); | 21 | va_start(args, format); |
22 | len = vsnprintf(buf[bufidx], sizeof(buf[bufidx]), format, args); | 22 | len = vsnprintf(buf[bufidx], sizeof(buf[bufidx]), format, args); |
23 | va_end(args); | 23 | va_end(args); |
24 | if (len>sizeof(buf[bufidx])) | 24 | if (len>sizeof(buf[bufidx])) |
25 | die("[html.c] string truncated: %s", format); | 25 | die("[html.c] string truncated: %s", format); |
26 | return buf[bufidx]; | 26 | return buf[bufidx]; |
27 | } | 27 | } |
28 | 28 | ||
29 | void html(const char *txt) | 29 | void html(const char *txt) |
30 | { | 30 | { |
31 | write(htmlfd, txt, strlen(txt)); | 31 | write(htmlfd, txt, strlen(txt)); |
32 | } | 32 | } |
33 | 33 | ||
34 | void htmlf(const char *format, ...) | 34 | void htmlf(const char *format, ...) |
35 | { | 35 | { |
36 | static char buf[65536]; | 36 | static char buf[65536]; |
37 | va_list args; | 37 | va_list args; |
38 | 38 | ||
39 | va_start(args, format); | 39 | va_start(args, format); |
40 | vsnprintf(buf, sizeof(buf), format, args); | 40 | vsnprintf(buf, sizeof(buf), format, args); |
41 | va_end(args); | 41 | va_end(args); |
42 | html(buf); | 42 | html(buf); |
43 | } | 43 | } |
44 | 44 | ||
45 | void html_txt(char *txt) | 45 | void html_txt(char *txt) |
46 | { | 46 | { |
47 | char *t = txt; | 47 | char *t = txt; |
48 | while(*t){ | 48 | while(*t){ |
49 | int c = *t; | 49 | int c = *t; |
50 | if (c=='<' || c=='>' || c=='&') { | 50 | if (c=='<' || c=='>' || c=='&') { |
51 | *t = '\0'; | 51 | *t = '\0'; |
52 | html(txt); | 52 | html(txt); |
53 | *t = c; | 53 | *t = c; |
54 | if (c=='>') | 54 | if (c=='>') |
55 | html(">"); | 55 | html(">"); |
56 | else if (c=='<') | 56 | else if (c=='<') |
57 | html("<"); | 57 | html("<"); |
58 | else if (c=='&') | 58 | else if (c=='&') |
59 | html("&"); | 59 | html("&"); |
60 | txt = t+1; | 60 | txt = t+1; |
61 | } | 61 | } |
62 | t++; | 62 | t++; |
63 | } | 63 | } |
64 | if (t!=txt) | 64 | if (t!=txt) |
65 | html(txt); | 65 | html(txt); |
66 | } | 66 | } |
67 | 67 | ||
68 | void html_ntxt(int len, char *txt) | ||
69 | { | ||
70 | char *t = txt; | ||
71 | while(*t && len--){ | ||
72 | int c = *t; | ||
73 | if (c=='<' || c=='>' || c=='&') { | ||
74 | *t = '\0'; | ||
75 | html(txt); | ||
76 | *t = c; | ||
77 | if (c=='>') | ||
78 | html(">"); | ||
79 | else if (c=='<') | ||
80 | html("<"); | ||
81 | else if (c=='&') | ||
82 | html("&"); | ||
83 | txt = t+1; | ||
84 | } | ||
85 | t++; | ||
86 | } | ||
87 | if (t!=txt) { | ||
88 | char c = *t; | ||
89 | *t = '\0'; | ||
90 | html(txt); | ||
91 | *t = c; | ||
92 | } | ||
93 | if (len<0) | ||
94 | html("..."); | ||
95 | } | ||
68 | 96 | ||
69 | void html_attr(char *txt) | 97 | void html_attr(char *txt) |
70 | { | 98 | { |
71 | char *t = txt; | 99 | char *t = txt; |
72 | while(*t){ | 100 | while(*t){ |
73 | int c = *t; | 101 | int c = *t; |
74 | if (c=='<' || c=='>' || c=='\'') { | 102 | if (c=='<' || c=='>' || c=='\'') { |
75 | *t = '\0'; | 103 | *t = '\0'; |
76 | html(txt); | 104 | html(txt); |
77 | *t = c; | 105 | *t = c; |
78 | if (c=='>') | 106 | if (c=='>') |
79 | html(">"); | 107 | html(">"); |
80 | else if (c=='<') | 108 | else if (c=='<') |
81 | html("<"); | 109 | html("<"); |
82 | else if (c=='\'') | 110 | else if (c=='\'') |
83 | html(""e;"); | 111 | html(""e;"); |
84 | txt = t+1; | 112 | txt = t+1; |
85 | } | 113 | } |
86 | t++; | 114 | t++; |
87 | } | 115 | } |
88 | if (t!=txt) | 116 | if (t!=txt) |
89 | html(txt); | 117 | html(txt); |
90 | } | 118 | } |
91 | 119 | ||
92 | void html_link_open(char *url, char *title, char *class) | 120 | void html_link_open(char *url, char *title, char *class) |
93 | { | 121 | { |
94 | html("<a href='"); | 122 | html("<a href='"); |
95 | html_attr(url); | 123 | html_attr(url); |
96 | if (title) { | 124 | if (title) { |
97 | html("' title='"); | 125 | html("' title='"); |
98 | html_attr(title); | 126 | html_attr(title); |
99 | } | 127 | } |
100 | if (class) { | 128 | if (class) { |
101 | html("' class='"); | 129 | html("' class='"); |
102 | html_attr(class); | 130 | html_attr(class); |
103 | } | 131 | } |
104 | html("'>"); | 132 | html("'>"); |
105 | } | 133 | } |
106 | 134 | ||
107 | void html_link_close(void) | 135 | void html_link_close(void) |
108 | { | 136 | { |
109 | html("</a>"); | 137 | html("</a>"); |
110 | } | 138 | } |
111 | 139 | ||
112 | void html_fileperm(unsigned short mode) | 140 | void html_fileperm(unsigned short mode) |
113 | { | 141 | { |
114 | htmlf("%c%c%c", (mode & 4 ? 'r' : '-'), | 142 | htmlf("%c%c%c", (mode & 4 ? 'r' : '-'), |
115 | (mode & 2 ? 'w' : '-'), (mode & 1 ? 'x' : '-')); | 143 | (mode & 2 ? 'w' : '-'), (mode & 1 ? 'x' : '-')); |
@@ -1,91 +1,91 @@ | |||
1 | /* ui-log.c: functions for log output | 1 | /* ui-log.c: functions for log output |
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 | 10 | ||
11 | void print_commit(struct commit *commit) | 11 | void print_commit(struct commit *commit) |
12 | { | 12 | { |
13 | char buf[32]; | 13 | char buf[32]; |
14 | struct commitinfo *info; | 14 | struct commitinfo *info; |
15 | struct tm *time; | 15 | struct tm *time; |
16 | 16 | ||
17 | info = cgit_parse_commit(commit); | 17 | info = cgit_parse_commit(commit); |
18 | time = gmtime(&commit->date); | 18 | time = gmtime(&commit->date); |
19 | html("<tr><td>"); | 19 | html("<tr><td>"); |
20 | strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); | 20 | strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); |
21 | html_txt(buf); | 21 | html_txt(buf); |
22 | html("</td><td>"); | 22 | html("</td><td>"); |
23 | char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); | 23 | char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); |
24 | char *url = cgit_pageurl(cgit_query_repo, "commit", qry); | 24 | char *url = cgit_pageurl(cgit_query_repo, "commit", qry); |
25 | html_link_open(url, NULL, NULL); | 25 | html_link_open(url, NULL, NULL); |
26 | html_txt(info->subject); | 26 | html_ntxt(80, info->subject); |
27 | html_link_close(); | 27 | html_link_close(); |
28 | html("</td><td>"); | 28 | html("</td><td>"); |
29 | html_txt(info->author); | 29 | html_txt(info->author); |
30 | html("</td></tr>\n"); | 30 | html("</td></tr>\n"); |
31 | cgit_free_commitinfo(info); | 31 | cgit_free_commitinfo(info); |
32 | } | 32 | } |
33 | 33 | ||
34 | 34 | ||
35 | void cgit_print_log(const char *tip, int ofs, int cnt) | 35 | void cgit_print_log(const char *tip, int ofs, int cnt) |
36 | { | 36 | { |
37 | struct rev_info rev; | 37 | struct rev_info rev; |
38 | struct commit *commit; | 38 | struct commit *commit; |
39 | const char *argv[2] = {NULL, tip}; | 39 | const char *argv[2] = {NULL, tip}; |
40 | int i; | 40 | int i; |
41 | 41 | ||
42 | init_revisions(&rev, NULL); | 42 | init_revisions(&rev, NULL); |
43 | rev.abbrev = DEFAULT_ABBREV; | 43 | rev.abbrev = DEFAULT_ABBREV; |
44 | rev.commit_format = CMIT_FMT_DEFAULT; | 44 | rev.commit_format = CMIT_FMT_DEFAULT; |
45 | rev.verbose_header = 1; | 45 | rev.verbose_header = 1; |
46 | rev.show_root_diff = 0; | 46 | rev.show_root_diff = 0; |
47 | setup_revisions(2, argv, &rev, NULL); | 47 | setup_revisions(2, argv, &rev, NULL); |
48 | prepare_revision_walk(&rev); | 48 | prepare_revision_walk(&rev); |
49 | 49 | ||
50 | html("<h2>Log</h2>"); | 50 | html("<h2>Log</h2>"); |
51 | html("<table class='list log'>"); | 51 | html("<table class='list nowrap'>"); |
52 | html("<tr><th class='left'>Date</th>" | 52 | html("<tr><th class='left'>Date</th>" |
53 | "<th class='left'>Message</th>" | 53 | "<th class='left'>Message</th>" |
54 | "<th class='left'>Author</th></tr>\n"); | 54 | "<th class='left'>Author</th></tr>\n"); |
55 | 55 | ||
56 | if (ofs<0) | 56 | if (ofs<0) |
57 | ofs = 0; | 57 | ofs = 0; |
58 | 58 | ||
59 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { | 59 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
60 | free(commit->buffer); | 60 | free(commit->buffer); |
61 | commit->buffer = NULL; | 61 | commit->buffer = NULL; |
62 | free_commit_list(commit->parents); | 62 | free_commit_list(commit->parents); |
63 | commit->parents = NULL; | 63 | commit->parents = NULL; |
64 | } | 64 | } |
65 | 65 | ||
66 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { | 66 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { |
67 | print_commit(commit); | 67 | print_commit(commit); |
68 | free(commit->buffer); | 68 | free(commit->buffer); |
69 | commit->buffer = NULL; | 69 | commit->buffer = NULL; |
70 | free_commit_list(commit->parents); | 70 | free_commit_list(commit->parents); |
71 | commit->parents = NULL; | 71 | commit->parents = NULL; |
72 | } | 72 | } |
73 | html("</table>\n"); | 73 | html("</table>\n"); |
74 | 74 | ||
75 | html("<div class='pager'>"); | 75 | html("<div class='pager'>"); |
76 | if (ofs > 0) { | 76 | if (ofs > 0) { |
77 | html(" <a href='"); | 77 | html(" <a href='"); |
78 | html(cgit_pageurl(cgit_query_repo, cgit_query_page, | 78 | html(cgit_pageurl(cgit_query_repo, cgit_query_page, |
79 | fmt("h=%s&ofs=%d", tip, ofs-cnt))); | 79 | fmt("h=%s&ofs=%d", tip, ofs-cnt))); |
80 | html("'>[prev]</a> "); | 80 | html("'>[prev]</a> "); |
81 | } | 81 | } |
82 | 82 | ||
83 | if ((commit = get_revision(&rev)) != NULL) { | 83 | if ((commit = get_revision(&rev)) != NULL) { |
84 | html(" <a href='"); | 84 | html(" <a href='"); |
85 | html(cgit_pageurl(cgit_query_repo, "log", | 85 | html(cgit_pageurl(cgit_query_repo, "log", |
86 | fmt("h=%s&ofs=%d", tip, ofs+cnt))); | 86 | fmt("h=%s&ofs=%d", tip, ofs+cnt))); |
87 | html("'>[next]</a> "); | 87 | html("'>[next]</a> "); |
88 | } | 88 | } |
89 | html("</div>"); | 89 | html("</div>"); |
90 | } | 90 | } |
91 | 91 | ||
diff --git a/ui-summary.c b/ui-summary.c index 638c8f6..de95053 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -1,67 +1,67 @@ | |||
1 | /* ui-summary.c: functions for generating repo summary page | 1 | /* ui-summary.c: functions for generating repo summary 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 | 10 | ||
11 | static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, | 11 | static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, |
12 | int flags, void *cb_data) | 12 | int flags, void *cb_data) |
13 | { | 13 | { |
14 | struct commit *commit; | 14 | struct commit *commit; |
15 | struct commitinfo *info; | 15 | struct commitinfo *info; |
16 | char buf[256], *url; | 16 | char buf[256], *url; |
17 | 17 | ||
18 | commit = lookup_commit(sha1); | 18 | commit = lookup_commit(sha1); |
19 | if (commit && !parse_commit(commit)){ | 19 | if (commit && !parse_commit(commit)){ |
20 | info = cgit_parse_commit(commit); | 20 | info = cgit_parse_commit(commit); |
21 | html("<tr><td>"); | 21 | html("<tr><td>"); |
22 | url = cgit_pageurl(cgit_query_repo, "log", | 22 | url = cgit_pageurl(cgit_query_repo, "log", |
23 | fmt("h=%s", refname)); | 23 | fmt("h=%s", refname)); |
24 | html_link_open(url, NULL, NULL); | 24 | html_link_open(url, NULL, NULL); |
25 | strncpy(buf, refname, sizeof(buf)); | 25 | strncpy(buf, refname, sizeof(buf)); |
26 | html_txt(buf); | 26 | html_txt(buf); |
27 | html_link_close(); | 27 | html_link_close(); |
28 | html("</td><td>"); | 28 | html("</td><td>"); |
29 | cgit_print_date(commit->date); | 29 | cgit_print_date(commit->date); |
30 | html("</td><td>"); | 30 | html("</td><td>"); |
31 | url = cgit_pageurl(cgit_query_repo, "commit", | 31 | url = cgit_pageurl(cgit_query_repo, "commit", |
32 | fmt("id=%s", sha1_to_hex(sha1))); | 32 | fmt("id=%s", sha1_to_hex(sha1))); |
33 | html_link_open(url, NULL, NULL); | 33 | html_link_open(url, NULL, NULL); |
34 | html_txt(info->subject); | 34 | html_ntxt(80, info->subject); |
35 | html_link_close(); | 35 | html_link_close(); |
36 | html("</td><td>"); | 36 | html("</td><td>"); |
37 | html_txt(info->author); | 37 | html_txt(info->author); |
38 | html("</td></tr>\n"); | 38 | html("</td></tr>\n"); |
39 | cgit_free_commitinfo(info); | 39 | cgit_free_commitinfo(info); |
40 | } else { | 40 | } else { |
41 | html("<tr><td>"); | 41 | html("<tr><td>"); |
42 | html_txt(buf); | 42 | html_txt(buf); |
43 | html("</td><td>"); | 43 | html("</td><td>"); |
44 | htmlf("*** bad ref %s", sha1_to_hex(sha1)); | 44 | htmlf("*** bad ref %s", sha1_to_hex(sha1)); |
45 | html("</td></tr>\n"); | 45 | html("</td></tr>\n"); |
46 | } | 46 | } |
47 | return 0; | 47 | return 0; |
48 | } | 48 | } |
49 | 49 | ||
50 | static void cgit_print_branches() | 50 | static void cgit_print_branches() |
51 | { | 51 | { |
52 | html("<table class='list'>"); | 52 | html("<table class='list nowrap'>"); |
53 | html("<tr><th class='left'>Branch</th>" | 53 | html("<tr><th class='left'>Branch</th>" |
54 | "<th class='left'>Updated</th>" | 54 | "<th class='left'>Updated</th>" |
55 | "<th class='left'>Commit subject</th>" | 55 | "<th class='left'>Commit subject</th>" |
56 | "<th class='left'>Author</th></tr>\n"); | 56 | "<th class='left'>Author</th></tr>\n"); |
57 | for_each_branch_ref(cgit_print_branch_cb, NULL); | 57 | for_each_branch_ref(cgit_print_branch_cb, NULL); |
58 | html("</table>"); | 58 | html("</table>"); |
59 | } | 59 | } |
60 | 60 | ||
61 | void cgit_print_summary() | 61 | void cgit_print_summary() |
62 | { | 62 | { |
63 | html("<h2>"); | 63 | html("<h2>"); |
64 | html_txt("Repo summary page"); | 64 | html_txt("Repo summary page"); |
65 | html("</h2>"); | 65 | html("</h2>"); |
66 | cgit_print_branches(); | 66 | cgit_print_branches(); |
67 | } | 67 | } |