소스 검색

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

Unknwon 7 년 전
부모
커밋
a851b77ac9
6개의 변경된 파일19개의 추가작업 그리고 7개의 파일을 삭제
  1. 1 1
      gogs.go
  2. 2 2
      public/config.codekit
  3. 3 0
      public/css/gogs.css
  4. 5 1
      public/less/_repository.less
  5. 1 1
      templates/.VERSION
  6. 7 2
      templates/repo/view_file.tmpl

+ 1 - 1
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

+ 2 - 2
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,

+ 3 - 0
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;

+ 5 - 1
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;

+ 1 - 1
templates/.VERSION

@@ -1 +1 @@
-0.11.16.0605
+0.11.17.0606

+ 7 - 2
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>