summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2007-05-08 21:52:56 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-05-08 21:52:56 (UTC)
commit7250a154678477a1e8260efbc9810ec389754ef9 (patch) (unidiff)
tree519559a2f9238fc386b7715c55bc3e2326be8d54
parent61c3ca978c586c673aec618cb94210657278dda8 (diff)
downloadcgit-7250a154678477a1e8260efbc9810ec389754ef9.zip
cgit-7250a154678477a1e8260efbc9810ec389754ef9.tar.gz
cgit-7250a154678477a1e8260efbc9810ec389754ef9.tar.bz2
ui-view: show pathname if specified in querystring
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.c2
-rw-r--r--cgit.h2
-rw-r--r--ui-view.c11
3 files changed, 10 insertions, 5 deletions
diff --git a/cgit.c b/cgit.c
index fedf355..6dddcbb 100644
--- a/cgit.c
+++ b/cgit.c
@@ -100,25 +100,25 @@ static void cgit_print_repo_page(struct cacheitem *item)
100 } 100 }
101 101
102 cgit_print_pageheader(cgit_query_page, show_search); 102 cgit_print_pageheader(cgit_query_page, show_search);
103 103
104 if (!strcmp(cgit_query_page, "log")) { 104 if (!strcmp(cgit_query_page, "log")) {
105 cgit_print_log(cgit_query_head, cgit_query_ofs, 100, 105 cgit_print_log(cgit_query_head, cgit_query_ofs, 100,
106 cgit_query_search); 106 cgit_query_search);
107 } else if (!strcmp(cgit_query_page, "tree")) { 107 } else if (!strcmp(cgit_query_page, "tree")) {
108 cgit_print_tree(cgit_query_sha1, cgit_query_path); 108 cgit_print_tree(cgit_query_sha1, cgit_query_path);
109 } else if (!strcmp(cgit_query_page, "commit")) { 109 } else if (!strcmp(cgit_query_page, "commit")) {
110 cgit_print_commit(cgit_query_sha1); 110 cgit_print_commit(cgit_query_sha1);
111 } else if (!strcmp(cgit_query_page, "view")) { 111 } else if (!strcmp(cgit_query_page, "view")) {
112 cgit_print_view(cgit_query_sha1); 112 cgit_print_view(cgit_query_sha1, cgit_query_path);
113 } else if (!strcmp(cgit_query_page, "diff")) { 113 } else if (!strcmp(cgit_query_page, "diff")) {
114 cgit_print_diff(cgit_query_sha1, cgit_query_sha2); 114 cgit_print_diff(cgit_query_sha1, cgit_query_sha2);
115 } else { 115 } else {
116 cgit_print_error("Invalid request"); 116 cgit_print_error("Invalid request");
117 } 117 }
118 cgit_print_docend(); 118 cgit_print_docend();
119} 119}
120 120
121static void cgit_fill_cache(struct cacheitem *item, int use_cache) 121static void cgit_fill_cache(struct cacheitem *item, int use_cache)
122{ 122{
123 static char buf[PATH_MAX]; 123 static char buf[PATH_MAX];
124 int stdout2; 124 int stdout2;
diff --git a/cgit.h b/cgit.h
index 222c9c2..2615231 100644
--- a/cgit.h
+++ b/cgit.h
@@ -146,21 +146,21 @@ extern char *cgit_pageurl(const char *reponame, const char *pagename,
146extern void cgit_print_error(char *msg); 146extern void cgit_print_error(char *msg);
147extern void cgit_print_date(unsigned long secs); 147extern void cgit_print_date(unsigned long secs);
148extern void cgit_print_docstart(char *title, struct cacheitem *item); 148extern void cgit_print_docstart(char *title, struct cacheitem *item);
149extern void cgit_print_docend(); 149extern void cgit_print_docend();
150extern void cgit_print_pageheader(char *title, int show_search); 150extern void cgit_print_pageheader(char *title, int show_search);
151extern void cgit_print_snapshot_start(const char *mimetype, 151extern void cgit_print_snapshot_start(const char *mimetype,
152 const char *filename, 152 const char *filename,
153 struct cacheitem *item); 153 struct cacheitem *item);
154 154
155extern void cgit_print_repolist(struct cacheitem *item); 155extern void cgit_print_repolist(struct cacheitem *item);
156extern void cgit_print_summary(); 156extern void cgit_print_summary();
157extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep); 157extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep);
158extern void cgit_print_view(const char *hex); 158extern void cgit_print_view(const char *hex, char *path);
159extern void cgit_print_tree(const char *hex, char *path); 159extern void cgit_print_tree(const char *hex, char *path);
160extern void cgit_print_commit(const char *hex); 160extern void cgit_print_commit(const char *hex);
161extern void cgit_print_diff(const char *old_hex, const char *new_hex); 161extern void cgit_print_diff(const char *old_hex, const char *new_hex);
162extern void cgit_print_snapshot(struct cacheitem *item, const char *hex, 162extern void cgit_print_snapshot(struct cacheitem *item, const char *hex,
163 const char *format, const char *prefix, 163 const char *format, const char *prefix,
164 const char *filename); 164 const char *filename);
165 165
166#endif /* CGIT_H */ 166#endif /* CGIT_H */
diff --git a/ui-view.c b/ui-view.c
index 9d23c45..7d022fd 100644
--- a/ui-view.c
+++ b/ui-view.c
@@ -1,23 +1,23 @@
1/* ui-view.c: functions to output _any_ object, given it's sha1 1/* ui-view.c: functions to output _any_ object, given it's sha1
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
11void cgit_print_view(const char *hex) 11void cgit_print_view(const char *hex, char *path)
12{ 12{
13 unsigned char sha1[20]; 13 unsigned char sha1[20];
14 enum object_type type; 14 enum object_type type;
15 unsigned char *buf; 15 unsigned char *buf;
16 unsigned long size; 16 unsigned long size;
17 17
18 if (get_sha1_hex(hex, sha1)){ 18 if (get_sha1_hex(hex, sha1)){
19 cgit_print_error(fmt("Bad hex value: %s", hex)); 19 cgit_print_error(fmt("Bad hex value: %s", hex));
20 return; 20 return;
21 } 21 }
22 22
23 type = sha1_object_info(sha1, &size); 23 type = sha1_object_info(sha1, &size);
@@ -25,19 +25,24 @@ void cgit_print_view(const char *hex)
25 cgit_print_error(fmt("Bad object name: %s", hex)); 25 cgit_print_error(fmt("Bad object name: %s", hex));
26 return; 26 return;
27 } 27 }
28 28
29 buf = read_sha1_file(sha1, &type, &size); 29 buf = read_sha1_file(sha1, &type, &size);
30 if (!buf) { 30 if (!buf) {
31 cgit_print_error(fmt("Error reading object %s", hex)); 31 cgit_print_error(fmt("Error reading object %s", hex));
32 return; 32 return;
33 } 33 }
34 34
35 buf[size] = '\0'; 35 buf[size] = '\0';
36 html("<table class='list'>\n"); 36 html("<table class='list'>\n");
37 htmlf("<tr class='nohover'><th class='left'>%s %s, %li bytes</th></tr>\n", 37 html("<tr class='nohover'><th class='left'>");
38 typename(type), hex, size); 38 if (path)
39 htmlf("%s (", path);
40 htmlf("%s %s, %li bytes", typename(type), hex, size);
41 if (path)
42 html(")");
43 html("</th></tr>\n");
39 html("<tr><td class='blob'>\n"); 44 html("<tr><td class='blob'>\n");
40 html_txt(buf); 45 html_txt(buf);
41 html("\n</td></tr>\n"); 46 html("\n</td></tr>\n");
42 html("</table>\n"); 47 html("</table>\n");
43} 48}