“0b061960effdaa8dbdbcd9044c4100389deeb4a3”上不存在“doc/tutorials/text_generation/index_en.html”
未验证 提交 ac8d5705 编写于 作者: D daminglu 提交者: GitHub

Fix prod build bug and add sanitizing check for graph data (#384)

上级 68e76c5d
......@@ -14,6 +14,8 @@ import {getPluginGraphsGraph} from '../../service';
// for d3 drawing
import * as d3 from 'd3';
import has from 'lodash/has';
export default {
props: {
'doDownload': {
......@@ -63,6 +65,10 @@ export default {
mounted() {
let chartScope = this;
getPluginGraphsGraph().then(({errno, data}) => {
if (has(data, 'data') === false) {
return;
}
let graphData = data.data;
// d3 svg drawing
......@@ -85,6 +91,9 @@ export default {
};
// add input nodes
if (has(graphData, 'input') === false) {
return;
}
for (let i=0; i<graphData['input'].length; ++i) {
let curInputNode = graphData['input'][i];
let nodeKey = curInputNode['name'];
......@@ -105,6 +114,9 @@ export default {
}
// add operator nodes then add edges from inputs to operator and from operator to output
if (has(graphData, 'node') === false) {
return;
}
for (let i=0; i<graphData['node'].length; ++i) {
let curOperatorNode = graphData['node'][i];
let nodeKey = 'opNode_' + i;
......@@ -129,6 +141,9 @@ export default {
nodeKeys.push(nodeKey);
// add output node
if (has(graphData, 'output') === false) {
return;
}
let outputNodeKey = curOperatorNode['output'][0];
let outputPadding = ' '.repeat(Math.floor(outputNodeKey.length/2));
g.setNode(
......@@ -155,7 +170,7 @@ export default {
}
g.setEdge(nodeKey, curOperatorNode['output'][0], {
style: 'stroke: #333;stroke-width: 1.5px'
style: 'stroke: #333;stroke-width: 1.5px',
});
}
......
......@@ -24,13 +24,22 @@ webpackConfig.plugins = webpackConfig.plugins.concat([
var name = opt.outputName.replace(/\.html$/, '');
var feRoot = feRoots[name];
/*
We do not need the following hack, which was added here:
if (feRoot) {
html = html
.replace(/href="/g, 'href="' + feRoot)
.replace(/src="/g, 'src="' + feRoot);
}
https://github.com/PaddlePaddle/VisualDL/commit/75f5c3b55fb411e0329b98d66253e60137f88bd5#diff-b6dc766994d45268924eff9a07f0765bR31
What it does is simply add './' in front of 'src' and 'href' to make sure it is loading local files.
But it should be able to load both local JS files and CDN files via 'https://...'
*/
// var feRoot = feRoots[name];
// if (feRoot) {
// html = html
// .replace(/href="/g, 'href="' + feRoot);
// .replace(/src="/g, 'src="' + feRoot);
// }
return html;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册