瀏覽代碼

[repo/view] Context data renaming (Doi -> DOI)

Updated doifile template accordingly.
Achilleas Koutsou 6 年之前
父節點
當前提交
ddd10d166f
共有 2 個文件被更改,包括 18 次插入18 次删除
  1. 6 6
      routes/repo/view.go
  2. 12 12
      templates/repo/doifile.tmpl

+ 6 - 6
routes/repo/view.go

@@ -64,7 +64,7 @@ func renderDirectory(c *context.Context, treeLink string) {
 	c.Data["DOI"] = false
 	var readmeFile *git.Blob
 	for _, entry := range entries {
-		if entry.IsDir() || (!markup.IsReadmeFile(entry.Name()) && !(entry.Name() == "datacite.yml") && !(entry.Name() == "LICENSE")) {
+		if entry.IsDir() || !markup.IsReadmeFile(entry.Name()) && entry.Name() != "datacite.yml" && entry.Name() != "LICENSE" {
 			continue
 		}
 
@@ -76,21 +76,21 @@ func renderDirectory(c *context.Context, treeLink string) {
 			c.Data["DOI"] = true
 			doiData, err := entry.Blob().Data()
 			if err != nil {
-				log.Trace("Doi Blob could not be read:%v", err)
+				log.Trace("DOI Blob could not be read: %v", err)
 			}
 			buf, err := ioutil.ReadAll(doiData)
 			doiInfo := libgin.DOIRegInfo{}
 			err = yaml.Unmarshal(buf, &doiInfo)
 			if err != nil {
-				log.Trace("Doi Blob could not be unmarshalled:%v", err)
+				log.Trace("DOI Blob could not be unmarshalled: %v", err)
 			}
-			c.Data["DoiInfo"] = &doiInfo
+			c.Data["DOIInfo"] = &doiInfo
 
 			doi := GDoiRepo(c, setting.Doi.DoiBase)
 			//ddata, err := ginDoi.GDoiMData(doi, "https://api.datacite.org/works/") //todo configure URL?
 
-			c.Data["DoiReg"] = libgin.IsRegisteredDOI(doi)
-			c.Data["doi"] = doi
+			c.Data["DOIReg"] = libgin.IsRegisteredDOI(doi)
+			c.Data["DOI"] = doi
 
 		}
 	}

+ 12 - 12
templates/repo/doifile.tmpl

@@ -13,36 +13,36 @@
 				<tbody>
 				<tr>
 						<td>Title</td>
-						<td>{{.DoiInfo.Title}}</td>
+						<td>{{.DOIInfo.Title}}</td>
 				</tr>
 				<tr>
 						<td>Authors</td>
 						<td>
-								{{range $index, $auth := .DoiInfo.Authors}}
+								{{range $index, $auth := .DOIInfo.Authors}}
 								{{ $auth.RenderAuthor }}
 								<br>
 								{{end}}
 						</td>
 				</tr>
-				{{if .DoiInfo.Description}}
+				{{if .DOIInfo.Description}}
 				<tr>
 						<td>Description</td>
-						<td>{{.DoiInfo.Description}}
+						<td>{{.DOIInfo.Description}}
 						</td>
 				</tr>
 				{{end}}
-				{{if .DoiInfo.License}}
+				{{if .DOIInfo.License}}
 				<tr>
 						<td>License</td>
-						<td>{{.DoiInfo.License.Name}} ({{.DoiInfo.License.Url}})
+						<td>{{.DOIInfo.License.Name}} ({{.DOIInfo.License.URL}})
 						</td>
 				</tr>
 				{{end}}
 				<tr>
 						<td>References</td>
 						<td>
-								{{range $index, $ref := .DoiInfo.References}}
-								{{ $ref.Name }} [{{ $ref.Doi }}] ({{ $ref.Reftype }})
+								{{range $index, $ref := .DOIInfo.References}}
+								{{ $ref.Name }} [{{ $ref.DOI }}] ({{ $ref.Reftype }})
 								<br>
 								{{end}}
 						</td>
@@ -50,17 +50,17 @@
 				<tr>
 						<td>Funding</td>
 						<td>
-								{{range $index, $ref := .DoiInfo.Funding}}
+								{{range $index, $ref := .DOIInfo.Funding}}
 								{{ $ref}}
 								<br>
 								{{end}}
 						</td>
 				</tr>
-				{{if .DoiInfo.Keywords}}
+				{{if .DOIInfo.Keywords}}
 				<tr>
 						<td>Keywords</td>
 						<td>
-								{{range $index, $sub := .DoiInfo.Keywords}}
+								{{range $index, $sub := .DOIInfo.Keywords}}
 								{{ $sub }}
 								<br>
 								{{end}}
@@ -69,7 +69,7 @@
 				<tr>
 					<td>Resource Type</td>
 					<td>
-						<i>{{.DoiInfo.GetType}}</i><br>
+						<i>{{.DOIInfo.GetType}}</i><br>
 					</td>
 				</tr>
 				{{end}}