]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-repolist.c
scan-tree: Unify gitweb.* and cgit.* settings into one config option.
[ps-cgit] / ui-repolist.c
index 943eaab77995bc9ef8c8fd3c59e1503b0c210aae..36c067a3cb22643c6dca3187c6f84c0a73fda53e 100644 (file)
@@ -43,8 +43,10 @@ static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime)
        path = fmt("%s/%s", repo->path, ctx.cfg.agefile);
        if (stat(path, &s) == 0) {
                *mtime = read_agefile(path);
-               r->mtime = *mtime;
-               return 1;
+               if (*mtime) {
+                       r->mtime = *mtime;
+                       return 1;
+               }
        }
 
        path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch ?
@@ -102,7 +104,7 @@ void print_sort_header(const char *title, const char *sort)
 {
        htmlf("<th class='left'><a href='%s?s=%s", cgit_rooturl(), sort);
        if (ctx.qry.search) {
-               html("&q=");
+               html("&amp;q=");
                html_url_arg(ctx.qry.search);
        }
        htmlf("'>%s</a></th>", title);
@@ -123,11 +125,14 @@ void print_header(int columns)
 
 void print_pager(int items, int pagelen, char *search, char *sort)
 {
-       int i;
+       int i, ofs;
+       char *class = NULL;
        html("<div class='pager'>");
-       for(i = 0; i * pagelen < items; i++)
-               cgit_index_link(fmt("[%d]", i+1), fmt("Page %d", i+1), NULL,
-                               search, sort, i * pagelen);
+       for(i = 0, ofs = 0; ofs < items; i++, ofs = i * pagelen) {
+               class = (ctx.qry.ofs == ofs) ? "current" : NULL;
+               cgit_index_link(fmt("[%d]", i+1), fmt("Page %d", i+1), class,
+                               search, sort, ofs);
+       }
        html("</div>");
 }
 
@@ -155,7 +160,7 @@ static int sort_section(const void *a, const void *b)
 
        result = cmp(r1->section, r2->section);
        if (!result) {
-               if (!strcmp(ctx.cfg.section_sort, "age")) {
+               if (!strcmp(ctx.cfg.repository_sort, "age")) {
                        // get_repo_modtime caches the value in r->mtime, so we don't
                        // have to worry about inefficiencies here.
                        if (get_repo_modtime(r1, &t) && get_repo_modtime(r2, &t))