From 4b3224702cd52afcaafde65110e8a55e1b9ce79a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 13 Mar 2015 11:11:31 +0100 Subject: [PATCH] Fixed asset revving issue with css files --- Gruntfile.js | 1 - src/app/components/config.js | 2 +- src/config.sample.js | 105 --------------------------------- src/index.html | 51 ---------------- src/test/test-main.js | 2 +- src/views/index.html | 2 +- tasks/build_task.js | 20 +++++++ tasks/options/clean.js | 5 +- tasks/options/usemin.js | 24 +++++++- tasks/options/useminPrepare.js | 1 - 10 files changed, 46 insertions(+), 167 deletions(-) delete mode 100644 src/config.sample.js delete mode 100644 src/index.html diff --git a/Gruntfile.js b/Gruntfile.js index b175e3aa961..b99c5ed9c1e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,7 +8,6 @@ module.exports = function (grunt) { srcDir: 'src', destDir: 'dist', tempDir: 'tmp', - docsDir: 'docs/', arch: grunt.option('arch') || 'x86_64', }; diff --git a/src/app/components/config.js b/src/app/components/config.js index 4d8d34d857a..e26a55e097b 100644 --- a/src/app/components/config.js +++ b/src/app/components/config.js @@ -4,7 +4,7 @@ define([ function (Settings) { "use strict"; - var bootData = window.grafanaBootData; + var bootData = window.grafanaBootData || { settings: {} }; var options = bootData.settings; return new Settings(options); diff --git a/src/config.sample.js b/src/config.sample.js deleted file mode 100644 index ad14b7f7520..00000000000 --- a/src/config.sample.js +++ /dev/null @@ -1,105 +0,0 @@ -// == Configuration -// config.js is where you will find the core Grafana configuration. This file contains parameter that -// must be set before Grafana is run for the first time. - -define(['settings'], function(Settings) { - "use strict"; - - return new Settings({ - - /* Data sources - * ======================================================== - * Datasources are used to fetch metrics, annotations, and serve as dashboard storage - * - You can have multiple of the same type. - * - grafanaDB: true marks it for use for dashboard storage - * - default: true marks the datasource as the default metric source (if you have multiple) - * - basic authentication: use url syntax http://username:password@domain:port - */ - - // InfluxDB example setup (the InfluxDB databases specified need to exist) - /* - datasources: { - influxdb: { - type: 'influxdb', - url: "http://my_influxdb_server:8086/db/database_name", - username: 'admin', - password: 'admin', - }, - grafana: { - type: 'influxdb', - url: "http://my_influxdb_server:8086/db/grafana", - username: 'admin', - password: 'admin', - grafanaDB: true - }, - }, - */ - - // Graphite & Elasticsearch example setup - /* - datasources: { - graphite: { - type: 'graphite', - url: "http://my.graphite.server.com:8080", - }, - elasticsearch: { - type: 'elasticsearch', - url: "http://my.elastic.server.com:9200", - index: 'grafana-dash', - grafanaDB: true, - } - }, - */ - - // OpenTSDB & Elasticsearch example setup - /* - datasources: { - opentsdb: { - type: 'opentsdb', - url: "http://opentsdb.server:4242", - }, - elasticsearch: { - type: 'elasticsearch', - url: "http://my.elastic.server.com:9200", - index: 'grafana-dash', - grafanaDB: true, - } - }, - */ - - /* Global configuration options - * ======================================================== - */ - - // specify the limit for dashboard search results - search: { - max_results: 100 - }, - - // default home dashboard - default_route: 'dashboard/file/default.json', - - // set to false to disable unsaved changes warning - unsaved_changes_warning: true, - - // set the default timespan for the playlist feature - // Example: "1m", "1h" - playlist_timespan: "1m", - - // Change window title prefix from 'Grafana - ' - window_title_prefix: 'Grafana - ', - - // Add your own custom panels - plugins: { - // list of plugin panels - panels: [], - // requirejs modules in plugins folder that should be loaded - // for example custom datasources - dependencies: [], - } - - }); -}); - - - diff --git a/src/index.html b/src/index.html deleted file mode 100644 index 8c55154067f..00000000000 --- a/src/index.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - Grafana - - - - - - - - - - - - - - -
-
- -
{{alert.title}}
-
-
-
- -
- - - - - - diff --git a/src/test/test-main.js b/src/test/test-main.js index d21f8969dec..1bd25f3732b 100644 --- a/src/test/test-main.js +++ b/src/test/test-main.js @@ -5,7 +5,7 @@ require.config({ specs: '../test/specs', mocks: '../test/mocks', helpers: '../test/specs/helpers', - config: ['../config', '../config.sample'], + config: 'components/config', kbn: 'components/kbn', store: 'components/store', diff --git a/src/views/index.html b/src/views/index.html index a5b0dbba05c..fd92bccd0d5 100644 --- a/src/views/index.html +++ b/src/views/index.html @@ -20,7 +20,7 @@ window.grafanaBackend = true; - + diff --git a/tasks/build_task.js b/tasks/build_task.js index b295ca48506..64f87522515 100644 --- a/tasks/build_task.js +++ b/tasks/build_task.js @@ -19,11 +19,31 @@ module.exports = function(grunt) { 'requirejs:build', 'concat:js', 'filerev', + 'remapFilerev', 'usemin', 'clean:temp', 'uglify:dest' ]); + + // task to add [[.AppSubUrl]] to reved path + grunt.registerTask('remapFilerev', function(){ + var root = grunt.config().destDir; + var summary = grunt.filerev.summary; + var fixed = {}; + + for(var key in summary){ + if(summary.hasOwnProperty(key)){ + + var orig = key.replace(root, root+'/[[.AppSubUrl]]'); + var revved = summary[key].replace(root, root+'/[[.AppSubUrl]]'); + fixed[orig] = revved; + } + } + + grunt.filerev.summary = fixed; + }); + grunt.registerTask('build-post-process', function() { grunt.config('copy.dist_to_tmp', { expand: true, diff --git a/tasks/options/clean.js b/tasks/options/clean.js index 7db6ef22f26..26bc01bc617 100644 --- a/tasks/options/clean.js +++ b/tasks/options/clean.js @@ -1,7 +1,6 @@ module.exports = function(config) { return { on_start: ['<%= destDir %>', '<%= tempDir %>'], - temp: ['<%= tempDir %>'], - docs: ['<%= docsDir %>'] + temp: ['<%= tempDir %>'] }; -}; \ No newline at end of file +}; diff --git a/tasks/options/usemin.js b/tasks/options/usemin.js index 8c09fd0a6e7..f87a70ea672 100644 --- a/tasks/options/usemin.js +++ b/tasks/options/usemin.js @@ -1,11 +1,29 @@ -module.exports = function(config) { +module.exports = function() { + 'use strict'; + return { html: [ '<%= destDir %>/views/index.html', - '<%= destDir %>/index.html', ], options: { - assetsDirs: ['<%= destDir %>'] + assetsDirs: ['<%= destDir %>'], + patterns: { + css: [ + [/(\.css)/, 'Replacing reference to image.png'] + ] + } + // blockReplacements: { + // css: function (block) { + // console.log('aaaaaaaaaaaaa', block); + // return ''; + // } + // } + // css: [ + // [/(grafana\.light\.min\.css)/, 'Replacing reference to light css', function(asd) { + // console.log("Match", asd); + // return 'css/grafana.light.min.css'; + // }] + // ] } }; }; diff --git a/tasks/options/useminPrepare.js b/tasks/options/useminPrepare.js index 17123ac8790..f4b948a846d 100644 --- a/tasks/options/useminPrepare.js +++ b/tasks/options/useminPrepare.js @@ -2,7 +2,6 @@ module.exports = function(config) { return { html: [ 'tmp/index.html', - 'tmp/views/index.html', ] }; };