-rw-r--r-- | cgit.css | 149 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | cgit.png | bin | 0 -> 3790 bytes | |||
-rw-r--r-- | cgitrc | 9 | ||||
-rw-r--r-- | shared.c | 31 | ||||
-rw-r--r-- | ui-shared.c | 172 | ||||
-rw-r--r-- | ui-summary.c | 65 |
7 files changed, 231 insertions, 197 deletions
@@ -1,454 +1,431 @@ -body { - font-family: arial, sans-serif; - font-size: 11pt; - color: black; - background: white; -} - body, table { padding: 0em; margin: 0em; } +body { + font-family: sans; + font-size: 10pt; + color: #333; + background: white; + padding-left: 4px; +} + table { border-collapse: collapse; } h2 { font-size: 120%; font-weight: bold; margin-top: 0em; margin-bottom: 0.25em; } h3 { margin-top: 0em; font-size: 100%; font-weight: normal; } h4 { margin-top: 1.5em; margin-bottom: 0.1em; font-size: 100%; font-weight: bold; } a { - color: blue; + color: #600; text-decoration: none; } a:hover { - text-decoration: underline; + background-color: #ddd; + text-decoration: none; } table.list { border: none; border-collapse: collapse; } table.list tr { background: white; } table.list tr:hover { - background: #eee; + background: #f8f8f8; } table.list tr.nohover:hover { background: white; } table.list th { font-weight: bold; border-bottom: solid 1px #777; padding: 0.1em 0.5em 0.1em 0.5em; vertical-align: baseline; } table.list td { border: none; padding: 0.1em 0.5em 0.1em 0.5em; } img { border: none; } -table#layout { - width: 100%; - border-collapse: collapse; - margin: 0px; -} - -td#header, td#logo { - color: #666; - background-color: #ddd; - border-bottom: solid 1px #000; -} - -td#header { - font-size: 150%; - font-weight: bold; - padding: 0.2em 0.5em; - vertical-align: text-bottom; -} - -td#header a { - color: #666; -} - -td#header a:hover { - text-decoration: underline; +div#sidebar { + vertical-align: top; + width: 162px; + padding: 0px 0px 0px 0px; + margin: 4px; + float: left; } -td#logo { - text-align: right; - vertical-align: middle; - padding-right: 0.5em; +div#logo { + margin: 0px; + padding: 4px 0px 4px 0px; + text-align: center; + background-color: #ccc; + border-top: solid 1px #eee; + border-left: solid 1px #eee; + border-right: solid 1px #aaa; + border-bottom: solid 1px #aaa; } -td#crumb, td#search { - color: #ccc; - border-top: solid 3px #555; - background-color: #666; - border-bottom: solid 1px #333; - padding: 2px 1em; +div#sidebar div.infobox { + margin: 0px 0px 0pax 0px; + padding: 0.5em; + text-align: left; + background-color: #ccc; + border-top: solid 1px #eee; + border-left: solid 1px #eee; + border-right: solid 1px #aaa; + border-bottom: solid 1px #aaa; } -td#crumb { +div#sidebar div.infobox h1 { + font-size: 11pt; font-weight: bold; + margin: 0px; } -td#crumb a { - color: #ccc; - background-color: #666; - padding: 0em 0.5em 0em 0.5em; -} - -td#crumb a:hover { - color: #666; +div#sidebar div.infobox a.menu { + display: block; background-color: #ccc; + padding: 0.1em 0.5em; text-decoration: none; } -td#search { - text-align: right; - vertical-align: middle; - padding-right: 0.5em; -} - -td#search form { - margin: 0px; - padding: 0px; +div#sidebar div.infobox a.menu:hover { + background-color: #bbb; + text-decoration: none; } -td#search select { - font-size: 9pt; +div#sidebar div.infobox select { + width: 100%; + border: solid 1px #aaa; + background-color: #bbb; + margin: 2px 0px 0px 0px; padding: 0px; - border: solid 1px #333; - color: #333; - background-color: #fff; } -td#search input { - font-size: 9pt; - padding: 0px; +div#sidebar div.infobox input.txt { + width: 100%; + border: solid 1px #aaa; + background-color: #bbb; + margin: 2px 0px 0px 0px; + padding: 0; } -td#search input.txt { - width: 8em; - border: solid 1px #333; - color: #333; - background-color: #fff; +table#grid { + margin: 0px; } -td#search input.btn { - border: solid 1px #333; - color: #333; - background-color: #ccc; +td#content { + vertical-align: top; + padding: 1em 2em 1em 1em; + border: none; } div#summary { vertical-align: top; margin-bottom: 1em; } table#downloads { float: right; border-collapse: collapse; border: solid 1px #777; margin-left: 0.5em; margin-bottom: 0.5em; } table#downloads th { background-color: #ccc; } -td#content { - padding: 1em 0.5em; -} - div#blob { border: solid 1px black; } div.error { color: red; font-weight: bold; margin: 1em 2em; } a.ls-blob, a.ls-dir, a.ls-mod { font-family: monospace; } td.ls-size { text-align: right; } td.ls-size { font-family: monospace; } td.ls-mode { font-family: monospace; } table.blob { margin-top: 0.5em; border-top: solid 1px black; } table.blob td.no { border-right: solid 1px black; color: black; background-color: #eee; text-align: right; } table.blob td.no a { color: black; } table.blob td.no a:hover { color: black; text-decoration: none; } table.blob td.txt { white-space: pre; font-family: monospace; padding-left: 0.5em; } table.nowrap td { white-space: nowrap; } table.commit-info { border-collapse: collapse; margin-top: 1.5em; } table.commit-info th { text-align: left; font-weight: normal; padding: 0.1em 1em 0.1em 0.1em; vertical-align: top; } table.commit-info td { font-weight: normal; padding: 0.1em 1em 0.1em 0.1em; } div.commit-subject { font-weight: bold; font-size: 125%; margin: 1.5em 0em 0.5em 0em; padding: 0em; } div.commit-msg { white-space: pre; font-family: monospace; } div.diffstat-header { font-weight: bold; padding-top: 1.5em; } table.diffstat { border-collapse: collapse; - width: 100%; border: solid 1px #aaa; background-color: #eee; } table.diffstat th { font-weight: normal; text-align: left; text-decoration: underline; padding: 0.1em 1em 0.1em 0.1em; font-size: 100%; } table.diffstat td { padding: 0.2em 0.2em 0.1em 0.1em; font-size: 100%; border: none; } table.diffstat td.mode { white-space: nowrap; } table.diffstat td span.modechange { padding-left: 1em; color: red; } table.diffstat td.add a { color: green; } table.diffstat td.del a { color: red; } table.diffstat td.upd a { color: blue; } table.diffstat td.graph { - width: 75%; + width: 500px; vertical-align: middle; } table.diffstat td.graph table { border: none; } table.diffstat td.graph td { padding: 0px; border: 0px; height: 7pt; } table.diffstat td.graph td.add { background-color: #5c5; } table.diffstat td.graph td.rem { background-color: #c55; } div.diffstat-summary { color: #888; padding-top: 0.5em; } table.diff { width: 100%; } table.diff td { font-family: monospace; white-space: pre; } table.diff td div.head { font-weight: bold; margin-top: 1em; background-color: #eee; } table.diff td div.hunk { color: #009; } table.diff td div.add { color: green; } table.diff td div.del { color: red; } .sha1 { font-family: monospace; font-size: 90%; } .left { text-align: left; } .right { text-align: right; } table.list td.repogroup { font-style: italic; color: #888; } a.button { font-size: 80%; color: #aaa; background-color: #eee; border: solid 1px #aaa; padding: 0em 0.5em; margin: 0.1em 0.25em; } a.button:hover { text-decoration: none; color: #333; background-color: #ccc; } a.primary { font-size: 100%; } a.secondary { font-size: 90%; } td.toplevel-repo { } table.list td.sublevel-repo { padding-left: 1.5em; } span.age-mins { font-weight: bold; color: #080; } span.age-hours { color: #080; } span.age-days { color: #040; } span.age-weeks { color: #444; } span.age-months { color: #888; } span.age-years { color: #bbb; } @@ -1,280 +1,282 @@ #ifndef CGIT_H #define CGIT_H #include <git-compat-util.h> #include <cache.h> #include <grep.h> #include <object.h> #include <tree.h> #include <commit.h> #include <tag.h> #include <diff.h> #include <diffcore.h> #include <refs.h> #include <revision.h> #include <log-tree.h> #include <archive.h> #include <xdiff/xdiff.h> /* * The valid cgit repo-commands */ #define CMD_LOG 1 #define CMD_COMMIT 2 #define CMD_DIFF 3 #define CMD_TREE 4 #define CMD_BLOB 5 #define CMD_SNAPSHOT 6 #define CMD_TAG 7 #define CMD_REFS 8 /* * Dateformats used on misc. pages */ #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" #define FMT_SHORTDATE "%Y-%m-%d" /* * Limits used for relative dates */ #define TM_MIN 60 #define TM_HOUR (TM_MIN * 60) #define TM_DAY (TM_HOUR * 24) #define TM_WEEK (TM_DAY * 7) #define TM_YEAR (TM_DAY * 365) #define TM_MONTH (TM_YEAR / 12.0) typedef void (*configfn)(const char *name, const char *value); typedef void (*filepair_fn)(struct diff_filepair *pair); typedef void (*linediff_fn)(char *line, int len); struct cacheitem { char *name; struct stat st; int ttl; int fd; }; struct repoinfo { char *url; char *name; char *path; char *desc; char *owner; char *defbranch; char *group; char *module_link; char *readme; int snapshots; int enable_log_filecount; int enable_log_linecount; }; 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; }; struct refinfo { const char *refname; struct object *object; union { struct taginfo *tag; struct commitinfo *commit; }; }; struct reflist { struct refinfo **refs; int alloc; int count; }; extern const char *cgit_version; extern struct repolist cgit_repolist; extern struct repoinfo *cgit_repo; extern int cgit_cmd; extern char *cgit_root_title; extern char *cgit_css; extern char *cgit_logo; extern char *cgit_index_header; extern char *cgit_index_info; extern char *cgit_logo_link; extern char *cgit_module_link; extern char *cgit_agefile; extern char *cgit_virtual_root; extern char *cgit_script_name; extern char *cgit_cache_root; extern char *cgit_repo_group; extern int cgit_nocache; extern int cgit_snapshots; extern int cgit_enable_index_links; extern int cgit_enable_log_filecount; extern int cgit_enable_log_linecount; 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_summary_log; extern int cgit_summary_tags; extern int cgit_summary_branches; extern int cgit_max_msg_len; extern int cgit_max_repodesc_len; extern int cgit_max_commit_count; 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_grep; 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 int cgit_get_cmd_index(const char *cmd); extern struct repoinfo *cgit_get_repoinfo(const char *url); 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 chk_non_negative(int result, char *msg); extern int hextoint(char c); extern char *trim_end(const char *str, char c); +extern char *strlpart(char *txt, int maxlen); +extern char *strrpart(char *txt, int maxlen); extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, int flags, void *cb_data); 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, const char *prefix); 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); extern void html_ntxt(int len, char *txt); extern void html_attr(char *txt); extern void html_hidden(char *name, char *value); extern void html_option(char *value, char *text, char *selected_value); extern void html_link_open(char *url, char *title, char *class); extern void html_link_close(void); extern void html_filemode(unsigned short mode); extern int html_include(const char *filename); extern int cgit_read_config(const char *filename, configfn fn); extern int cgit_parse_query(char *txt, configfn fn); extern struct commitinfo *cgit_parse_commit(struct commit *commit); extern struct taginfo *cgit_parse_tag(struct tag *tag); extern void cgit_parse_url(const char *url); extern char *cache_safe_filename(const char *unsafe); extern int cache_lock(struct cacheitem *item); extern int cache_unlock(struct cacheitem *item); extern int cache_cancel_lock(struct cacheitem *item); extern int cache_exist(struct cacheitem *item); extern int cache_expired(struct cacheitem *item); extern char *cgit_repourl(const char *reponame); extern char *cgit_fileurl(const char *reponame, const char *pagename, const char *filename, const char *query); extern char *cgit_pageurl(const char *reponame, const char *pagename, const char *query); extern const char *cgit_repobasename(const char *reponame); extern void cgit_tree_link(char *name, char *title, char *class, char *head, char *rev, char *path); extern void cgit_log_link(char *name, char *title, char *class, char *head, char *rev, char *path, int ofs); extern void cgit_commit_link(char *name, char *title, char *class, char *head, char *rev); extern void cgit_refs_link(char *name, char *title, char *class, char *head, char *rev, char *path); extern void cgit_snapshot_link(char *name, char *title, char *class, char *head, char *rev, char *archivename); extern void cgit_diff_link(char *name, char *title, char *class, char *head, char *new_rev, char *old_rev, char *path); extern void cgit_object_link(struct object *obj); extern void cgit_print_error(char *msg); extern void cgit_print_date(time_t secs, char *format); extern void cgit_print_age(time_t t, time_t max_relative, char *format); extern void cgit_print_docstart(char *title, struct cacheitem *item); extern void cgit_print_docend(); extern void cgit_print_pageheader(char *title, int show_search); extern void cgit_print_snapshot_start(const char *mimetype, const char *filename, struct cacheitem *item); extern void cgit_print_branches(int maxcount); extern void cgit_print_tags(int maxcount); extern void cgit_print_repolist(struct cacheitem *item); extern void cgit_print_summary(); extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, char *path, int pager); extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); extern void cgit_print_tree(const char *rev, char *path); extern void cgit_print_commit(char *hex); extern void cgit_print_refs(); extern void cgit_print_tag(char *revname); extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix); extern void cgit_print_snapshot(struct cacheitem *item, const char *head, const char *hex, const char *prefix, const char *filename, int snapshot); extern void cgit_print_snapshot_links(const char *repo, const char *head, const char *hex, int snapshots); extern int cgit_parse_snapshots_mask(const char *str); #endif /* CGIT_H */ diff --git a/cgit.png b/cgit.png Binary files differnew file mode 100644 index 0000000..ee48197 --- a/dev/null +++ b/cgit.png @@ -1,177 +1,182 @@ ## ## cgitrc: template for /etc/cgitrc ## ## Uncomment and set to 1 to deactivate caching of generated pages. Mostly ## usefull for testing. #nocache=0 ## Set allowed snapshot types by default. Can be overridden per repo # can be any combination of zip/tar.gz/tar.bz2/tar #snapshots=0 ## Enable/disable extra links to summary/log/tree per repo on index page #enable-index-links=0 ## Enable/disable display of 'number of files changed' in log view #enable-log-filecount=0 ## Enable/disable display of 'number of lines changed' in log view #enable-log-linecount=0 ## Enable/disable display of HEAD shortlog in summary view. Set it to maximum ## number of commits that should be displayed #summary-log=0 ## Restrict the number of branches printed in summary view. Set to 0 to ## print all branches. #summary-branches=0 ## Restrict the number of tags printed in summary view. Set to 0 to ## print all tags. #summary-tags=0 ## The "Idle" column on the repository index page can read a timestamp ## from the specified agefile (if this file cannot be found, the mtime ## of HEAD is used). ## The cgit repo on hjemli.net uses the the following command in it's ## post-receive hook to update the age-file: ## git-for-each-ref --format="%(committerdate)" --sort=-committerdate \ ## --count=1 > $GIT_DIR/info/web/last-modifie ## #agefile=info/web/last-modified ## Git detects renames, but with a limit on the number of files to ## consider. This option can be used to specify another limit (or -1 to ## use the default limit). ## #renamelimit=-1 ## Specify a root for virtual urls. This makes cgit generate urls like ## ## http://localhost/git/repo/log/?h=branch ## ## instead of ## ## http://localhost/cgit/cgit.cgi?url=repo/log&h=branch ## ## For this to work with apache, a rewrite rule must be added to httpd.conf, ## possibly looking something like this: ## ## RewriteRule ^/git/(.*)$ /cgit/cgit.cgi?url=$1 [L,QSA] ## ## For this to work with lighttpd, the rewrite rule should look more like this: ## ## url.rewrite = ( ## "^/git/([^?/]+/[^?]*)?(?:\?(.*))?$" => "/cgit.cgi?url=$1&$2" ## ) ## ## This setting is disabled by default. #virtual-root=/git ## Set the title printed on the root page #root-title=Git repository browser -## If specified, the file at this path will be included as HTML in the index -## of repositories +## If specified, the file at this path will be included as HTML in the +## sidebar on the repository index page +#index-info= + + +## If specified, the file at this path will be included as HTML above +## the repository index #index-header= ## 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 ## this is the path to $GIT_DIR #repo.owner=Lars Hjemli #repo.defbranch=master ## define a default branch #repo.snapshots=tar.bz2 ## override a sitewide snapshot-setting #repo.enable-log-filecount=0 ## override the default filecount setting #repo.enable-log-linecount=0 ## override the default linecount setting #repo.module-link=/git/%s/commit/?id=%s ## override the standard module-link #repo.readme=info/web/readme ## specify a file to include on summary page ## Additional repositories grouped under "mirrors" #repo.group=mirrors #repo.url=git #repo.path=/pub/git/git # #repo.url=linux #repo.path=/pub/git/linux ## A group of private repositories (with a working directory) #repo.group=private #repo.url=larsh/cgit #repo.path=/home/larsh/src/cgit/.git #repo.url=larsh/git #repo.path=/home/larsh/src/git/.git @@ -114,365 +114,396 @@ struct repoinfo *add_repo(const char *url) ret = &cgit_repolist.repos[cgit_repolist.count-1]; ret->url = trim_end(url, '/'); ret->name = ret->url; ret->path = NULL; ret->desc = NULL; ret->owner = NULL; ret->group = cgit_repo_group; ret->defbranch = "master"; ret->snapshots = cgit_snapshots; ret->enable_log_filecount = cgit_enable_log_filecount; ret->enable_log_linecount = cgit_enable_log_linecount; ret->module_link = cgit_module_link; ret->readme = NULL; return ret; } struct repoinfo *cgit_get_repoinfo(const char *url) { int i; struct repoinfo *repo; for (i=0; i<cgit_repolist.count; i++) { repo = &cgit_repolist.repos[i]; if (!strcmp(repo->url, url)) return repo; } return NULL; } 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, "index-header")) cgit_index_header = xstrdup(value); else if (!strcmp(name, "index-info")) cgit_index_info = 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 = trim_end(value, '/'); else if (!strcmp(name, "nocache")) cgit_nocache = atoi(value); else if (!strcmp(name, "snapshots")) cgit_snapshots = cgit_parse_snapshots_mask(value); else if (!strcmp(name, "enable-index-links")) cgit_enable_index_links = atoi(value); else if (!strcmp(name, "enable-log-filecount")) cgit_enable_log_filecount = atoi(value); else if (!strcmp(name, "enable-log-linecount")) cgit_enable_log_linecount = 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, "summary-log")) cgit_summary_log = atoi(value); else if (!strcmp(name, "summary-branches")) cgit_summary_branches = atoi(value); else if (!strcmp(name, "summary-tags")) cgit_summary_tags = atoi(value); else if (!strcmp(name, "agefile")) cgit_agefile = xstrdup(value); else if (!strcmp(name, "renamelimit")) cgit_renamelimit = atoi(value); else if (!strcmp(name, "repo.group")) cgit_repo_group = xstrdup(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 = trim_end(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 = cgit_snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); else if (cgit_repo && !strcmp(name, "repo.module-link")) cgit_repo->module_link= xstrdup(value); else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) { if (*value == '/') cgit_repo->readme = xstrdup(value); else cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, 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); cgit_repo = cgit_get_repoinfo(value); } else if (!strcmp(name, "p")) { cgit_query_page = xstrdup(value); cgit_cmd = cgit_get_cmd_index(value); } else if (!strcmp(name, "url")) { cgit_parse_url(value); } else if (!strcmp(name, "qt")) { cgit_query_grep = 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 = trim_end(value, '/'); } else if (!strcmp(name, "name")) { cgit_query_name = xstrdup(value); } } void *cgit_free_commitinfo(struct commitinfo *info) { free(info->author); free(info->author_email); free(info->committer); free(info->committer_email); free(info->subject); free(info); return NULL; } int hextoint(char c) { if (c >= 'a' && c <= 'f') return 10 + c - 'a'; else if (c >= 'A' && c <= 'F') return 10 + c - 'A'; else if (c >= '0' && c <= '9') return c - '0'; else return -1; } char *trim_end(const char *str, char c) { int len; char *s, *t; if (str == NULL) return NULL; t = (char *)str; len = strlen(t); while(len > 0 && t[len - 1] == c) len--; if (len == 0) return NULL; c = t[len]; t[len] = '\0'; s = xstrdup(t); t[len] = c; return s; } +char *strlpart(char *txt, int maxlen) +{ + char *result; + + if (!txt) + return txt; + + if (strlen(txt) <= maxlen) + return txt; + result = xmalloc(maxlen + 1); + memcpy(result, txt, maxlen - 3); + result[maxlen-1] = result[maxlen-2] = result[maxlen-3] = '.'; + result[maxlen] = '\0'; + return result; +} + +char *strrpart(char *txt, int maxlen) +{ + char *result; + + if (!txt) + return txt; + + if (strlen(txt) <= maxlen) + return txt; + result = xmalloc(maxlen + 1); + memcpy(result + 3, txt + strlen(txt) - maxlen + 4, maxlen - 3); + result[0] = result[1] = result[2] = '.'; + return result; +} + void cgit_add_ref(struct reflist *list, struct refinfo *ref) { size_t size; if (list->count >= list->alloc) { list->alloc += (list->alloc ? list->alloc : 4); size = list->alloc * sizeof(struct refinfo *); list->refs = xrealloc(list->refs, size); } list->refs[list->count++] = ref; } struct refinfo *cgit_mk_refinfo(const char *refname, const unsigned char *sha1) { struct refinfo *ref; ref = xmalloc(sizeof (struct refinfo)); ref->refname = xstrdup(refname); ref->object = parse_object(sha1); switch (ref->object->type) { case OBJ_TAG: ref->tag = cgit_parse_tag((struct tag *)ref->object); break; case OBJ_COMMIT: ref->commit = cgit_parse_commit((struct commit *)ref->object); break; } return ref; } int cgit_refs_cb(const char *refname, const unsigned char *sha1, int flags, void *cb_data) { struct reflist *list = (struct reflist *)cb_data; struct refinfo *info = cgit_mk_refinfo(refname, sha1); if (info) cgit_add_ref(list, info); return 0; } void cgit_diff_tree_cb(struct diff_queue_struct *q, struct diff_options *options, void *data) { int i; for (i = 0; i < q->nr; i++) { if (q->queue[i]->status == 'U') continue; ((filepair_fn)data)(q->queue[i]); } } static int load_mmfile(mmfile_t *file, const unsigned char *sha1) { enum object_type type; if (is_null_sha1(sha1)) { file->ptr = (char *)""; file->size = 0; } else { file->ptr = read_sha1_file(sha1, &type, (unsigned long *)&file->size); } return 1; } /* * Receive diff-buffers from xdiff and concatenate them as * needed across multiple callbacks. * * This is basically a copy of xdiff-interface.c/xdiff_outf(), * ripped from git and modified to use globals instead of * a special callback-struct. */ char *diffbuf = NULL; int buflen = 0; int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf) { int i; for (i = 0; i < nbuf; i++) { if (mb[i].ptr[mb[i].size-1] != '\n') { /* Incomplete line */ diffbuf = xrealloc(diffbuf, buflen + mb[i].size); memcpy(diffbuf + buflen, mb[i].ptr, mb[i].size); buflen += mb[i].size; continue; } /* we have a complete line */ if (!diffbuf) { ((linediff_fn)priv)(mb[i].ptr, mb[i].size); continue; } diffbuf = xrealloc(diffbuf, buflen + mb[i].size); memcpy(diffbuf + buflen, mb[i].ptr, mb[i].size); ((linediff_fn)priv)(diffbuf, buflen + mb[i].size); free(diffbuf); diffbuf = NULL; buflen = 0; } if (diffbuf) { ((linediff_fn)priv)(diffbuf, buflen); free(diffbuf); diffbuf = NULL; buflen = 0; } return 0; } int cgit_diff_files(const unsigned char *old_sha1, const unsigned char *new_sha1, linediff_fn fn) { mmfile_t file1, file2; xpparam_t diff_params; xdemitconf_t emit_params; xdemitcb_t emit_cb; if (!load_mmfile(&file1, old_sha1) || !load_mmfile(&file2, new_sha1)) return 1; diff_params.flags = XDF_NEED_MINIMAL; emit_params.ctxlen = 3; emit_params.flags = XDL_EMIT_FUNCNAMES; emit_params.find_func = NULL; emit_cb.outf = filediff_cb; emit_cb.priv = fn; xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb); return 0; } void cgit_diff_tree(const unsigned char *old_sha1, const unsigned char *new_sha1, filepair_fn fn, const char *prefix) { struct diff_options opt; int ret; int prefixlen; diff_setup(&opt); opt.output_format = DIFF_FORMAT_CALLBACK; opt.detect_rename = 1; opt.rename_limit = cgit_renamelimit; opt.recursive = 1; opt.format_callback = cgit_diff_tree_cb; opt.format_callback_data = fn; if (prefix) { opt.nr_paths = 1; opt.paths = &prefix; prefixlen = strlen(prefix); opt.pathlens = &prefixlen; } diff_setup_done(&opt); if (old_sha1 && !is_null_sha1(old_sha1)) ret = diff_tree_sha1(old_sha1, new_sha1, "", &opt); else ret = diff_root_tree_sha1(new_sha1, "", &opt); diffcore_std(&opt); diff_flush(&opt); } void cgit_diff_commit(struct commit *commit, filepair_fn fn) { unsigned char *old_sha1 = NULL; if (commit->parents) old_sha1 = commit->parents->item->object.sha1; cgit_diff_tree(old_sha1, commit->object.sha1, fn, NULL); } diff --git a/ui-shared.c b/ui-shared.c index 1418010..1d66940 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -173,275 +173,347 @@ static char *repolink(char *title, char *class, char *page, char *head, static void reporevlink(char *page, char *name, char *title, char *class, char *head, char *rev, char *path) { char *delim; delim = repolink(title, class, page, head, path); if (rev && strcmp(rev, cgit_query_head)) { html(delim); html("id="); html_attr(rev); } html("'>"); html_txt(name); html("</a>"); } void cgit_tree_link(char *name, char *title, char *class, char *head, char *rev, char *path) { reporevlink("tree", name, title, class, head, rev, path); } void cgit_log_link(char *name, char *title, char *class, char *head, char *rev, char *path, int ofs) { char *delim; delim = repolink(title, class, "log", head, path); if (rev && strcmp(rev, cgit_query_head)) { html(delim); html("id="); html_attr(rev); delim = "&"; } if (ofs > 0) { html(delim); html("ofs="); htmlf("%d", ofs); } html("'>"); html_txt(name); html("</a>"); } void cgit_commit_link(char *name, char *title, char *class, char *head, char *rev) { if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) { name[cgit_max_msg_len] = '\0'; name[cgit_max_msg_len - 1] = '.'; name[cgit_max_msg_len - 2] = '.'; name[cgit_max_msg_len - 3] = '.'; } reporevlink("commit", name, title, class, head, rev, NULL); } void cgit_refs_link(char *name, char *title, char *class, char *head, char *rev, char *path) { reporevlink("refs", name, title, class, head, rev, path); } void cgit_snapshot_link(char *name, char *title, char *class, char *head, char *rev, char *archivename) { reporevlink("snapshot", name, title, class, head, rev, archivename); } void cgit_diff_link(char *name, char *title, char *class, char *head, char *new_rev, char *old_rev, char *path) { char *delim; delim = repolink(title, class, "diff", head, path); if (new_rev && strcmp(new_rev, cgit_query_head)) { html(delim); html("id="); html_attr(new_rev); delim = "&"; } if (old_rev) { html(delim); html("id2="); html_attr(old_rev); } html("'>"); html_txt(name); html("</a>"); } void cgit_object_link(struct object *obj) { char *page, *arg, *url; if (obj->type == OBJ_COMMIT) { cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, cgit_query_head, sha1_to_hex(obj->sha1)); return; } else if (obj->type == OBJ_TREE) { page = "tree"; arg = "id"; } else if (obj->type == OBJ_TAG) { page = "tag"; arg = "id"; } else { page = "blob"; arg = "id"; } url = cgit_pageurl(cgit_query_repo, page, fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); html_link_open(url, NULL, NULL); htmlf("%s %s", typename(obj->type), sha1_to_hex(obj->sha1)); html_link_close(); } void cgit_print_date(time_t secs, char *format) { char buf[64]; struct tm *time; time = gmtime(&secs); strftime(buf, sizeof(buf)-1, format, time); html_txt(buf); } void cgit_print_age(time_t t, time_t max_relative, char *format) { time_t now, secs; time(&now); secs = now - t; if (secs > max_relative && max_relative >= 0) { cgit_print_date(t, format); return; } if (secs < TM_HOUR * 2) { htmlf("<span class='age-mins'>%.0f min.</span>", secs * 1.0 / TM_MIN); return; } if (secs < TM_DAY * 2) { htmlf("<span class='age-hours'>%.0f hours</span>", secs * 1.0 / TM_HOUR); return; } if (secs < TM_WEEK * 2) { htmlf("<span class='age-days'>%.0f days</span>", secs * 1.0 / TM_DAY); return; } if (secs < TM_MONTH * 2) { htmlf("<span class='age-weeks'>%.0f weeks</span>", secs * 1.0 / TM_WEEK); return; } if (secs < TM_YEAR * 2) { htmlf("<span class='age-months'>%.0f months</span>", secs * 1.0 / TM_MONTH); return; } htmlf("<span class='age-years'>%.0f years</span>", secs * 1.0 / TM_YEAR); } void cgit_print_docstart(char *title, struct cacheitem *item) { html("Content-Type: text/html; charset=utf-8\n"); htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); htmlf("Expires: %s\n", http_date(item->st.st_mtime + ttl_seconds(item->ttl))); html("\n"); html(cgit_doctype); html("<html>\n"); html("<head>\n"); html("<title>"); html_txt(title); html("</title>\n"); htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); html("<link rel='stylesheet' type='text/css' href='"); html_attr(cgit_css); html("'/>\n"); html("</head>\n"); html("<body>\n"); } void cgit_print_docend() { - html("</td></tr></table>"); - html("</body>\n</html>\n"); + html("</td>\n</tr>\n<table>\n</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, cgit_query_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); + if (!obj) + return 1; + if (obj->type == OBJ_TAG) { + tag = lookup_tag(sha1); + if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) + return 0; + hashcpy(fileid, tag->tagged->sha1); + } else if (obj->type != OBJ_BLOB) { + return 0; + } else { + hashcpy(fileid, sha1); + } + if (!*header) { + html("<p><h1>download</h1>"); + *header = 1; + } + url = cgit_pageurl(cgit_query_repo, "blob", + fmt("id=%s&path=%s", sha1_to_hex(fileid), + buf)); + html_link_open(url, NULL, "menu"); + html_txt(strlpart(buf, 20)); + html_link_close(); + return 0; +} + +void add_hidden_formfields(int incl_head, int incl_search) +{ + if (!cgit_virtual_root) { + if (cgit_query_repo) + html_hidden("r", cgit_query_repo); + if (cgit_query_page) + html_hidden("p", cgit_query_page); + } + + if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch)) + html_hidden("h", cgit_query_head); + + if (cgit_query_sha1) + html_hidden("id", cgit_query_sha1); + if (cgit_query_sha2) + html_hidden("id2", cgit_query_sha2); + + if (incl_search) { + if (cgit_query_grep) + html_hidden("qt", cgit_query_grep); + if (cgit_query_search) + html_hidden("q", cgit_query_search); + } } void cgit_print_pageheader(char *title, int show_search) { - html("<table id='layout'>"); - html("<tr><td id='header'><a href='"); - html_attr(cgit_rooturl()); - html("'>"); - html_txt(cgit_root_title); - html("</a></td><td id='logo'>"); + static const char *default_info = "This is cgit, a fast webinterface for git repositories"; + int header = 0; + + html("<div id='sidebar'>\n"); html("<a href='"); - html_attr(cgit_logo_link); - htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo); - html("</td></tr>"); - html("<tr><td id='crumb'>"); + html_attr(cgit_rooturl()); + htmlf("'><div id='logo'><img src='%s' alt='cgit'/></div></a>\n", + cgit_logo); + html("<div class='infobox'>"); if (cgit_query_repo) { - html_txt(cgit_repo->name); - html(" ("); - html_txt(cgit_query_head); - html(") : "); - reporevlink(NULL, "summary", NULL, NULL, cgit_query_head, + html("<h1>"); + html_txt(strrpart(cgit_repo->name, 20)); + html("</h1>\n"); + html_txt(cgit_repo->desc); + if (cgit_repo->owner) { + html("<p>\n<h1>owner</h1>\n"); + html_txt(cgit_repo->owner); + } + html("<p>\n<h1>navigate</h1>\n"); + reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, NULL, NULL); - html(" "); - cgit_log_link("log", NULL, NULL, cgit_query_head, + cgit_log_link("log", NULL, "menu", cgit_query_head, cgit_query_sha1, cgit_query_path, 0); - html(" "); - cgit_tree_link("tree", NULL, NULL, cgit_query_head, + cgit_tree_link("tree", NULL, "menu", cgit_query_head, cgit_query_sha1, NULL); - html(" "); - cgit_commit_link("commit", NULL, NULL, cgit_query_head, + cgit_commit_link("commit", NULL, "menu", cgit_query_head, cgit_query_sha1); - html(" "); - cgit_diff_link("diff", NULL, NULL, cgit_query_head, + cgit_diff_link("diff", NULL, "menu", cgit_query_head, cgit_query_sha1, cgit_query_sha2, cgit_query_path); - } else { - html_txt("Index of repositories"); - } - html("</td>"); - html("<td id='search'>"); - if (show_search) { + + for_each_ref(print_archive_ref, &header); + + html("<p>\n<h1>branch</h1>\n"); + html("<form method='get' action=''>\n"); + add_hidden_formfields(0, 1); + html("<select name='h' onchange='this.form.submit();'>\n"); + for_each_branch_ref(print_branch_option, cgit_query_head); + html("</select>\n"); + html("</form>\n"); + + html("<p>\n<h1>search</h1>\n"); html("<form method='get' action='"); - html_attr(cgit_currurl()); - html("'>"); - if (!cgit_virtual_root) { - if (cgit_query_repo) - html_hidden("r", cgit_query_repo); - if (cgit_query_page) - html_hidden("p", cgit_query_page); - } - if (cgit_query_head) - html_hidden("h", cgit_query_head); - if (cgit_query_sha1) - html_hidden("id", cgit_query_sha1); - if (cgit_query_sha2) - html_hidden("id2", cgit_query_sha2); - html("<select name='qt'>"); + html_attr(cgit_pageurl(cgit_query_repo, "log", NULL)); + html("'>\n"); + add_hidden_formfields(1, 0); + html("<select name='qt'>\n"); html_option("grep", "log msg", cgit_query_grep); html_option("author", "author", cgit_query_grep); html_option("committer", "committer", cgit_query_grep); - html("</select>"); + html("</select>\n"); html("<input class='txt' type='text' name='q' value='"); html_attr(cgit_query_search); - html("'/><input class='btn' type='submit' value='...'/></form>"); + html("'/>\n"); + html("</form>\n"); + } else { + if (!cgit_index_info || html_include(cgit_index_info)) + html(default_info); } - html("</td></tr>"); - html("<tr><td id='content' colspan='2'>"); + + html("</div>\n"); + + html("</div>\n<table class='grid'><tr><td id='content'>\n"); } + void cgit_print_snapshot_start(const char *mimetype, const char *filename, struct cacheitem *item) { htmlf("Content-Type: %s\n", mimetype); htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); htmlf("Expires: %s\n", http_date(item->st.st_mtime + ttl_seconds(item->ttl))); html("\n"); } /* vim:set sw=8: */ diff --git a/ui-summary.c b/ui-summary.c index ba90510..39fe330 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -1,253 +1,200 @@ /* ui-summary.c: functions for generating repo summary page * * Copyright (C) 2006 Lars Hjemli * * Licensed under GNU General Public License v2 * (see COPYING for full license text) */ #include "cgit.h" static int header; static int cmp_age(int age1, int age2) { if (age1 != 0 && age2 != 0) return age2 - age1; if (age1 == 0 && age2 == 0) return 0; if (age1 == 0) return +1; return -1; } static int cmp_ref_name(const void *a, const void *b) { struct refinfo *r1 = *(struct refinfo **)a; struct refinfo *r2 = *(struct refinfo **)b; return strcmp(r1->refname, r2->refname); } static int cmp_branch_age(const void *a, const void *b) { struct refinfo *r1 = *(struct refinfo **)a; struct refinfo *r2 = *(struct refinfo **)b; return cmp_age(r1->commit->committer_date, r2->commit->committer_date); } static int cmp_tag_age(const void *a, const void *b) { struct refinfo *r1 = *(struct refinfo **)a; struct refinfo *r2 = *(struct refinfo **)b; return cmp_age(r1->tag->tagger_date, r2->tag->tagger_date); } static int print_branch(struct refinfo *ref) { struct commitinfo *info = ref->commit; char *name = (char *)ref->refname; if (!info) return 1; html("<tr><td>"); cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0); html("</td><td>"); if (ref->object->type == OBJ_COMMIT) { cgit_print_age(info->commit->date, -1, NULL); html("</td><td>"); html_txt(info->author); html("</td><td>"); cgit_commit_link(info->subject, NULL, NULL, name, NULL); } else { html("</td><td></td><td>"); cgit_object_link(ref->object); } html("</td></tr>\n"); return 0; } static void print_tag_header() { html("<tr class='nohover'><th class='left'>Tag</th>" "<th class='left'>Age</th>" "<th class='left'>Author</th>" "<th class='left'>Reference</th></tr>\n"); header = 1; } static int print_tag(struct refinfo *ref) { struct tag *tag; struct taginfo *info; char *url, *name = (char *)ref->refname; if (ref->object->type == OBJ_TAG) { tag = (struct tag *)ref->object; info = ref->tag; if (!tag || !info) return 1; html("<tr><td>"); url = cgit_pageurl(cgit_query_repo, "tag", fmt("id=%s", name)); html_link_open(url, NULL, NULL); html_txt(name); html_link_close(); html("</td><td>"); if (info->tagger_date > 0) cgit_print_age(info->tagger_date, -1, NULL); html("</td><td>"); if (info->tagger) html(info->tagger); html("</td><td>"); cgit_object_link(tag->tagged); html("</td></tr>\n"); } else { if (!header) print_tag_header(); html("<tr><td>"); html_txt(name); html("</td><td colspan='2'/><td>"); cgit_object_link(ref->object); html("</td></tr>\n"); } return 0; } -static int cgit_print_archive_cb(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]; - - if (prefixcmp(refname, "refs/archives")) - return 0; - strncpy(buf, refname+14, sizeof(buf)); - obj = parse_object(sha1); - if (!obj) - return 1; - if (obj->type == OBJ_TAG) { - tag = lookup_tag(sha1); - if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) - return 0; - hashcpy(fileid, tag->tagged->sha1); - } else if (obj->type != OBJ_BLOB) { - return 0; - } else { - hashcpy(fileid, sha1); - } - if (!header) { - html("<table id='downloads'>"); - html("<tr><th>Downloads</th></tr>"); - header = 1; - } - html("<tr><td>"); - url = cgit_pageurl(cgit_query_repo, "blob", - fmt("id=%s&path=%s", sha1_to_hex(fileid), - buf)); - html_link_open(url, NULL, NULL); - html_txt(buf); - html_link_close(); - html("</td></tr>"); - return 0; -} - static void print_refs_link(char *path) { html("<tr class='nohover'><td colspan='4'>"); cgit_refs_link("[...]", NULL, NULL, cgit_query_head, NULL, path); html("</td></tr>"); } void cgit_print_branches(int maxcount) { struct reflist list; int i; html("<tr class='nohover'><th class='left'>Branch</th>" "<th class='left'>Idle</th>" "<th class='left'>Author</th>" "<th class='left'>Head commit</th></tr>\n"); list.refs = NULL; list.alloc = list.count = 0; for_each_branch_ref(cgit_refs_cb, &list); if (maxcount == 0 || maxcount > list.count) maxcount = list.count; if (maxcount < list.count) { qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); } for(i=0; i<maxcount; i++) print_branch(list.refs[i]); if (maxcount < list.count) print_refs_link("heads"); } void cgit_print_tags(int maxcount) { struct reflist list; int i; header = 0; list.refs = NULL; list.alloc = list.count = 0; for_each_tag_ref(cgit_refs_cb, &list); if (list.count == 0) return; qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); if (!maxcount) maxcount = list.count; else if (maxcount > list.count) maxcount = list.count; print_tag_header(); for(i=0; i<maxcount; i++) print_tag(list.refs[i]); if (maxcount < list.count) print_refs_link("tags"); } -static void cgit_print_archives() -{ - header = 0; - for_each_ref(cgit_print_archive_cb, NULL); - if (header) - html("</table>"); -} - void cgit_print_summary() { - html("<div id='summary'>"); - cgit_print_archives(); - html("<h2>"); - html_txt(cgit_repo->name); - html(" - "); - html_txt(cgit_repo->desc); - html("</h2>"); - if (cgit_repo->readme) + if (cgit_repo->readme) { + html("<div id='summary'>"); html_include(cgit_repo->readme); - html("</div>"); + html("</div>"); + } if (cgit_summary_log > 0) - cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, NULL, 0); + cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, + NULL, NULL, 0); html("<table class='list nowrap'>"); if (cgit_summary_log > 0) html("<tr class='nohover'><td colspan='4'> </td></tr>"); cgit_print_branches(cgit_summary_branches); html("<tr class='nohover'><td colspan='4'> </td></tr>"); cgit_print_tags(cgit_summary_tags); html("</table>"); } |