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) (side-by-side diff)
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)
}
cgit_print_pageheader(cgit_query_page, show_search);
if (!strcmp(cgit_query_page, "log")) {
cgit_print_log(cgit_query_head, cgit_query_ofs, 100,
cgit_query_search);
} else if (!strcmp(cgit_query_page, "tree")) {
cgit_print_tree(cgit_query_sha1, cgit_query_path);
} else if (!strcmp(cgit_query_page, "commit")) {
cgit_print_commit(cgit_query_sha1);
} else if (!strcmp(cgit_query_page, "view")) {
- cgit_print_view(cgit_query_sha1);
+ cgit_print_view(cgit_query_sha1, cgit_query_path);
} else if (!strcmp(cgit_query_page, "diff")) {
cgit_print_diff(cgit_query_sha1, cgit_query_sha2);
} else {
cgit_print_error("Invalid request");
}
cgit_print_docend();
}
static void cgit_fill_cache(struct cacheitem *item, int use_cache)
{
static char buf[PATH_MAX];
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,
extern void cgit_print_error(char *msg);
extern void cgit_print_date(unsigned long secs);
extern void cgit_print_docstart(char *title, struct cacheitem *item);
extern void cgit_print_docend();
extern void cgit_print_pageheader(char *title, int show_search);
extern void cgit_print_snapshot_start(const char *mimetype,
const char *filename,
struct cacheitem *item);
extern void cgit_print_repolist(struct cacheitem *item);
extern void cgit_print_summary();
extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep);
-extern void cgit_print_view(const char *hex);
+extern void cgit_print_view(const char *hex, char *path);
extern void cgit_print_tree(const char *hex, char *path);
extern void cgit_print_commit(const char *hex);
extern void cgit_print_diff(const char *old_hex, const char *new_hex);
extern void cgit_print_snapshot(struct cacheitem *item, const char *hex,
const char *format, const char *prefix,
const char *filename);
#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 @@
/* ui-view.c: functions to output _any_ object, given it's sha1
*
* Copyright (C) 2006 Lars Hjemli
*
* Licensed under GNU General Public License v2
* (see COPYING for full license text)
*/
#include "cgit.h"
-void cgit_print_view(const char *hex)
+void cgit_print_view(const char *hex, char *path)
{
unsigned char sha1[20];
enum object_type type;
unsigned char *buf;
unsigned long size;
if (get_sha1_hex(hex, sha1)){
cgit_print_error(fmt("Bad hex value: %s", hex));
return;
}
type = sha1_object_info(sha1, &size);
@@ -25,19 +25,24 @@ void cgit_print_view(const char *hex)
cgit_print_error(fmt("Bad object name: %s", hex));
return;
}
buf = read_sha1_file(sha1, &type, &size);
if (!buf) {
cgit_print_error(fmt("Error reading object %s", hex));
return;
}
buf[size] = '\0';
html("<table class='list'>\n");
- htmlf("<tr class='nohover'><th class='left'>%s %s, %li bytes</th></tr>\n",
- typename(type), hex, size);
+ html("<tr class='nohover'><th class='left'>");
+ if (path)
+ htmlf("%s (", path);
+ htmlf("%s %s, %li bytes", typename(type), hex, size);
+ if (path)
+ html(")");
+ html("</th></tr>\n");
html("<tr><td class='blob'>\n");
html_txt(buf);
html("\n</td></tr>\n");
html("</table>\n");
}