Thu Dec 1 22:07:08 UTC 2005 stephane@sources.org * ATOM support for syndication diff -rN -u old-darcsweb/darcsweb.cgi new-darcsweb/darcsweb.cgi --- old-darcsweb/darcsweb.cgi 2015-04-18 08:11:44.000000000 +0000 +++ new-darcsweb/darcsweb.cgi 2015-04-18 08:11:44.000000000 +0000 @@ -20,6 +20,7 @@ import xml.sax from xml.sax.saxutils import escape as xml_escape +iso_datetime = '%Y-%m-%dT%H:%M:%SZ' # empty configuration class, we will fill it in later depending on the repo class config: @@ -1715,7 +1716,68 @@ print_log(topi = topi) print_footer() +def do_atom(): + print "Content-type: application/atom+xml; charset=utf-8\n" + print '' + inv = config.repodir + '/_darcs/inventory' + repo_lastmod = os.stat(inv).st_mtime + print """ + %(reponame)s darcs repository + + + %(url)s + darcs repository (several authors) + darcsweb.cgi + %(lastmod)s + %(desc)s + """ % { + 'reponame': config.reponame, + 'url': config.myurl + '/' + config.myreponame, + 'desc': config.repodesc, + 'lastmod': time.strftime(iso_datetime, time.localtime(repo_lastmod))} + ps = get_last_patches(20) + for p in ps: + title = time.strftime('%d %b %H:%M', time.localtime(p.date)) + title += ' - ' + p.name + pdate = time.strftime(iso_datetime, + time.localtime(p.date)) + link = '%s/%s;a=commit;h=%s' % (config.myurl, + config.myreponame, p.hash) + print """ + + %(title)s + %(author)s + %(pdate)s + %(url)s/%(pname)s + + %(desc)s + """ % { + 'title': escape(title), + 'author': p.author, + 'url': config.myurl + '/' + config.myreponame, + 'pdate': pdate, + 'pname': escape(p.name), + 'link': link, + 'desc': escape(p.name), + } + # TODO: allow to get plain text, not HTML? + print '

' + print escape(p.name) + '
' + if p.comment: + print '
' + print escape(p.comment).replace('\n', '
\n') + print '
' + print '
' + changed = p.adds + p.removes + p.modifies.keys() + \ + p.moves.keys() + p.diradds + p.dirremoves + \ + p.replaces.keys() + for i in changed: # TODO: link to the file + print '%s
' % i + print '

' + print '
' + print '
' + def do_rss(): print "Content-type: text/xml; charset=utf-8\n" print '' @@ -2128,6 +2190,9 @@ elif action == 'rss': do_rss() +elif action == 'atom': + do_atom() + else: action = "invalid query" do_die()