Luke Ross

Colorado

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

Web-based git repository viewer.

Commit 251133b8cf0a96de255bb67f48c3348498664199

Revert "Hook in feed to template" This reverts commit 0674bf9f1626c4b144c6c9a60d6d9863f4caf3b0.

Committed 11 Sep 2019 by Luke Ross

colorado/templates/base.xml

@@ -6,7 +6,6 @@
 <meta name="viewport" content="width=device-width" />
 <title meld:id="html-title">Git Viewer</title>
 <link href="/static/colorado.css" rel="stylesheet" meld:id="static-css" type="text/css" />
-<link rel="alternate" type="application/atom+xml" title="Feed" href="/feed" meld:id="html-feed" />
 </head>
 
 <body>


colorado/views.py

@@ -50,25 +50,19 @@ def run_on_meld(tpl, id, fn):
 		return fn(node)
 
 
-def configure_template(tpl, repo=None, feed=None):
-	css = [
-		c for c in (
-			url_for(".static", filename="colorado.css"),
-			current_app.config.get('COLORADO_CSS', None)
-		) if c
-	]
-	for ele, fn in tpl.findmeld("static-css").repeat(css):
-		ele.set("href", fn)
-
+def configure_template(tpl, repo=None):
+	run_on_meld(
+		tpl,
+		"static-css",
+		lambda n: n.set(
+			"href",
+			current_app.config.get('COLORADO_CSS', None) or
+			url_for(".static", filename="colorado.css")
+		)
+	)
 	run_on_meld(tpl, "static-js", lambda n: n.set("src", url_for(
 		".static", filename="colorado.js"
 	)))
-
-	if feed:
-		run_on_meld(tpl, "html-feed", lambda n: n.set("href", feed))
-	else:
-		run_on_meld(tpl, "html-feed", lambda n: n.deparent())
-
 	if repo:
 		run_on_meld(tpl, "html-title", lambda n: n.content(
 			repo.name
@@ -234,8 +228,7 @@ def look_up_thing(slug, type, id):
 @bp.route("/<slug>/", methods=["GET"])
 def repo_home(slug):
 	repo = get_repo(slug)
-	feed = url_for(".feed_view", slug=slug)
-	return top_level_view(slug, "branch", repo.get_master().name, feed)
+	return top_level_view(slug, "branch", repo.get_master().name)
 
 
 def get_parent_diff(git, commit, **kwargs):
@@ -357,10 +350,7 @@ def history_view(slug, type, id):
 	configure_template(tpl, repo)
 	all_commits = chain([commit], commit.iter_parents())
 	for ele, c in tpl.findmeld("rev").repeat(all_commits):
-		repeats = ele.findmeld("rev-tag-repeat").repeat(
-			tag_things.get(c.hexsha, [])
-		)
-		for inner, (thing, type) in repeats:
+		for inner, (thing, type) in ele.findmeld("rev-tag-repeat").repeat(tag_things.get(c.hexsha, [])):
 			inner.findmeld("rev-tag-link").content(thing.name)
 			inner.findmeld("rev-tag-link").set("href", url_for(
 				".top_level_view", slug=slug, type=type, id=thing.name
@@ -490,14 +480,14 @@ def tree_view(slug, type, id, path):
 
 
 @bp.route("/<slug>/<type>/<id>/tree", methods=["GET"])
-def top_level_view(slug, type, id, feed=None):
+def top_level_view(slug, type, id):
 	repo, point, commit = look_up_thing(slug, type, id)
 	show_download = type in ("branch", "release")
 	return tree_base_view(
-		slug, type, id, repo, commit, commit.tree, show_download, feed)
+		slug, type, id, repo, commit, commit.tree, show_download)
 
 
-def tree_base_view(slug, type, id, repo, commit, tree, show_download=False, feed=None):
+def tree_base_view(slug, type, id, repo, commit, tree, show_download=False):
 	by_file = {}
 	commit_count = 0
 	for current in chain([commit], commit.iter_parents()):
@@ -512,7 +502,7 @@ def tree_base_view(slug, type, id, repo, commit, tree, show_download=False, feed
 				by_file[diff.b_path] = current
 
 	tpl = parse_xml_for_template("repo-home")
-	configure_template(tpl, repo, feed)
+	configure_template(tpl, repo)
 	tpl.findmeld("repo-name").content(repo.name)
 	tpl.findmeld("repo-desc").content(repo.description)
 	tpl.findmeld("repo-commits")[0].content(str(commit_count))
@@ -685,7 +675,4 @@ def feed_view(slug):
 	from colorado.feed import make_feed
 	from lxml import etree
 	repo = get_repo(slug)
-	return make_response(
-		etree.tostring(make_feed(repo), pretty_print=True),
-		{"Content-Type": "application/atom+xml"}
-	)
+	return etree.tostring(make_feed(repo), pretty_print=True)