2 cehtehs git web frontend
5 2007, 2008, Christian Thaeter <ct@pipapo.org>
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Affero General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Affero General Public License for more details.
17 You should have received a copy of the GNU Affero General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #define SHA1_HEADER <openssl/sha.h>
28 #include "git/cache.h"
29 #include "git/commit.h"
31 #include "git/revision.h"
34 webgit_log_link (struct webgit_query* query,
37 const char* object, int object_len,
43 html_attr ("href", html(
44 html_fmt ("%s?repo=%s&action=log",
45 query->request->script_name,
47 head ? html_fmt("&ref=%s", head)
49 object ? html_fmt("&object=%.*s",
52 count > 0 ? html_fmt("&count=%d",
64 webgit_log_menu_action (struct webgit_repo_info* repo)
66 return html (html_tag ("div"),
67 webgit_repo_logo (repo), "<br />",
68 // TODO: ...., "<br />",
69 webgit_summary_link (repo->query, repo, html("Summary")), "<br />",
70 webgit_main_link (repo->query, html ("Main"))
76 webgit_log_table (struct webgit_query* query, const char* head, const char* object, int count, int verbosity)
79 const char* argv[] = {NULL, object, NULL};
82 webgit_object_deduce (query);
84 init_revisions (&rev, NULL);
85 rev.verbose_header = 1;
88 setup_revisions (argc, argv, &rev, NULL);
90 prepare_revision_walk(&rev);
92 Html table = html_list ();
93 Html cont = html_list ();
96 // TODO "Prev..." to go back
98 struct commit *commit;
99 while ((commit = get_revision (&rev)))
103 /* displayed query->count lines, finish */
104 html_list_append (cont,
109 sha1_to_hex (commit->object.sha1), 40,
113 free(commit->buffer);
114 commit->buffer = NULL;
115 free_commit_list(commit->parents);
116 commit->parents = NULL;
120 /* TODO: check if commit is one of the heads and display that */
123 webgit_object_commit_committer_date_parse (commit, &tm);
125 char pretty_date[256];
126 strftime (pretty_date, 255, "%c", &tm);
130 html_list_append (table,
133 html_attr ("id", "commit"),
134 html_attr ("class", (row & 1) ? "odd" : "even")
136 html(html_tag ("div",
137 html_attr ("class", "date")
139 html_strndup (pretty_date, 254)
141 html(html_tag ("div",
142 html_attr ("class", "message-summary")
144 webgit_object_link (query, webgit_object_commit_header_parse (commit),
147 "commit", sha1_to_hex (commit->object.sha1))
149 // TODO please refactor this if it's really silly
152 html(html_tag ("div",
153 html_attr ("class", "author")
156 webgit_object_commit_author_name_parse (commit),
157 webgit_object_commit_author_email_parse (commit)
160 html (html_tag ("div",
161 html_attr ("class", "action")
166 webgit_object_link (query, html ("Tree"),
169 "commit", webgit_object_commit_tree_parse (commit),
179 html(html_tag ("div",
180 html_attr ("class", "message")
182 html(html_tag ("pre"),
183 webgit_object_commit_message_parse (commit)
192 #if 0 /* traverse parents */
193 struct commit *parent;
194 while ((parent = pop_commit (&commit->parents)))
199 free(commit->buffer);
200 commit->buffer = NULL;
201 free_commit_list(commit->parents);
202 commit->parents = NULL;
205 return html (html( html_tag ("div", html_attr ("id", "log")), table), cont);
210 webgit_log_content_action (struct webgit_repo_info* repo)
212 struct webgit_query* query = repo->query;
216 object = query->object;
217 else if (query->head)
218 object = query->head;
222 return webgit_log_table (query, query->head, object, query->count, 2);
228 // c-file-style: "gnu"
229 // indent-tabs-mode: nil