Use templating for MDL libs included in copy-to-Codepen feature.
parent
0fea59555f
commit
05a672b63a
|
@ -28,10 +28,15 @@ CodeBlockCodePen.prototype.init = function() {
|
|||
'use strict';
|
||||
|
||||
// Also insert the MDL Library.
|
||||
var mdlLibs = '<!-- MDL library and Material icons font -->\n' +
|
||||
'<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">\n' +
|
||||
'<link rel="stylesheet" href="https://storage.googleapis.com/materialdesignlite/material.css">\n' +
|
||||
'<script src="https://storage.googleapis.com/materialdesignlite/material.min.js"></script>\n\n';
|
||||
var mdlLibs = [
|
||||
'<!-- MDL library and Material icons font -->',
|
||||
'<link rel="stylesheet" href="//fonts.googleapis.com/icon?family=Material+Icons">',
|
||||
'<link rel="stylesheet" href="$$hosted_libs_prefix$$/$$version$$/material.indigo-pink.min.css">',
|
||||
'<script src="$$hosted_libs_prefix$$/$$version$$/material.min.js"></script>',
|
||||
// TODO: Remove below before launch. For testing only.
|
||||
'<link rel="stylesheet" href="https://storage.googleapis.com/materialdesignlite/material.css">',
|
||||
'<script src="https://storage.googleapis.com/materialdesignlite/material.min.js"></script>'
|
||||
];
|
||||
|
||||
for (var i = 0, len = this.htmlCodeBlocks.length; i < len; i++) {
|
||||
var pre = this.htmlCodeBlocks[i];
|
||||
|
@ -56,7 +61,13 @@ CodeBlockCodePen.prototype.init = function() {
|
|||
var input = document.createElement('input');
|
||||
input.setAttribute('type', 'hidden');
|
||||
input.setAttribute('name', 'data');
|
||||
input.setAttribute('value', JSON.stringify({html: mdlLibs + pre.innerText}));
|
||||
input.setAttribute('value', JSON.stringify(
|
||||
{html: '<html>\n <head>\n ' +
|
||||
mdlLibs.join('\n ') +
|
||||
'\n </head>\n <body>\n ' +
|
||||
code.split('\n').join('\n ').trim() +
|
||||
'\n </body>\n</html>',
|
||||
css: styleLines.join('\n')}));
|
||||
form.appendChild(input);
|
||||
pre.appendChild(form);
|
||||
}
|
||||
|
|
|
@ -412,6 +412,8 @@ gulp.task('assets', function () {
|
|||
'node_modules/clippy/build/clippy.swf',
|
||||
'node_modules/swfobject-npm/swfobject/src/swfobject.js'
|
||||
])
|
||||
.pipe($.if(/\.js/i, $.replace('$$version$$', pkg.version)))
|
||||
.pipe($.if(/\.js/i, $.replace('$$hosted_libs_prefix$$', hostedLibsUrlPrefix)))
|
||||
.pipe($.if(/\.(svg|jpg|png)$/i, $.imagemin({
|
||||
progressive: true,
|
||||
interlaced: true
|
||||
|
|
Loading…
Reference in New Issue