summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c4
-rw-r--r--cgit.h2
-rw-r--r--cgitrc.5.txt9
-rw-r--r--ui-shared.c28
4 files changed, 37 insertions, 6 deletions
diff --git a/cgit.c b/cgit.c
index 513ea12..2039ab1 100644
--- a/cgit.c
+++ b/cgit.c
@@ -52,4 +52,6 @@ void config_cb(const char *name, const char *value)
} else if (!strcmp(name, "nocache"))
ctx.cfg.nocache = atoi(value);
+ else if (!strcmp(name, "noheader"))
+ ctx.cfg.noheader = atoi(value);
else if (!strcmp(name, "snapshots"))
ctx.cfg.snapshots = cgit_parse_snapshots_mask(value);
@@ -74,4 +76,6 @@ void config_cb(const char *name, const char *value)
else if (!strcmp(name, "cache-dynamic-ttl"))
ctx.cfg.cache_dynamic_ttl = atoi(value);
+ else if (!strcmp(name, "embedded"))
+ ctx.cfg.embedded = atoi(value);
else if (!strcmp(name, "max-message-length"))
ctx.cfg.max_msg_len = atoi(value);
diff --git a/cgit.h b/cgit.h
index 78b30ba..8c64efe 100644
--- a/cgit.h
+++ b/cgit.h
@@ -157,4 +157,5 @@ struct cgit_config {
int cache_root_ttl;
int cache_static_ttl;
+ int embedded;
int enable_index_links;
int enable_log_filecount;
@@ -168,4 +169,5 @@ struct cgit_config {
int max_stats;
int nocache;
+ int noheader;
int renamelimit;
int snapshots;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 683f3b5..a207fe0 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -60,4 +60,9 @@ css::
Default value: "/cgit.css".
+embedded::
+ Flag which, when set to "1", will make cgit generate a html fragment
+ suitable for embedding in other html pages. Default value: none. See
+ also: "noheader".
+
enable-index-links::
Flag which, when set to "1", will make cgit generate extra links for
@@ -154,4 +159,8 @@ nocache::
value: "0".
+noheader::
+ Flag which, when set to "1", will make cgit omit the standard header
+ on all pages. Default value: none. See also: "embedded".
+
renamelimit::
Maximum number of files to consider when detecting renames. The value
diff --git a/ui-shared.c b/ui-shared.c
index 66d5b82..015c52b 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -470,4 +470,7 @@ void cgit_print_http_headers(struct cgit_context *ctx)
const char *method = getenv("REQUEST_METHOD");
+ if (ctx->cfg.embedded)
+ return;
+
if (ctx->page.status)
htmlf("Status: %d %s\n", ctx->page.status, ctx->page.statusmsg);
@@ -493,4 +496,7 @@ void cgit_print_http_headers(struct cgit_context *ctx)
void cgit_print_docstart(struct cgit_context *ctx)
{
+ if (ctx->cfg.embedded)
+ return;
+
char *host = cgit_hosturl();
html(cgit_doctype);
@@ -538,4 +544,7 @@ void cgit_print_docend()
html("</div>\n");
}
+ html("</div>");
+ if (ctx.cfg.embedded)
+ return;
html("</body>\n</html>\n");
}
@@ -625,11 +634,6 @@ char *hc(struct cgit_cmd *cmd, const char *page)
}
-void cgit_print_pageheader(struct cgit_context *ctx)
+static void print_header(struct cgit_context *ctx)
{
- struct cgit_cmd *cmd = cgit_get_cmd(ctx);
-
- if (!cmd && ctx->repo)
- fallback_cmd = "summary";
-
html("<table id='header'>\n");
html("<tr>\n");
@@ -672,4 +676,16 @@ void cgit_print_pageheader(struct cgit_context *ctx)
}
html("</td></tr></table>\n");
+}
+
+void cgit_print_pageheader(struct cgit_context *ctx)
+{
+ struct cgit_cmd *cmd = cgit_get_cmd(ctx);
+
+ if (!cmd && ctx->repo)
+ fallback_cmd = "summary";
+
+ html("<div id='cgit'>");
+ if (!ctx->cfg.noheader)
+ print_header(ctx);
html("<table class='tabs'><tr><td>\n");