]>
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");
57 html("<link rel='alternate' type='text/html' href='");
58 html(cgit_httpscheme());
60 pageurl
= cgit_pageurl(ctx
.repo
->url
, "commit", NULL
);
62 if (ctx
.cfg
.virtual_root
)
64 htmlf("%cid=%s", delim
, hex
);
68 htmlf("<id>%s</id>\n", hex
);
69 html("<content type='text'>\n");
72 html("<content type='xhtml'>\n");
73 html("<div xmlns='http://www.w3.org/1999/xhtml'>\n");
80 cgit_free_commitinfo(info
);
84 void cgit_print_atom(char *tip
, char *path
, int max_count
)
87 const char *argv
[] = {NULL
, tip
, NULL
, NULL
, NULL
};
88 struct commit
*commit
;
95 argv
[1] = ctx
.qry
.head
;
102 init_revisions(&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 *repourl
= cgit_repourl(ctx
.repo
->url
);
132 html("<link rel='alternate' type='text/html' href='");
133 html(cgit_httpscheme());
139 while ((commit
= get_revision(&rev
)) != NULL
) {
140 add_entry(commit
, host
);
141 free_commit_buffer(commit
);
142 free_commit_list(commit
->parents
);
143 commit
->parents
= NULL
;