]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-repolist.c
Makefile: install cgit.{css,png} in CGIT_DATA_PATH
[ps-cgit] / ui-repolist.c
index ee4facb2b34f56f6ed77c435af40c65a79dd609a..2324273f8df7cc0a81ee787dd707b3047a4a350a 100644 (file)
@@ -6,6 +6,10 @@
  *   (see COPYING for full license text)
  */
 
  *   (see COPYING for full license text)
  */
 
+/* This is needed for strcasestr to be defined by <string.h> */
+#define _GNU_SOURCE 1
+#include <string.h>
+
 #include <time.h>
 
 #include "cgit.h"
 #include <time.h>
 
 #include "cgit.h"
@@ -19,7 +23,8 @@ time_t read_agefile(char *path)
 
        if (!(f = fopen(path, "r")))
                return -1;
 
        if (!(f = fopen(path, "r")))
                return -1;
-       fgets(buf, sizeof(buf), f);
+       if (fgets(buf, sizeof(buf), f) == NULL)
+               return -1;
        fclose(f);
        if (parse_date(buf, buf2, sizeof(buf2)))
                return strtoul(buf2, NULL, 10);
        fclose(f);
        if (parse_date(buf, buf2, sizeof(buf2)))
                return strtoul(buf2, NULL, 10);
@@ -59,6 +64,15 @@ int is_match(struct cgit_repo *repo)
        return 0;
 }
 
        return 0;
 }
 
+int is_in_url(struct cgit_repo *repo)
+{
+       if (!ctx.qry.url)
+               return 1;
+       if (repo->url && !prefixcmp(repo->url, ctx.qry.url))
+               return 1;
+       return 0;
+}
+
 void print_header(int columns)
 {
        html("<tr class='nohover'>"
 void print_header(int columns)
 {
        html("<tr class='nohover'>"
@@ -101,7 +115,7 @@ void cgit_print_repolist()
        html("<table summary='repository list' class='list nowrap'>");
        for (i=0; i<cgit_repolist.count; i++) {
                ctx.repo = &cgit_repolist.repos[i];
        html("<table summary='repository list' class='list nowrap'>");
        for (i=0; i<cgit_repolist.count; i++) {
                ctx.repo = &cgit_repolist.repos[i];
-               if (!is_match(ctx.repo))
+               if (!(is_match(ctx.repo) && is_in_url(ctx.repo)))
                        continue;
                hits++;
                if (hits <= ctx.qry.ofs)
                        continue;
                hits++;
                if (hits <= ctx.qry.ofs)
@@ -122,9 +136,7 @@ void cgit_print_repolist()
                }
                htmlf("<tr><td class='%s'>",
                      ctx.repo->group ? "sublevel-repo" : "toplevel-repo");
                }
                htmlf("<tr><td class='%s'>",
                      ctx.repo->group ? "sublevel-repo" : "toplevel-repo");
-               html_link_open(cgit_repourl(ctx.repo->url), NULL, NULL);
-               html_txt(ctx.repo->name);
-               html_link_close();
+               cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL);
                html("</td><td>");
                html_link_open(cgit_repourl(ctx.repo->url), NULL, NULL);
                html_ntxt(ctx.cfg.max_repodesc_len, ctx.repo->desc);
                html("</td><td>");
                html_link_open(cgit_repourl(ctx.repo->url), NULL, NULL);
                html_ntxt(ctx.cfg.max_repodesc_len, ctx.repo->desc);
@@ -136,9 +148,7 @@ void cgit_print_repolist()
                html("</td>");
                if (ctx.cfg.enable_index_links) {
                        html("<td>");
                html("</td>");
                if (ctx.cfg.enable_index_links) {
                        html("<td>");
-                       html_link_open(cgit_repourl(ctx.repo->url),
-                                      NULL, "button");
-                       html("summary</a>");
+                       cgit_summary_link("summary", NULL, "button", NULL);
                        cgit_log_link("log", NULL, "button", NULL, NULL, NULL,
                                      0, NULL, NULL);
                        cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL);
                        cgit_log_link("log", NULL, "button", NULL, NULL, NULL,
                                      0, NULL, NULL);
                        cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL);