]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-shared.c
Make print_branch() handle refs not pointing at commits
[ps-cgit] / ui-shared.c
index 3e378a48246d944f771fd05b31bd1209b58eb5d7..45105dc813ec0bad2dbcc770527149dbbf6c8256 100644 (file)
@@ -227,6 +227,18 @@ void cgit_commit_link(char *name, char *title, char *class, char *head,
        reporevlink("commit", name, title, class, head, rev, NULL);
 }
 
+void cgit_refs_link(char *name, char *title, char *class, char *head,
+                   char *rev, char *path)
+{
+       reporevlink("refs", name, title, class, head, rev, path);
+}
+
+void cgit_snapshot_link(char *name, char *title, char *class, char *head,
+                       char *rev, char *archivename)
+{
+       reporevlink("snapshot", name, title, class, head, rev, archivename);
+}
+
 void cgit_diff_link(char *name, char *title, char *class, char *head,
                    char *new_rev, char *old_rev, char *path)
 {
@@ -249,6 +261,30 @@ void cgit_diff_link(char *name, char *title, char *class, char *head,
        html("</a>");
 }
 
+void cgit_object_link(struct object *obj)
+{
+       char *page, *arg, *url;
+
+       if (obj->type == OBJ_COMMIT) {
+                cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL,
+                                cgit_query_head, sha1_to_hex(obj->sha1));
+               return;
+       } else if (obj->type == OBJ_TREE) {
+               page = "tree";
+               arg = "id";
+       } else {
+               page = "blob";
+               arg = "id";
+       }
+
+       url = cgit_pageurl(cgit_query_repo, page,
+                          fmt("%s=%s", arg, sha1_to_hex(obj->sha1)));
+       html_link_open(url, NULL, NULL);
+       htmlf("%s %s", typename(obj->type),
+             sha1_to_hex(obj->sha1));
+       html_link_close();
+}
+
 void cgit_print_date(time_t secs, char *format)
 {
        char buf[64];
@@ -381,9 +417,14 @@ void cgit_print_pageheader(char *title, int show_search)
                        html_hidden("id", cgit_query_sha1);
                if (cgit_query_sha2)
                        html_hidden("id2", cgit_query_sha2);
-               html("<input type='text' name='q' value='");
+               html("<select name='qt'>");
+               html_option("grep", "log msg", cgit_query_grep);
+               html_option("author", "author", cgit_query_grep);
+               html_option("committer", "committer", cgit_query_grep);
+               html("</select>");
+               html("<input class='txt' type='text' name='q' value='");
                html_attr(cgit_query_search);
-               html("'/></form>");
+               html("'/><input class='btn' type='submit' value='...'/></form>");
        }
        html("</td></tr>");
        html("<tr><td id='content' colspan='2'>");