]> gitweb.ps.run Git - ps-cgit/blobdiff - cgit.c
Merge branch 'master' of git://git.klever.net/patchwork/cgit
[ps-cgit] / cgit.c
diff --git a/cgit.c b/cgit.c
index 4dc8eecc7f71c57cac77ebdb978d63d023bb5949..0deae12d2fd04d911a0772fa2a569c73694ddb08 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -19,6 +19,10 @@ void config_cb(const char *name, const char *value)
 {
        if (!strcmp(name, "root-title"))
                ctx.cfg.root_title = xstrdup(value);
+       else if (!strcmp(name, "root-desc"))
+               ctx.cfg.root_desc = xstrdup(value);
+       else if (!strcmp(name, "root-readme"))
+               ctx.cfg.root_readme = xstrdup(value);
        else if (!strcmp(name, "css"))
                ctx.cfg.css = xstrdup(value);
        else if (!strcmp(name, "logo"))
@@ -61,6 +65,8 @@ void config_cb(const char *name, const char *value)
                ctx.cfg.max_msg_len = atoi(value);
        else if (!strcmp(name, "max-repodesc-length"))
                ctx.cfg.max_repodesc_len = atoi(value);
+       else if (!strcmp(name, "max-repo-count"))
+               ctx.cfg.max_repo_count = atoi(value);
        else if (!strcmp(name, "max-commit-count"))
                ctx.cfg.max_commit_count = atoi(value);
        else if (!strcmp(name, "summary-log"))
@@ -138,6 +144,8 @@ static void querystring_cb(const char *name, const char *value)
                ctx.qry.path = trim_end(value, '/');
        } else if (!strcmp(name, "name")) {
                ctx.qry.name = xstrdup(value);
+       } else if (!strcmp(name, "mimetype")) {
+               ctx.qry.mimetype = xstrdup(value);
        }
 }
 
@@ -155,6 +163,7 @@ static void prepare_context(struct cgit_context *ctx)
        ctx->cfg.cache_static_ttl = -1;
        ctx->cfg.css = "/cgit.css";
        ctx->cfg.logo = "/git-logo.png";
+       ctx->cfg.max_repo_count = 50;
        ctx->cfg.max_commit_count = 50;
        ctx->cfg.max_lock_attempts = 5;
        ctx->cfg.max_msg_len = 60;
@@ -163,6 +172,7 @@ static void prepare_context(struct cgit_context *ctx)
        ctx->cfg.renamelimit = -1;
        ctx->cfg.robots = "index, nofollow";
        ctx->cfg.root_title = "Git repository browser";
+       ctx->cfg.root_desc = "a fast webinterface for the git dscm";
        ctx->cfg.script_name = CGIT_SCRIPT_NAME;
        ctx->page.mimetype = "text/html";
        ctx->page.charset = PAGE_ENCODING;
@@ -270,7 +280,16 @@ static void process_request(void *cbdata)
                return;
        }
 
-       if (cmd->want_repo && prepare_repo_cmd(ctx))
+       if (cmd->want_repo && !ctx->repo) {
+               cgit_print_http_headers(ctx);
+               cgit_print_docstart(ctx);
+               cgit_print_pageheader(ctx);
+               cgit_print_error(fmt("No repository selected"));
+               cgit_print_docend();
+               return;
+       }
+
+       if (ctx->repo && prepare_repo_cmd(ctx))
                return;
 
        if (cmd->want_layout) {
@@ -363,7 +382,7 @@ int main(int argc, const char **argv)
        err = cache_process(ctx.cfg.cache_size, ctx.cfg.cache_root,
                            ctx.qry.raw, ttl, process_request, &ctx);
        if (err)
-               cache_log("[cgit] error %d - %s\n",
-                         err, strerror(err));
+               cgit_print_error(fmt("Error processing page: %s (%d)",
+                                    strerror(err), err));
        return err;
 }