Luke Ross

Colorado

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

Web-based git repository viewer.

Commit 441a3154e93d2a686b25d1bebffca3431c68fc70

Some clean-up, and easier custom branding.

Committed 7 Jun 2018 by Luke Ross

README.md

@@ -12,7 +12,7 @@ Copyright and license
 ---------------------
 
 Colorado viewer for git repositories
-(c) 2017 Luke Ross <luke@lukeross.name>
+(c) 2017-2018 Luke Ross <luke@lukeross.name>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as


setup.py

@@ -11,6 +11,7 @@ setup(
 	url="https://lukeross.name/",
 	install_requires=[
 		"arrow",
+		"chardet",
 		"flask",
 		"flask-sqlalchemy",
 		"gitpython",


src/colorado/templates/base.xml

@@ -9,7 +9,7 @@
 </head>
 
 <body>
-<h1>Git Viewer</h1>
+<h1><a href="/" meld:id="page-title">Git Viewer</a></h1>
 
 <div meld:id="container"></div>
 


src/colorado/templates/repo-blob.xml

@@ -6,7 +6,7 @@
 <a href="#" meld:id="repo-branches"><span>2</span> branches</a>
 <a href="#" meld:id="repo-tags"><span>5</span> releases</a>
 <a href="#" meld:id="repo-issues"><span>5</span> issues</a>
-<span meld:id="repo-clone">http://example.com/clone-me</span>
+<tt>git clone <span meld:id="repo-clone">http://example.com/clone-me</span></tt>
 </div>
 
 <p meld:id="repo-desc">


src/colorado/templates/repo-history.xml

@@ -7,7 +7,7 @@
 <a href="#" meld:id="repo-branches"><span>2</span> branches</a>
 <a href="#" meld:id="repo-tags"><span>5</span> releases</a>
 <a href="#" meld:id="repo-issues"><span>5</span> issues</a>
-<span meld:id="repo-clone">http://example.com/clone-me</span>
+<tt>git clone <span meld:id="repo-clone">http://example.com/clone-me</span></tt>
 </div>
 
 <p meld:id="repo-desc">


src/colorado/templates/repo-home.xml

@@ -8,7 +8,7 @@
 <a href="#" meld:id="repo-commits"><span>20</span> commits</a>
 <a href="#" meld:id="repo-issues"><span>5</span> issues</a>
 <a href="#" meld:id="repo-download">foo-master-20170612.tar.gz</a>
-<span meld:id="repo-clone">http://example.com/clone-me</span>
+<tt>git clone <span meld:id="repo-clone">http://example.com/clone-me</span></tt>
 </div>
 
 <p meld:id="repo-desc">


src/colorado/templates/repo-revision.xml

@@ -6,7 +6,7 @@
 <a href="#" meld:id="repo-branches"><span>2</span> branches</a>
 <a href="#" meld:id="repo-tags"><span>5</span> releases</a>
 <a href="#" meld:id="repo-issues"><span>5</span> issues</a>
-<span meld:id="repo-clone">http://example.com/clone-me</span>
+<tt>git clone <span meld:id="repo-clone">http://example.com/clone-me</span></tt>
 </div>
 
 <p meld:id="repo-desc">


src/colorado/templates/repo-trees.xml

@@ -6,7 +6,7 @@
 <a href="#" meld:id="repo-branches"><span>2</span> branches</a>
 <a href="#" meld:id="repo-tags"><span>5</span> releases</a>
 <a href="#" meld:id="repo-issues"><span>5</span> issues</a>
-<span meld:id="repo-clone">http://example.com/clone-me</span>
+<tt>git clone <span meld:id="repo-clone">http://example.com/clone-me</span></tt>
 </div>
 
 <p meld:id="repo-desc">


src/colorado/views.py

@@ -1,6 +1,7 @@
 import arrow
 import chardet
-from flask import abort, Blueprint, make_response, send_file, url_for
+from flask import abort, Blueprint, current_app, make_response, send_file, \
+	url_for
 from io import BytesIO
 from itertools import chain
 from lxmlmeld import parse_xml
@@ -48,9 +49,15 @@ def run_on_meld(tpl, id, fn):
 
 
 def configure_template(tpl, repo=None):
-	run_on_meld(tpl, "static-css", lambda n: n.set("href", url_for(
-		".static", filename="colorado.css"
-	)))
+	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"
 	)))
@@ -85,6 +92,19 @@ def configure_template(tpl, repo=None):
 			))
 		else:
 			run_on_meld(tpl, "repo-tags", lambda n: n.deparent())
+	run_on_meld(tpl, "page-title", lambda n: n.set(
+		"href",
+		current_app.config.get('COLORADO_HREF', None) or
+		url_for(".index")
+	))
+	if 'COLORADO_TITLE' in current_app.config:
+		run_on_meld(tpl, "page-title", lambda n: n.content(
+			current_app.config['COLORADO_TITLE']
+		))
+		if not repo:
+			run_on_meld(tpl, "html-title", lambda n: n.content(
+				current_app.config['COLORADO_TITLE']
+			))
 
 
 def parse_xml_file(template_name, using):


stdeb.cfg -> (removed)

@@ -1,2 +0,0 @@
-[DEFAULT]
-Depends3: python3-chardet