summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2010-08-04 01:10:24 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2010-08-04 01:10:24 (UTC)
commite6c960c7c0f0d2e54b51cc43ef190df3ce52755e (patch) (unidiff)
tree29b49ca32a3de23b58ef5c2b7e522b607b60f356
parent6a8f65bf184d85a0c51ffecca16f48e6f4b1ff12 (diff)
parent39c2e224d3c55dfa1a7668399897be295be07dc7 (diff)
downloadcgit-e6c960c7c0f0d2e54b51cc43ef190df3ce52755e.zip
cgit-e6c960c7c0f0d2e54b51cc43ef190df3ce52755e.tar.gz
cgit-e6c960c7c0f0d2e54b51cc43ef190df3ce52755e.tar.bz2
Merge branch 'js/notes'
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.css29
-rw-r--r--cgit.h1
-rw-r--r--ui-commit.c15
-rw-r--r--ui-log.c12
4 files changed, 57 insertions, 0 deletions
diff --git a/cgit.css b/cgit.css
index 6e47eb3..0c88b65 100644
--- a/cgit.css
+++ b/cgit.css
@@ -155,24 +155,35 @@ table.list td {
155 155
156table.list td.logsubject { 156table.list td.logsubject {
157 font-family: monospace; 157 font-family: monospace;
158 font-weight: bold; 158 font-weight: bold;
159} 159}
160 160
161table.list td.logmsg { 161table.list td.logmsg {
162 font-family: monospace; 162 font-family: monospace;
163 white-space: pre; 163 white-space: pre;
164 padding: 1em 0.5em 2em 0.5em; 164 padding: 1em 0.5em 2em 0.5em;
165} 165}
166 166
167table.list td.lognotes-label {
168 text-align:right;
169 vertical-align:top;
170}
171
172table.list td.lognotes {
173 font-family: monospace;
174 white-space: pre;
175 padding: 0em 0.5em 2em 0.5em;
176}
177
167table.list td a { 178table.list td a {
168 color: black; 179 color: black;
169} 180}
170 181
171table.list td a.ls-dir { 182table.list td a.ls-dir {
172 font-weight: bold; 183 font-weight: bold;
173 color: #00f; 184 color: #00f;
174} 185}
175 186
176table.list td a:hover { 187table.list td a:hover {
177 color: #00f; 188 color: #00f;
178} 189}
@@ -317,24 +328,42 @@ table.commit-info td {
317div.commit-subject { 328div.commit-subject {
318 font-weight: bold; 329 font-weight: bold;
319 font-size: 125%; 330 font-size: 125%;
320 margin: 1.5em 0em 0.5em 0em; 331 margin: 1.5em 0em 0.5em 0em;
321 padding: 0em; 332 padding: 0em;
322} 333}
323 334
324div.commit-msg { 335div.commit-msg {
325 white-space: pre; 336 white-space: pre;
326 font-family: monospace; 337 font-family: monospace;
327} 338}
328 339
340div.notes-header {
341 font-weight: bold;
342 padding-top: 1.5em;
343}
344
345div.notes {
346 white-space: pre;
347 font-family: monospace;
348 border: solid 1px #ee9;
349 background-color: #ffd;
350 padding: 0.3em 2em 0.3em 1em;
351 float: left;
352}
353
354div.notes-footer {
355 clear: left;
356}
357
329div.diffstat-header { 358div.diffstat-header {
330 font-weight: bold; 359 font-weight: bold;
331 padding-top: 1.5em; 360 padding-top: 1.5em;
332} 361}
333 362
334table.diffstat { 363table.diffstat {
335 border-collapse: collapse; 364 border-collapse: collapse;
336 border: solid 1px #aaa; 365 border: solid 1px #aaa;
337 background-color: #eee; 366 background-color: #eee;
338} 367}
339 368
340table.diffstat th { 369table.diffstat th {
diff --git a/cgit.h b/cgit.h
index e9e2718..32d9d2b 100644
--- a/cgit.h
+++ b/cgit.h
@@ -10,24 +10,25 @@
10#include <commit.h> 10#include <commit.h>
11#include <tag.h> 11#include <tag.h>
12#include <diff.h> 12#include <diff.h>
13#include <diffcore.h> 13#include <diffcore.h>
14#include <refs.h> 14#include <refs.h>
15#include <revision.h> 15#include <revision.h>
16#include <log-tree.h> 16#include <log-tree.h>
17#include <archive.h> 17#include <archive.h>
18#include <string-list.h> 18#include <string-list.h>
19#include <xdiff-interface.h> 19#include <xdiff-interface.h>
20#include <xdiff/xdiff.h> 20#include <xdiff/xdiff.h>
21#include <utf8.h> 21#include <utf8.h>
22#include <notes.h>
22 23
23 24
24/* 25/*
25 * Dateformats used on misc. pages 26 * Dateformats used on misc. pages
26 */ 27 */
27#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)" 28#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)"
28#define FMT_SHORTDATE "%Y-%m-%d" 29#define FMT_SHORTDATE "%Y-%m-%d"
29#define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ" 30#define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ"
30 31
31 32
32/* 33/*
33 * Limits used for relative dates 34 * Limits used for relative dates
diff --git a/ui-commit.c b/ui-commit.c
index a11bc5f..45af450 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -8,42 +8,45 @@
8 8
9#include "cgit.h" 9#include "cgit.h"
10#include "html.h" 10#include "html.h"
11#include "ui-shared.h" 11#include "ui-shared.h"
12#include "ui-diff.h" 12#include "ui-diff.h"
13#include "ui-log.h" 13#include "ui-log.h"
14 14
15void cgit_print_commit(char *hex, const char *prefix) 15void cgit_print_commit(char *hex, const char *prefix)
16{ 16{
17 struct commit *commit, *parent; 17 struct commit *commit, *parent;
18 struct commitinfo *info, *parent_info; 18 struct commitinfo *info, *parent_info;
19 struct commit_list *p; 19 struct commit_list *p;
20 struct strbuf notes = STRBUF_INIT;
20 unsigned char sha1[20]; 21 unsigned char sha1[20];
21 char *tmp, *tmp2; 22 char *tmp, *tmp2;
22 int parents = 0; 23 int parents = 0;
23 24
24 if (!hex) 25 if (!hex)
25 hex = ctx.qry.head; 26 hex = ctx.qry.head;
26 27
27 if (get_sha1(hex, sha1)) { 28 if (get_sha1(hex, sha1)) {
28 cgit_print_error(fmt("Bad object id: %s", hex)); 29 cgit_print_error(fmt("Bad object id: %s", hex));
29 return; 30 return;
30 } 31 }
31 commit = lookup_commit_reference(sha1); 32 commit = lookup_commit_reference(sha1);
32 if (!commit) { 33 if (!commit) {
33 cgit_print_error(fmt("Bad commit reference: %s", hex)); 34 cgit_print_error(fmt("Bad commit reference: %s", hex));
34 return; 35 return;
35 } 36 }
36 info = cgit_parse_commit(commit); 37 info = cgit_parse_commit(commit);
37 38
39 get_commit_notes(commit, &notes, PAGE_ENCODING, 0);
40
38 load_ref_decorations(DECORATE_FULL_REFS); 41 load_ref_decorations(DECORATE_FULL_REFS);
39 42
40 html("<table summary='commit info' class='commit-info'>\n"); 43 html("<table summary='commit info' class='commit-info'>\n");
41 html("<tr><th>author</th><td>"); 44 html("<tr><th>author</th><td>");
42 html_txt(info->author); 45 html_txt(info->author);
43 if (!ctx.cfg.noplainemail) { 46 if (!ctx.cfg.noplainemail) {
44 html(" "); 47 html(" ");
45 html_txt(info->author_email); 48 html_txt(info->author_email);
46 } 49 }
47 html("</td><td class='right'>"); 50 html("</td><td class='right'>");
48 cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time); 51 cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time);
49 html("</td></tr>\n"); 52 html("</td></tr>\n");
@@ -111,21 +114,33 @@ void cgit_print_commit(char *hex, const char *prefix)
111 html_txt(info->subject); 114 html_txt(info->subject);
112 if (ctx.repo->commit_filter) 115 if (ctx.repo->commit_filter)
113 cgit_close_filter(ctx.repo->commit_filter); 116 cgit_close_filter(ctx.repo->commit_filter);
114 show_commit_decorations(commit); 117 show_commit_decorations(commit);
115 html("</div>"); 118 html("</div>");
116 html("<div class='commit-msg'>"); 119 html("<div class='commit-msg'>");
117 if (ctx.repo->commit_filter) 120 if (ctx.repo->commit_filter)
118 cgit_open_filter(ctx.repo->commit_filter); 121 cgit_open_filter(ctx.repo->commit_filter);
119 html_txt(info->msg); 122 html_txt(info->msg);
120 if (ctx.repo->commit_filter) 123 if (ctx.repo->commit_filter)
121 cgit_close_filter(ctx.repo->commit_filter); 124 cgit_close_filter(ctx.repo->commit_filter);
122 html("</div>"); 125 html("</div>");
126 if (notes.len != 0) {
127 html("<div class='notes-header'>Notes</div>");
128 html("<div class='notes'>");
129 if (ctx.repo->commit_filter)
130 cgit_open_filter(ctx.repo->commit_filter);
131 html_txt(notes.buf);
132 if (ctx.repo->commit_filter)
133 cgit_close_filter(ctx.repo->commit_filter);
134 html("</div>");
135 html("<div class='notes-footer'></div>");
136 }
123 if (parents < 3) { 137 if (parents < 3) {
124 if (parents) 138 if (parents)
125 tmp = sha1_to_hex(commit->parents->item->object.sha1); 139 tmp = sha1_to_hex(commit->parents->item->object.sha1);
126 else 140 else
127 tmp = NULL; 141 tmp = NULL;
128 cgit_print_diff(ctx.qry.sha1, tmp, prefix); 142 cgit_print_diff(ctx.qry.sha1, tmp, prefix);
129 } 143 }
144 strbuf_release(&notes);
130 cgit_free_commitinfo(info); 145 cgit_free_commitinfo(info);
131} 146}
diff --git a/ui-log.c b/ui-log.c
index ee93653..7f38d2a 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -102,33 +102,45 @@ void print_commit(struct commit *commit)
102 add_lines = 0; 102 add_lines = 0;
103 rem_lines = 0; 103 rem_lines = 0;
104 cgit_diff_commit(commit, inspect_files); 104 cgit_diff_commit(commit, inspect_files);
105 html("</td><td>"); 105 html("</td><td>");
106 htmlf("%d", files); 106 htmlf("%d", files);
107 if (ctx.repo->enable_log_linecount) { 107 if (ctx.repo->enable_log_linecount) {
108 html("</td><td>"); 108 html("</td><td>");
109 htmlf("-%d/+%d", rem_lines, add_lines); 109 htmlf("-%d/+%d", rem_lines, add_lines);
110 } 110 }
111 } 111 }
112 html("</td></tr>\n"); 112 html("</td></tr>\n");
113 if (ctx.qry.showmsg) { 113 if (ctx.qry.showmsg) {
114 struct strbuf notes = STRBUF_INIT;
115 get_commit_notes(commit, &notes, PAGE_ENCODING, 0);
116
114 if (ctx.repo->enable_log_filecount) { 117 if (ctx.repo->enable_log_filecount) {
115 cols++; 118 cols++;
116 if (ctx.repo->enable_log_linecount) 119 if (ctx.repo->enable_log_linecount)
117 cols++; 120 cols++;
118 } 121 }
119 htmlf("<tr class='nohover'><td/><td colspan='%d' class='logmsg'>", 122 htmlf("<tr class='nohover'><td/><td colspan='%d' class='logmsg'>",
120 cols); 123 cols);
121 html_txt(info->msg); 124 html_txt(info->msg);
122 html("</td></tr>\n"); 125 html("</td></tr>\n");
126 if (notes.len != 0) {
127 html("<tr class='nohover'>");
128 html("<td class='lognotes-label'>Notes:</td>");
129 htmlf("<td colspan='%d' class='lognotes'>",
130 cols);
131 html_txt(notes.buf);
132 html("</td></tr>\n");
133 }
134 strbuf_release(&notes);
123 } 135 }
124 cgit_free_commitinfo(info); 136 cgit_free_commitinfo(info);
125} 137}
126 138
127static const char *disambiguate_ref(const char *ref) 139static const char *disambiguate_ref(const char *ref)
128{ 140{
129 unsigned char sha1[20]; 141 unsigned char sha1[20];
130 const char *longref; 142 const char *longref;
131 143
132 longref = fmt("refs/heads/%s", ref); 144 longref = fmt("refs/heads/%s", ref);
133 if (get_sha1(longref, sha1) == 0) 145 if (get_sha1(longref, sha1) == 0)
134 return longref; 146 return longref;