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
@@ -53,2 +53,4 @@ void config_cb(const char *name, const char *value)
ctx.cfg.nocache = atoi(value);
+ else if (!strcmp(name, "noheader"))
+ ctx.cfg.noheader = atoi(value);
else if (!strcmp(name, "snapshots"))
@@ -75,2 +77,4 @@ void config_cb(const char *name, const char *value)
ctx.cfg.cache_dynamic_ttl = atoi(value);
+ else if (!strcmp(name, "embedded"))
+ ctx.cfg.embedded = atoi(value);
else if (!strcmp(name, "max-message-length"))
diff --git a/cgit.h b/cgit.h
index 78b30ba..8c64efe 100644
--- a/cgit.h
+++ b/cgit.h
@@ -158,2 +158,3 @@ struct cgit_config {
int cache_static_ttl;
+ int embedded;
int enable_index_links;
@@ -169,2 +170,3 @@ struct cgit_config {
int nocache;
+ int noheader;
int renamelimit;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 683f3b5..a207fe0 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -61,2 +61,7 @@ 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::
@@ -155,2 +160,6 @@ nocache::
+noheader::
+ Flag which, when set to "1", will make cgit omit the standard header
+ on all pages. Default value: none. See also: "embedded".
+
renamelimit::
diff --git a/ui-shared.c b/ui-shared.c
index 66d5b82..015c52b 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -471,2 +471,5 @@ void cgit_print_http_headers(struct cgit_context *ctx)
+ if (ctx->cfg.embedded)
+ return;
+
if (ctx->page.status)
@@ -494,2 +497,5 @@ void cgit_print_docstart(struct cgit_context *ctx)
{
+ if (ctx->cfg.embedded)
+ return;
+
char *host = cgit_hosturl();
@@ -539,2 +545,5 @@ void cgit_print_docend()
}
+ html("</div>");
+ if (ctx.cfg.embedded)
+ return;
html("</body>\n</html>\n");
@@ -626,9 +635,4 @@ 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");
@@ -673,2 +677,14 @@ 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);