summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.h2
-rw-r--r--ui-repolist.c4
-rw-r--r--ui-shared.c20
-rw-r--r--ui-summary.c6
-rw-r--r--ui-tree.c12
5 files changed, 24 insertions, 20 deletions
diff --git a/cgit.h b/cgit.h
index 9a19c97..b2f6361 100644
--- a/cgit.h
+++ b/cgit.h
@@ -190,32 +190,34 @@ extern struct commitinfo *cgit_parse_commit(struct commit *commit);
extern struct taginfo *cgit_parse_tag(struct tag *tag);
extern void cgit_parse_url(const char *url);
extern char *cache_safe_filename(const char *unsafe);
extern int cache_lock(struct cacheitem *item);
extern int cache_unlock(struct cacheitem *item);
extern int cache_cancel_lock(struct cacheitem *item);
extern int cache_exist(struct cacheitem *item);
extern int cache_expired(struct cacheitem *item);
extern char *cgit_repourl(const char *reponame);
extern char *cgit_pageurl(const char *reponame, const char *pagename,
const char *query);
extern void cgit_tree_link(char *name, char *title, char *class, char *head,
char *rev, char *path);
+extern void cgit_log_link(char *name, char *title, char *class, char *head,
+ char *rev, char *path);
extern void cgit_print_error(char *msg);
extern void cgit_print_date(time_t secs, char *format);
extern void cgit_print_age(time_t t, time_t max_relative, char *format);
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, char *path, int pager);
extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path);
extern void cgit_print_tree(const char *rev, char *path);
diff --git a/ui-repolist.c b/ui-repolist.c
index 8ade91a..2018dab 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -76,25 +76,23 @@ void cgit_print_repolist(struct cacheitem *item)
}
htmlf("<tr><td class='%s'>",
cgit_repo->group ? "sublevel-repo" : "toplevel-repo");
html_link_open(cgit_repourl(cgit_repo->url), NULL, NULL);
html_txt(cgit_repo->name);
html_link_close();
html("</td><td>");
html_ntxt(cgit_max_repodesc_len, cgit_repo->desc);
html("</td><td>");
html_txt(cgit_repo->owner);
html("</td><td>");
print_modtime(cgit_repo);
html("</td><td>");
html_link_open(cgit_repourl(cgit_repo->url),
"Summary", "button");
html("S</a>");
- html_link_open(cgit_pageurl(cgit_repo->name, "log", NULL),
- "Log", "button");
- html("L</a>");
+ cgit_log_link("L", "Log", "button", NULL, NULL, NULL);
cgit_tree_link("F", "Files", "button", NULL, NULL, NULL);
html("</td></tr>\n");
}
html("</table>");
cgit_print_docend();
}
diff --git a/ui-shared.c b/ui-shared.c
index 657e8af..64ee79c 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -114,57 +114,69 @@ static char *repolink(char *title, char *class, char *page, char *head,
html(page);
html("/");
if (path)
html_attr(path);
} else {
html(cgit_script_name);
html("?url=");
html_attr(cgit_repo->url);
if (cgit_repo->url[strlen(cgit_repo->url) - 1] != '/')
html("/");
html(page);
html("/");
if (path)
html_attr(path);
delim = "&amp;";
}
- if (head && strcmp(head, cgit_query_head)) {
+ if (head && strcmp(head, cgit_repo->defbranch)) {
html(delim);
html("h=");
html_attr(head);
delim = "&amp;";
}
return fmt("%s", delim);
}
-void cgit_tree_link(char *name, char *title, char *class, char *head,
- char *rev, char *path)
+static char *reporevlink(char *page, char *name, char *title, char *class,
+ char *head, char *rev, char *path)
{
char *delim;
- delim = repolink(title, class, "tree", head, path);
+ delim = repolink(title, class, page, head, path);
if (rev && strcmp(rev, cgit_query_head)) {
html(delim);
html("id=");
html_attr(rev);
}
html("'>");
html_txt(name);
html("</a>");
}
+void cgit_tree_link(char *name, char *title, char *class, char *head,
+ char *rev, char *path)
+{
+ reporevlink("tree", name, title, class, head, rev, path);
+}
+
+void cgit_log_link(char *name, char *title, char *class, char *head,
+ char *rev, char *path)
+{
+ reporevlink("log", name, title, class, head, rev, path);
+}
+
void cgit_print_date(time_t secs, char *format)
{
char buf[64];
struct tm *time;
time = gmtime(&secs);
strftime(buf, sizeof(buf)-1, format, time);
html_txt(buf);
}
void cgit_print_age(time_t t, time_t max_relative, char *format)
{
time_t now, secs;
time(&now);
secs = now - t;
diff --git a/ui-summary.c b/ui-summary.c
index 4bda4c2..29b76e3 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -12,37 +12,33 @@ static int header;
static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
int flags, void *cb_data)
{
struct commit *commit;
struct commitinfo *info;
char buf[256], *url;
strncpy(buf, refname, sizeof(buf));
commit = lookup_commit(sha1);
// object is not really parsed at this point, because of some fallout
// from previous calls to git functions in cgit_print_log()
commit->object.parsed = 0;
if (commit && !parse_commit(commit)){
info = cgit_parse_commit(commit);
html("<tr><td>");
- url = cgit_pageurl(cgit_query_repo, "log",
- fmt("h=%s", refname));
- html_link_open(url, NULL, NULL);
- html_txt(buf);
- html_link_close();
+ cgit_log_link(refname, NULL, NULL, refname, NULL, NULL);
html("</td><td>");
cgit_print_age(commit->date, -1, NULL);
html("</td><td>");
html_txt(info->author);
html("</td><td>");
url = cgit_pageurl(cgit_query_repo, "commit",
fmt("h=%s", sha1_to_hex(sha1)));
html_link_open(url, NULL, NULL);
html_ntxt(cgit_max_msg_len, info->subject);
html_link_close();
html("</td></tr>\n");
cgit_free_commitinfo(info);
} else {
html("<tr><td>");
html_txt(buf);
html("</td><td colspan='3'>");
diff --git a/ui-tree.c b/ui-tree.c
index d503bee..e16b638 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -79,40 +79,36 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
htmlf("<a class='ls-mod' href='");
html_attr(fmt(cgit_repo->module_link,
name,
sha1_to_hex(sha1)));
html("'>");
html_txt(name);
html("</a>");
} else if (S_ISDIR(mode)) {
cgit_tree_link(name, NULL, "ls-dir", cgit_query_head,
curr_rev, fullpath);
} else {
cgit_tree_link(name, NULL, "ls-blob", cgit_query_head,
curr_rev, fullpath);
}
htmlf("</td><td class='ls-size'>%li</td>", size);
- html("<td><a href='");
- qry = fmt("h=%s&amp;path=%s%s%s", curr_rev,
- cgit_query_path ? cgit_query_path : "",
- cgit_query_path ? "/" : "", pathname);
- url = cgit_pageurl(cgit_query_repo, "log", qry);
- html_attr(url);
- html("' title='Log' class='button'>L</a></td>");
- html("</tr>\n");
+ html("<td>");
+ cgit_log_link("L", "Log", "button", cgit_query_head, curr_rev,
+ fullpath);
+ html("</td></tr>\n");
free(name);
return 0;
}
static void ls_head()
{
html("<table class='list'>\n");
html("<tr class='nohover'>");
html("<th class='left'>Mode</th>");
html("<th class='left'>Name</th>");
html("<th class='right'>Size</th>");
html("<th/>");
html("</tr>\n");
header = 1;
}