Luke Ross

Colorado

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

Web-based git repository viewer.

Commit fd40eb3715e4b4329997f94485ef0168c3aa88dd

Remove branding to make a generic version

Committed 9 Aug 2017 by Luke Ross

src/colorado/static/colorado.css

@@ -1,69 +1,12 @@
-.list { width: 100%; }
-#file-list { margin-top: 1em; }
-.tidbit { font-style: italic; }
+.diff-add { color: #008000; }
+.diff-del { color: #800000; }
+.diff-hunk { font-weight: bold; }
 .ellipsis { text-overflow: ellipsis; overflow: hidden; }
 .file-box { background-color: white; margin: 1em; padding: 1em; }
 .file-box h3 { margin-top: 0; }
+.list { width: 100%; }
 .rev-id { display: inline-block; max-width: 6em; text-overflow: ellipsis; overflow: hidden; }
-#rev-diff-id { display: inline-block; margin: 0; }
-.diff-hunk { font-weight: bold; }
-.diff-add { color: #008000; }
-.diff-del { color: #800000; }
+.tidbit { font-style: italic; }
 
-/* Copy-pasta */
-@media screen {
-	body {
-		background-color: #fafcef;
-		padding-top: 3.5em;
-	}
-	h1 {
-		background-color: #880c1c;
-		color: #fafcef;
-		left: 0px;
-		margin: 0em;
-		padding-bottom: 0.2em;
-		padding-left: 0.4em;
-		padding-right: 0.4em;
-		padding-top: 0.2em;
-		position: absolute;
-		top: 0px;
-		right: 0px;
-	}
-	h1 a {
-		color: #fafcef;
-	}
-}
-@media print {
-	h1 { color: #880c1c }
-}
-body {
-	color: black;
-}
-h1 {
-	font-size: xx-large;
-	font-weight: bold;
-}
-h1 a {
-	text-decoration: none;
-}
-h1:after {
-	content: ".name";
-	font-size: x-large;
-	font-style: italic;
-	font-weight: normal;
-	opacity: 0.6;
-}
-h1,h2,h3 {
-	font-family: "Utopia", serif;
-}
-h2,h3 {
-	color: #880c1c;
-	font-weight: normal;
-}
-p,li {
-	text-align: justify;
-}
-a {
-	color: #880c1c;
-	text-decoration: underline;
-}
+#file-list { margin-top: 1em; }
+#rev-diff-id { display: inline-block; margin: 0; }


src/colorado/static/colorado.js -> (removed)

@@ -1,21 +0,0 @@
-const setTimes = () => {
-	for(let ele of document.getElementsByClassName("dt-rel")) {
-		let val = ele.getAttribute("title");
-		if (val) {
-			ele.innerHTML = moment(val).fromNow();
-		}
-	}
-};
-
-const changeBranch = (e) => {
-	location.href = e.selectedOptions[0].value;
-};
-
-const bindClickButtons = () => {
-	for(let ele of document.getElementsByClassName("click-button")) {
-		let val = ele.getAttribute("href");
-		if (val) {
-			ele.onclick = () => { location.href = val; };
-		}
-	}
-};


src/colorado/templates/base.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:meld="http://www.plope.com/software/meld3">
+
+<head>
+<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" />
+</head>
+
+<body>
+<h1>Git Viewer</h1>
+
+<div meld:id="container"></div>
+
+</body>
+</html>


src/colorado/templates/index.xml

@@ -1,16 +1,5 @@
 <?xml version="1.0" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:meld="http://www.plope.com/software/meld3">
-
-<head>
-<meta name="viewport" content="width=device-width" />
-<title meld:id="html-title">Repository</title>
-<link href="/static/colorado.css" rel="stylesheet" meld:id="static-css" type="text/css" />
-<script src="/static/colorado.js" meld:id="static-js" type="text/javascript"></script>
-</head>
-
-<body>
-<h1><a href="/">Luke Ross</a></h1>
+<div xmlns="http://www.w3.org/1999/xhtml" xmlns:meld="http://www.plope.com/software/meld3" meld:id="container">
 <h2>Repositories</h2>
 
 <div meld:id="repo">
@@ -18,6 +7,4 @@
 <p class="tidbit">Last updated <span meld:id="repo-updated" title="2017-01-01 00:00:00">2017-01-01 00:00:00</span></p>
 <p meld:id="repo-desc">Description</p>
 </div>
-
-</body>
-</html>
+</div>


src/colorado/templates/repo-blob.xml

@@ -1,15 +1,5 @@
 <?xml version="1.0" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:meld="http://www.plope.com/software/meld3">
-
-<head>
-<meta name="viewport" content="width=device-width" />
-<title meld:id="html-title">Repository</title>
-<link href="/static/colorado.css" rel="stylesheet" meld:id="static-css" type="text/css" />
-</head>
-
-<body>
-<h1><a href="/">Luke Ross</a></h1>
+<div xmlns="http://www.w3.org/1999/xhtml" xmlns:meld="http://www.plope.com/software/meld3" meld:id="container">
 <h2><a href="#" meld:id="repo-name">Repository</a></h2>
 
 <div meld:id="toolbar">
@@ -35,5 +25,4 @@ content
 </pre>
 </div>
 
-</body>
-</html>
+</div>


src/colorado/templates/repo-history.xml

@@ -1,15 +1,5 @@
 <?xml version="1.0" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:meld="http://www.plope.com/software/meld3">
-
-<head>
-<meta name="viewport" content="width=device-width" />
-<title meld:id="html-title">Repository</title>
-<link href="/static/colorado.css" rel="stylesheet" meld:id="static-css" type="text/css" />
-</head>
-
-<body>
-<h1><a href="/">Luke Ross</a></h1>
+<div xmlns="http://www.w3.org/1999/xhtml" xmlns:meld="http://www.plope.com/software/meld3" meld:id="container">
 <h2><a href="#" meld:id="repo-name">Repository</a></h2>
 
 <div meld:id="toolbar">
@@ -33,5 +23,4 @@ Brief introduction to the repo.
 </tr>
 </table>
 
-</body>
-</html>
+</div>


src/colorado/templates/repo-home.xml

@@ -1,15 +1,5 @@
 <?xml version="1.0" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:meld="http://www.plope.com/software/meld3">
-
-<head>
-<meta name="viewport" content="width=device-width" />
-<title meld:id="html-title">Repository</title>
-<link href="/static/colorado.css" rel="stylesheet" meld:id="static-css" type="text/css" />
-</head>
-
-<body>
-<h1><a href="/">Luke Ross</a></h1>
+<div xmlns="http://www.w3.org/1999/xhtml" xmlns:meld="http://www.plope.com/software/meld3" meld:id="container">
 <h2><a href="#" meld:id="repo-name">Repository</a></h2>
 
 <div meld:id="toolbar">
@@ -46,5 +36,4 @@ This is the contents of README.txt
 </pre>
 </div>
 
-</body>
-</html>
+</div>


src/colorado/templates/repo-revision.xml

@@ -1,15 +1,5 @@
 <?xml version="1.0" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:meld="http://www.plope.com/software/meld3">
-
-<head>
-<meta name="viewport" content="width=device-width" />
-<title meld:id="html-title">Repository</title>
-<link href="/static/colorado.css" rel="stylesheet" meld:id="static-css" type="text/css" />
-</head>
-
-<body>
-<h1><a href="/">Luke Ross</a></h1>
+<div xmlns="http://www.w3.org/1999/xhtml" xmlns:meld="http://www.plope.com/software/meld3" meld:id="container">
 <h2><a href="#" meld:id="repo-name">Repository</a></h2>
 
 <div meld:id="toolbar">
@@ -37,5 +27,4 @@ Brief introduction to the repo.
 </pre>
 </div>
 
-</body>
-</html>
+</div>


src/colorado/templates/repo-trees.xml

@@ -1,15 +1,5 @@
 <?xml version="1.0" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:meld="http://www.plope.com/software/meld3">
-
-<head>
-<meta name="viewport" content="width=device-width" />
-<title meld:id="html-title">Repository</title>
-<link href="/static/colorado.css" rel="stylesheet" meld:id="static-css" type="text/css" />
-</head>
-
-<body>
-<h1><a href="/">Luke Ross</a></h1>
+<div xmlns="http://www.w3.org/1999/xhtml" xmlns:meld="http://www.plope.com/software/meld3" meld:id="container">
 <h2><a href="#" meld:id="repo-name">Repository</a></h2>
 
 <div meld:id="toolbar">
@@ -33,5 +23,4 @@ Brief introduction to the repo.
 </tr>
 </table>
 
-</body>
-</html>
+</div>


src/colorado/views.py

@@ -1,6 +1,6 @@
 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
@@ -55,7 +55,7 @@ def configure_template(tpl, repo=None):
 		".static", filename="colorado.js"
 	)))
 	run_on_meld(tpl, "html-title", lambda n: n.content(
-		repo.name if repo else "LukeRoss.name"
+		repo.name if repo else current_app.config.get("SITE_NAME", "Git Viewer")
 	))
 	if repo:
 		git = repo.repo
@@ -87,7 +87,7 @@ def configure_template(tpl, repo=None):
 			run_on_meld(tpl, "repo-tags", lambda n: n.deparent())
 
 
-def parse_xml_for_template(template_name, using=bp):
+def parse_xml_file(template_name, using):
 	"""
 	Method: parse_xml_for_template
 
@@ -110,6 +110,13 @@ def parse_xml_for_template(template_name, using=bp):
 	))
 
 
+def parse_xml_for_template(template_name, using=bp):
+	base = parse_xml_file("base", using)
+	inner = parse_xml_file(template_name, using)
+	base.findmeld("container").replace(inner[:])
+	return base
+
+
 def write_template(doc):
 	"""
 	Method: write_template