Преглед на файлове

[GinR] Show code and rendered view

for yaml,json and odml
cgars преди 7 години
родител
ревизия
e85cdd5db0
променени са 2 файла, в които са добавени 24 реда и са изтрити 2 реда
  1. 1 1
      routes/doi.go
  2. 23 1
      templates/repo/view_file.tmpl

+ 1 - 1
routes/doi.go

@@ -8,7 +8,7 @@ import (
 )
 
 func RequestDoi(c *context.Context) {
-	if !c.Repo.IsAdmin(){
+	if !c.Repo.IsAdmin() {
 		c.Status(http.StatusUnauthorized)
 		return
 	}

+ 23 - 1
templates/repo/view_file.tmpl

@@ -35,7 +35,13 @@
 			</div>
 		{{end}}
 	</h4>
-	<div class="{{if or .IsJSON .IsYAML}}{{else}}ui attached table segment{{end}}">
+	{{if or .IsJSON (or .IsYAML .IsOdML)}}
+	<div class="ui top attached tabular menu">
+		<a class="item active" data-tab="code"><i class="octicon octicon-file-code"></i> Code</a>
+		<a class="item" data-tab="view"><i class="octicon octicon-file"></i> View</a>
+	</div>
+	{{end}}
+	<div class="{{if or .IsJSON (or .IsYAML .IsOdML)}}ui bottom attached tab segment" data-tab="view{{else}}ui attached table segment{{end}}">
 		<div id="{{if not (or .IsJSON .IsYAML)}}{{if .IsIPythonNotebook}}ipython-notebook{{end}}" class="file-view {{if .IsMarkdown}}markdown{{else if .IsIPythonNotebook}}ipython-notebook{{else if .IsIPythonNotebook}}ipython-notebook{{else if .ReadmeInList}}plain-text{{else if and .IsTextFile}}code-view{{end}} has-emoji{{end}}">
 			{{if .IsMarkdown}}
 				{{if .FileContent}}{{.FileContent | Str2html}}{{end}}
@@ -157,6 +163,22 @@
 			{{end}}
 		</div>
 	</div>
+	{{if or .IsJSON (or .IsYAML .IsOdML)}}
+	<div class="ui bottom attached tab active segment" data-tab="code">
+	<table>
+		<tbody>
+		<tr>
+			{{if .IsFileTooLarge}}
+			<td><strong>{{.i18n.Tr "repo.file_too_large"}}</strong></td>
+			{{else}}
+			<td class="lines-num">{{.LineNums}}</td>
+			<td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol class="linenums">{{.FileContent}}</ol></code></pre></td>
+			{{end}}
+		</tr>
+		</tbody>
+	</table>
+	</div>
+	{{end}}
 </div>
 
 <script>