aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2017-06-06 15:41:27 -0400
committerUnknwon <u@gogs.io>2017-06-06 15:41:27 -0400
commita851b77ac9e5d95f71fb0e98cd134cd0e692f782 (patch)
tree3ed238d30773b379218e4259dcf49ca9180823e1
parente9a2b72ddb0a5d069e72aceabb36337e5b9e9dcd (diff)
markup: able to display image from IPython notebook (#4366)
-rw-r--r--gogs.go2
-rw-r--r--public/config.codekit4
-rw-r--r--public/css/gogs.css3
-rw-r--r--public/less/_repository.less6
-rw-r--r--templates/.VERSION2
-rw-r--r--templates/repo/view_file.tmpl9
6 files changed, 19 insertions, 7 deletions
diff --git a/gogs.go b/gogs.go
index 42add979..c720dce3 100644
--- a/gogs.go
+++ b/gogs.go
@@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/pkg/setting"
)
-const APP_VER = "0.11.16.0605"
+const APP_VER = "0.11.17.0606"
func init() {
setting.AppVer = APP_VER
diff --git a/public/config.codekit b/public/config.codekit
index 245159c5..60412298 100644
--- a/public/config.codekit
+++ b/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",
-"creatorBuild": "19127",
+"creatorBuild": "19115",
"files": {
"\/css\/github.min.css": {
"fileType": 16,
@@ -66,7 +66,7 @@
"fileType": 32768,
"ignore": 0,
"ignoreWasSetByUser": 0,
- "initialSize": 514087,
+ "initialSize": 4048,
"inputAbbreviatedPath": "\/img\/avatar_default.png",
"outputAbbreviatedPath": "\/img\/avatar_default.png",
"outputPathIsOutsideProject": 0,
diff --git a/public/css/gogs.css b/public/css/gogs.css
index 48c3d405..1f023210 100644
--- a/public/css/gogs.css
+++ b/public/css/gogs.css
@@ -1402,6 +1402,9 @@ footer .ui.language .menu {
.repository.file.list #file-content #ipython-notebook .nb-cell.nb-heading-cell {
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 {
white-space: pre-wrap;
background-color: #f5f2f0;
diff --git a/public/less/_repository.less b/public/less/_repository.less
index 5260af61..fd48fd39 100644
--- a/public/less/_repository.less
+++ b/public/less/_repository.less
@@ -324,6 +324,10 @@
&.nb-heading-cell {
margin-top: 0.5em;
}
+
+ img {
+ max-width: 100%;
+ }
}
.nb-raw-cell {
@@ -370,7 +374,7 @@
font-size: 14px;
}
img {
- max-width: 100%;
+ max-width: 100%;
}
table {
border: 1px solid #000;
diff --git a/templates/.VERSION b/templates/.VERSION
index 250a5040..08cfb8f7 100644
--- a/templates/.VERSION
+++ b/templates/.VERSION
@@ -1 +1 @@
-0.11.16.0605 \ No newline at end of file
+0.11.17.0606 \ No newline at end of file
diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl
index b8d6c1e4..dea9493e 100644
--- a/templates/repo/view_file.tmpl
+++ b/templates/repo/view_file.tmpl
@@ -42,7 +42,6 @@
{{else if .IsIPythonNotebook}}
<script>
var rendered = null;
- console.log("fuck")
$.getJSON("{{.RawFileLink}}", null, function(notebook_json) {
var notebook = nb.parse(notebook_json);
rendered = notebook.render();
@@ -52,8 +51,14 @@
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) {
- $(markdown).html(marked($(markdown).html()));
+ $(markdown).html(marked($(markdown).html(), {renderer: renderer}));
});
});
</script>