]>
git.cameronkatri.com Git - cgit.git/blob - ui-atom.c
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
= sha1_to_hex(commit
->object
.sha1
);
25 html_txt(info
->subject
);
28 cgit_print_date(info
->committer_date
, FMT_ATOMDATE
, 0);
33 html_txt(info
->author
);
36 if (info
->author_email
&& !ctx
.cfg
.noplainemail
) {
37 mail
= xstrdup(info
->author_email
);
38 t
= strchr(mail
, '<');
53 cgit_print_date(info
->author_date
, FMT_ATOMDATE
, 0);
54 html("</published>\n");
56 html("<link rel='alternate' type='text/html' href='");
57 html(cgit_httpscheme());
59 html_attr(cgit_pageurl(ctx
.repo
->url
, "commit", NULL
));
60 if (ctx
.cfg
.virtual_root
)
62 htmlf("%cid=%s", delim
, hex
);
65 htmlf("<id>%s</id>\n", hex
);
66 html("<content type='text'>\n");
69 html("<content type='xhtml'>\n");
70 html("<div xmlns='http://www.w3.org/1999/xhtml'>\n");
77 cgit_free_commitinfo(info
);
81 void cgit_print_atom(char *tip
, char *path
, int max_count
)
84 const char *argv
[] = {NULL
, tip
, NULL
, NULL
, NULL
};
85 struct commit
*commit
;
92 argv
[1] = ctx
.qry
.head
;
99 init_revisions(&rev
, NULL
);
100 rev
.abbrev
= DEFAULT_ABBREV
;
101 rev
.commit_format
= CMIT_FMT_DEFAULT
;
102 rev
.verbose_header
= 1;
103 rev
.show_root_diff
= 0;
104 rev
.max_count
= max_count
;
105 setup_revisions(argc
, argv
, &rev
, NULL
);
106 prepare_revision_walk(&rev
);
108 host
= cgit_hosturl();
109 ctx
.page
.mimetype
= "text/xml";
110 ctx
.page
.charset
= "utf-8";
111 cgit_print_http_headers();
112 html("<feed xmlns='http://www.w3.org/2005/Atom'>\n");
114 html_txt(ctx
.repo
->name
);
119 if (tip
&& !ctx
.qry
.show_all
) {
125 html_txt(ctx
.repo
->desc
);
126 html("</subtitle>\n");
128 char *repourl
= cgit_repourl(ctx
.repo
->url
);
129 html("<link rel='alternate' type='text/html' href='");
130 html(cgit_httpscheme());
136 while ((commit
= get_revision(&rev
)) != NULL
) {
137 add_entry(commit
, host
);
138 free_commit_buffer(commit
);
139 free_commit_list(commit
->parents
);
140 commit
->parents
= NULL
;