]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-shared.c
Add cgit_diff_link()
[ps-cgit] / ui-shared.c
index 9ab6409349be11a29b4b7784be3afb44e2189b1f..15d825460f6d604441c0f3746e7ffa478af18cd7 100644 (file)
@@ -127,7 +127,7 @@ static char *repolink(char *title, char *class, char *page, char *head,
                        html_attr(path);
                delim = "&";
        }
-       if (head && head != cgit_query_head) {
+       if (head && strcmp(head, cgit_repo->defbranch)) {
                html(delim);
                html("h=");
                html_attr(head);
@@ -136,16 +136,62 @@ static char *repolink(char *title, char *class, char *page, char *head,
        return fmt("%s", delim);
 }
 
+static void reporevlink(char *page, char *name, char *title, char *class,
+                       char *head, char *rev, char *path)
+{
+       char *delim;
+
+       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_commit_link(char *name, char *title, char *class, char *head,
+                     char *rev)
+{
+       if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) {
+               name[cgit_max_msg_len] = '\0';
+               name[cgit_max_msg_len - 1] = '.';
+               name[cgit_max_msg_len - 2] = '.';
+               name[cgit_max_msg_len - 3] = '.';
+       }
+       reporevlink("commit", name, title, class, head, rev, NULL);
+}
+
+void cgit_diff_link(char *name, char *title, char *class, char *head,
+                   char *new_rev, char *old_rev, char *path)
 {
        char *delim;
 
-       delim = repolink(title, class, "tree", head, path);
-       if (rev && rev != cgit_query_head) {
+       delim = repolink(title, class, "diff", head, path);
+       if (new_rev && strcmp(new_rev, cgit_query_head)) {
                html(delim);
                html("id=");
-               html_attr(rev);
+               html_attr(new_rev);
+               delim = "&amp;";
+       }
+       if (old_rev) {
+               html(delim);
+               html("id2=");
+               html_attr(old_rev);
        }
        html("'>");
        html_txt(name);