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)
9 #define USE_THE_REPOSITORY_VARIABLE
14 #include "ui-shared.h"
16 static void add_entry(struct commit *commit, const char *host)
21 struct commitinfo *info;
23 info = cgit_parse_commit(commit);
24 hex = oid_to_hex(&commit->object.oid);
27 html_txt(info->subject);
30 html_txt(show_date(info->committer_date, 0,
31 date_mode_from_type(DATE_ISO8601_STRICT)));
36 html_txt(info->author);
39 if (info->author_email && !ctx.cfg.noplainemail) {
40 mail = xstrdup(info->author_email);
41 t = strchr(mail, '<');
56 html_txt(show_date(info->author_date, 0,
57 date_mode_from_type(DATE_ISO8601_STRICT)));
58 html("</published>\n");
61 html("<link rel='alternate' type='text/html' href='");
62 html(cgit_httpscheme());
64 pageurl = cgit_pageurl(ctx.repo->url, "commit", NULL);
66 if (ctx.cfg.virtual_root)
68 html_attrf("%cid=%s", delim, hex);
73 html_txtf("urn:%s:%s", the_hash_algo->name, hex);
75 html("<content type='text'>\n");
79 cgit_free_commitinfo(info);
83 void cgit_print_atom(char *tip, const char *path, int max_count)
86 const char *argv[] = {NULL, tip, NULL, NULL, NULL};
87 struct commit *commit;
95 argv[1] = ctx.qry.head;
102 repo_init_revisions(the_repository, &rev, NULL);
103 rev.abbrev = DEFAULT_ABBREV;
104 rev.commit_format = CMIT_FMT_DEFAULT;
105 rev.verbose_header = 1;
106 rev.show_root_diff = 0;
107 rev.max_count = max_count;
108 setup_revisions(argc, argv, &rev, NULL);
109 prepare_revision_walk(&rev);
111 host = cgit_hosturl();
112 ctx.page.mimetype = "text/xml";
113 ctx.page.charset = "utf-8";
114 cgit_print_http_headers();
115 html("<feed xmlns='http://www.w3.org/2005/Atom'>\n");
117 html_txt(ctx.repo->name);
122 if (tip && !ctx.qry.show_all) {
128 html_txt(ctx.repo->desc);
129 html("</subtitle>\n");
131 char *fullurl = cgit_currentfullurl();
132 char *repourl = cgit_repourl(ctx.repo->url);
134 html_txtf("%s%s%s", cgit_httpscheme(), host, fullurl);
136 html("<link rel='self' href='");
137 html_attrf("%s%s%s", cgit_httpscheme(), host, fullurl);
139 html("<link rel='alternate' type='text/html' href='");
140 html_attrf("%s%s%s", cgit_httpscheme(), host, repourl);
145 while ((commit = get_revision(&rev)) != NULL) {
148 html_txt(show_date(commit->date, 0,
149 date_mode_from_type(DATE_ISO8601_STRICT)));
150 html("</updated>\n");
153 add_entry(commit, host);
154 release_commit_memory(the_repository->parsed_objects, commit);
155 commit->parents = NULL;