Make the page title in the html templates a variable in default_settings.py (#378)

Make the page title configurable.

Admins with many sites running separate puppetservers with separate puppetbords may find it useful to be able to chagen the page title from Puppetboard to something more site specific.
This commit is contained in:
tparkercbn
2017-10-18 12:50:54 -04:00
committed by Mike Terzo
parent b957753662
commit 98c4cb608c
5 changed files with 24 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ DISPLAYED_METRICS = ['resources.total',
OFFLINE_MODE = False OFFLINE_MODE = False
ENABLE_CATALOG = False ENABLE_CATALOG = False
OVERVIEW_FILTER = None OVERVIEW_FILTER = None
PAGE_TITLE = "Puppetboard"
GRAPH_TYPE = 'pie' GRAPH_TYPE = 'pie'
GRAPH_FACTS = ['architecture', GRAPH_FACTS = ['architecture',
'clientversion', 'clientversion',

View File

@@ -43,6 +43,7 @@ DISPLAYED_METRICS = [x.strip() for x in os.getenv('DISPLAYED_METRICS',
OFFLINE_MODE = bool(os.getenv('OFFLINE_MODE', 'False').upper() == 'TRUE') OFFLINE_MODE = bool(os.getenv('OFFLINE_MODE', 'False').upper() == 'TRUE')
ENABLE_CATALOG = bool(os.getenv('ENABLE_CATALOG', 'False').upper() == 'TRUE') ENABLE_CATALOG = bool(os.getenv('ENABLE_CATALOG', 'False').upper() == 'TRUE')
OVERVIEW_FILTER = os.getenv('OVERVIEW_FILTER', None) OVERVIEW_FILTER = os.getenv('OVERVIEW_FILTER', None)
PAGE_TITLE = os.getenv('PAGE_TITLE', 'Puppetboard')
GRAPH_FACTS_DEFAULT = ','.join(['architecture', 'clientversion', 'domain', GRAPH_FACTS_DEFAULT = ','.join(['architecture', 'clientversion', 'domain',
'lsbcodename', 'lsbdistcodename', 'lsbdistid', 'lsbcodename', 'lsbdistcodename', 'lsbdistid',

View File

@@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Puppetboard</title> <title>{{config.PAGE_TITLE}}</title>
{% if config.OFFLINE_MODE %} {% if config.OFFLINE_MODE %}
<style> <style>
@font-face { @font-face {

View File

@@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<title>Puppetboard</title> <title>{{config.PAGE_TITLE}}</title>
{% if config.REFRESH_RATE > 0 %} {% if config.REFRESH_RATE > 0 %}
<meta http-equiv='refresh' content="{{config.REFRESH_RATE}}"/> <meta http-equiv='refresh' content="{{config.REFRESH_RATE}}"/>
{% endif %} {% endif %}

View File

@@ -837,3 +837,23 @@ def test_offline_static(client):
assert 'Content-Type' in rv.headers assert 'Content-Type' in rv.headers
assert 'text/css' in rv.headers['Content-Type'] assert 'text/css' in rv.headers['Content-Type']
assert rv.status_code == 200 assert rv.status_code == 200
def test_custom_title(client, mocker):
custom_title = 'Dev - Puppetboard'
app.app.config['PAGE_TITLE'] = custom_title
mock_puppetdb_environments(mocker)
mock_puppetdb_default_nodes(mocker)
query_data = {
'nodes': [[{'count': 10}]],
'resources': [[{'count': 40}]],
}
dbquery = MockDbQuery(query_data)
mocker.patch.object(app.puppetdb, '_query', side_effect=dbquery.get)
rv = client.get('/')
soup = BeautifulSoup(rv.data, 'html.parser')
assert soup.title.contents[0] == custom_title