@@ -1,6 +1,7 @@ | |||||
.nb-notebook { | .nb-notebook { | ||||
line-height: 1.5; | line-height: 1.5; | ||||
margin-left: 7em; | |||||
margin-left: 6em; | |||||
} | } | ||||
.nb-stdout, .nb-stderr { | .nb-stdout, .nb-stderr { | ||||
@@ -15,6 +16,7 @@ | |||||
.nb-cell + .nb-cell { | .nb-cell + .nb-cell { | ||||
margin-top: 0.5em; | margin-top: 0.5em; | ||||
max-width: 100%; | |||||
} | } | ||||
.nb-output table { | .nb-output table { | ||||
@@ -40,6 +42,11 @@ | |||||
padding-left: 1em; | padding-left: 1em; | ||||
} | } | ||||
.nb-notebook img { | |||||
max-width: 80%; | |||||
padding: 3px; | |||||
} | |||||
.nb-cell { | .nb-cell { | ||||
position: relative; | position: relative; | ||||
} | } | ||||
@@ -60,7 +67,8 @@ | |||||
} | } | ||||
.nb-output img { | .nb-output img { | ||||
max-width: 100%; | |||||
max-width: 80%; | |||||
padding: 3px; | |||||
} | } | ||||
.nb-output:before, .nb-input:before { | .nb-output:before, .nb-input:before { | ||||
@@ -484,6 +484,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st | |||||
) | ) | ||||
} else if isNoteBook { | } else if isNoteBook { | ||||
ctx.Data["FileContent"] = string(buf) | ctx.Data["FileContent"] = string(buf) | ||||
ctx.Data["FileParentURL"] = path.Dir(rawLink+"/"+ctx.Repo.TreePath) + "/" | |||||
} else { | } else { | ||||
// Building code view blocks with line number on server side. | // Building code view blocks with line number on server side. | ||||
var fileContent string | var fileContent string | ||||
@@ -190,7 +190,6 @@ | |||||
<script src="{{StaticUrlPrefix}}/self/js/notebook/katex.min.js"></script> | <script src="{{StaticUrlPrefix}}/self/js/notebook/katex.min.js"></script> | ||||
<script src="{{StaticUrlPrefix}}/self/js/notebook/katex-auto-render.min.js"></script> | <script src="{{StaticUrlPrefix}}/self/js/notebook/katex-auto-render.min.js"></script> | ||||
<script src="{{StaticUrlPrefix}}/self/js/notebook/notebook.min.js"></script> | <script src="{{StaticUrlPrefix}}/self/js/notebook/notebook.min.js"></script> | ||||
<script src="{{StaticUrlPrefix}}/self/js/notebook/notebook.min.js"></script> | |||||
<link rel="stylesheet" href="{{StaticUrlPrefix}}/self/css/notebook/katex.min.css" /> | <link rel="stylesheet" href="{{StaticUrlPrefix}}/self/css/notebook/katex.min.css" /> | ||||
<link rel="stylesheet" href="{{StaticUrlPrefix}}/self/css/notebook/prism.css" /> | <link rel="stylesheet" href="{{StaticUrlPrefix}}/self/css/notebook/prism.css" /> | ||||
<link rel="stylesheet" href="{{StaticUrlPrefix}}/self/css/notebook/notebook.css" /> | <link rel="stylesheet" href="{{StaticUrlPrefix}}/self/css/notebook/notebook.css" /> |
@@ -103,20 +103,23 @@ | |||||
{{end}} | {{end}} | ||||
</div> | </div> | ||||
{{else if .FileSize}} | {{else if .FileSize}} | ||||
<table> | |||||
{{if .IsNoteBook}} | |||||
<div id="notebook"></div> | |||||
{{else}} | |||||
<table> | |||||
<tbody> | <tbody> | ||||
<tr> | <tr> | ||||
{{if .IsFileTooLarge}} | {{if .IsFileTooLarge}} | ||||
<td><strong>{{.i18n.Tr "repo.file_too_large"}}</strong></td> | <td><strong>{{.i18n.Tr "repo.file_too_large"}}</strong></td> | ||||
{{else if .IsNoteBook}} | |||||
<td id="notebook"></td> | |||||
{{else}} | {{else}} | ||||
<td class="lines-num">{{.LineNums}}</td> | <td class="lines-num">{{.LineNums}}</td> | ||||
<td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol class="linenums">{{.FileContent}}</ol></code></pre></td> | <td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol class="linenums">{{.FileContent}}</ol></code></pre></td> | ||||
{{end}} | {{end}} | ||||
</tr> | </tr> | ||||
</tbody> | </tbody> | ||||
</table> | |||||
</table> | |||||
{{end}} | |||||
{{end}} | {{end}} | ||||
</div> | </div> | ||||
</div> | </div> | ||||
@@ -134,6 +137,9 @@ function showNoteBook(){ | |||||
var isNoteBook = {{.IsNoteBook}} | var isNoteBook = {{.IsNoteBook}} | ||||
if (isNoteBook) { | if (isNoteBook) { | ||||
var jsonStr = "{{.FileContent}}" | var jsonStr = "{{.FileContent}}" | ||||
nb.markdown.setOptions({ | |||||
baseUrl: {{.FileParentURL}} | |||||
}); | |||||
var notebook = nb.parse(JSON.parse(jsonStr)); | var notebook = nb.parse(JSON.parse(jsonStr)); | ||||
var rendered = notebook.render(); | var rendered = notebook.render(); | ||||
$("#notebook").append(rendered); | $("#notebook").append(rendered); | ||||