ソースを参照

[GINR] Show cloudberry as content item

cgars 7 年 前
コミット
2907f9dafe

+ 4 - 0
public/css/gogs.css

@@ -3229,3 +3229,7 @@ figure figcaption {
   font-style: italic;
   text-align: justify;
 }
+
+#cloudberry-view {
+  margin-top: 14px;
+}

+ 17 - 2
routes/repo/view.go

@@ -18,6 +18,10 @@ import (
 	"github.com/gogits/git-module"
 
 	"bufio"
+	"io"
+	"os"
+
+	"github.com/G-Node/gin-doi/src"
 	"github.com/G-Node/go-annex"
 	"github.com/G-Node/gogs/models"
 	"github.com/G-Node/gogs/pkg/context"
@@ -26,9 +30,8 @@ import (
 	"github.com/G-Node/gogs/pkg/template"
 	"github.com/G-Node/gogs/pkg/template/highlight"
 	"github.com/G-Node/gogs/pkg/tool"
-	"io"
-	"os"
 	"github.com/go-macaron/captcha"
+	"gopkg.in/yaml.v2"
 )
 
 const (
@@ -70,6 +73,18 @@ func renderDirectory(c *context.Context, treeLink string) {
 			readmeFile = entry.Blob()
 		} else if entry.Name() == "cloudberry.yml" {
 			c.Data["DOI"] = true
+			doiData, err := entry.Blob().Data()
+			if err != nil {
+				log.Trace("Doi Blob could nor be read:%v", err)
+			}
+			buf, err := ioutil.ReadAll(doiData)
+			doiInfo := ginDoi.CBerry{}
+			err = yaml.Unmarshal(buf, &doiInfo)
+			if err != nil {
+				log.Trace("Doi Blob could not be unmarshalled:%v", err)
+			}
+			log.Trace("Doi info was: %v ", doiInfo)
+			c.Data["DoiInfo"] = doiInfo
 		}
 	}
 

+ 1 - 1
templates/admin/user/edit.tmpl

@@ -52,7 +52,7 @@
 							<label for="website">{{.i18n.Tr "settings.website"}}</label>
 							<input id="website" name="website" type="url" value="{{.User.Website}}" placeholder="e.g. http://mydomain.com or https://mydomain.com">
 						</div>
-						<div class="field {{if .Err_Location}}error{{end}}">
+						<div class="field {{if .locationErr_Location}}error{{end}}">
 							<label for="location">{{.i18n.Tr "settings.location"}}</label>
 							<input id="location" name="location" value="{{.User.Location}}">
 						</div>

+ 11 - 5
templates/repo/doifile.tmpl

@@ -1,9 +1,15 @@
-<div id="file-content" class="tab-size-8">
-<h4 class="ui top attached header" id="repo-doi">
-			<i class="octicon octicon-book"></i>
-				<strong>Cloudberry</strong>
-	</h4>
+<div id = "cloudberry-view" class="tab-size-8">
 		<table class="ui fixed single line table">
+		<thead>
+    		<tr>
+    			<th class="two wide">
+			<i class="octicon octicon-squirrel"></i>
+				<strong>Cloudberry</strong>
+    			</th>
+    			<th class="fourteen wide">
+    			</th>
+    		</tr>
+    	</thead>
 				<tbody>
 				<tr>
 						<td>Title</td>

+ 3 - 0
templates/repo/view_list.tmpl

@@ -59,3 +59,6 @@
 {{if and .ReadmeExist .IsTextFile}}
 	{{template "repo/view_file" .}}
 {{end}}
+{{if and .DOI .IsTextFile}}
+	{{template "repo/doifile" .}}
+{{end}}