Browse Source

[GinR] Show no license warning

cgars 7 years ago
parent
commit
c347783719
2 changed files with 15 additions and 1 deletions
  1. 3 1
      routes/repo/view.go
  2. 12 0
      templates/repo/view_list.tmpl

+ 3 - 1
routes/repo/view.go

@@ -67,7 +67,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")) {
+		if entry.IsDir() || (!markup.IsReadmeFile(entry.Name()) && !(entry.Name() == "datacite.yml")&& !(entry.Name() == "LICENSE")) {
 			continue
 		}
 
@@ -89,6 +89,8 @@ func renderDirectory(c *context.Context, treeLink string) {
 			}
 			log.Trace("Doi info was: %v ", doiInfo)
 			c.Data["DoiInfo"] = doiInfo
+		} else if entry.Name() == "LICENSE" {
+			c.Data["LicenseExists"] = true
 		}
 	}
 

+ 12 - 0
templates/repo/view_list.tmpl

@@ -1,3 +1,15 @@
+{{if and (not .IsPrivate) (and (not .LicenseExists) $.IsRepositoryAdmin)}}
+<div class="ui warning icon message">
+	<i class="comment outline icon"></i>
+	<div class="content">
+	<div class="header">
+		You have provided no LICENSE file!
+	</div>
+	Your repository is public, however, you have provided no LICENSE file. You should really consider adding one! <a href="/G-Node/Info/wiki/Licensing">I want to know more.</a>
+</div>
+</div>
+{{end}}
+
 <table id="repo-files-table" class="ui fixed single line table">
 	<thead>
 		<tr>