summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c2
-rw-r--r--cgit.css19
-rw-r--r--cgit.h4
-rw-r--r--shared.c3
-rw-r--r--ui-log.c9
-rw-r--r--ui-shared.c9
-rw-r--r--ui-summary.c2
7 files changed, 39 insertions, 9 deletions
diff --git a/cgit.c b/cgit.c
index cc18ed4..142e416 100644
--- a/cgit.c
+++ b/cgit.c
@@ -73,49 +73,49 @@ static void cgit_print_repo_page(struct cacheitem *item)
cgit_query_path,
cgit_repo->snapshots );
return;
}
if (cgit_cmd == CMD_BLOB) {
cgit_print_blob(item, cgit_query_sha1, cgit_query_path);
return;
}
show_search = (cgit_cmd == CMD_LOG);
cgit_print_docstart(title, item);
if (!cgit_cmd) {
cgit_print_pageheader("summary", show_search);
cgit_print_summary();
cgit_print_docend();
return;
}
cgit_print_pageheader(cgit_query_page, show_search);
switch(cgit_cmd) {
case CMD_LOG:
cgit_print_log(cgit_query_sha1, cgit_query_ofs,
- cgit_max_commit_count, cgit_query_search,
+ cgit_max_commit_count, cgit_query_grep, cgit_query_search,
cgit_query_path, 1);
break;
case CMD_TREE:
cgit_print_tree(cgit_query_sha1, cgit_query_path);
break;
case CMD_COMMIT:
cgit_print_commit(cgit_query_sha1);
break;
case CMD_REFS:
cgit_print_refs();
break;
case CMD_TAG:
cgit_print_tag(cgit_query_sha1);
break;
case CMD_DIFF:
cgit_print_diff(cgit_query_sha1, cgit_query_sha2, cgit_query_path);
break;
default:
cgit_print_error("Invalid request");
}
cgit_print_docend();
}
static void cgit_fill_cache(struct cacheitem *item, int use_cache)
diff --git a/cgit.css b/cgit.css
index b8c3d81..5d47099 100644
--- a/cgit.css
+++ b/cgit.css
@@ -123,57 +123,74 @@ td#crumb {
td#crumb a {
color: #ccc;
background-color: #666;
padding: 0em 0.5em 0em 0.5em;
}
td#crumb a:hover {
color: #666;
background-color: #ccc;
text-decoration: none;
}
td#search {
text-align: right;
vertical-align: middle;
padding-right: 0.5em;
}
td#search form {
margin: 0px;
padding: 0px;
}
+td#search select {
+ font-size: 9pt;
+ padding: 0px;
+ border: solid 1px #333;
+ color: #333;
+ background-color: #fff;
+}
+
td#search input {
font-size: 9pt;
padding: 0px;
- width: 10em;
+}
+
+td#search input.txt {
+ width: 8em;
border: solid 1px #333;
color: #333;
background-color: #fff;
}
+td#search input.btn {
+ border: solid 1px #333;
+ color: #333;
+ background-color: #ccc;
+}
+
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;
}
diff --git a/cgit.h b/cgit.h
index 0baa679..dd83f70 100644
--- a/cgit.h
+++ b/cgit.h
@@ -137,48 +137,49 @@ 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 void cgit_add_ref(struct reflist *list, struct refinfo *ref);
extern int cgit_refs_cb(const char *refname, const unsigned char *sha1,
@@ -239,39 +240,40 @@ 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 *path, int pager);
+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/shared.c b/shared.c
index 7eb2b0e..4fab1c9 100644
--- a/shared.c
+++ b/shared.c
@@ -33,48 +33,49 @@ int cgit_enable_log_filecount = 0;
int cgit_enable_log_linecount = 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_summary_log = 0;
int cgit_summary_tags = 0;
int cgit_summary_branches = 0;
int cgit_renamelimit = -1;
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_grep = 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 cgit_get_cmd_index(const char *cmd)
{
static char *cmds[] = {"log", "commit", "diff", "tree", "blob",
"snapshot", "tag", "refs", NULL};
int i;
for(i = 0; cmds[i]; i++)
if (!strcmp(cmd, cmds[i]))
return i + 1;
return 0;
}
int chk_zero(int result, char *msg)
{
if (result != 0)
@@ -211,48 +212,50 @@ void cgit_global_config_cb(const char *name, const char *value)
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);
diff --git a/ui-log.c b/ui-log.c
index d38e40a..e7f7d6f 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -30,61 +30,64 @@ void print_commit(struct commit *commit)
info = cgit_parse_commit(commit);
html("<tr><td>");
cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE);
html("</td><td>");
cgit_commit_link(info->subject, NULL, NULL, cgit_query_head,
sha1_to_hex(commit->object.sha1));
if (cgit_repo->enable_log_filecount) {
files = 0;
lines = 0;
cgit_diff_commit(commit, inspect_files);
html("</td><td class='right'>");
htmlf("%d", files);
if (cgit_repo->enable_log_linecount) {
html("</td><td class='right'>");
htmlf("%d", lines);
}
}
html("</td><td>");
html_txt(info->author);
html("</td></tr>\n");
cgit_free_commitinfo(info);
}
-void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path, int pager)
+void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, char *path, int pager)
{
struct rev_info rev;
struct commit *commit;
const char *argv[] = {NULL, tip, NULL, NULL, NULL};
int argc = 2;
int i;
if (!tip)
argv[1] = cgit_query_head;
- if (grep)
- argv[argc++] = fmt("--grep=%s", grep);
+ if (grep && pattern && (!strcmp(grep, "grep") ||
+ !strcmp(grep, "author") ||
+ !strcmp(grep, "committer")))
+ argv[argc++] = fmt("--%s=%s", grep, pattern);
+
if (path) {
argv[argc++] = "--";
argv[argc++] = path;
}
init_revisions(&rev, NULL);
rev.abbrev = DEFAULT_ABBREV;
rev.commit_format = CMIT_FMT_DEFAULT;
rev.verbose_header = 1;
rev.show_root_diff = 0;
setup_revisions(argc, argv, &rev, NULL);
if (rev.grep_filter) {
rev.grep_filter->regflags |= REG_ICASE;
compile_grep_patterns(rev.grep_filter);
}
prepare_revision_walk(&rev);
html("<table class='list nowrap'>");
html("<tr class='nohover'><th class='left'>Age</th>"
"<th class='left'>Message</th>");
if (cgit_repo->enable_log_filecount) {
html("<th class='left'>Files</th>");
if (cgit_repo->enable_log_linecount)
html("<th class='left'>Lines</th>");
diff --git a/ui-shared.c b/ui-shared.c
index e4bb98f..45105dc 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -396,44 +396,49 @@ void cgit_print_pageheader(char *title, int show_search)
cgit_diff_link("diff", NULL, NULL, 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) {
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("<input type='text' name='q' value='");
+ html("<select name='qt'>");
+ 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("<input class='txt' type='text' name='q' value='");
html_attr(cgit_query_search);
- html("'/></form>");
+ html("'/><input class='btn' type='submit' value='...'/></form>");
}
html("</td></tr>");
html("<tr><td id='content' colspan='2'>");
}
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 178e959..04a466a 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -215,33 +215,33 @@ void cgit_print_tags(int maxcount)
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)
html_include(cgit_repo->readme);
html("</div>");
if (cgit_summary_log > 0)
- cgit_print_log(cgit_query_head, 0, cgit_summary_log, 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'>&nbsp;</td></tr>");
cgit_print_branches(cgit_summary_branches);
html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
cgit_print_tags(cgit_summary_tags);
html("</table>");
}