Browse Source

[Doi] Show doi button for reg. datasets

cgars 7 năm trước cách đây
mục cha
commit
62b79149f0
4 tập tin đã thay đổi với 77 bổ sung24 xóa
  1. 19 0
      public/css/gogs.css
  2. 22 0
      public/less/_gin.less
  3. 7 1
      routes/repo/view.go
  4. 29 23
      templates/repo/header.tmpl

+ 19 - 0
public/css/gogs.css

@@ -3276,3 +3276,22 @@ figure figcaption {
 .ui.segment.results.hide {
   z-index: 1000;
 }
+.gin.doi {
+  float: left;
+  background-color: #5b5b5b;
+  color: white;
+  border-top-left-radius: .28571429rem;
+  border-bottom-left-radius: .28571429rem;
+  padding: .833em 1em;
+}
+.gin.doinr {
+  background-color: #2185D0;
+  float: right;
+  color: white;
+  border-top-right-radius: .28571429rem;
+  border-bottom-right-radius: .28571429rem;
+  padding: .833em 1em;
+}
+.ui.image.label.nobg {
+  background: none;
+}

+ 22 - 0
public/less/_gin.less

@@ -109,3 +109,25 @@ figure figcaption {
 .ui.segment.results.hide {
   z-index: 1000;
 }
+
+.gin.doi {
+  float: left;
+  background-color: #5b5b5b;
+  color: white;
+  border-top-left-radius: .28571429rem;
+  border-bottom-left-radius: .28571429rem;
+  padding: .833em 1em;
+}
+
+.gin.doinr {
+    background-color: #2185D0;
+    float: right;
+    color: white;
+    border-top-right-radius: .28571429rem;
+    border-bottom-right-radius: .28571429rem;
+    padding: .833em 1em;
+}
+
+.ui.image.label.nobg {
+ background: none;
+}

+ 7 - 1
routes/repo/view.go

@@ -79,7 +79,7 @@ func renderDirectory(c *context.Context, treeLink string) {
 			c.Data["DOI"] = true
 			doiData, err := entry.Blob().Data()
 			if err != nil {
-				log.Trace("Doi Blob could nor be read:%v", err)
+				log.Trace("Doi Blob could not be read:%v", err)
 			}
 			buf, err := ioutil.ReadAll(doiData)
 			doiInfo := ginDoi.CBerry{}
@@ -88,6 +88,12 @@ func renderDirectory(c *context.Context, treeLink string) {
 				log.Trace("Doi Blob could not be unmarshalled:%v", err)
 			}
 			c.Data["DoiInfo"] = doiInfo
+			doi := ginDoi.MakeDoi(ginDoi.RepoP2UUID(c.Repo.Repository.FullName()), "10.12751/g-node.")
+			//ddata, err := ginDoi.GDoiMData(doi, "https://api.datacite.org/works/") //todo configure URL?
+
+			c.Data["DoiReg"] = ginDoi.IsRegsitredDoi(doi)
+			c.Data["doi"] = doi
+
 		}
 	}
 	c.Data["LicenseExists"] = true

+ 29 - 23
templates/repo/header.tmpl

@@ -12,7 +12,6 @@
 						{{if .IsMirror}}<div class="fork-flag">{{$.i18n.Tr "repo.mirror_from"}} <a target="_blank" href="{{$.Mirror.Address}}">{{$.Mirror.Address}}</a></div>{{end}}
 						{{if .IsFork}}<div class="fork-flag">{{$.i18n.Tr "repo.forked_from"}} <a href="{{.BaseRepo.Link}}">{{SubStr .BaseRepo.RelLink 1 -1}}</a></div>{{end}}
 					</div>
-
 					{{if not $.IsGuest}}
 						<div class="ui right">
 							<div class="ui labeled button" tabindex="0">
@@ -34,29 +33,36 @@
 									</a>
 								</div>
 							{{end}}
-							{{if and (and $.DOI $.IsRepositoryAdmin) (not .IsPrivate)}}
-							<div class="ui labeled button" tabindex="0">
-								<a class="ui basic button"
-									 href="/{{.Owner.Name}}/{{.Name}}/doi">
-									<i class="octicon octicon-squirrel"></i> DOIfy
-								</a>
-							</div>
+							{{if not $.DoiReg}}
+								{{if and (and $.DOI $.IsRepositoryAdmin) (not .IsPrivate)}}
+								<div class="ui labeled button" tabindex="0">
+									<a class="ui basic button"
+										 href="/{{.Owner.Name}}/{{.Name}}/doi">
+										<i class="octicon octicon-squirrel"></i> DOIfy
+									</a>
+								</div>
+								{{else}}
+								{{if and $.IsRepositoryAdmin $.CommitsCount}}
+								<div class="ui labeled button	" tabindex="0">
+									<a class="ui basic button"
+										 data-tooltip="Your repository does not fulfill all requirements for a doi yet. Click to get instructions."
+										 data-position="bottom center"
+										 href="/G-Node/Info/wiki/DOIfile">
+										<i class="octicon octicon-squirrel"></i> DOIfy
+									</a>
+									<a class="ui basic label" href="{{$.RepoLink}}/_add/{{EscapePound $.BranchName}}/datacite.yml"
+										data-tooltip="Add Doifile"
+										data-position="bottom center">
+										<i class="octicon octicon-file"></i>
+									</a>
+								</div>
+								{{end}}
+								{{end}}
 							{{else}}
-							{{if and $.IsRepositoryAdmin $.CommitsCount}}
-							<div class="ui labeled button	" tabindex="0">
-								<a class="ui basic button"
-									 data-tooltip="Your repository does not fulfill all requirements for a doi yet. Click to get instructions."
-									 data-position="bottom center"
-									 href="/G-Node/Info/wiki/DOIfile">
-									<i class="octicon octicon-squirrel"></i> DOIfy
-								</a>
-								<a class="ui basic label" href="{{$.RepoLink}}/_add/{{EscapePound $.BranchName}}/datacite.yml"
-									data-tooltip="Add Doifile"
-									data-position="bottom center">
-									<i class="octicon octicon-file"></i>
-								</a>
-							</div>
-							{{end}}
+										<div class="nobg ui image label">
+												<div class="gin doi">DOI</div>
+												<div class="gin doinr">{{$.doi}}</div>
+										</div>
 							{{end}}
 						</div>
 					{{end}}