]> git.cameronkatri.com Git - cgit.git/blobdiff - ui-shared.c
Default repo description to "[no description]"
[cgit.git] / ui-shared.c
index 1d6694041baac51f214477a803a8c9360fe31347..4944dfd2e9676dfadbd0ba916c347af1b1751e08 100644 (file)
@@ -60,19 +60,21 @@ char *cgit_repourl(const char *reponame)
 char *cgit_fileurl(const char *reponame, const char *pagename,
                   const char *filename, const char *query)
 {
 char *cgit_fileurl(const char *reponame, const char *pagename,
                   const char *filename, const char *query)
 {
+       char *tmp;
+       char *delim;
+
        if (cgit_virtual_root) {
        if (cgit_virtual_root) {
-               if (query)
-                       return fmt("%s/%s/%s/%s?%s", cgit_virtual_root, reponame,
-                                  pagename, filename?filename:"", query);
-               else
-                       return fmt("%s/%s/%s/", cgit_virtual_root, reponame,
-                                  pagename);
+               tmp = fmt("%s/%s/%s/%s", cgit_virtual_root, reponame,
+                         pagename, (filename ? filename:""));
+               delim = "?";
        } else {
        } else {
-               if (query)
-                       return fmt("?r=%s&p=%s&%s", reponame, pagename, query);
-               else
-                       return fmt("?r=%s&p=%s", reponame, pagename);
+               tmp = fmt("?url=%s/%s/%s", reponame, pagename,
+                         (filename ? filename : ""));
+               delim = "&";
        }
        }
+       if (query)
+               tmp = fmt("%s%s%s", tmp, delim, query);
+       return tmp;
 }
 
 char *cgit_pageurl(const char *reponame, const char *pagename,
 }
 
 char *cgit_pageurl(const char *reponame, const char *pagename,
@@ -194,7 +196,7 @@ void cgit_tree_link(char *name, char *title, char *class, char *head,
 }
 
 void cgit_log_link(char *name, char *title, char *class, char *head,
 }
 
 void cgit_log_link(char *name, char *title, char *class, char *head,
-                  char *rev, char *path, int ofs)
+                  char *rev, char *path, int ofs, char *grep, char *pattern)
 {
        char *delim;
 
 {
        char *delim;
 
@@ -205,6 +207,15 @@ void cgit_log_link(char *name, char *title, char *class, char *head,
                html_attr(rev);
                delim = "&";
        }
                html_attr(rev);
                delim = "&";
        }
+       if (grep && pattern) {
+               html(delim);
+               html("qt=");
+               html_attr(grep);
+               delim = "&";
+               html(delim);
+               html("q=");
+               html_attr(pattern);
+       }
        if (ofs > 0) {
                html(delim);
                html("ofs=");
        if (ofs > 0) {
                html(delim);
                html("ofs=");
@@ -293,6 +304,8 @@ void cgit_print_date(time_t secs, char *format)
        char buf[64];
        struct tm *time;
 
        char buf[64];
        struct tm *time;
 
+       if (!secs)
+               return;
        time = gmtime(&secs);
        strftime(buf, sizeof(buf)-1, format, time);
        html_txt(buf);
        time = gmtime(&secs);
        strftime(buf, sizeof(buf)-1, format, time);
        html_txt(buf);
@@ -302,6 +315,8 @@ void cgit_print_age(time_t t, time_t max_relative, char *format)
 {
        time_t now, secs;
 
 {
        time_t now, secs;
 
+       if (!t)
+               return;
        time(&now);
        secs = now - t;
 
        time(&now);
        secs = now - t;
 
@@ -412,13 +427,15 @@ int print_archive_ref(const char *refname, const unsigned char *sha1,
        return 0;
 }
 
        return 0;
 }
 
-void add_hidden_formfields(int incl_head, int incl_search)
+void add_hidden_formfields(int incl_head, int incl_search, char *page)
 {
 {
+       char *url;
+
        if (!cgit_virtual_root) {
        if (!cgit_virtual_root) {
-               if (cgit_query_repo)
-                       html_hidden("r", cgit_query_repo);
-               if (cgit_query_page)
-                       html_hidden("p", cgit_query_page);
+               url = fmt("%s/%s", cgit_query_repo, page);
+               if (cgit_query_path)
+                       url = fmt("%s/%s", url, cgit_query_path);
+               html_hidden("url", url);
        }
 
        if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch))
        }
 
        if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch))
@@ -460,31 +477,36 @@ void cgit_print_pageheader(char *title, int show_search)
                html("<p>\n<h1>navigate</h1>\n");
                reporevlink(NULL, "summary", NULL, "menu", cgit_query_head,
                            NULL, NULL);
                html("<p>\n<h1>navigate</h1>\n");
                reporevlink(NULL, "summary", NULL, "menu", cgit_query_head,
                            NULL, NULL);
-               cgit_log_link("log", NULL, "menu", cgit_query_head,
-                             cgit_query_sha1, cgit_query_path, 0);
+               cgit_log_link("log", NULL, "menu", cgit_query_head, NULL, NULL,
+                             0, NULL, NULL);
                cgit_tree_link("tree", NULL, "menu", cgit_query_head,
                               cgit_query_sha1, NULL);
                cgit_commit_link("commit", NULL, "menu", cgit_query_head,
                              cgit_query_sha1);
                cgit_diff_link("diff", NULL, "menu", cgit_query_head,
                cgit_tree_link("tree", NULL, "menu", cgit_query_head,
                               cgit_query_sha1, NULL);
                cgit_commit_link("commit", NULL, "menu", cgit_query_head,
                              cgit_query_sha1);
                cgit_diff_link("diff", NULL, "menu", cgit_query_head,
-                              cgit_query_sha1, cgit_query_sha2,
-                              cgit_query_path);
+                              cgit_query_sha1, cgit_query_sha2, NULL);
 
                for_each_ref(print_archive_ref, &header);
 
                html("<p>\n<h1>branch</h1>\n");
                html("<form method='get' action=''>\n");
 
                for_each_ref(print_archive_ref, &header);
 
                html("<p>\n<h1>branch</h1>\n");
                html("<form method='get' action=''>\n");
-               add_hidden_formfields(0, 1);
+               add_hidden_formfields(0, 1, cgit_query_page);
+               html("<table class='grid'><tr><td id='branch-dropdown-cell'>");
                html("<select name='h' onchange='this.form.submit();'>\n");
                for_each_branch_ref(print_branch_option, cgit_query_head);
                html("</select>\n");
                html("<select name='h' onchange='this.form.submit();'>\n");
                for_each_branch_ref(print_branch_option, cgit_query_head);
                html("</select>\n");
+               html("</td><td>");
+               html("<noscript><input type='submit' id='switch-btn' value='..'></noscript>\n");
+               html("</td></tr></table>");
                html("</form>\n");
 
                html("<p>\n<h1>search</h1>\n");
                html("<form method='get' action='");
                html("</form>\n");
 
                html("<p>\n<h1>search</h1>\n");
                html("<form method='get' action='");
-               html_attr(cgit_pageurl(cgit_query_repo, "log", NULL));
+               if (cgit_virtual_root)
+                       html_attr(cgit_fileurl(cgit_query_repo, "log",
+                                              cgit_query_path, NULL));
                html("'>\n");
                html("'>\n");
-               add_hidden_formfields(1, 0);
+               add_hidden_formfields(1, 0, "log");
                html("<select name='qt'>\n");
                html_option("grep", "log msg", cgit_query_grep);
                html_option("author", "author", cgit_query_grep);
                html("<select name='qt'>\n");
                html_option("grep", "log msg", cgit_query_grep);
                html_option("author", "author", cgit_query_grep);