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 | 9193 +++++++++++----------- 2 files changed, 4606 insertions(+), 4589 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,122 +137,105 @@ 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 = []; -/* styles */ -__webpack_require__(43) - -var Component = __webpack_require__(0)( - /* script */ - __webpack_require__(11), - /* template */ - __webpack_require__(29), - /* scopeId */ - "data-v-4f6bf458", - /* cssModules */ - null -) -Component.options.__file = "/Users/phil/Projects/notebooklab/src/cells/prompt.vue" -if (Component.esModule && Object.keys(Component.esModule).some(function (key) {return key !== "default" && key !== "__esModule"})) {console.error("named exports are not supported in *.vue files.")} -if (Component.options.functional) {console.error("[vue-loader] prompt.vue: functional components are not supported with templates, they should use render functions.")} - -/* hot reload */ -if (false) {(function () { - var hotAPI = require("vue-hot-reload-api") - hotAPI.install(require("vue"), false) - if (!hotAPI.compatible) return - module.hot.accept() - if (!module.hot.data) { - hotAPI.createRecord("data-v-4f6bf458", Component.options) - } else { - hotAPI.reload("data-v-4f6bf458", Component.options) - } -})()} - -module.exports = Component.exports - + // 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(""); + }; -/***/ }), -/* 2 */ -/***/ (function(module, exports) { + // 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; +}; -var g; - -// This works in non-strict mode -g = (function() { - return this; -})(); - -try { - // This works if eval is allowed (see CSP) - g = g || Function("return this")() || (1,eval)("this"); -} catch(e) { - // This works if the window reference is available - if(typeof window === "object") - g = window; -} - -// g can still be undefined, but nothing to do about it... -// We return undefined, instead of nothing here, so it's -// easier to handle this case. if(!global) { ...} - -module.exports = g; +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 + ' */' + }); -/***/ }), -/* 3 */ -/***/ (function(module, exports, __webpack_require__) { + return [content].concat(sourceURLs).concat([sourceMapping]).join('\n'); + } -var Component = __webpack_require__(0)( - /* script */ - __webpack_require__(6), - /* template */ - __webpack_require__(31), - /* scopeId */ - null, - /* cssModules */ - null -) -Component.options.__file = "/Users/phil/Projects/notebooklab/src/cells/code/index.vue" -if (Component.esModule && Object.keys(Component.esModule).some(function (key) {return key !== "default" && key !== "__esModule"})) {console.error("named exports are not supported in *.vue files.")} -if (Component.options.functional) {console.error("[vue-loader] index.vue: functional components are not supported with templates, they should use render functions.")} + return [content].join('\n'); +} -/* hot reload */ -if (false) {(function () { - var hotAPI = require("vue-hot-reload-api") - hotAPI.install(require("vue"), false) - if (!hotAPI.compatible) return - module.hot.accept() - if (!module.hot.data) { - hotAPI.createRecord("data-v-d42105b8", Component.options) - } else { - hotAPI.reload("data-v-d42105b8", Component.options) - } -})()} +// 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; -module.exports = Component.exports + return '/*# ' + data + ' */'; +} +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(18).Buffer)) /***/ }), -/* 4 */ +/* 2 */ /***/ (function(module, exports, __webpack_require__) { /* styles */ -__webpack_require__(39) +__webpack_require__(44) var Component = __webpack_require__(0)( /* script */ - __webpack_require__(12), + __webpack_require__(13), /* template */ - __webpack_require__(28), + __webpack_require__(39), /* scopeId */ - null, + "data-v-4f6bf458", /* cssModules */ null ) -Component.options.__file = "/Users/phil/Projects/notebooklab/src/index.vue" +Component.options.__file = "/Users/phil/Projects/notebooklab/src/cells/prompt.vue" if (Component.esModule && Object.keys(Component.esModule).some(function (key) {return key !== "default" && key !== "__esModule"})) {console.error("named exports are not supported in *.vue files.")} -if (Component.options.functional) {console.error("[vue-loader] index.vue: functional components are not supported with templates, they should use render functions.")} +if (Component.options.functional) {console.error("[vue-loader] prompt.vue: functional components are not supported with templates, they should use render functions.")} /* hot reload */ if (false) {(function () { @@ -261,9 +244,9 @@ if (false) {(function () { if (!hotAPI.compatible) return module.hot.accept() if (!module.hot.data) { - hotAPI.createRecord("data-v-4cb2b168", Component.options) + hotAPI.createRecord("data-v-4f6bf458", Component.options) } else { - hotAPI.reload("data-v-4cb2b168", Component.options) + hotAPI.reload("data-v-4f6bf458", Component.options) } })()} @@ -271,241 +254,327 @@ module.exports = Component.exports /***/ }), -/* 5 */ +/* 3 */ /***/ (function(module, exports, __webpack_require__) { -"use strict"; +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra + Modified by Evan You @yyx990803 +*/ +var hasDocument = typeof document !== 'undefined' -Object.defineProperty(exports, "__esModule", { - value: true -}); +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 _index = __webpack_require__(3); +var listToStyles = __webpack_require__(46) -var _index2 = _interopRequireDefault(_index); +/* +type StyleObject = { + id: number; + parts: Array +} -var _index3 = __webpack_require__(23); +type StyleObjectPart = { + css: string; + media: string; + sourceMap: ?string +} +*/ -var _index4 = _interopRequireDefault(_index3); +var stylesInDom = {/* + [id: number]: { + id: number, + refs: number, + parts: Array<(obj?: StyleObjectPart) => void> + } +*/} -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +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