Browse Source

markup: able to display image from IPython notebook (#4366)

pull/4551/head
Unknwon 8 years ago
parent
commit
a851b77ac9
No known key found for this signature in database
GPG Key ID: 7A02C406FAC875A2
  1. 2
      gogs.go
  2. 4
      public/config.codekit
  3. 3
      public/css/gogs.css
  4. 4
      public/less/_repository.less
  5. 2
      templates/.VERSION
  6. 9
      templates/repo/view_file.tmpl

2
gogs.go

@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
) )
const APP_VER = "0.11.16.0605" const APP_VER = "0.11.17.0606"
func init() { func init() {
setting.AppVer = APP_VER setting.AppVer = APP_VER

4
public/config.codekit

@ -1,6 +1,6 @@
{ {
"CodeKitInfo": "This is a CodeKit 2.x project configuration file. It is designed to sync project settings across multiple machines. MODIFYING THE CONTENTS OF THIS FILE IS A POOR LIFE DECISION. If you do so, you will likely cause CodeKit to crash. This file is not useful unless accompanied by the project that created it in CodeKit 2. This file is not backwards-compatible with CodeKit 1.x. For more information, see: http:\/\/incident57.com\/codekit", "CodeKitInfo": "This is a CodeKit 2.x project configuration file. It is designed to sync project settings across multiple machines. MODIFYING THE CONTENTS OF THIS FILE IS A POOR LIFE DECISION. If you do so, you will likely cause CodeKit to crash. This file is not useful unless accompanied by the project that created it in CodeKit 2. This file is not backwards-compatible with CodeKit 1.x. For more information, see: http:\/\/incident57.com\/codekit",
"creatorBuild": "19127", "creatorBuild": "19115",
"files": { "files": {
"\/css\/github.min.css": { "\/css\/github.min.css": {
"fileType": 16, "fileType": 16,
@ -66,7 +66,7 @@
"fileType": 32768, "fileType": 32768,
"ignore": 0, "ignore": 0,
"ignoreWasSetByUser": 0, "ignoreWasSetByUser": 0,
"initialSize": 514087, "initialSize": 4048,
"inputAbbreviatedPath": "\/img\/avatar_default.png", "inputAbbreviatedPath": "\/img\/avatar_default.png",
"outputAbbreviatedPath": "\/img\/avatar_default.png", "outputAbbreviatedPath": "\/img\/avatar_default.png",
"outputPathIsOutsideProject": 0, "outputPathIsOutsideProject": 0,

3
public/css/gogs.css

@ -1402,6 +1402,9 @@ footer .ui.language .menu {
.repository.file.list #file-content #ipython-notebook .nb-cell.nb-heading-cell { .repository.file.list #file-content #ipython-notebook .nb-cell.nb-heading-cell {
margin-top: 0.5em; margin-top: 0.5em;
} }
.repository.file.list #file-content #ipython-notebook .nb-cell img {
max-width: 100%;
}
.repository.file.list #file-content #ipython-notebook .nb-raw-cell { .repository.file.list #file-content #ipython-notebook .nb-raw-cell {
white-space: pre-wrap; white-space: pre-wrap;
background-color: #f5f2f0; background-color: #f5f2f0;

4
public/less/_repository.less

@ -324,6 +324,10 @@
&.nb-heading-cell { &.nb-heading-cell {
margin-top: 0.5em; margin-top: 0.5em;
} }
img {
max-width: 100%;
}
} }
.nb-raw-cell { .nb-raw-cell {

2
templates/.VERSION

@ -1 +1 @@
0.11.16.0605 0.11.17.0606

9
templates/repo/view_file.tmpl

@ -42,7 +42,6 @@
{{else if .IsIPythonNotebook}} {{else if .IsIPythonNotebook}}
<script> <script>
var rendered = null; var rendered = null;
console.log("fuck")
$.getJSON("{{.RawFileLink}}", null, function(notebook_json) { $.getJSON("{{.RawFileLink}}", null, function(notebook_json) {
var notebook = nb.parse(notebook_json); var notebook = nb.parse(notebook_json);
rendered = notebook.render(); rendered = notebook.render();
@ -52,8 +51,14 @@
hljs.highlightBlock(block); hljs.highlightBlock(block);
}); });
// Overwrite image method to append proper prefix to the source URL
var renderer = new marked.Renderer();
var context = '{{.TreeLink}}'.replace('/src/', '/raw/');
renderer.image = function (href, title, text) {
return `<img src="${context}/${href}"`
}
$("#ipython-notebook .nb-markdown-cell").each(function(i, markdown) { $("#ipython-notebook .nb-markdown-cell").each(function(i, markdown) {
$(markdown).html(marked($(markdown).html())); $(markdown).html(marked($(markdown).html(), {renderer: renderer}));
}); });
}); });
</script> </script>

Loading…
Cancel
Save