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);
71 html_txtf("urn:%s:%s", the_hash_algo->name, hex);
73 html("<content type='text'>\n");
77 cgit_free_commitinfo(info);
81 void cgit_print_atom(char *tip, const char *path, int max_count)
84 const char *argv[] = {NULL, tip, NULL, NULL, NULL};
85 struct commit *commit;
93 argv[1] = ctx.qry.head;
100 init_revisions(&rev, NULL);
101 rev.abbrev = DEFAULT_ABBREV;
102 rev.commit_format = CMIT_FMT_DEFAULT;
103 rev.verbose_header = 1;
104 rev.show_root_diff = 0;
105 rev.max_count = max_count;
106 setup_revisions(argc, argv, &rev, NULL);
107 prepare_revision_walk(&rev);
109 host = cgit_hosturl();
110 ctx.page.mimetype = "text/xml";
111 ctx.page.charset = "utf-8";
112 cgit_print_http_headers();
113 html("<feed xmlns='http://www.w3.org/2005/Atom'>\n");
115 html_txt(ctx.repo->name);
120 if (tip && !ctx.qry.show_all) {
126 html_txt(ctx.repo->desc);
127 html("</subtitle>\n");
129 char *fullurl = cgit_currentfullurl();
130 char *repourl = cgit_repourl(ctx.repo->url);
132 html_txtf("%s%s%s", cgit_httpscheme(), host, fullurl);
134 html("<link rel='self' href='");
135 html_attrf("%s%s%s", cgit_httpscheme(), host, fullurl);
137 html("<link rel='alternate' type='text/html' href='");
138 html_attrf("%s%s%s", cgit_httpscheme(), host, repourl);
143 while ((commit = get_revision(&rev)) != NULL) {
146 html_txt(show_date(commit->date, 0,
147 date_mode_from_type(DATE_ISO8601_STRICT)));
148 html("</updated>\n");
151 add_entry(commit, host);
152 release_commit_memory(the_repository->parsed_objects, commit);
153 commit->parents = NULL;