-rw-r--r-- | cgit.css | 2 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | html.c | 28 | ||||
-rw-r--r-- | ui-log.c | 4 | ||||
-rw-r--r-- | ui-summary.c | 4 |
5 files changed, 34 insertions, 5 deletions
@@ -91,25 +91,25 @@ td.filesize { | |||
91 | } | 91 | } |
92 | td.filemode { | 92 | td.filemode { |
93 | font-family: monospace; | 93 | font-family: monospace; |
94 | } | 94 | } |
95 | 95 | ||
96 | td.blob { | 96 | td.blob { |
97 | white-space: pre; | 97 | white-space: pre; |
98 | font-family: courier; | 98 | font-family: courier; |
99 | font-size: 100%; | 99 | font-size: 100%; |
100 | background-color: white; | 100 | background-color: white; |
101 | } | 101 | } |
102 | 102 | ||
103 | table.log td { | 103 | table.nowrap td { |
104 | white-space: nowrap; | 104 | white-space: nowrap; |
105 | } | 105 | } |
106 | 106 | ||
107 | table.commit-info { | 107 | table.commit-info { |
108 | border-collapse: collapse; | 108 | border-collapse: collapse; |
109 | margin-top: 1.5em; | 109 | margin-top: 1.5em; |
110 | } | 110 | } |
111 | table.commit-info th { | 111 | table.commit-info th { |
112 | text-align: left; | 112 | text-align: left; |
113 | font-weight: normal; | 113 | font-weight: normal; |
114 | padding: 0.1em 1em 0.1em 0.1em; | 114 | padding: 0.1em 1em 0.1em 0.1em; |
115 | } | 115 | } |
@@ -64,24 +64,25 @@ extern int htmlfd; | |||
64 | 64 | ||
65 | extern void cgit_global_config_cb(const char *name, const char *value); | 65 | extern void cgit_global_config_cb(const char *name, const char *value); |
66 | extern void cgit_repo_config_cb(const char *name, const char *value); | 66 | extern void cgit_repo_config_cb(const char *name, const char *value); |
67 | extern void cgit_querystring_cb(const char *name, const char *value); | 67 | extern void cgit_querystring_cb(const char *name, const char *value); |
68 | 68 | ||
69 | extern void *cgit_free_commitinfo(struct commitinfo *info); | 69 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
70 | 70 | ||
71 | extern char *fmt(const char *format,...); | 71 | extern char *fmt(const char *format,...); |
72 | 72 | ||
73 | extern void html(const char *txt); | 73 | extern void html(const char *txt); |
74 | extern void htmlf(const char *format,...); | 74 | extern void htmlf(const char *format,...); |
75 | extern void html_txt(char *txt); | 75 | extern void html_txt(char *txt); |
76 | extern void html_ntxt(int len, char *txt); | ||
76 | extern void html_attr(char *txt); | 77 | extern void html_attr(char *txt); |
77 | extern void html_link_open(char *url, char *title, char *class); | 78 | extern void html_link_open(char *url, char *title, char *class); |
78 | extern void html_link_close(void); | 79 | extern void html_link_close(void); |
79 | extern void html_filemode(unsigned short mode); | 80 | extern void html_filemode(unsigned short mode); |
80 | 81 | ||
81 | extern int cgit_read_config(const char *filename, configfn fn); | 82 | extern int cgit_read_config(const char *filename, configfn fn); |
82 | extern int cgit_parse_query(char *txt, configfn fn); | 83 | extern int cgit_parse_query(char *txt, configfn fn); |
83 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 84 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
84 | 85 | ||
85 | extern void cache_prepare(struct cacheitem *item); | 86 | extern void cache_prepare(struct cacheitem *item); |
86 | extern int cache_lock(struct cacheitem *item); | 87 | extern int cache_lock(struct cacheitem *item); |
87 | extern int cache_unlock(struct cacheitem *item); | 88 | extern int cache_unlock(struct cacheitem *item); |
@@ -56,24 +56,52 @@ void html_txt(char *txt) | |||
56 | else if (c=='<') | 56 | else if (c=='<') |
57 | html("<"); | 57 | html("<"); |
58 | else if (c=='&') | 58 | else if (c=='&') |
59 | html("&"); | 59 | html("&"); |
60 | txt = t+1; | 60 | txt = t+1; |
61 | } | 61 | } |
62 | t++; | 62 | t++; |
63 | } | 63 | } |
64 | if (t!=txt) | 64 | if (t!=txt) |
65 | html(txt); | 65 | html(txt); |
66 | } | 66 | } |
67 | 67 | ||
68 | void html_ntxt(int len, char *txt) | ||
69 | { | ||
70 | char *t = txt; | ||
71 | while(*t && len--){ | ||
72 | int c = *t; | ||
73 | if (c=='<' || c=='>' || c=='&') { | ||
74 | *t = '\0'; | ||
75 | html(txt); | ||
76 | *t = c; | ||
77 | if (c=='>') | ||
78 | html(">"); | ||
79 | else if (c=='<') | ||
80 | html("<"); | ||
81 | else if (c=='&') | ||
82 | html("&"); | ||
83 | txt = t+1; | ||
84 | } | ||
85 | t++; | ||
86 | } | ||
87 | if (t!=txt) { | ||
88 | char c = *t; | ||
89 | *t = '\0'; | ||
90 | html(txt); | ||
91 | *t = c; | ||
92 | } | ||
93 | if (len<0) | ||
94 | html("..."); | ||
95 | } | ||
68 | 96 | ||
69 | void html_attr(char *txt) | 97 | void html_attr(char *txt) |
70 | { | 98 | { |
71 | char *t = txt; | 99 | char *t = txt; |
72 | while(*t){ | 100 | while(*t){ |
73 | int c = *t; | 101 | int c = *t; |
74 | if (c=='<' || c=='>' || c=='\'') { | 102 | if (c=='<' || c=='>' || c=='\'') { |
75 | *t = '\0'; | 103 | *t = '\0'; |
76 | html(txt); | 104 | html(txt); |
77 | *t = c; | 105 | *t = c; |
78 | if (c=='>') | 106 | if (c=='>') |
79 | html(">"); | 107 | html(">"); |
@@ -14,50 +14,50 @@ void print_commit(struct commit *commit) | |||
14 | struct commitinfo *info; | 14 | struct commitinfo *info; |
15 | struct tm *time; | 15 | struct tm *time; |
16 | 16 | ||
17 | info = cgit_parse_commit(commit); | 17 | info = cgit_parse_commit(commit); |
18 | time = gmtime(&commit->date); | 18 | time = gmtime(&commit->date); |
19 | html("<tr><td>"); | 19 | html("<tr><td>"); |
20 | strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); | 20 | strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); |
21 | html_txt(buf); | 21 | html_txt(buf); |
22 | html("</td><td>"); | 22 | html("</td><td>"); |
23 | char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); | 23 | char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); |
24 | char *url = cgit_pageurl(cgit_query_repo, "commit", qry); | 24 | char *url = cgit_pageurl(cgit_query_repo, "commit", qry); |
25 | html_link_open(url, NULL, NULL); | 25 | html_link_open(url, NULL, NULL); |
26 | html_txt(info->subject); | 26 | html_ntxt(80, info->subject); |
27 | html_link_close(); | 27 | html_link_close(); |
28 | html("</td><td>"); | 28 | html("</td><td>"); |
29 | html_txt(info->author); | 29 | html_txt(info->author); |
30 | html("</td></tr>\n"); | 30 | html("</td></tr>\n"); |
31 | cgit_free_commitinfo(info); | 31 | cgit_free_commitinfo(info); |
32 | } | 32 | } |
33 | 33 | ||
34 | 34 | ||
35 | void cgit_print_log(const char *tip, int ofs, int cnt) | 35 | void cgit_print_log(const char *tip, int ofs, int cnt) |
36 | { | 36 | { |
37 | struct rev_info rev; | 37 | struct rev_info rev; |
38 | struct commit *commit; | 38 | struct commit *commit; |
39 | const char *argv[2] = {NULL, tip}; | 39 | const char *argv[2] = {NULL, tip}; |
40 | int i; | 40 | int i; |
41 | 41 | ||
42 | init_revisions(&rev, NULL); | 42 | init_revisions(&rev, NULL); |
43 | rev.abbrev = DEFAULT_ABBREV; | 43 | rev.abbrev = DEFAULT_ABBREV; |
44 | rev.commit_format = CMIT_FMT_DEFAULT; | 44 | rev.commit_format = CMIT_FMT_DEFAULT; |
45 | rev.verbose_header = 1; | 45 | rev.verbose_header = 1; |
46 | rev.show_root_diff = 0; | 46 | rev.show_root_diff = 0; |
47 | setup_revisions(2, argv, &rev, NULL); | 47 | setup_revisions(2, argv, &rev, NULL); |
48 | prepare_revision_walk(&rev); | 48 | prepare_revision_walk(&rev); |
49 | 49 | ||
50 | html("<h2>Log</h2>"); | 50 | html("<h2>Log</h2>"); |
51 | html("<table class='list log'>"); | 51 | html("<table class='list nowrap'>"); |
52 | html("<tr><th class='left'>Date</th>" | 52 | html("<tr><th class='left'>Date</th>" |
53 | "<th class='left'>Message</th>" | 53 | "<th class='left'>Message</th>" |
54 | "<th class='left'>Author</th></tr>\n"); | 54 | "<th class='left'>Author</th></tr>\n"); |
55 | 55 | ||
56 | if (ofs<0) | 56 | if (ofs<0) |
57 | ofs = 0; | 57 | ofs = 0; |
58 | 58 | ||
59 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { | 59 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
60 | free(commit->buffer); | 60 | free(commit->buffer); |
61 | commit->buffer = NULL; | 61 | commit->buffer = NULL; |
62 | free_commit_list(commit->parents); | 62 | free_commit_list(commit->parents); |
63 | commit->parents = NULL; | 63 | commit->parents = NULL; |
diff --git a/ui-summary.c b/ui-summary.c index 638c8f6..de95053 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -22,43 +22,43 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, | |||
22 | url = cgit_pageurl(cgit_query_repo, "log", | 22 | url = cgit_pageurl(cgit_query_repo, "log", |
23 | fmt("h=%s", refname)); | 23 | fmt("h=%s", refname)); |
24 | html_link_open(url, NULL, NULL); | 24 | html_link_open(url, NULL, NULL); |
25 | strncpy(buf, refname, sizeof(buf)); | 25 | strncpy(buf, refname, sizeof(buf)); |
26 | html_txt(buf); | 26 | html_txt(buf); |
27 | html_link_close(); | 27 | html_link_close(); |
28 | html("</td><td>"); | 28 | html("</td><td>"); |
29 | cgit_print_date(commit->date); | 29 | cgit_print_date(commit->date); |
30 | html("</td><td>"); | 30 | html("</td><td>"); |
31 | url = cgit_pageurl(cgit_query_repo, "commit", | 31 | url = cgit_pageurl(cgit_query_repo, "commit", |
32 | fmt("id=%s", sha1_to_hex(sha1))); | 32 | fmt("id=%s", sha1_to_hex(sha1))); |
33 | html_link_open(url, NULL, NULL); | 33 | html_link_open(url, NULL, NULL); |
34 | html_txt(info->subject); | 34 | html_ntxt(80, info->subject); |
35 | html_link_close(); | 35 | html_link_close(); |
36 | html("</td><td>"); | 36 | html("</td><td>"); |
37 | html_txt(info->author); | 37 | html_txt(info->author); |
38 | html("</td></tr>\n"); | 38 | html("</td></tr>\n"); |
39 | cgit_free_commitinfo(info); | 39 | cgit_free_commitinfo(info); |
40 | } else { | 40 | } else { |
41 | html("<tr><td>"); | 41 | html("<tr><td>"); |
42 | html_txt(buf); | 42 | html_txt(buf); |
43 | html("</td><td>"); | 43 | html("</td><td>"); |
44 | htmlf("*** bad ref %s", sha1_to_hex(sha1)); | 44 | htmlf("*** bad ref %s", sha1_to_hex(sha1)); |
45 | html("</td></tr>\n"); | 45 | html("</td></tr>\n"); |
46 | } | 46 | } |
47 | return 0; | 47 | return 0; |
48 | } | 48 | } |
49 | 49 | ||
50 | static void cgit_print_branches() | 50 | static void cgit_print_branches() |
51 | { | 51 | { |
52 | html("<table class='list'>"); | 52 | html("<table class='list nowrap'>"); |
53 | html("<tr><th class='left'>Branch</th>" | 53 | html("<tr><th class='left'>Branch</th>" |
54 | "<th class='left'>Updated</th>" | 54 | "<th class='left'>Updated</th>" |
55 | "<th class='left'>Commit subject</th>" | 55 | "<th class='left'>Commit subject</th>" |
56 | "<th class='left'>Author</th></tr>\n"); | 56 | "<th class='left'>Author</th></tr>\n"); |
57 | for_each_branch_ref(cgit_print_branch_cb, NULL); | 57 | for_each_branch_ref(cgit_print_branch_cb, NULL); |
58 | html("</table>"); | 58 | html("</table>"); |
59 | } | 59 | } |
60 | 60 | ||
61 | void cgit_print_summary() | 61 | void cgit_print_summary() |
62 | { | 62 | { |
63 | html("<h2>"); | 63 | html("<h2>"); |
64 | html_txt("Repo summary page"); | 64 | html_txt("Repo summary page"); |