From c71831e80c2bf8044697414edff3fb6f1c09579e Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 29 Mar 2017 09:52:56 +0100 Subject: [PATCH] Added worksheets support to notebook viewer Updated some Ruby code based on comments --- app/models/blob.rb | 2 +- vendor/assets/javascripts/notebooklab.js | 6021 +++++++++++----------- 2 files changed, 3020 insertions(+), 3003 deletions(-) diff --git a/app/models/blob.rb b/app/models/blob.rb index 5b71ac21cc0..95d2111a992 100644 --- a/app/models/blob.rb +++ b/app/models/blob.rb @@ -47,7 +47,7 @@ class Blob < SimpleDelegator end def ipython_notebook? - text? && language && language.name == 'Jupyter Notebook' + text? && language&.name == 'Jupyter Notebook' end def size_within_svg_limits? diff --git a/vendor/assets/javascripts/notebooklab.js b/vendor/assets/javascripts/notebooklab.js index 35397019173..296271205d1 100644 --- a/vendor/assets/javascripts/notebooklab.js +++ b/vendor/assets/javascripts/notebooklab.js @@ -73,7 +73,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 32); +/******/ return __webpack_require__(__webpack_require__.s = 47); /******/ }) /************************************************************************/ /******/ ([ @@ -137,15 +137,97 @@ module.exports = function normalizeComponent ( /* 1 */ /***/ (function(module, exports, __webpack_require__) { +/* WEBPACK VAR INJECTION */(function(Buffer) {/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +// css base code, injected by the css-loader +module.exports = function(useSourceMap) { + var list = []; + + // return the list of modules as css string + list.toString = function toString() { + return this.map(function (item) { + var content = cssWithMappingToString(item, useSourceMap); + if(item[2]) { + return "@media " + item[2] + "{" + content + "}"; + } else { + return content; + } + }).join(""); + }; + + // import a list of modules into the list + list.i = function(modules, mediaQuery) { + if(typeof modules === "string") + modules = [[null, modules, ""]]; + var alreadyImportedModules = {}; + for(var i = 0; i < this.length; i++) { + var id = this[i][0]; + if(typeof id === "number") + alreadyImportedModules[id] = true; + } + for(i = 0; i < modules.length; i++) { + var item = modules[i]; + // skip already imported module + // this implementation is not 100% perfect for weird media query combinations + // when a module is imported multiple times with different media queries. + // I hope this will never occur (Hey this way we have smaller bundles) + if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) { + if(mediaQuery && !item[2]) { + item[2] = mediaQuery; + } else if(mediaQuery) { + item[2] = "(" + item[2] + ") and (" + mediaQuery + ")"; + } + list.push(item); + } + } + }; + return list; +}; + +function cssWithMappingToString(item, useSourceMap) { + var content = item[1] || ''; + var cssMapping = item[3]; + if (!cssMapping) { + return content; + } + + if (useSourceMap) { + var sourceMapping = toComment(cssMapping); + var sourceURLs = cssMapping.sources.map(function (source) { + return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */' + }); + + return [content].concat(sourceURLs).concat([sourceMapping]).join('\n'); + } + + return [content].join('\n'); +} + +// Adapted from convert-source-map (MIT) +function toComment(sourceMap) { + var base64 = new Buffer(JSON.stringify(sourceMap)).toString('base64'); + var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64; + + return '/*# ' + data + ' */'; +} + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(18).Buffer)) + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + /* styles */ -__webpack_require__(43) +__webpack_require__(44) var Component = __webpack_require__(0)( /* script */ - __webpack_require__(11), + __webpack_require__(13), /* template */ - __webpack_require__(29), + __webpack_require__(39), /* scopeId */ "data-v-4f6bf458", /* cssModules */ @@ -172,7 +254,228 @@ module.exports = Component.exports /***/ }), -/* 2 */ +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra + Modified by Evan You @yyx990803 +*/ + +var hasDocument = typeof document !== 'undefined' + +if (typeof DEBUG !== 'undefined' && DEBUG) { + if (!hasDocument) { + throw new Error( + 'vue-style-loader cannot be used in a non-browser environment. ' + + "Use { target: 'node' } in your Webpack config to indicate a server-rendering environment." + ) } +} + +var listToStyles = __webpack_require__(46) + +/* +type StyleObject = { + id: number; + parts: Array +} + +type StyleObjectPart = { + css: string; + media: string; + sourceMap: ?string +} +*/ + +var stylesInDom = {/* + [id: number]: { + id: number, + refs: number, + parts: Array<(obj?: StyleObjectPart) => void> + } +*/} + +var head = hasDocument && (document.head || document.getElementsByTagName('head')[0]) +var singletonElement = null +var singletonCounter = 0 +var isProduction = false +var noop = function () {} + +// Force single-tag solution on IE6-9, which has a hard limit on the # of