summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.h1
-rw-r--r--cgitrc4
-rw-r--r--shared.c3
-rw-r--r--ui-repolist.c2
4 files changed, 9 insertions, 1 deletions
diff --git a/cgit.h b/cgit.h
index 764225d..290401f 100644
--- a/cgit.h
+++ b/cgit.h
@@ -44,96 +44,97 @@ struct repolist {
int length;
int count;
struct repoinfo *repos;
};
struct commitinfo {
struct commit *commit;
char *author;
char *author_email;
unsigned long author_date;
char *committer;
char *committer_email;
unsigned long committer_date;
char *subject;
char *msg;
};
struct taginfo {
char *tagger;
char *tagger_email;
int tagger_date;
char *msg;
};
extern const char cgit_version[];
extern struct repolist cgit_repolist;
extern struct repoinfo *cgit_repo;
extern char *cgit_root_title;
extern char *cgit_css;
extern char *cgit_logo;
extern char *cgit_logo_link;
extern char *cgit_module_link;
extern char *cgit_virtual_root;
extern char *cgit_script_name;
extern char *cgit_cache_root;
extern int cgit_nocache;
extern int cgit_snapshots;
extern int cgit_max_lock_attempts;
extern int cgit_cache_root_ttl;
extern int cgit_cache_repo_ttl;
extern int cgit_cache_dynamic_ttl;
extern int cgit_cache_static_ttl;
extern int cgit_cache_max_create_time;
extern int cgit_max_msg_len;
+extern int cgit_max_repodesc_len;
extern int cgit_max_commit_count;
extern char *cgit_repo_name;
extern char *cgit_repo_desc;
extern char *cgit_repo_owner;
extern int cgit_query_has_symref;
extern int cgit_query_has_sha1;
extern char *cgit_querystring;
extern char *cgit_query_repo;
extern char *cgit_query_page;
extern char *cgit_query_search;
extern char *cgit_query_head;
extern char *cgit_query_sha1;
extern char *cgit_query_sha2;
extern char *cgit_query_path;
extern char *cgit_query_name;
extern int cgit_query_ofs;
extern int htmlfd;
extern void cgit_global_config_cb(const char *name, const char *value);
extern void cgit_repo_config_cb(const char *name, const char *value);
extern void cgit_querystring_cb(const char *name, const char *value);
extern int chk_zero(int result, char *msg);
extern int chk_positive(int result, char *msg);
extern int hextoint(char c);
extern void *cgit_free_commitinfo(struct commitinfo *info);
extern int cgit_diff_files(const unsigned char *old_sha1,
const unsigned char *new_sha1,
linediff_fn fn);
extern void cgit_diff_tree(const unsigned char *old_sha1,
const unsigned char *new_sha1,
filepair_fn fn);
extern void cgit_diff_commit(struct commit *commit, filepair_fn fn);
extern char *fmt(const char *format,...);
extern void html(const char *txt);
extern void htmlf(const char *format,...);
extern void html_txt(char *txt);
diff --git a/cgitrc b/cgitrc
index e7e731c..f923cc4 100644
--- a/cgitrc
+++ b/cgitrc
@@ -6,91 +6,95 @@
## Uncomment and set to 1 to deactivate caching of generated pages. Mostly
## usefull for testing.
#nocache=0
## Enable/disable snapshots by default. This can be overridden per repo
#snapshots=0
## Specify a root for virtual urls. This makes cgit generate urls like
##
## http://localhost/git/repo/log/?id=master
##
## instead of
##
## http://localhost/cgit/cgit.cgi?r=repo&p=log&id=master
##
## For this to work with apache, rewrite rules must be added to httpd.conf,
## possibly looking something like this:
##
## RewriteRule ^/git/$ /cgit/cgit.cgi [L,QSA]
## RewriteRule ^/git/([^/]+)/$ /cgit/cgit.cgi?r=$1 [L,QSA]
## RewriteRule ^/git/([^/]+)/([^/]+)/$ /cgit/cgit.cgi?r=$1&p=$2 [L,QSA]
##
## This setting is disabled by default.
#virtual-root=/git
## Set the title printed on the root page
#root-title=Git repository browser
## Link to css file
#css=/cgit/cgit.css
## Link to logo file
#logo=/cgit/git-logo.png
## Url loaded when clicking the logo
#logo-link=http://www.kernel.org/pub/software/scm/git/docs/
## Url loaded when clicking a submodule link
#module-link=./?repo=%s&page=commit&id=%s
+## Number of chars shown of repo description (in repolist view)
+#max-repodesc-length=60
+
+
## Number of chars shown of commit subject message (in log view)
#max-message-length=60
## Number of commits per page in log view
#max-commit-count=50
## Root of cached output
#cache-root=/var/cache/cgit
## Include another config-file
#include=/var/cgit/repolist
##
## Time-To-Live settings: specifies how long (in minutes) different pages
## should be cached (0 for instant expiration, -1 for immortal pages)
##
## ttl for root page
#cache-root-ttl=5
## ttl for repo summary page
#cache-repo-ttl=5
## ttl for other dynamic pages
#cache-dynamic-ttl=5
## ttl for static pages (addressed by SHA-1)
#cache-static-ttl=-1
## Example repository entry. Required values are repo.url and repo.path (each
## repository section must start with repo.url).
#repo.url=cgit
#repo.name=cgit
#repo.desc=the caching cgi for git
#repo.path=/pub/git/cgit
#repo.owner=Lars Hjemli
#repo.snapshots=1 # override a sitewide snapshot-setting
#repo.module-link=/git/%s/commit/?id=%s # override the standard module-link
diff --git a/shared.c b/shared.c
index a1e1acd..752ceac 100644
--- a/shared.c
+++ b/shared.c
@@ -1,168 +1,171 @@
/* shared.c: global vars + some callback functions
*
* Copyright (C) 2006 Lars Hjemli
*
* Licensed under GNU General Public License v2
* (see COPYING for full license text)
*/
#include "cgit.h"
struct repolist cgit_repolist;
struct repoinfo *cgit_repo;
char *cgit_root_title = "Git repository browser";
char *cgit_css = "/cgit.css";
char *cgit_logo = "/git-logo.png";
char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/";
char *cgit_module_link = "./?repo=%s&page=commit&id=%s";
char *cgit_virtual_root = NULL;
char *cgit_script_name = CGIT_SCRIPT_NAME;
char *cgit_cache_root = "/var/cache/cgit";
int cgit_nocache = 0;
int cgit_snapshots = 0;
int cgit_max_lock_attempts = 5;
int cgit_cache_root_ttl = 5;
int cgit_cache_repo_ttl = 5;
int cgit_cache_dynamic_ttl = 5;
int cgit_cache_static_ttl = -1;
int cgit_cache_max_create_time = 5;
int cgit_max_msg_len = 60;
+int cgit_max_repodesc_len = 60;
int cgit_max_commit_count = 50;
int cgit_query_has_symref = 0;
int cgit_query_has_sha1 = 0;
char *cgit_querystring = NULL;
char *cgit_query_repo = NULL;
char *cgit_query_page = NULL;
char *cgit_query_head = NULL;
char *cgit_query_search = NULL;
char *cgit_query_sha1 = NULL;
char *cgit_query_sha2 = NULL;
char *cgit_query_path = NULL;
char *cgit_query_name = NULL;
int cgit_query_ofs = 0;
int htmlfd = 0;
int chk_zero(int result, char *msg)
{
if (result != 0)
die("%s: %s", msg, strerror(errno));
return result;
}
int chk_positive(int result, char *msg)
{
if (result <= 0)
die("%s: %s", msg, strerror(errno));
return result;
}
struct repoinfo *add_repo(const char *url)
{
struct repoinfo *ret;
if (++cgit_repolist.count > cgit_repolist.length) {
if (cgit_repolist.length == 0)
cgit_repolist.length = 8;
else
cgit_repolist.length *= 2;
cgit_repolist.repos = xrealloc(cgit_repolist.repos,
cgit_repolist.length *
sizeof(struct repoinfo));
}
ret = &cgit_repolist.repos[cgit_repolist.count-1];
ret->url = xstrdup(url);
ret->name = ret->url;
ret->path = NULL;
ret->desc = NULL;
ret->owner = NULL;
ret->defbranch = "master";
ret->snapshots = cgit_snapshots;
ret->module_link = cgit_module_link;
return ret;
}
void cgit_global_config_cb(const char *name, const char *value)
{
if (!strcmp(name, "root-title"))
cgit_root_title = xstrdup(value);
else if (!strcmp(name, "css"))
cgit_css = xstrdup(value);
else if (!strcmp(name, "logo"))
cgit_logo = xstrdup(value);
else if (!strcmp(name, "logo-link"))
cgit_logo_link = xstrdup(value);
else if (!strcmp(name, "module-link"))
cgit_module_link = xstrdup(value);
else if (!strcmp(name, "virtual-root"))
cgit_virtual_root = xstrdup(value);
else if (!strcmp(name, "nocache"))
cgit_nocache = atoi(value);
else if (!strcmp(name, "snapshots"))
cgit_snapshots = atoi(value);
else if (!strcmp(name, "cache-root"))
cgit_cache_root = xstrdup(value);
else if (!strcmp(name, "cache-root-ttl"))
cgit_cache_root_ttl = atoi(value);
else if (!strcmp(name, "cache-repo-ttl"))
cgit_cache_repo_ttl = atoi(value);
else if (!strcmp(name, "cache-static-ttl"))
cgit_cache_static_ttl = atoi(value);
else if (!strcmp(name, "cache-dynamic-ttl"))
cgit_cache_dynamic_ttl = atoi(value);
else if (!strcmp(name, "max-message-length"))
cgit_max_msg_len = atoi(value);
+ else if (!strcmp(name, "max-repodesc-length"))
+ cgit_max_repodesc_len = atoi(value);
else if (!strcmp(name, "max-commit-count"))
cgit_max_commit_count = atoi(value);
else if (!strcmp(name, "repo.url"))
cgit_repo = add_repo(value);
else if (!strcmp(name, "repo.name"))
cgit_repo->name = xstrdup(value);
else if (cgit_repo && !strcmp(name, "repo.path"))
cgit_repo->path = xstrdup(value);
else if (cgit_repo && !strcmp(name, "repo.desc"))
cgit_repo->desc = xstrdup(value);
else if (cgit_repo && !strcmp(name, "repo.owner"))
cgit_repo->owner = xstrdup(value);
else if (cgit_repo && !strcmp(name, "repo.defbranch"))
cgit_repo->defbranch = xstrdup(value);
else if (cgit_repo && !strcmp(name, "repo.snapshots"))
cgit_repo->snapshots = atoi(value);
else if (cgit_repo && !strcmp(name, "repo.module-link"))
cgit_repo->module_link= xstrdup(value);
else if (!strcmp(name, "include"))
cgit_read_config(value, cgit_global_config_cb);
}
void cgit_querystring_cb(const char *name, const char *value)
{
if (!strcmp(name,"r")) {
cgit_query_repo = xstrdup(value);
} else if (!strcmp(name, "p")) {
cgit_query_page = xstrdup(value);
} else if (!strcmp(name, "q")) {
cgit_query_search = xstrdup(value);
} else if (!strcmp(name, "h")) {
cgit_query_head = xstrdup(value);
cgit_query_has_symref = 1;
} else if (!strcmp(name, "id")) {
cgit_query_sha1 = xstrdup(value);
cgit_query_has_sha1 = 1;
} else if (!strcmp(name, "id2")) {
cgit_query_sha2 = xstrdup(value);
cgit_query_has_sha1 = 1;
} else if (!strcmp(name, "ofs")) {
cgit_query_ofs = atoi(value);
} else if (!strcmp(name, "path")) {
cgit_query_path = xstrdup(value);
} else if (!strcmp(name, "name")) {
cgit_query_name = xstrdup(value);
}
}
diff --git a/ui-repolist.c b/ui-repolist.c
index d341193..d7311e4 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -1,53 +1,53 @@
/* ui-repolist.c: functions for generating the repolist page
*
* Copyright (C) 2006 Lars Hjemli
*
* Licensed under GNU General Public License v2
* (see COPYING for full license text)
*/
#include "cgit.h"
void cgit_print_repolist(struct cacheitem *item)
{
struct repoinfo *repo;
int i;
cgit_print_docstart(cgit_root_title, item);
cgit_print_pageheader(cgit_root_title, 0);
html("<table class='list nowrap'>");
html("<tr class='nohover'>"
"<th class='left'>Name</th>"
"<th class='left'>Description</th>"
"<th class='left'>Owner</th>"
"<th class='left'>Links</th></tr>\n");
for (i=0; i<cgit_repolist.count; i++) {
repo = &cgit_repolist.repos[i];
html("<tr><td>");
html_link_open(cgit_repourl(repo->url), NULL, NULL);
html_txt(repo->name);
html_link_close();
html("</td><td>");
- html_txt(repo->desc);
+ html_ntxt(cgit_max_repodesc_len, repo->desc);
html("</td><td>");
html_txt(repo->owner);
html("</td><td>");
html_link_open(cgit_pageurl(repo->name, "commit", NULL),
"Commit: display last commit", NULL);
html("C</a> ");
html_link_open(cgit_pageurl(repo->name, "diff", NULL),
"Diff: see changes introduced by last commit", NULL);
html("D</a> ");
html_link_open(cgit_pageurl(repo->name, "log", NULL),
"Log: show history of the main branch", NULL);
html("L</a> ");
html_link_open(cgit_pageurl(repo->name, "tree", NULL),
"Tree: browse the files in the main branch", NULL);
html("T</a>");
html("</td></tr>\n");
}
html("</table>");
cgit_print_docend();
}