Luke Ross

Colorado

4 releases git clone https://lukeross.name/projects/colorado.git/

Web-based git repository viewer.

Commit d12df9ab0f7e7e8e1c636f52f048eb915a739ff4

Revert "basic atom feed support" This reverts commit 2efe114521cdc83cfe163b1bc32f7f19996e70cf.

Committed 11 Sep 2019 by Luke Ross

colorado/feed.py -> (removed)

@@ -1,83 +0,0 @@
-from activitystreams_lxml import atom, activitystream
-from datetime import datetime
-from dateutil.tz import tzutc
-from flask import url_for
-from functools import partial
-from itertools import chain
-
-
-def make_authors(c):
-    if c.author == c.committer:
-        people = [c.author]
-    else:
-        people = [c.author, c.committer]
-
-    authors = []
-    for p in people:
-        a = atom.Author()
-        a.name = p.name
-        authors.append(a)
-
-    return authors
-
-
-def tag_to_entry(repo, tag):
-    return atom.Entry()
-
-
-def commit_to_entry(repo, commit):
-    e = atom.Entry()
-    e.title = ("Commit: {}".format(commit.message.split("\n")[0].strip()))
-    e.content = commit.message.strip()
-    e.updated = datetime.fromtimestamp(commit.committed_date).replace(tzinfo=tzutc())
-    e.id = commit.hexsha
-    l = atom.Link()
-    l.rel = "alternate"
-    l.type = "text/html"
-    l.href = url_for(".diff_view",
-      slug=repo.slug, id=commit.hexsha, _external=True)
-    e.append(l)
-    e.extend(make_authors(commit))
-    e.tail = "\n"
-    return e
-
-
-def queue_commit(queue, repo, commit):
-    queue.append((commit.committed_date, partial(commit_to_entry, repo, commit)))
-    return commit.parents
-
-
-def make_feed(record, num_items=10):
-    feed = atom.Feed(nsmap={None: atom.NS})
-    author = atom.Author()
-    author.name = 'Colorado Git Viewer'
-    author.url = url_for('.index', _external=True)
-    feed.append(author)
-    feed.generator = 'Colorado Git Viewer'
-    feed.id = 'fixme'
-    self_link = atom.Link()
-    self_link.href = url_for('.feed_view', slug=record.slug, _external=True)
-    self_link.rel = 'self'
-    self_link.type = 'application/atom+xml'
-    feed.append(self_link)
-    web_link = atom.Link()
-    web_link.href = url_for('.repo_home', slug=record.slug, _external=True)
-    web_link.rel = 'alternate'
-    web_link.type = 'text/html'
-    feed.append(web_link)
-    feed.title = record.name
-    repo = record.repo
-    tidbits = []
-    tidbits.extend(((t.tag.tagged_date, partial(tag_to_entry, record, t.tag)) for t in repo.tags if t.tag))
-    for branch in repo.branches:
-        commits = [branch.commit]
-        for _ in range(num_items):
-            commits = list(chain.from_iterable((queue_commit(tidbits, record, commit) for commit in commits)))
-
-    tidbits = sorted(tidbits, key=lambda i: i[0], reverse=True)
-    tidbits = tidbits[:num_items]
-    feed.updated = datetime.fromtimestamp(tidbits[0][0]).replace(tzinfo=tzutc())
-    for _, handler in tidbits:
-        feed.append(handler())
-
-    return feed


colorado/views.py

@@ -672,7 +672,4 @@ def trees_view(slug):
 
 @bp.route("/<slug>/feed", methods=["GET"])
 def feed_view(slug):
-	from colorado.feed import make_feed
-	from lxml import etree
-	repo = get_repo(slug)
-	return etree.tostring(make_feed(repo))
+	pass