Show version number next to copyright in QE

Fixes #672
This commit is contained in:
Joseph Schorr 2015-12-28 13:27:32 -05:00
parent 16f16e8a15
commit be61730224
2 changed files with 17 additions and 2 deletions

View file

@ -3,6 +3,7 @@ import json
import string
import datetime
import os
import re
# Register the various exceptions via decorators.
import endpoints.decorated
@ -11,6 +12,7 @@ from flask import make_response, render_template, request, abort, session
from flask.ext.login import login_user
from flask.ext.principal import identity_changed
from random import SystemRandom
from cachetools import lru_cache
from data import model
from app import app, oauth_apps, LoginWrappedDBUser
@ -129,6 +131,14 @@ def list_files(path, extension):
filepath = 'static/' + path
return [join_path(dp, f) for dp, dn, files in os.walk(filepath) for f in files if matches(f)]
@lru_cache(maxsize=1)
def _get_version_number():
try:
with open('CHANGELOG.md') as f:
return re.search('(v[0-9]+\.[0-9]+\.[0-9]+)', f.readline()).group(0)
except IOError:
return ''
def render_page_template(name, **kwargs):
debugging = app.config.get('DEBUGGING', False)
if debugging:
@ -172,6 +182,10 @@ def render_page_template(name, **kwargs):
if len(app.config.get('CONTACT_INFO', [])) == 1:
contact_href = app.config['CONTACT_INFO'][0]
version_number = ''
if not features.BILLING:
version_number = ' - ' + _get_version_number()
resp = make_response(render_template(name,
route_data=json.dumps(get_route_data()),
external_styles=external_styles,
@ -194,7 +208,8 @@ def render_page_template(name, **kwargs):
contact_href=contact_href,
hostname=app.config['SERVER_HOSTNAME'],
preferred_scheme=app.config['PREFERRED_URL_SCHEME'],
**kwargs))
version_number=version_number,
**kwargs))
resp.headers['X-FRAME-OPTIONS'] = 'DENY'
return resp

View file

@ -106,7 +106,7 @@ mixpanel.init("{{ mixpanel_key }}", { track_pageview : false, debug: {{ is_debug
<nav id="co-l-footer" class="page-footer hidden-xs">
<div class="col-md-8">
<ul>
<li><span class="copyright">&copy;2015 CoreOS, Inc.</span></li>
<li><span class="copyright">&copy;2016 CoreOS, Inc. {{ version_number }}</span></li>
<li quay-require="['BILLING']"><a href="/tos" target="_self">Terms</a></li>
<li quay-require="['BILLING']"><a href="/privacy" target="_self">Privacy</a></li>
<li quay-require="['BILLING']"><a href="/security/" target="_self">Security</a></li>