Merge pull request #2468 from agaoglu/version-statics

Adding version to names of static files
This commit is contained in:
Julius Volz 2017-03-07 22:22:01 +01:00 committed by GitHub
commit e22553edd2
9 changed files with 121 additions and 113 deletions

View file

@ -1,17 +1,20 @@
{{/* vim: set ft=html: */}} {{/* vim: set ft=html: */}}
{{/* Load Prometheus console library JS/CSS. Should go in <head> */}} {{/* Load Prometheus console library JS/CSS. Should go in <head> */}}
{{ define "prom_console_head" }} {{ define "prom_console_head" }}
<link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/rickshaw/rickshaw.min.css"> <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/rickshaw/rickshaw.min.css?v={{ buildVersion }}">
<link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/bootstrap-3.3.1/css/bootstrap.min.css"> <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/bootstrap-3.3.1/css/bootstrap.min.css?v={{ buildVersion }}">
<link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/css/prom_console.css"> <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/css/prom_console.css?v={{ buildVersion }}">
<script src="{{ pathPrefix }}/static/vendor/rickshaw/vendor/d3.v3.js"></script> <script src="{{ pathPrefix }}/static/vendor/rickshaw/vendor/d3.v3.js?v={{ buildVersion }}"></script>
<script src="{{ pathPrefix }}/static/vendor/rickshaw/vendor/d3.layout.min.js"></script> <script src="{{ pathPrefix }}/static/vendor/rickshaw/vendor/d3.layout.min.js?v={{ buildVersion }}"></script>
<script src="{{ pathPrefix }}/static/vendor/rickshaw/rickshaw.min.js"></script> <script src="{{ pathPrefix }}/static/vendor/rickshaw/rickshaw.min.js?v={{ buildVersion }}"></script>
<script src="{{ pathPrefix }}/static/vendor/js/jquery.min.js"></script> <script src="{{ pathPrefix }}/static/vendor/js/jquery.min.js?v={{ buildVersion }}"></script>
<script src="{{ pathPrefix }}/static/vendor/bootstrap-3.3.1/js/bootstrap.min.js"></script> <script src="{{ pathPrefix }}/static/vendor/bootstrap-3.3.1/js/bootstrap.min.js?v={{ buildVersion }}"></script>
<script>var PATH_PREFIX = "{{ pathPrefix }}";</script> <script>
<script src="{{ pathPrefix }}/static/js/prom_console.js"></script> var PATH_PREFIX = "{{ pathPrefix }}";
var BUILD_VERSION = "{{ buildVersion }}";
</script>
<script src="{{ pathPrefix }}/static/js/prom_console.js?v={{ buildVersion }}"></script>
{{ end }} {{ end }}
{{/* Top of all pages. */}} {{/* Top of all pages. */}}

File diff suppressed because one or more lines are too long

View file

@ -46,7 +46,10 @@ Prometheus.Graph.prototype.initialize = function() {
// Draw graph controls and container from Handlebars template. // Draw graph controls and container from Handlebars template.
var options = {'pathPrefix': PATH_PREFIX}; var options = {
'pathPrefix': PATH_PREFIX,
'buildVersion': BUILD_VERSION
};
jQuery.extend(options, self.options); jQuery.extend(options, self.options);
self.graphHTML = $(Mustache.render(graphTemplate, options)); self.graphHTML = $(Mustache.render(graphTemplate, options));
self.el.append(self.graphHTML); self.el.append(self.graphHTML);
@ -819,7 +822,7 @@ function init() {
}); });
$.ajax({ $.ajax({
url: PATH_PREFIX + "/static/js/graph_template.handlebar", url: PATH_PREFIX + "/static/js/graph_template.handlebar?v=" + BUILD_VERSION,
success: function(data) { success: function(data) {
graphTemplate = data; graphTemplate = data;

View file

@ -6,7 +6,7 @@
</div> </div>
<div class="col-lg-2"> <div class="col-lg-2">
<div class="eval_stats pull-right"></div> <div class="eval_stats pull-right"></div>
<img src="{{ pathPrefix }}/static/img/ajax-loader.gif" class="spinner" alt="ajax_spinner"> <img src="{{ pathPrefix }}/static/img/ajax-loader.gif?v={{ buildVersion }}" class="spinner" alt="ajax_spinner">
</div> </div>
</div> </div>
<div class="row"> <div class="row">

View file

@ -578,7 +578,7 @@ PromConsole.Graph.prototype.dispatch = function() {
} }
var loadingImg = document.createElement("img"); var loadingImg = document.createElement("img");
loadingImg.src = PATH_PREFIX + '/static/img/ajax-loader.gif'; loadingImg.src = PATH_PREFIX + '/static/img/ajax-loader.gif?v=' + BUILD_VERSION;
loadingImg.alt = 'Loading...'; loadingImg.alt = 'Loading...';
loadingImg.className = 'prom_graph_loading'; loadingImg.className = 'prom_graph_loading';
this.graphTd.appendChild(loadingImg); this.graphTd.appendChild(loadingImg);

View file

@ -3,15 +3,16 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Prometheus Time Series Collection and Processing Server</title> <title>Prometheus Time Series Collection and Processing Server</title>
<link rel="shortcut icon" href="{{ pathPrefix }}/static/img/favicon.ico"> <link rel="shortcut icon" href="{{ pathPrefix }}/static/img/favicon.ico?v={{ buildVersion }}">
<script src="{{ pathPrefix }}/static/vendor/js/jquery.min.js"></script> <script src="{{ pathPrefix }}/static/vendor/js/jquery.min.js?v={{ buildVersion }}"></script>
<script src="{{ pathPrefix }}/static/vendor/bootstrap-3.3.1/js/bootstrap.min.js"></script> <script src="{{ pathPrefix }}/static/vendor/bootstrap-3.3.1/js/bootstrap.min.js?v={{ buildVersion }}"></script>
<link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/bootstrap-3.3.1/css/bootstrap.min.css"> <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/bootstrap-3.3.1/css/bootstrap.min.css?v={{ buildVersion }}">
<link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/css/prometheus.css"> <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/css/prometheus.css?v={{ buildVersion }}">
<script> <script>
var PATH_PREFIX = "{{ pathPrefix }}"; var PATH_PREFIX = "{{ pathPrefix }}";
var BUILD_VERSION = "{{ buildVersion }}";
$(function () { $(function () {
$('[data-toggle="tooltip"]').tooltip() $('[data-toggle="tooltip"]').tooltip()
}) })

View file

@ -1,6 +1,6 @@
{{define "head"}} {{define "head"}}
<link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/css/alerts.css"> <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/css/alerts.css?v={{ buildVersion }}">
<script src="{{ pathPrefix }}/static/js/alerts.js"></script> <script src="{{ pathPrefix }}/static/js/alerts.js?v={{ buildVersion }}"></script>
{{end}} {{end}}
{{define "content"}} {{define "content"}}

View file

@ -1,22 +1,22 @@
{{define "head"}} {{define "head"}}
<link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/css/graph.css"> <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/css/graph.css?v={{ buildVersion }}">
<link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/rickshaw/rickshaw.min.css"> <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/rickshaw/rickshaw.min.css?v={{ buildVersion }}">
<link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/eonasdan-bootstrap-datetimepicker/bootstrap-datetimepicker.min.css"> <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/eonasdan-bootstrap-datetimepicker/bootstrap-datetimepicker.min.css?v={{ buildVersion }}">
<script src="{{ pathPrefix }}/static/vendor/rickshaw/vendor/d3.v3.js"></script> <script src="{{ pathPrefix }}/static/vendor/rickshaw/vendor/d3.v3.js?v={{ buildVersion }}"></script>
<script src="{{ pathPrefix }}/static/vendor/rickshaw/vendor/d3.layout.min.js"></script> <script src="{{ pathPrefix }}/static/vendor/rickshaw/vendor/d3.layout.min.js?v={{ buildVersion }}"></script>
<script src="{{ pathPrefix }}/static/vendor/rickshaw/rickshaw.min.js"></script> <script src="{{ pathPrefix }}/static/vendor/rickshaw/rickshaw.min.js?v={{ buildVersion }}"></script>
<script src="{{ pathPrefix }}/static/vendor/moment/moment.min.js"></script> <script src="{{ pathPrefix }}/static/vendor/moment/moment.min.js?v={{ buildVersion }}"></script>
<script src="{{ pathPrefix }}/static/vendor/eonasdan-bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script> <script src="{{ pathPrefix }}/static/vendor/eonasdan-bootstrap-datetimepicker/bootstrap-datetimepicker.min.js?v={{ buildVersion }}"></script>
<script src="{{ pathPrefix }}/static/vendor/bootstrap3-typeahead/bootstrap3-typeahead.min.js"></script> <script src="{{ pathPrefix }}/static/vendor/bootstrap3-typeahead/bootstrap3-typeahead.min.js?v={{ buildVersion }}"></script>
<script src="{{ pathPrefix }}/static/vendor/fuzzy/fuzzy.js"></script> <script src="{{ pathPrefix }}/static/vendor/fuzzy/fuzzy.js?v={{ buildVersion }}"></script>
<script src="{{ pathPrefix }}/static/vendor/mustache/mustache.min.js"></script> <script src="{{ pathPrefix }}/static/vendor/mustache/mustache.min.js?v={{ buildVersion }}"></script>
<script src="{{ pathPrefix }}/static/vendor/js/jquery.selection.js"></script> <script src="{{ pathPrefix }}/static/vendor/js/jquery.selection.js?v={{ buildVersion }}"></script>
<script src="{{ pathPrefix }}/static/vendor/js/jquery.hotkeys.js"></script> <script src="{{ pathPrefix }}/static/vendor/js/jquery.hotkeys.js?v={{ buildVersion }}"></script>
<script src="{{ pathPrefix }}/static/js/graph.js?v=1"></script> <script src="{{ pathPrefix }}/static/js/graph.js?v={{ buildVersion }}"></script>
<script id="graph_template" type="text/x-handlebars-template"></script> <script id="graph_template" type="text/x-handlebars-template"></script>
{{end}} {{end}}

View file

@ -425,6 +425,7 @@ func tmplFuncs(consolesPath string, opts *Options) template_text.FuncMap {
}, },
"consolesPath": func() string { return consolesPath }, "consolesPath": func() string { return consolesPath },
"pathPrefix": func() string { return opts.ExternalURL.Path }, "pathPrefix": func() string { return opts.ExternalURL.Path },
"buildVersion": func() string { return opts.Version.Revision[:7] },
"stripLabels": func(lset model.LabelSet, labels ...model.LabelName) model.LabelSet { "stripLabels": func(lset model.LabelSet, labels ...model.LabelName) model.LabelSet {
for _, ln := range labels { for _, ln := range labels {
delete(lset, ln) delete(lset, ln)