1 /* ui-atom.c: functions for atom feeds
3 * Copyright (C) 2006-2014 cgit Development Team <cgit@lists.zx2c4.com>
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
12 #include "ui-shared.h"
14 static void add_entry(struct commit *commit, const char *host)
19 struct commitinfo *info;
20 struct date_mode mode = {
21 .type = DATE_STRFTIME,
22 .strftime_fmt = FMT_ATOMDATE,
26 info = cgit_parse_commit(commit);
27 hex = oid_to_hex(&commit->object.oid);
30 html_txt(info->subject);
33 html_txt(show_date(info->committer_date, 0, &mode));
38 html_txt(info->author);
41 if (info->author_email && !ctx.cfg.noplainemail) {
42 mail = xstrdup(info->author_email);
43 t = strchr(mail, '<');
58 html_txt(show_date(info->author_date, 0, &mode));
59 html("</published>\n");
62 html("<link rel='alternate' type='text/html' href='");
63 html(cgit_httpscheme());
65 pageurl = cgit_pageurl(ctx.repo->url, "commit", NULL);
67 if (ctx.cfg.virtual_root)
69 htmlf("%cid=%s", delim, hex);
73 htmlf("<id>%s</id>\n", hex);
74 html("<content type='text'>\n");
77 html("<content type='xhtml'>\n");
78 html("<div xmlns='http://www.w3.org/1999/xhtml'>\n");
85 cgit_free_commitinfo(info);
89 void cgit_print_atom(char *tip, char *path, int max_count)
92 const char *argv[] = {NULL, tip, NULL, NULL, NULL};
93 struct commit *commit;
100 argv[1] = ctx.qry.head;
107 init_revisions(&rev, NULL);
108 rev.abbrev = DEFAULT_ABBREV;
109 rev.commit_format = CMIT_FMT_DEFAULT;
110 rev.verbose_header = 1;
111 rev.show_root_diff = 0;
112 rev.max_count = max_count;
113 setup_revisions(argc, argv, &rev, NULL);
114 prepare_revision_walk(&rev);
116 host = cgit_hosturl();
117 ctx.page.mimetype = "text/xml";
118 ctx.page.charset = "utf-8";
119 cgit_print_http_headers();
120 html("<feed xmlns='http://www.w3.org/2005/Atom'>\n");
122 html_txt(ctx.repo->name);
127 if (tip && !ctx.qry.show_all) {
133 html_txt(ctx.repo->desc);
134 html("</subtitle>\n");
136 char *repourl = cgit_repourl(ctx.repo->url);
137 html("<link rel='alternate' type='text/html' href='");
138 html(cgit_httpscheme());
144 while ((commit = get_revision(&rev)) != NULL) {
145 add_entry(commit, host);
146 free_commit_buffer(commit);
147 free_commit_list(commit->parents);
148 commit->parents = NULL;