author | Lars Hjemli <hjemli@gmail.com> | 2006-12-13 23:40:34 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2006-12-13 23:40:34 (UTC) |
commit | 420712ac2531f65a2b94d5ec6d8e03de6942331e (patch) (unidiff) | |
tree | 4849b20b4341a55d1b6435c104de860cda5f6ad6 | |
parent | c45b8178d0e042a668395541a28d59f907da150b (diff) | |
download | cgit-420712ac2531f65a2b94d5ec6d8e03de6942331e.zip cgit-420712ac2531f65a2b94d5ec6d8e03de6942331e.tar.gz cgit-420712ac2531f65a2b94d5ec6d8e03de6942331e.tar.bz2 |
Add simple pager to log page
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | shared.c | 9 | ||||
-rw-r--r-- | ui-log.c | 31 |
4 files changed, 37 insertions, 6 deletions
@@ -31,3 +31,3 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
31 | } else if (!strcmp(cgit_query_page, "log")) { | 31 | } else if (!strcmp(cgit_query_page, "log")) { |
32 | cgit_print_log(cgit_query_head, 0, 100); | 32 | cgit_print_log(cgit_query_head, cgit_query_ofs, 100); |
33 | } else if (!strcmp(cgit_query_page, "tree")) { | 33 | } else if (!strcmp(cgit_query_page, "tree")) { |
@@ -46,2 +46,3 @@ extern char *cgit_query_head; | |||
46 | extern char *cgit_query_sha1; | 46 | extern char *cgit_query_sha1; |
47 | extern int cgit_query_ofs; | ||
47 | 48 | ||
@@ -30,2 +30,3 @@ char *cgit_query_head = NULL; | |||
30 | char *cgit_query_sha1 = NULL; | 30 | char *cgit_query_sha1 = NULL; |
31 | int cgit_query_ofs = 0; | ||
31 | 32 | ||
@@ -61,7 +62,7 @@ void cgit_querystring_cb(const char *name, const char *value) | |||
61 | { | 62 | { |
62 | if (!strcmp(name,"r")) | 63 | if (!strcmp(name,"r")) { |
63 | cgit_query_repo = xstrdup(value); | 64 | cgit_query_repo = xstrdup(value); |
64 | else if (!strcmp(name, "p")) | 65 | } else if (!strcmp(name, "p")) { |
65 | cgit_query_page = xstrdup(value); | 66 | cgit_query_page = xstrdup(value); |
66 | else if (!strcmp(name, "h")) { | 67 | } else if (!strcmp(name, "h")) { |
67 | cgit_query_head = xstrdup(value); | 68 | cgit_query_head = xstrdup(value); |
@@ -71,2 +72,4 @@ void cgit_querystring_cb(const char *name, const char *value) | |||
71 | cgit_query_has_sha1 = 1; | 72 | cgit_query_has_sha1 = 1; |
73 | } else if (!strcmp(name, "ofs")) { | ||
74 | cgit_query_ofs = atoi(value); | ||
72 | } | 75 | } |
@@ -97,3 +97,3 @@ void cgit_print_log(const char *tip, int ofs, int cnt) | |||
97 | const char *argv[2] = {NULL, tip}; | 97 | const char *argv[2] = {NULL, tip}; |
98 | int n = 0; | 98 | int i; |
99 | 99 | ||
@@ -110,3 +110,14 @@ void cgit_print_log(const char *tip, int ofs, int cnt) | |||
110 | html("<tr><th>Date</th><th>Message</th><th>Author</th><th>Link</th></tr>\n"); | 110 | html("<tr><th>Date</th><th>Message</th><th>Author</th><th>Link</th></tr>\n"); |
111 | while ((commit = get_revision(&rev)) != NULL && n++ < 100) { | 111 | |
112 | if (ofs<0) | ||
113 | ofs = 0; | ||
114 | |||
115 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { | ||
116 | free(commit->buffer); | ||
117 | commit->buffer = NULL; | ||
118 | free_commit_list(commit->parents); | ||
119 | commit->parents = NULL; | ||
120 | } | ||
121 | |||
122 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { | ||
112 | cgit_print_commit_shortlog(commit); | 123 | cgit_print_commit_shortlog(commit); |
@@ -118,2 +129,18 @@ void cgit_print_log(const char *tip, int ofs, int cnt) | |||
118 | html("</table>\n"); | 129 | html("</table>\n"); |
130 | |||
131 | html("<div class='pager'>"); | ||
132 | if (ofs > 0) { | ||
133 | html(" <a href='"); | ||
134 | html(cgit_pageurl(cgit_query_repo, cgit_query_page, | ||
135 | fmt("h=%s&ofs=%d", tip, ofs-cnt))); | ||
136 | html("'>[prev]</a> "); | ||
137 | } | ||
138 | |||
139 | if ((commit = get_revision(&rev)) != NULL) { | ||
140 | html(" <a href='"); | ||
141 | html(cgit_pageurl(cgit_query_repo, "log", | ||
142 | fmt("h=%s&ofs=%d", tip, ofs+cnt))); | ||
143 | html("'>[next]</a> "); | ||
144 | } | ||
145 | html("</div>"); | ||
119 | } | 146 | } |