author | Lars Hjemli <hjemli@gmail.com> | 2009-07-25 09:40:25 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-07-25 09:41:06 (UTC) |
commit | fbe091a716447be496519ce439451d36d5b9fc24 (patch) (unidiff) | |
tree | c6560c6f2ab6b4760ac6eaecda1759321da2746e | |
parent | e429fb0cca1e8c78da0ec38fe578bafdeec65534 (diff) | |
parent | 694dd43886f23723f415aed3afb62131cdbcaa51 (diff) | |
download | cgit-fbe091a716447be496519ce439451d36d5b9fc24.zip cgit-fbe091a716447be496519ce439451d36d5b9fc24.tar.gz cgit-fbe091a716447be496519ce439451d36d5b9fc24.tar.bz2 |
Merge branch 'do/https'
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-atom.c | 6 | ||||
-rw-r--r-- | ui-shared.c | 14 | ||||
-rw-r--r-- | ui-shared.h | 1 |
3 files changed, 18 insertions, 3 deletions
@@ -49,13 +49,14 @@ void add_entry(struct commit *commit, char *host) | |||
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"); |
@@ -110,13 +111,14 @@ void cgit_print_atom(char *tip, char *path, int max_count) | |||
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); |
diff --git a/ui-shared.c b/ui-shared.c index 2630f23..29036d0 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -31,12 +31,23 @@ void 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 | ||
37 | char *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 | |||
37 | char *cgit_hosturl() | 48 | char *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) { |
@@ -491,13 +502,14 @@ void cgit_print_docstart(struct cgit_context *ctx) | |||
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"); |
diff --git a/ui-shared.h b/ui-shared.h index 5a3821f..bff4826 100644 --- a/ui-shared.h +++ b/ui-shared.h | |||
@@ -1,9 +1,10 @@ | |||
1 | #ifndef UI_SHARED_H | 1 | #ifndef UI_SHARED_H |
2 | #define UI_SHARED_H | 2 | #define UI_SHARED_H |
3 | 3 | ||
4 | extern char *cgit_httpscheme(); | ||
4 | extern char *cgit_hosturl(); | 5 | extern char *cgit_hosturl(); |
5 | extern char *cgit_repourl(const char *reponame); | 6 | extern char *cgit_repourl(const char *reponame); |
6 | extern char *cgit_fileurl(const char *reponame, const char *pagename, | 7 | extern char *cgit_fileurl(const char *reponame, const char *pagename, |
7 | const char *filename, const char *query); | 8 | const char *filename, const char *query); |
8 | extern char *cgit_pageurl(const char *reponame, const char *pagename, | 9 | extern char *cgit_pageurl(const char *reponame, const char *pagename, |
9 | const char *query); | 10 | const char *query); |