]> git.cameronkatri.com Git - cgit.git/blobdiff - ui-commit.c
Add ui-shared.h
[cgit.git] / ui-commit.c
index bf5e6dca6451b0f6a87d97695bad681850b7858f..8019e3608f0fd35911024d2b8294e61e864831a2 100644 (file)
@@ -7,6 +7,8 @@
  */
 
 #include "cgit.h"
+#include "html.h"
+#include "ui-shared.h"
 
 static int files, slots;
 static int total_adds, total_rems, max_changes;
@@ -62,21 +64,21 @@ void print_fileinfo(struct fileinfo *info)
        html("<tr>");
        htmlf("<td class='mode'>");
        if (is_null_sha1(info->new_sha1)) {
-               html_filemode(info->old_mode);
+               cgit_print_filemode(info->old_mode);
        } else {
-               html_filemode(info->new_mode);
+               cgit_print_filemode(info->new_mode);
        }
 
        if (info->old_mode != info->new_mode &&
            !is_null_sha1(info->old_sha1) &&
            !is_null_sha1(info->new_sha1)) {
                html("<span class='modechange'>[");
-               html_filemode(info->old_mode);
+               cgit_print_filemode(info->old_mode);
                html("]</span>");
        }
        htmlf("</td><td class='%s'>", class);
-       cgit_tree_link(info->new_path, NULL, NULL, cgit_query_head, curr_rev,
-                      info->new_path);
+       cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, curr_rev,
+                      NULL, info->new_path);
        if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED)
                htmlf(" (%s from %s)",
                      info->status == DIFF_STATUS_COPIED ? "copied" : "renamed",
@@ -84,7 +86,7 @@ void print_fileinfo(struct fileinfo *info)
        html("</td><td class='right'>");
        htmlf("%d", info->added + info->removed);
        html("</td><td class='graph'>");
-       htmlf("<table width='%d%%'><tr>", (max_changes > 100 ? 100 : max_changes));
+       htmlf("<table summary='file diffstat' width='%d%%'><tr>", (max_changes > 100 ? 100 : max_changes));
        htmlf("<td class='add' style='width: %.1f%%;'/>",
              info->added * 100.0 / max_changes);
        htmlf("<td class='rem' style='width: %.1f%%;'/>",
@@ -143,7 +145,7 @@ void cgit_print_commit(char *hex)
        int i;
 
        if (!hex)
-               hex = cgit_query_head;
+               hex = ctx.qry.head;
        curr_rev = hex;
 
        if (get_sha1(hex, sha1)) {
@@ -157,7 +159,7 @@ void cgit_print_commit(char *hex)
        }
        info = cgit_parse_commit(commit);
 
-       html("<table class='commit-info'>\n");
+       html("<table summary='commit info' class='commit-info'>\n");
        html("<tr><th>author</th><td>");
        html_txt(info->author);
        html(" ");
@@ -175,7 +177,7 @@ void cgit_print_commit(char *hex)
        html("<tr><th>tree</th><td colspan='2' class='sha1'>");
        tmp = xstrdup(hex);
        cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL,
-                      cgit_query_head, tmp, NULL);
+                      ctx.qry.head, tmp, NULL);
        html("</td></tr>\n");
        for (p = commit->parents; p ; p = p->next) {
                parent = lookup_commit_reference(p->item->object.sha1);
@@ -188,15 +190,16 @@ void cgit_print_commit(char *hex)
                html("<tr><th>parent</th>"
                     "<td colspan='2' class='sha1'>");
                cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL,
-                                cgit_query_head, sha1_to_hex(p->item->object.sha1));
+                                ctx.qry.head, sha1_to_hex(p->item->object.sha1));
                html(" (");
-               cgit_diff_link("diff", NULL, NULL, cgit_query_head, hex,
+               cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex,
                               sha1_to_hex(p->item->object.sha1), NULL);
                html(")</td></tr>");
        }
-       if (cgit_repo->snapshots) {
+       if (ctx.repo->snapshots) {
                html("<tr><th>download</th><td colspan='2' class='sha1'>");
-               cgit_print_snapshot_links(cgit_query_repo,hex);
+               cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
+                                         hex, ctx.repo->snapshots);
                html("</td></tr>");
        }
        html("</table>\n");
@@ -208,7 +211,7 @@ void cgit_print_commit(char *hex)
        html("</div>");
        if (!(commit->parents && commit->parents->next && commit->parents->next->next)) {
                html("<div class='diffstat-header'>Diffstat</div>");
-               html("<table class='diffstat'>");
+               html("<table summary='diffstat' class='diffstat'>");
                max_changes = 0;
                cgit_diff_commit(commit, inspect_filepair);
                for(i = 0; i<files; i++)
@@ -217,7 +220,7 @@ void cgit_print_commit(char *hex)
                html("<div class='diffstat-summary'>");
                htmlf("%d files changed, %d insertions, %d deletions (",
                      files, total_adds, total_rems);
-               cgit_diff_link("show diff", NULL, NULL, cgit_query_head, hex,
+               cgit_diff_link("show diff", NULL, NULL, ctx.qry.head, hex,
                               NULL, NULL);
                html(")</div>");
        }