Added git information to website

master
Gina Häußge 2013-06-29 13:41:39 +02:00
parent 1b45d15430
commit 1caba2d634
4 changed files with 45 additions and 10 deletions

View File

@ -130,6 +130,7 @@ class PrinterStateConnection(tornadio2.SocketConnection):
@app.route("/") @app.route("/")
def index(): def index():
branch, commit = util.getGitInfo()
return render_template( return render_template(
"index.jinja2", "index.jinja2",
ajaxBaseUrl=BASEURL, ajaxBaseUrl=BASEURL,
@ -138,7 +139,9 @@ def index():
enableGCodeVisualizer=settings().get(["feature", "gCodeVisualizer"]), enableGCodeVisualizer=settings().get(["feature", "gCodeVisualizer"]),
enableSystemMenu=settings().get(["system"]) is not None and settings().get(["system", "actions"]) is not None and len(settings().get(["system", "actions"])) > 0, enableSystemMenu=settings().get(["system"]) is not None and settings().get(["system", "actions"]) is not None and len(settings().get(["system", "actions"])) > 0,
enableAccessControl=userManager is not None, enableAccessControl=userManager is not None,
enableSdSupport=settings().get(["feature", "sdSupport"]) enableSdSupport=settings().get(["feature", "sdSupport"]),
gitBranch=branch,
gitCommit=commit
) )
#~~ Printer control #~~ Printer control

View File

@ -441,15 +441,22 @@ ul.dropdown-menu li a {
/** Footer */ /** Footer */
.footer { .footer {
text-align: right; ul {
margin: 0;
ul li { li {
display: inline; &:first-child {
margin-left: 1em; margin-left: 0;
font-size: 85%; }
a {
color: #555; display: inline;
margin-left: 1em;
font-size: 85%;
a {
color: #555;
}
} }
} }
} }

View File

@ -568,7 +568,12 @@
</div> </div>
</div> </div>
<div class="footer"> <div class="footer">
<ul> {% if gitBranch and gitCommit %}
<ul class="pull-left muted">
<li><small>Branch: {{ gitBranch }}, Commit: {{ gitCommit }}</small></li>
</ul>
{% endif %}
<ul class="pull-right">
<li><a href="http://octoprint.org"><i class="icon-home"></i> Homepage</a></li> <li><a href="http://octoprint.org"><i class="icon-home"></i> Homepage</a></li>
<li><a href="https://github.com/foosel/OctoPrint/"><i class="icon-download"></i> Sourcecode</a></li> <li><a href="https://github.com/foosel/OctoPrint/"><i class="icon-download"></i> Sourcecode</a></li>
<li><a href="https://github.com/foosel/OctoPrint/wiki"><i class="icon-book"></i> Documentation</a></li> <li><a href="https://github.com/foosel/OctoPrint/wiki"><i class="icon-book"></i> Documentation</a></li>

View File

@ -3,6 +3,7 @@ __author__ = "Gina Häußge <osd@foosel.net>"
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html' __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
import re import re
import os
def getFormattedSize(num): def getFormattedSize(num):
""" """
@ -43,4 +44,23 @@ def getClass(name):
return m return m
def matchesGcode(line, gcode): def matchesGcode(line, gcode):
return re.search("^%s(\D|$)" % gcode.strip(), line, re.I) return re.search("^%s(\D|$)" % gcode.strip(), line, re.I)
def getGitInfo():
gitPath = os.path.abspath(os.path.join(os.path.split(os.path.abspath(__file__))[0], "../../.git"))
if not os.path.exists(gitPath):
return (None, None)
headref = None
with open(os.path.join(gitPath, "HEAD"), "r") as f:
headref = f.readline().strip()
if headref is None:
return (None, None)
headref = headref[len("ref: "):]
branch = headref[headref.rfind("/") + 1:]
with open(os.path.join(gitPath, headref)) as f:
head = f.readline().strip()
return (branch, head)