summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2009-07-25 09:40:25 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2009-07-25 09:41:06 (UTC)
commitfbe091a716447be496519ce439451d36d5b9fc24 (patch) (unidiff)
treec6560c6f2ab6b4760ac6eaecda1759321da2746e
parente429fb0cca1e8c78da0ec38fe578bafdeec65534 (diff)
parent694dd43886f23723f415aed3afb62131cdbcaa51 (diff)
downloadcgit-fbe091a716447be496519ce439451d36d5b9fc24.zip
cgit-fbe091a716447be496519ce439451d36d5b9fc24.tar.gz
cgit-fbe091a716447be496519ce439451d36d5b9fc24.tar.bz2
Merge branch 'do/https'
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
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
@@ -47,17 +47,18 @@ void add_entry(struct commit *commit, char *host)
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);
@@ -108,17 +109,18 @@ void cgit_print_atom(char *tip, char *path, int max_count)
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;
diff --git a/ui-shared.c b/ui-shared.c
index 2630f23..29036d0 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -29,16 +29,27 @@ static char *http_date(time_t t)
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 {
@@ -489,17 +500,18 @@ void cgit_print_docstart(struct cgit_context *ctx)
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)
diff --git a/ui-shared.h b/ui-shared.h
index 5a3821f..bff4826 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -1,11 +1,12 @@
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,