author | Diego Ongaro <ongardie@gmail.com> | 2009-06-10 23:18:34 (UTC) |
---|---|---|
committer | Diego Ongaro <ongardie@gmail.com> | 2009-06-11 05:01:32 (UTC) |
commit | 694dd43886f23723f415aed3afb62131cdbcaa51 (patch) (side-by-side diff) | |
tree | 891ce59bcac2673e9ca294cfa83e69eec23ccbd5 | |
parent | 87a89aed41136d388537b146000c4af6c1135a8c (diff) | |
download | cgit-694dd43886f23723f415aed3afb62131cdbcaa51.zip cgit-694dd43886f23723f415aed3afb62131cdbcaa51.tar.gz cgit-694dd43886f23723f415aed3afb62131cdbcaa51.tar.bz2 |
use cgit_httpscheme() for atom feed
-rw-r--r-- | ui-atom.c | 6 | ||||
-rw-r--r-- | ui-shared.c | 3 |
2 files changed, 6 insertions, 3 deletions
@@ -23,107 +23,109 @@ void add_entry(struct commit *commit, char *host) html("<title>"); html_txt(info->subject); html("</title>\n"); html("<updated>"); cgit_print_date(info->author_date, FMT_ATOMDATE, ctx.cfg.local_time); html("</updated>\n"); html("<author>\n"); if (info->author) { html("<name>"); html_txt(info->author); html("</name>\n"); } if (info->author_email) { mail = xstrdup(info->author_email); t = strchr(mail, '<'); if (t) t++; else t = mail; t2 = strchr(t, '>'); if (t2) *t2 = '\0'; html("<email>"); html_txt(t); html("</email>\n"); free(mail); } html("</author>\n"); html("<published>"); cgit_print_date(info->author_date, FMT_ATOMDATE, ctx.cfg.local_time); html("</published>\n"); if (host) { - html("<link rel='alternate' type='text/html' href='http://"); + html("<link rel='alternate' type='text/html' href='"); + html(cgit_httpscheme()); html_attr(host); html_attr(cgit_pageurl(ctx.repo->url, "commit", NULL)); if (ctx.cfg.virtual_root) delim = '?'; htmlf("%cid=%s", delim, hex); html("'/>\n"); } htmlf("<id>%s</id>\n", hex); html("<content type='text'>\n"); html_txt(info->msg); html("</content>\n"); html("<content type='xhtml'>\n"); html("<div xmlns='http://www.w3.org/1999/xhtml'>\n"); html("<pre>\n"); html_txt(info->msg); html("</pre>\n"); html("</div>\n"); html("</content>\n"); html("</entry>\n"); cgit_free_commitinfo(info); } void cgit_print_atom(char *tip, char *path, int max_count) { char *host; const char *argv[] = {NULL, tip, NULL, NULL, NULL}; struct commit *commit; struct rev_info rev; int argc = 2; if (!tip) argv[1] = ctx.qry.head; if (path) { argv[argc++] = "--"; argv[argc++] = path; } init_revisions(&rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.commit_format = CMIT_FMT_DEFAULT; rev.verbose_header = 1; rev.show_root_diff = 0; rev.max_count = max_count; setup_revisions(argc, argv, &rev, NULL); prepare_revision_walk(&rev); host = cgit_hosturl(); ctx.page.mimetype = "text/xml"; ctx.page.charset = "utf-8"; cgit_print_http_headers(&ctx); html("<feed xmlns='http://www.w3.org/2005/Atom'>\n"); html("<title>"); html_txt(ctx.repo->name); html("</title>\n"); html("<subtitle>"); html_txt(ctx.repo->desc); html("</subtitle>\n"); if (host) { - html("<link rel='alternate' type='text/html' href='http://"); + html("<link rel='alternate' type='text/html' href='"); + html(cgit_httpscheme()); html_attr(host); html_attr(cgit_repourl(ctx.repo->url)); html("'/>\n"); } while ((commit = get_revision(&rev)) != NULL) { add_entry(commit, host); free(commit->buffer); commit->buffer = NULL; free_commit_list(commit->parents); commit->parents = NULL; } html("</feed>\n"); } diff --git a/ui-shared.c b/ui-shared.c index 749ea35..5ce2bc5 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -474,65 +474,66 @@ void cgit_print_http_headers(struct cgit_context *ctx) htmlf("Content-Type: %s\n", ctx->page.mimetype); if (ctx->page.size) htmlf("Content-Length: %ld\n", ctx->page.size); if (ctx->page.filename) htmlf("Content-Disposition: inline; filename=\"%s\"\n", ctx->page.filename); htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); htmlf("Expires: %s\n", http_date(ctx->page.expires)); html("\n"); } void cgit_print_docstart(struct cgit_context *ctx) { char *host = cgit_hosturl(); html(cgit_doctype); html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); html("<head>\n"); html("<title>"); html_txt(ctx->page.title); html("</title>\n"); htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); if (ctx->cfg.robots && *ctx->cfg.robots) htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); html("<link rel='stylesheet' type='text/css' href='"); html_attr(ctx->cfg.css); html("'/>\n"); if (ctx->cfg.favicon) { html("<link rel='shortcut icon' href='"); html_attr(ctx->cfg.favicon); html("'/>\n"); } if (host && ctx->repo) { - html("<link rel='alternate' title='Atom feed' href='http://"); + html("<link rel='alternate' title='Atom feed' href='"); + html(cgit_httpscheme()); html_attr(cgit_hosturl()); html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, fmt("h=%s", ctx->qry.head))); html("' type='application/atom+xml'/>"); } html("</head>\n"); html("<body>\n"); if (ctx->cfg.header) html_include(ctx->cfg.header); } void cgit_print_docend() { html("</div>"); if (ctx.cfg.footer) html_include(ctx.cfg.footer); else { htmlf("<div class='footer'>generated by cgit %s at ", cgit_version); cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time); html("</div>\n"); } html("</body>\n</html>\n"); } int print_branch_option(const char *refname, const unsigned char *sha1, int flags, void *cb_data) { char *name = (char *)refname; html_option(name, name, ctx.qry.head); return 0; } |