Sfoglia il codice sorgente

[DOI] Show doify button only with doifiable repos

cgars 8 anni fa
parent
commit
f230e7d3b0
3 ha cambiato i file con 16 aggiunte e 9 eliminazioni
  1. 0 4
      models/repo.go
  2. 7 4
      routes/repo/view.go
  3. 9 1
      templates/repo/header.tmpl

+ 0 - 4
models/repo.go

@@ -195,10 +195,6 @@ type Repository struct {
 	UpdatedUnix int64
 	UpdatedUnix int64
 }
 }
 
 
-func (repo *Repository) CanDoified() bool {
-	return true
-}
-
 func (repo *Repository) BeforeInsert() {
 func (repo *Repository) BeforeInsert() {
 	repo.CreatedUnix = time.Now().Unix()
 	repo.CreatedUnix = time.Now().Unix()
 	repo.UpdatedUnix = repo.CreatedUnix
 	repo.UpdatedUnix = repo.CreatedUnix

+ 7 - 4
routes/repo/view.go

@@ -52,16 +52,19 @@ func renderDirectory(c *context.Context, treeLink string) {
 		c.ServerError("GetCommitsInfoWithCustomConcurrency", err)
 		c.ServerError("GetCommitsInfoWithCustomConcurrency", err)
 		return
 		return
 	}
 	}
-
+	c.Data["DOI"] = false
 	var readmeFile *git.Blob
 	var readmeFile *git.Blob
 	for _, entry := range entries {
 	for _, entry := range entries {
-		if entry.IsDir() || !markup.IsReadmeFile(entry.Name()) {
+		if entry.IsDir() || (!markup.IsReadmeFile(entry.Name()) && !(entry.Name() == "cloudberry.yml")) {
 			continue
 			continue
 		}
 		}
 
 
 		// TODO: collect all possible README files and show with priority.
 		// TODO: collect all possible README files and show with priority.
-		readmeFile = entry.Blob()
-		break
+		if markup.IsReadmeFile(entry.Name()) {
+			readmeFile = entry.Blob()
+		} else if entry.Name() == "cloudberry.yml" {
+			c.Data["DOI"] = true
+		}
 	}
 	}
 
 
 	if readmeFile != nil {
 	if readmeFile != nil {

+ 9 - 1
templates/repo/header.tmpl

@@ -33,13 +33,21 @@
 									</a>
 									</a>
 								</div>
 								</div>
 							{{end}}
 							{{end}}
-							{{if and .CanDoified $.IsRepositoryAdmin}}
+							{{if and $.DOI $.IsRepositoryAdmin}}
 							<div class="ui labeled button" tabindex="0">
 							<div class="ui labeled button" tabindex="0">
 								<a class="ui basic button"
 								<a class="ui basic button"
 									 href="https://doi.gin.g-node.org/?repo={{.FullName}}&user={{.Owner.Name}}&token={{$.SessionID}}">
 									 href="https://doi.gin.g-node.org/?repo={{.FullName}}&user={{.Owner.Name}}&token={{$.SessionID}}">
 									<i class="octicon octicon-squirrel"></i> DOIfy
 									<i class="octicon octicon-squirrel"></i> DOIfy
 								</a>
 								</a>
 							</div>
 							</div>
+							{{else}}
+							<div class="ui labeled button" tabindex="0">
+								<a class="ui basic button"
+									 href="/G-Node/Info/wiki/Doi#how-to-get-a-doi">
+									<i class="octicon octicon-squirrel"></i> DOIfy
+								</a>
+							</div>
+
 							{{end}}
 							{{end}}
 						</div>
 						</div>
 					{{end}}
 					{{end}}