summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2008-06-26 11:53:30 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-06-26 11:53:30 (UTC)
commitde5e9281719809c5b07051faa88e95bd16e8d485 (patch) (side-by-side diff)
tree30c6f6bc74c067ebad78e45e5602011006332f8b
parent29b37e9781ce1bb04e558c7490d2c29eb1a477e5 (diff)
downloadcgit-de5e9281719809c5b07051faa88e95bd16e8d485.zip
cgit-de5e9281719809c5b07051faa88e95bd16e8d485.tar.gz
cgit-de5e9281719809c5b07051faa88e95bd16e8d485.tar.bz2
Add support for including a footer on all pages
The new cgitrc option `footer` can be used to include a html-file which replaces the standard 'generated by cgit' message at the bottom of each page. Suggested-by: Peter Danenberg <pcd@wikitex.org> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c2
-rw-r--r--cgit.h1
-rw-r--r--ui-shared.c14
3 files changed, 13 insertions, 4 deletions
diff --git a/cgit.c b/cgit.c
index 0deae12..8f154c9 100644
--- a/cgit.c
+++ b/cgit.c
@@ -4,48 +4,50 @@
*
* Licensed under GNU General Public License v2
* (see COPYING for full license text)
*/
#include "cgit.h"
#include "cache.h"
#include "cmd.h"
#include "configfile.h"
#include "html.h"
#include "ui-shared.h"
const char *cgit_version = CGIT_VERSION;
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, "footer"))
+ ctx.cfg.footer = xstrdup(value);
else if (!strcmp(name, "logo"))
ctx.cfg.logo = xstrdup(value);
else if (!strcmp(name, "index-header"))
ctx.cfg.index_header = xstrdup(value);
else if (!strcmp(name, "index-info"))
ctx.cfg.index_info = xstrdup(value);
else if (!strcmp(name, "logo-link"))
ctx.cfg.logo_link = xstrdup(value);
else if (!strcmp(name, "module-link"))
ctx.cfg.module_link = xstrdup(value);
else if (!strcmp(name, "virtual-root")) {
ctx.cfg.virtual_root = trim_end(value, '/');
if (!ctx.cfg.virtual_root && (!strcmp(value, "/")))
ctx.cfg.virtual_root = "";
} else if (!strcmp(name, "nocache"))
ctx.cfg.nocache = atoi(value);
else if (!strcmp(name, "snapshots"))
ctx.cfg.snapshots = cgit_parse_snapshots_mask(value);
else if (!strcmp(name, "enable-index-links"))
ctx.cfg.enable_index_links = atoi(value);
else if (!strcmp(name, "enable-log-filecount"))
ctx.cfg.enable_log_filecount = atoi(value);
else if (!strcmp(name, "enable-log-linecount"))
ctx.cfg.enable_log_linecount = atoi(value);
diff --git a/cgit.h b/cgit.h
index 1972d75..d18d9ca 100644
--- a/cgit.h
+++ b/cgit.h
@@ -104,48 +104,49 @@ struct reflist {
};
struct cgit_query {
int has_symref;
int has_sha1;
char *raw;
char *repo;
char *page;
char *search;
char *grep;
char *head;
char *sha1;
char *sha2;
char *path;
char *name;
char *mimetype;
int ofs;
};
struct cgit_config {
char *agefile;
char *cache_root;
char *clone_prefix;
char *css;
+ char *footer;
char *index_header;
char *index_info;
char *logo;
char *logo_link;
char *module_link;
char *repo_group;
char *robots;
char *root_title;
char *root_desc;
char *root_readme;
char *script_name;
char *virtual_root;
int cache_size;
int cache_dynamic_ttl;
int cache_max_create_time;
int cache_repo_ttl;
int cache_root_ttl;
int cache_static_ttl;
int enable_index_links;
int enable_log_filecount;
int enable_log_linecount;
int max_repo_count;
int max_commit_count;
int max_lock_attempts;
diff --git a/ui-shared.c b/ui-shared.c
index cd98387..8a00099 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -422,52 +422,58 @@ void cgit_print_http_headers(struct cgit_context *ctx)
htmlf("Expires: %s\n", http_date(ctx->page.expires));
html("\n");
}
void cgit_print_docstart(struct cgit_context *ctx)
{
html(cgit_doctype);
html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n");
html("<head>\n");
html("<title>");
html_txt(ctx->page.title);
html("</title>\n");
htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version);
if (ctx->cfg.robots && *ctx->cfg.robots)
htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots);
html("<link rel='stylesheet' type='text/css' href='");
html_attr(ctx->cfg.css);
html("'/>\n");
html("</head>\n");
html("<body>\n");
}
void cgit_print_docend()
{
- html("</div><div class='footer'>generated ");
- cgit_print_date(time(NULL), FMT_LONGDATE);
- htmlf(" by cgit %s", cgit_version);
- html("</div>\n</body>\n</html>\n");
+ html("</div>");
+ if (ctx.cfg.footer)
+ html_include(ctx.cfg.footer);
+ else {
+ html("<div class='footer'>generated ");
+ cgit_print_date(time(NULL), FMT_LONGDATE);
+ htmlf(" by cgit %s", cgit_version);
+ html("</div>\n");
+ }
+ html("</body>\n</html>\n");
}
int print_branch_option(const char *refname, const unsigned char *sha1,
int flags, void *cb_data)
{
char *name = (char *)refname;
html_option(name, name, ctx.qry.head);
return 0;
}
int print_archive_ref(const char *refname, const unsigned char *sha1,
int flags, void *cb_data)
{
struct tag *tag;
struct taginfo *info;
struct object *obj;
char buf[256], *url;
unsigned char fileid[20];
int *header = (int *)cb_data;
if (prefixcmp(refname, "refs/archives"))
return 0;
strncpy(buf, refname+14, sizeof(buf));
obj = parse_object(sha1);