author | Lars Hjemli <hjemli@gmail.com> | 2009-07-25 10:29:22 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-07-25 10:29:22 (UTC) |
commit | 286a905842dc0bec6d21a614ec4a97c5f19d5bc4 (patch) (side-by-side diff) | |
tree | ec4a3bff9e0a47f1def3cebd2cd2212406df258a | |
parent | 542f6a433034935a1aa895f7ef3273968915a5d1 (diff) | |
parent | 7a8b3b4104aa5924163efd5f2af0de10b7fb5171 (diff) | |
download | cgit-286a905842dc0bec6d21a614ec4a97c5f19d5bc4.zip cgit-286a905842dc0bec6d21a614ec4a97c5f19d5bc4.tar.gz cgit-286a905842dc0bec6d21a614ec4a97c5f19d5bc4.tar.bz2 |
Merge branch 'lh/embedded'
Conflicts:
cgitrc.5.txt
ui-shared.c
-rw-r--r-- | cgit.c | 4 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | cgitrc.5.txt | 9 | ||||
-rw-r--r-- | ui-shared.c | 28 |
4 files changed, 37 insertions, 6 deletions
@@ -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")) @@ -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); |