summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-atom.c6
-rw-r--r--ui-shared.c14
-rw-r--r--ui-shared.h1
3 files changed, 18 insertions, 3 deletions
diff --git a/ui-atom.c b/ui-atom.c
index a6ea3ee..e5c31d9 100644
--- a/ui-atom.c
+++ b/ui-atom.c
@@ -39,33 +39,34 @@ void add_entry(struct commit *commit, char *host)
39 t++; 39 t++;
40 else 40 else
41 t = mail; 41 t = mail;
42 t2 = strchr(t, '>'); 42 t2 = strchr(t, '>');
43 if (t2) 43 if (t2)
44 *t2 = '\0'; 44 *t2 = '\0';
45 html("<email>"); 45 html("<email>");
46 html_txt(t); 46 html_txt(t);
47 html("</email>\n"); 47 html("</email>\n");
48 free(mail); 48 free(mail);
49 } 49 }
50 html("</author>\n"); 50 html("</author>\n");
51 html("<published>"); 51 html("<published>");
52 cgit_print_date(info->author_date, FMT_ATOMDATE, ctx.cfg.local_time); 52 cgit_print_date(info->author_date, FMT_ATOMDATE, ctx.cfg.local_time);
53 html("</published>\n"); 53 html("</published>\n");
54 if (host) { 54 if (host) {
55 html("<link rel='alternate' type='text/html' href='http://"); 55 html("<link rel='alternate' type='text/html' href='");
56 html(cgit_httpscheme());
56 html_attr(host); 57 html_attr(host);
57 html_attr(cgit_pageurl(ctx.repo->url, "commit", NULL)); 58 html_attr(cgit_pageurl(ctx.repo->url, "commit", NULL));
58 if (ctx.cfg.virtual_root) 59 if (ctx.cfg.virtual_root)
59 delim = '?'; 60 delim = '?';
60 htmlf("%cid=%s", delim, hex); 61 htmlf("%cid=%s", delim, hex);
61 html("'/>\n"); 62 html("'/>\n");
62 } 63 }
63 htmlf("<id>%s</id>\n", hex); 64 htmlf("<id>%s</id>\n", hex);
64 html("<content type='text'>\n"); 65 html("<content type='text'>\n");
65 html_txt(info->msg); 66 html_txt(info->msg);
66 html("</content>\n"); 67 html("</content>\n");
67 html("<content type='xhtml'>\n"); 68 html("<content type='xhtml'>\n");
68 html("<div xmlns='http://www.w3.org/1999/xhtml'>\n"); 69 html("<div xmlns='http://www.w3.org/1999/xhtml'>\n");
69 html("<pre>\n"); 70 html("<pre>\n");
70 html_txt(info->msg); 71 html_txt(info->msg);
71 html("</pre>\n"); 72 html("</pre>\n");
@@ -100,30 +101,31 @@ void cgit_print_atom(char *tip, char *path, int max_count)
100 rev.max_count = max_count; 101 rev.max_count = max_count;
101 setup_revisions(argc, argv, &rev, NULL); 102 setup_revisions(argc, argv, &rev, NULL);
102 prepare_revision_walk(&rev); 103 prepare_revision_walk(&rev);
103 104
104 host = cgit_hosturl(); 105 host = cgit_hosturl();
105 ctx.page.mimetype = "text/xml"; 106 ctx.page.mimetype = "text/xml";
106 ctx.page.charset = "utf-8"; 107 ctx.page.charset = "utf-8";
107 cgit_print_http_headers(&ctx); 108 cgit_print_http_headers(&ctx);
108 html("<feed xmlns='http://www.w3.org/2005/Atom'>\n"); 109 html("<feed xmlns='http://www.w3.org/2005/Atom'>\n");
109 html("<title>"); 110 html("<title>");
110 html_txt(ctx.repo->name); 111 html_txt(ctx.repo->name);
111 html("</title>\n"); 112 html("</title>\n");
112 html("<subtitle>"); 113 html("<subtitle>");
113 html_txt(ctx.repo->desc); 114 html_txt(ctx.repo->desc);
114 html("</subtitle>\n"); 115 html("</subtitle>\n");
115 if (host) { 116 if (host) {
116 html("<link rel='alternate' type='text/html' href='http://"); 117 html("<link rel='alternate' type='text/html' href='");
118 html(cgit_httpscheme());
117 html_attr(host); 119 html_attr(host);
118 html_attr(cgit_repourl(ctx.repo->url)); 120 html_attr(cgit_repourl(ctx.repo->url));
119 html("'/>\n"); 121 html("'/>\n");
120 } 122 }
121 while ((commit = get_revision(&rev)) != NULL) { 123 while ((commit = get_revision(&rev)) != NULL) {
122 add_entry(commit, host); 124 add_entry(commit, host);
123 free(commit->buffer); 125 free(commit->buffer);
124 commit->buffer = NULL; 126 commit->buffer = NULL;
125 free_commit_list(commit->parents); 127 free_commit_list(commit->parents);
126 commit->parents = NULL; 128 commit->parents = NULL;
127 } 129 }
128 html("</feed>\n"); 130 html("</feed>\n");
129} 131}
diff --git a/ui-shared.c b/ui-shared.c
index 2630f23..29036d0 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -21,32 +21,43 @@ static char *http_date(time_t t)
21 static char month[][4] = 21 static char month[][4] =
22 {"Jan", "Feb", "Mar", "Apr", "May", "Jun", 22 {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
23 "Jul", "Aug", "Sep", "Oct", "Now", "Dec"}; 23 "Jul", "Aug", "Sep", "Oct", "Now", "Dec"};
24 struct tm *tm = gmtime(&t); 24 struct tm *tm = gmtime(&t);
25 return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday], 25 return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday],
26 tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year, 26 tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year,
27 tm->tm_hour, tm->tm_min, tm->tm_sec); 27 tm->tm_hour, tm->tm_min, tm->tm_sec);
28} 28}
29 29
30void cgit_print_error(char *msg) 30void cgit_print_error(char *msg)
31{ 31{
32 html("<div class='error'>"); 32 html("<div class='error'>");
33 html_txt(msg); 33 html_txt(msg);
34 html("</div>\n"); 34 html("</div>\n");
35} 35}
36 36
37char *cgit_httpscheme()
38{
39 char *https;
40
41 https = getenv("HTTPS");
42 if (https != NULL && strcmp(https, "on") == 0)
43 return "https://";
44 else
45 return "http://";
46}
47
37char *cgit_hosturl() 48char *cgit_hosturl()
38{ 49{
39 char *host, *port; 50 char *host, *port;
40 51
41 host = getenv("HTTP_HOST"); 52 host = getenv("HTTP_HOST");
42 if (host) { 53 if (host) {
43 host = xstrdup(host); 54 host = xstrdup(host);
44 } else { 55 } else {
45 host = getenv("SERVER_NAME"); 56 host = getenv("SERVER_NAME");
46 if (!host) 57 if (!host)
47 return NULL; 58 return NULL;
48 port = getenv("SERVER_PORT"); 59 port = getenv("SERVER_PORT");
49 if (port && atoi(port) != 80) 60 if (port && atoi(port) != 80)
50 host = xstrdup(fmt("%s:%d", host, atoi(port))); 61 host = xstrdup(fmt("%s:%d", host, atoi(port)));
51 else 62 else
52 host = xstrdup(host); 63 host = xstrdup(host);
@@ -481,33 +492,34 @@ void cgit_print_docstart(struct cgit_context *ctx)
481 html("<head>\n"); 492 html("<head>\n");
482 html("<title>"); 493 html("<title>");
483 html_txt(ctx->page.title); 494 html_txt(ctx->page.title);
484 html("</title>\n"); 495 html("</title>\n");
485 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); 496 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version);
486 if (ctx->cfg.robots && *ctx->cfg.robots) 497 if (ctx->cfg.robots && *ctx->cfg.robots)
487 htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); 498 htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots);
488 html("<link rel='stylesheet' type='text/css' href='"); 499 html("<link rel='stylesheet' type='text/css' href='");
489 html_attr(ctx->cfg.css); 500 html_attr(ctx->cfg.css);
490 html("'/>\n"); 501 html("'/>\n");
491 if (ctx->cfg.favicon) { 502 if (ctx->cfg.favicon) {
492 html("<link rel='shortcut icon' href='"); 503 html("<link rel='shortcut icon' href='");
493 html_attr(ctx->cfg.favicon); 504 html_attr(ctx->cfg.favicon);
494 html("'/>\n"); 505 html("'/>\n");
495 } 506 }
496 if (host && ctx->repo) { 507 if (host && ctx->repo) {
497 html("<link rel='alternate' title='Atom feed' href='http://"); 508 html("<link rel='alternate' title='Atom feed' href='");
509 html(cgit_httpscheme());
498 html_attr(cgit_hosturl()); 510 html_attr(cgit_hosturl());
499 html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, 511 html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path,
500 fmt("h=%s", ctx->qry.head))); 512 fmt("h=%s", ctx->qry.head)));
501 html("' type='application/atom+xml'/>"); 513 html("' type='application/atom+xml'/>");
502 } 514 }
503 html("</head>\n"); 515 html("</head>\n");
504 html("<body>\n"); 516 html("<body>\n");
505 if (ctx->cfg.header) 517 if (ctx->cfg.header)
506 html_include(ctx->cfg.header); 518 html_include(ctx->cfg.header);
507} 519}
508 520
509void cgit_print_docend() 521void cgit_print_docend()
510{ 522{
511 html("</div>"); 523 html("</div>");
512 if (ctx.cfg.footer) 524 if (ctx.cfg.footer)
513 html_include(ctx.cfg.footer); 525 html_include(ctx.cfg.footer);
diff --git a/ui-shared.h b/ui-shared.h
index 5a3821f..bff4826 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -1,19 +1,20 @@
1#ifndef UI_SHARED_H 1#ifndef UI_SHARED_H
2#define UI_SHARED_H 2#define UI_SHARED_H
3 3
4extern char *cgit_httpscheme();
4extern char *cgit_hosturl(); 5extern char *cgit_hosturl();
5extern char *cgit_repourl(const char *reponame); 6extern char *cgit_repourl(const char *reponame);
6extern char *cgit_fileurl(const char *reponame, const char *pagename, 7extern char *cgit_fileurl(const char *reponame, const char *pagename,
7 const char *filename, const char *query); 8 const char *filename, const char *query);
8extern char *cgit_pageurl(const char *reponame, const char *pagename, 9extern char *cgit_pageurl(const char *reponame, const char *pagename,
9 const char *query); 10 const char *query);
10 11
11extern void cgit_index_link(char *name, char *title, char *class, 12extern void cgit_index_link(char *name, char *title, char *class,
12 char *pattern, int ofs); 13 char *pattern, int ofs);
13extern void cgit_summary_link(char *name, char *title, char *class, char *head); 14extern void cgit_summary_link(char *name, char *title, char *class, char *head);
14extern void cgit_tag_link(char *name, char *title, char *class, char *head, 15extern void cgit_tag_link(char *name, char *title, char *class, char *head,
15 char *rev); 16 char *rev);
16extern void cgit_tree_link(char *name, char *title, char *class, char *head, 17extern void cgit_tree_link(char *name, char *title, char *class, char *head,
17 char *rev, char *path); 18 char *rev, char *path);
18extern void cgit_plain_link(char *name, char *title, char *class, char *head, 19extern void cgit_plain_link(char *name, char *title, char *class, char *head,
19 char *rev, char *path); 20 char *rev, char *path);