diff --git a/public/css/gogs.css b/public/css/gogs.css
index c8d6f2ce3..ec4402d0b 100644
--- a/public/css/gogs.css
+++ b/public/css/gogs.css
@@ -812,7 +812,7 @@ footer .ui.language .menu {
border: solid 1px #ccc;
border-bottom-color: #bbb;
border-radius: 3px;
- box-shadow: inset 0 -1px 0 #bbb;
+ box-shadow: inset 0 -1px 0 #bbbbbb;
}
.markdown:not(code) input[type="checkbox"] {
vertical-align: middle !important;
@@ -883,7 +883,7 @@ footer .ui.language .menu {
}
.install form label {
text-align: right;
- width: 320px !important;
+ width: 320px;
}
.install form input {
width: 35% !important;
@@ -892,7 +892,7 @@ footer .ui.language .menu {
text-align: left;
}
.install form .field .help {
- margin-left: 335px !important;
+ margin-left: 335px;
}
.install form .field.optional .title {
margin-left: 38%;
@@ -928,18 +928,18 @@ footer .ui.language .menu {
text-align: center;
}
#create-page-form form .header {
- padding-left: 280px !important;
+ padding-left: 280px;
}
#create-page-form form .inline.field > label {
text-align: right;
- width: 250px !important;
+ width: 250px;
word-wrap: break-word;
}
#create-page-form form .help {
- margin-left: 265px !important;
+ margin-left: 265px;
}
#create-page-form form .optional .title {
- margin-left: 250px !important;
+ margin-left: 250px;
}
#create-page-form form input,
#create-page-form form textarea {
@@ -965,7 +965,7 @@ footer .ui.language .menu {
.user.reset.password form .header,
.user.signin form .header,
.user.signup form .header {
- padding-left: 280px !important;
+ padding-left: 280px;
}
.user.activate form .inline.field > label,
.user.forgot.password form .inline.field > label,
@@ -973,7 +973,7 @@ footer .ui.language .menu {
.user.signin form .inline.field > label,
.user.signup form .inline.field > label {
text-align: right;
- width: 250px !important;
+ width: 250px;
word-wrap: break-word;
}
.user.activate form .help,
@@ -981,14 +981,14 @@ footer .ui.language .menu {
.user.reset.password form .help,
.user.signin form .help,
.user.signup form .help {
- margin-left: 265px !important;
+ margin-left: 265px;
}
.user.activate form .optional .title,
.user.forgot.password form .optional .title,
.user.reset.password form .optional .title,
.user.signin form .optional .title,
.user.signup form .optional .title {
- margin-left: 250px !important;
+ margin-left: 250px;
}
.user.activate form input,
.user.forgot.password form input,
@@ -1014,14 +1014,14 @@ footer .ui.language .menu {
.user.reset.password form .header,
.user.signin form .header,
.user.signup form .header {
- padding-left: 230px !important;
+ padding-left: 230px;
}
.user.activate form .inline.field > label,
.user.forgot.password form .inline.field > label,
.user.reset.password form .inline.field > label,
.user.signin form .inline.field > label,
.user.signup form .inline.field > label {
- width: 200px !important;
+ width: 200px;
}
.repository.new.repo form,
.repository.new.migrate form,
@@ -1037,24 +1037,24 @@ footer .ui.language .menu {
.repository.new.repo form .header,
.repository.new.migrate form .header,
.repository.new.fork form .header {
- padding-left: 280px !important;
+ padding-left: 280px;
}
.repository.new.repo form .inline.field > label,
.repository.new.migrate form .inline.field > label,
.repository.new.fork form .inline.field > label {
text-align: right;
- width: 250px !important;
+ width: 250px;
word-wrap: break-word;
}
.repository.new.repo form .help,
.repository.new.migrate form .help,
.repository.new.fork form .help {
- margin-left: 265px !important;
+ margin-left: 265px;
}
.repository.new.repo form .optional .title,
.repository.new.migrate form .optional .title,
.repository.new.fork form .optional .title {
- margin-left: 250px !important;
+ margin-left: 250px;
}
.repository.new.repo form input,
.repository.new.migrate form input,
@@ -1083,7 +1083,7 @@ footer .ui.language .menu {
width: 50%!important;
}
.repository.new.repo .ui.form #auto-init {
- margin-left: 265px !important;
+ margin-left: 265px;
}
.new.webhook form .help {
margin-left: 25px;
@@ -1306,6 +1306,81 @@ footer .ui.language .menu {
.repository.file.list #file-content .view-raw img {
margin-bottom: -5px;
}
+.repository.file.list #file-content #ipython-notebook {
+ margin-left: 80px;
+}
+.repository.file.list #file-content #ipython-notebook .nb-notebook {
+ line-height: 1.5;
+}
+.repository.file.list #file-content #ipython-notebook .nb-stdout,
+.repository.file.list #file-content #ipython-notebook .nb-stderr {
+ white-space: pre-wrap;
+ margin: 1em 0;
+ padding: 0.1em 0.5em;
+}
+.repository.file.list #file-content #ipython-notebook .nb-stderr {
+ background-color: #FAA;
+}
+.repository.file.list #file-content #ipython-notebook .nb-cell + .nb-cell {
+ margin-top: 0.5em;
+}
+.repository.file.list #file-content #ipython-notebook .nb-output table {
+ border: 1px solid #000;
+ border-collapse: collapse;
+}
+.repository.file.list #file-content #ipython-notebook .nb-output th {
+ font-weight: bold;
+}
+.repository.file.list #file-content #ipython-notebook .nb-output th,
+.repository.file.list #file-content #ipython-notebook .nb-output td {
+ border: 1px solid #000;
+ padding: 0.25em;
+ text-align: left;
+ vertical-align: middle;
+ border-collapse: collapse;
+}
+.repository.file.list #file-content #ipython-notebook .nb-cell {
+ position: relative;
+}
+.repository.file.list #file-content #ipython-notebook .nb-raw-cell {
+ white-space: pre-wrap;
+ background-color: #f5f2f0;
+ font-family: Consolas, Monaco, 'Andale Mono', monospace;
+ padding: 1em;
+ margin: .5em 0;
+}
+.repository.file.list #file-content #ipython-notebook .nb-output {
+ min-height: 1em;
+ width: 100%;
+ overflow-x: scroll;
+ border-right: 1px dotted #CCC;
+}
+.repository.file.list #file-content #ipython-notebook .nb-output img {
+ max-width: 100%;
+}
+.repository.file.list #file-content #ipython-notebook .nb-output:before,
+.repository.file.list #file-content #ipython-notebook .nb-input:before {
+ position: absolute;
+ font-family: monospace;
+ color: #999;
+ left: -7.5em;
+ width: 7em;
+ text-align: right;
+}
+.repository.file.list #file-content #ipython-notebook .nb-input:before {
+ content: "In [" attr(data-prompt-number) "]:";
+}
+.repository.file.list #file-content #ipython-notebook .nb-output:before {
+ content: "Out [" attr(data-prompt-number) "]:";
+}
+.repository.file.list #file-content #ipython-notebook .nb-markdown-cell {
+ background-color: #eee;
+ margin-left: -80px;
+ padding: 11.5px 10px 19.5px 80px;
+}
+.repository.file.list #file-content #ipython-notebook div[style="max-height:1000px;max-width:1500px;overflow:auto;"] {
+ max-height: none !important;
+}
.repository.file.list #file-content .plain-text {
font-size: 14px;
padding: 10px 15px;
@@ -2539,18 +2614,18 @@ footer .ui.language .menu {
text-align: center;
}
.organization.new.org form .header {
- padding-left: 280px !important;
+ padding-left: 280px;
}
.organization.new.org form .inline.field > label {
text-align: right;
- width: 250px !important;
+ width: 250px;
word-wrap: break-word;
}
.organization.new.org form .help {
- margin-left: 265px !important;
+ margin-left: 265px;
}
.organization.new.org form .optional .title {
- margin-left: 250px !important;
+ margin-left: 250px;
}
.organization.new.org form input,
.organization.new.org form textarea {
diff --git a/public/less/_repository.less b/public/less/_repository.less
index 0deef516c..249ce3df1 100644
--- a/public/less/_repository.less
+++ b/public/less/_repository.less
@@ -251,6 +251,95 @@
}
}
+ #ipython-notebook {
+ margin-left: 80px;
+
+ .nb-notebook {
+ line-height: 1.5;
+ }
+
+ .nb-stdout, .nb-stderr {
+ white-space: pre-wrap;
+ margin: 1em 0;
+ padding: 0.1em 0.5em;
+ }
+
+ .nb-stderr {
+ background-color: #FAA;
+ }
+
+ .nb-cell + .nb-cell {
+ margin-top: 0.5em;
+ }
+
+ .nb-output table {
+ border: 1px solid #000;
+ border-collapse: collapse;
+ }
+
+ .nb-output th {
+ font-weight: bold;
+ }
+
+ .nb-output th, .nb-output td {
+ border: 1px solid #000;
+ padding: 0.25em;
+ text-align: left;
+ vertical-align: middle;
+ border-collapse: collapse;
+ }
+
+ .nb-cell {
+ position: relative;
+ }
+
+ .nb-raw-cell {
+ white-space: pre-wrap;
+ background-color: #f5f2f0;
+ font-family: Consolas, Monaco, 'Andale Mono', monospace;
+ padding: 1em;
+ margin: .5em 0;
+ }
+
+ .nb-output {
+ min-height: 1em;
+ width: 100%;
+ overflow-x: scroll;
+ border-right: 1px dotted #CCC;
+ }
+
+ .nb-output img {
+ max-width: 100%;
+ }
+
+ .nb-output:before, .nb-input:before {
+ position: absolute;
+ font-family: monospace;
+ color: #999;
+ left: -7.5em;
+ width: 7em;
+ text-align: right;
+ }
+
+ .nb-input:before {
+ content: "In [" attr(data-prompt-number) "]:";
+ }
+ .nb-output:before {
+ content: "Out [" attr(data-prompt-number) "]:";
+ }
+
+ .nb-markdown-cell {
+ background-color: #eee;
+ margin-left: -80px;
+ padding: 11.5px 10px 19.5px 80px;
+ }
+
+ // Fix pandas dataframe formatting
+ div[style="max-height:1000px;max-width:1500px;overflow:auto;"] {
+ max-height: none !important;
+ }
+ }
+
.plain-text {
font-size: 14px;
padding: 10px 15px;
diff --git a/public/plugins/marked-0.3.6/LICENSE b/public/plugins/marked-0.3.6/LICENSE
new file mode 100644
index 000000000..a7b812ed6
--- /dev/null
+++ b/public/plugins/marked-0.3.6/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2011-2014, Christopher Jeffrey (https://github.com/chjj/)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/public/plugins/marked-0.3.6/marked.min.js b/public/plugins/marked-0.3.6/marked.min.js
new file mode 100644
index 000000000..555c1dc1d
--- /dev/null
+++ b/public/plugins/marked-0.3.6/marked.min.js
@@ -0,0 +1,6 @@
+/**
+ * marked - a markdown parser
+ * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
+ * https://github.com/chjj/marked
+ */
+(function(){var block={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};block.bullet=/(?:[*+-]|\d+\.)/;block.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;block.item=replace(block.item,"gm")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+block.def.source+")")();block.blockquote=replace(block.blockquote)("def",block.def)();block._tag="(?!(?:"+"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code"+"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo"+"|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b";block.html=replace(block.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/ "+text+"
"}return'"+(escaped?code:escape(code,true))+"\n
\n"};Renderer.prototype.blockquote=function(quote){return"'+(escaped?code:escape(code,true))+"\n
\n"+quote+"
\n"};Renderer.prototype.html=function(html){return html};Renderer.prototype.heading=function(text,level,raw){return"
\n":"
\n"};Renderer.prototype.list=function(body,ordered){var type=ordered?"ol":"ul";return"<"+type+">\n"+body+""+type+">\n"};Renderer.prototype.listitem=function(text){return"\n"+"\n"+header+"\n"+"\n"+body+"\n"+"
\n"};Renderer.prototype.tablerow=function(content){return"\n"+content+" \n"};Renderer.prototype.tablecell=function(content,flags){var type=flags.header?"th":"td";var tag=flags.align?"<"+type+' style="text-align:'+flags.align+'">':"<"+type+">";return tag+content+""+type+">\n"};Renderer.prototype.strong=function(text){return""+text+""};Renderer.prototype.em=function(text){return""+text+""};Renderer.prototype.codespan=function(text){return""+text+"
"};Renderer.prototype.br=function(){return this.options.xhtml?"
":"
"};Renderer.prototype.del=function(text){return""+text+""};Renderer.prototype.link=function(href,title,text){if(this.options.sanitize){try{var prot=decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(prot.indexOf("javascript:")===0||prot.indexOf("vbscript:")===0){return""}}var out='"+text+"";return out};Renderer.prototype.image=function(href,title,text){var out='":">";return out};Renderer.prototype.text=function(text){return text};function Parser(options){this.tokens=[];this.token=null;this.options=options||marked.defaults;this.options.renderer=this.options.renderer||new Renderer;this.renderer=this.options.renderer;this.renderer.options=this.options}Parser.parse=function(src,options,renderer){var parser=new Parser(options,renderer);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options,this.renderer);this.tokens=src.reverse();var out="";while(this.next()){out+=this.tok()}return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text;while(this.peek().type==="text"){body+="\n"+this.next().text}return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case"space":{return""}case"hr":{return this.renderer.hr()}case"heading":{return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text)}case"code":{return this.renderer.code(this.token.text,this.token.lang,this.token.escaped)}case"table":{var header="",body="",i,row,cell,flags,j;cell="";for(i=0;i
"+escape(e.message+"",true)+""}throw e}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,sanitizer:null,mangle:true,smartLists:false,silent:false,highlight:null,langPrefix:"lang-",smartypants:false,headerPrefix:"",renderer:new Renderer,xhtml:false};marked.Parser=Parser;marked.parser=Parser.parse;marked.Renderer=Renderer;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;marked.parse=marked;if(typeof module!=="undefined"&&typeof exports==="object"){module.exports=marked}else if(typeof define==="function"&&define.amd){define(function(){return marked})}else{this.marked=marked}}).call(function(){return this||(typeof window!=="undefined"?window:global)}()); \ No newline at end of file diff --git a/public/plugins/notebookjs-0.2.6/LICENSE.txt b/public/plugins/notebookjs-0.2.6/LICENSE.txt new file mode 100644 index 000000000..a1155f84e --- /dev/null +++ b/public/plugins/notebookjs-0.2.6/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014, Jeremy Singer-Vine + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/public/plugins/notebookjs-0.2.6/notebook.min.js b/public/plugins/notebookjs-0.2.6/notebook.min.js new file mode 100644 index 000000000..ab8f6f5a8 --- /dev/null +++ b/public/plugins/notebookjs-0.2.6/notebook.min.js @@ -0,0 +1 @@ +(function(){var root=this;var VERSION="0.2.5";var doc=root.document||require("jsdom").jsdom();var ident=function(x){return x};var makeElement=function(tag,classNames){var el=doc.createElement(tag);el.className=(classNames||[]).map(function(cn){return nb.prefix+cn}).join(" ");return el};var escapeHTML=function(raw){var replaced=raw.replace(//g,">");return replaced};var joinText=function(text){if(text.join){return text.map(joinText).join("")}else{return text}};var condRequire=function(module_name){return typeof require==="function"&&require(module_name)};var getMarkdown=function(){return root.marked||condRequire("marked")};var getAnsi=function(){var req=condRequire("ansi_up");var lib=root.ansi_up||req;return lib&&lib.ansi_to_html};var nb={prefix:"nb-",markdown:getMarkdown()||ident,ansi:getAnsi()||ident,VERSION:VERSION};nb.Input=function(raw,cell){this.raw=raw;this.cell=cell};nb.Input.prototype.render=function(){if(!this.raw.length){return makeElement("div")}var holder=makeElement("div",["input"]);var cell=this.cell;if(typeof cell.number==="number"){holder.setAttribute("data-prompt-number",this.cell.number)}var pre_el=makeElement("pre");var code_el=makeElement("code");var notebook=cell.worksheet.notebook;var m=notebook.metadata;var lang=this.cell.raw.language||m.language||m.language_info.name;code_el.setAttribute("data-language",lang);code_el.className="lang-"+lang;code_el.innerHTML=escapeHTML(joinText(this.raw));pre_el.appendChild(code_el);holder.appendChild(pre_el);this.el=holder;return holder};var imageCreator=function(format){return function(data){var el=makeElement("img",["image-output"]);el.src="data:image/"+format+";base64,"+joinText(data).replace(/\n/g,"");return el}};nb.display={};nb.display.text=function(text){var el=makeElement("pre",["text-output"]);el.innerHTML=escapeHTML(joinText(text));return el};nb.display["text/plain"]=nb.display.text;nb.display.html=function(html){var el=makeElement("div",["html-output"]);el.innerHTML=joinText(html);return el};nb.display["text/html"]=nb.display.html;nb.display.marked=function(md){return nb.display.html(nb.markdown(joinText(md)))};nb.display["text/markdown"]=nb.display.marked;nb.display.svg=function(svg){var el=makeElement("div",["svg-output"]);el.innerHTML=joinText(svg);return el};nb.display["text/svg+xml"]=nb.display.svg;nb.display.latex=function(latex){var el=makeElement("div",["latex-output"]);el.innerHTML=joinText(latex);return el};nb.display["text/latex"]=nb.display.latex;nb.display.javascript=function(js){var el=makeElement("script");script.innerHTML=js;return el};nb.display["application/javascript"]=nb.display.javascript;nb.display.png=imageCreator("png");nb.display["image/png"]=nb.display.png;nb.display.jpeg=imageCreator("jpeg");nb.display["image/jpeg"]=nb.display.jpeg;nb.display_priority=["png","image/png","jpeg","image/jpeg","svg","text/svg+xml","html","text/html","text/markdown","latex","text/latex","javascript","application/javascript","text","text/plain"];var render_display_data=function(){var o=this;var formats=nb.display_priority.filter(function(d){return o.raw.data?o.raw.data[d]:o.raw[d]});var format=formats[0];if(format){if(nb.display[format]){return nb.display[format](o.raw[format]||o.raw.data[format])}}return makeElement("div",["empty-output"])};var render_error=function(){var el=makeElement("pre",["pyerr"]);var raw=this.raw.traceback.join("\n");el.innerHTML=nb.ansi(escapeHTML(raw));return el};nb.Output=function(raw,cell){this.raw=raw;this.cell=cell;this.type=raw.output_type};nb.Output.prototype.renderers={display_data:render_display_data,execute_result:render_display_data,pyout:render_display_data,pyerr:render_error,error:render_error,stream:function(){var el=makeElement("pre",[this.raw.stream||this.raw.name]);var raw=joinText(this.raw.text);el.innerHTML=nb.ansi(escapeHTML(raw));return el}};nb.Output.prototype.render=function(){var outer=makeElement("div",["output"]);if(typeof this.cell.number==="number"){outer.setAttribute("data-prompt-number",this.cell.number)}var inner=this.renderers[this.type].call(this);outer.appendChild(inner);this.el=outer;return outer};nb.coalesceStreams=function(outputs){if(!outputs.length){return outputs}var last=outputs[0];var new_outputs=[last];outputs.slice(1).forEach(function(o){if(o.raw.output_type==="stream"&&last.raw.output_type==="stream"&&o.raw.stream===last.raw.stream){last.raw.text=last.raw.text.concat(o.raw.text)}else{new_outputs.push(o);last=o}});return new_outputs};nb.Cell=function(raw,worksheet){var cell=this;cell.raw=raw;cell.worksheet=worksheet;cell.type=raw.cell_type;if(cell.type==="code"){cell.number=raw.prompt_number>-1?raw.prompt_number:raw.execution_count;var source=raw.input||[raw.source];cell.input=new nb.Input(source,cell);var raw_outputs=(cell.raw.outputs||[]).map(function(o){return new nb.Output(o,cell)});cell.outputs=nb.coalesceStreams(raw_outputs)}};nb.Cell.prototype.renderers={markdown:function(){var el=makeElement("div",["cell","markdown-cell"]);el.innerHTML=nb.markdown(joinText(this.raw.source));return el},heading:function(){var el=makeElement("h"+this.raw.level,["cell","heading-cell"]);el.innerHTML=joinText(this.raw.source);return el},raw:function(){var el=makeElement("div",["cell","raw-cell"]);el.innerHTML=joinText(this.raw.source);return el},code:function(){var cell_el=makeElement("div",["cell","code-cell"]);cell_el.appendChild(this.input.render());var output_els=this.outputs.forEach(function(o){cell_el.appendChild(o.render())});return cell_el}};nb.Cell.prototype.render=function(){var el=this.renderers[this.type].call(this);this.el=el;return el};nb.Worksheet=function(raw,notebook){var worksheet=this;this.raw=raw;this.notebook=notebook;this.cells=raw.cells.map(function(c){return new nb.Cell(c,worksheet)});this.render=function(){var worksheet_el=makeElement("div",["worksheet"]);worksheet.cells.forEach(function(c){worksheet_el.appendChild(c.render())});this.el=worksheet_el;return worksheet_el}};nb.Notebook=function(raw,config){var notebook=this;this.raw=raw;this.config=config;var meta=this.metadata=raw.metadata;this.title=meta.title||meta.name;var _worksheets=raw.worksheets||[{cells:raw.cells}];this.worksheets=_worksheets.map(function(ws){return new nb.Worksheet(ws,notebook)});this.sheet=this.worksheets[0]};nb.Notebook.prototype.render=function(){var notebook_el=makeElement("div",["notebook"]);this.worksheets.forEach(function(w){notebook_el.appendChild(w.render())});this.el=notebook_el;return notebook_el};nb.parse=function(nbjson,config){return new nb.Notebook(nbjson,config)};if(typeof define==="function"&&define.amd){define(function(){return nb})}if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports){exports=module.exports=nb}exports.nb=nb}else{root.nb=nb}}).call(this); \ No newline at end of file diff --git a/routers/repo/view.go b/routers/repo/view.go index 18c79e085..06e922edf 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -156,6 +156,8 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st ctx.Data["IsMarkdown"] = isMarkdown ctx.Data["ReadmeExist"] = isMarkdown && markdown.IsReadmeFile(blob.Name()) + ctx.Data["IsIPyNB"] = strings.HasSuffix(blob.Name(), ".ipynb") + if isMarkdown { ctx.Data["FileContent"] = string(markdown.Render(buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas())) } else { diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index e12aea408..9ca003c75 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -21,6 +21,12 @@ + + {{if .IsIPyNB }} + + + {{end}} + {{if .RequireSimpleMDE}} diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index 77f472325..4829c2510 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -39,6 +39,26 @@