Skip to content

Commit

Permalink
Merge pull request #7864 from elastic/jasper/backport/7855/7861/4.1
Browse files Browse the repository at this point in the history
[backport] PR #7855 to 4.1
  • Loading branch information
jbudz authored Jul 27, 2016
2 parents c5dc97a + b4226e8 commit 1ad184a
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 50 deletions.
5 changes: 3 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@
"requirejs": "2.1.18",
"requirejs-text": "2.0.14",
"lodash-deep": "spenceralger/lodash-deep#1a7eca8344",
"marked": "0.3.3",
"marked": "0.3.5",
"numeral": "1.5.3",
"leaflet-draw": "0.2.4",
"semver": "~4.3.4"
"semver": "~4.3.4",
"angular-sanitize": "1.5.8"
},
"devDependencies": {},
"resolutions": {
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,11 @@
"grunt-run": "^0.2.3",
"grunt-s3": "^0.2.0-alpha.3",
"grunt-simple-mocha": "^0.4.0",
"html-entities": "^1.1.1",
"http-proxy": "^1.8.1",
"husky": "^0.6.0",
"istanbul": "^0.2.4",
"license-checker": "^3.1.0",
"load-grunt-config": "^0.7.0",
"marked": "0.3.3",
"marked-text-renderer": "^0.1.0",
"mkdirp": "^0.5.0",
"mocha": "^2.2.5",
"npm": "^2.15.8",
Expand Down
4 changes: 2 additions & 2 deletions src/kibana/components/vislib/visualizations/tile_map.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
define(function (require) {
return function TileMapFactory(d3, Private, configFile) {
return function TileMapFactory(d3, Private, configFile, $sanitize) {
var _ = require('lodash');
var $ = require('jquery');
var L = require('leaflet');
Expand Down Expand Up @@ -84,7 +84,7 @@ define(function (require) {

var div = $(this).addClass('tilemap');
var tileLayer = L.tileLayer(configFile.tilemap_url, {
attribution: marked(configFile.tilemap_attribution),
attribution: $sanitize(marked(configFile.tilemap_attribution)),
subdomains: configFile.tilemap_subdomains,
minZoom: configFile.tilemap_min_zoom,
maxZoom: configFile.tilemap_max_zoom
Expand Down
3 changes: 2 additions & 1 deletion src/kibana/components/visualize/visualize.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
define(function (require) {
require('angular-sanitize');
require('modules')
.get('kibana/directive')
.get('kibana/directive', ['ngSanitize'])
.directive('visualize', function (Notifier, SavedVis, indexPatterns, Private) {

require('components/visualize/spy/spy');
Expand Down
7 changes: 4 additions & 3 deletions src/kibana/plugins/markdown_vis/markdown_vis_controller.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
define(function (require) {
var marked = require('marked');
require('angular-sanitize');
marked.setOptions({
gfm: true, // Github-flavored markdown
sanitize: true // Sanitize HTML tags
});

var module = require('modules').get('kibana/markdown_vis', ['kibana']);
var module = require('modules').get('kibana/markdown_vis', ['kibana', 'ngSanitize']);
module.controller('KbnMarkdownVisController', function ($scope, $sce) {
$scope.$watch('vis.params.markdown', function (html) {
if (!html) return;
$scope.html = $sce.trustAsHtml(marked(html));
$scope.html = marked(html);
});
});
});
});
1 change: 1 addition & 0 deletions src/kibana/require.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require.config({
'angular-bootstrap': 'bower_components/angular-bootstrap/ui-bootstrap-tpls',
'angular-elastic': 'bower_components/angular-elastic/elastic',
'angular-route': 'bower_components/angular-route/angular-route',
'angular-sanitize': 'bower_components/angular-sanitize/angular-sanitize',
'angular-ui-ace': 'bower_components/angular-ui-ace/ui-ace',
ace: 'bower_components/ace-builds/src-noconflict/ace',
'ace-json': 'bower_components/ace-builds/src-noconflict/mode-json',
Expand Down
44 changes: 5 additions & 39 deletions tasks/compile_dist_readme.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
var marked = require('marked');
var Promise = require('bluebird');
var join = require('path').join;
var TextRenderer = require('marked-text-renderer');
var _ = require('lodash');
var fs = require('fs');
var entities = new (require('html-entities').AllHtmlEntities)();

var readFile = Promise.promisify(fs.readFile);
var writeFile = Promise.promisify(fs.writeFile);

TextRenderer.prototype.heading = function (text, level, raw) {
return '\n\n' + text + '\n' + _.map(text, function () { return '='; }).join('') + '\n';
};

var process = function (input) {
var output = input.replace(/<\!\-\- [^\-]+ \-\->/g, '\n');
output = marked(output);
return entities.decode(output);
};

module.exports = function (grunt) {

Expand All @@ -32,29 +15,12 @@ module.exports = function (grunt) {
var srcLicense = join(root, 'LICENSE.md');
var distLicense = join(build, 'dist', 'kibana', 'LICENSE.txt');

marked.setOptions({
renderer: new TextRenderer(),
tables: true,
breaks: false,
pedantic: false,
sanitize: false,
smartLists: true,
smartypants: false
});

readFile(srcReadme, 'utf-8')
.then(function (data) {
return writeFile(distReadme, process(data.toString()));
})
.then(function () {
return readFile(srcLicense, 'utf-8');
})
.then(function (data) {
return writeFile(distLicense, process(data.toString()));
})
.then(done)
.catch(done);
function transformReadme(readme) {
return readme.replace(/\s##\sSnapshot\sBuilds[\s\S]*/, '');
}

grunt.file.copy(srcLicense, distLicense);
grunt.file.write(distReadme, transformReadme(grunt.file.read(srcReadme)));
});

};

0 comments on commit 1ad184a

Please sign in to comment.