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;
21 info = cgit_parse_commit(commit);
22 hex = oid_to_hex(&commit->object.oid);
25 html_txt(info->subject);
28 html_txt(show_date(info->committer_date, 0,
29 date_mode_from_type(DATE_ISO8601_STRICT)));
34 html_txt(info->author);
37 if (info->author_email && !ctx.cfg.noplainemail) {
38 mail = xstrdup(info->author_email);
39 t = strchr(mail, '<');
54 html_txt(show_date(info->author_date, 0,
55 date_mode_from_type(DATE_ISO8601_STRICT)));
56 html("</published>\n");
59 html("<link rel='alternate' type='text/html' href='");
60 html(cgit_httpscheme());
62 pageurl = cgit_pageurl(ctx.repo->url, "commit", NULL);
64 if (ctx.cfg.virtual_root)
66 html_attrf("%cid=%s", delim, hex);
70 htmlf("<id>%s</id>\n", hex);
71 html("<content type='text'>\n");
74 html("<content type='xhtml'>\n");
75 html("<div xmlns='http://www.w3.org/1999/xhtml'>\n");
82 cgit_free_commitinfo(info);
86 void cgit_print_atom(char *tip, const char *path, int max_count)
89 const char *argv[] = {NULL, tip, NULL, NULL, NULL};
90 struct commit *commit;
97 argv[1] = ctx.qry.head;
104 init_revisions(&rev, NULL);
105 rev.abbrev = DEFAULT_ABBREV;
106 rev.commit_format = CMIT_FMT_DEFAULT;
107 rev.verbose_header = 1;
108 rev.show_root_diff = 0;
109 rev.max_count = max_count;
110 setup_revisions(argc, argv, &rev, NULL);
111 prepare_revision_walk(&rev);
113 host = cgit_hosturl();
114 ctx.page.mimetype = "text/xml";
115 ctx.page.charset = "utf-8";
116 cgit_print_http_headers();
117 html("<feed xmlns='http://www.w3.org/2005/Atom'>\n");
119 html_txt(ctx.repo->name);
124 if (tip && !ctx.qry.show_all) {
130 html_txt(ctx.repo->desc);
131 html("</subtitle>\n");
133 char *repourl = cgit_repourl(ctx.repo->url);
134 html("<link rel='alternate' type='text/html' href='");
135 html(cgit_httpscheme());
141 while ((commit = get_revision(&rev)) != NULL) {
142 add_entry(commit, host);
143 free_commit_buffer(the_repository->parsed_objects, commit);
144 free_commit_list(commit->parents);
145 commit->parents = NULL;