Explorar el Código

[repo/header] Revert to upstream and inject GIN changes

Reverting repository home page header to upstream as much as possible.
Stars are back: Users can star repositories.
DOI badge and button is on a separate row of the header, separate from
the standard buttons.
New button logic:
- Badge is shown when registered
- DOIfy button is shown when repo is ready to register, even when the
  repository is already registered (must have changes since latest
  registration).
- Otherwise, link to instructions and datacite.yml template are shown,
  like before.
Achilleas Koutsou hace 5 años
padre
commit
0aa874671b
Se han modificado 2 ficheros con 39 adiciones y 72 borrados
  1. 2 72
      templates/repo/header.tmpl
  2. 37 0
      templates/repo/header_gin.tmpl

+ 2 - 72
templates/repo/header.tmpl

@@ -43,8 +43,7 @@
 								</div>
 								</div>
 							</form>
 							</form>
 							{{if .CanBeForked}}
 							{{if .CanBeForked}}
-							<div class="ui labeled button" tabindex="0"
-									 data-tooltip="Please note: annexed file content will not be forked" data-position="bottom center">
+							<div class="ui labeled button" tabindex="0" data-tooltip="Please note: annexed file content will not be forked" data-position="bottom center">
 									<a class="ui basic button {{if eq .OwnerID $.LoggedUserID}}poping up{{end}}" href="{{AppSubURL}}/repo/fork/{{.ID}}">
 									<a class="ui basic button {{if eq .OwnerID $.LoggedUserID}}poping up{{end}}" href="{{AppSubURL}}/repo/fork/{{.ID}}">
 										<i class="octicon octicon-repo-forked"></i>{{$.i18n.Tr "repo.fork"}}
 										<i class="octicon octicon-repo-forked"></i>{{$.i18n.Tr "repo.fork"}}
 									</a>
 									</a>
@@ -53,76 +52,6 @@
 									</a>
 									</a>
 								</div>
 								</div>
 							{{end}}
 							{{end}}
-							{{if not $.DOI}}
-								{{if and (and $.HasDatacite $.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/DOI">
-										<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}}
-							{{end}}
-						</div>
-					{{end}}
-				</div>
-			</div><!-- end column -->
-		</div><!-- end grid -->
-	</div><div class="ui container"><!-- start container -->
-		<div class="ui vertically padded grid head"><!-- start grid -->
-			<div class="column"><!-- start column -->
-				<div class="ui header">
-					{{if not $.IsGuest}}
-						<div class="ui right">
-							<form class="display inline" action="{{$.RepoLink}}/action/{{if $.IsWatchingRepo}}un{{end}}watch?redirect_to={{$.Link}}" method="POST">
-								{{$.CSRFTokenHTML}}
-							</form>
-								{{if and (and $.HasDatacite $.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/DOI">
-										<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}}
-								<div class="nobg ui image label">
-									<a href="https://doi.org/{{$.DOI}}">
-										<div class="gin doi">DOI</div>
-									</a>
-									<div class="gin doinr">{{$.DOI}}</div>
-								</div>
 						</div>
 						</div>
 					{{end}}
 					{{end}}
 				</div>
 				</div>
@@ -130,6 +59,7 @@
 		</div><!-- end grid -->
 		</div><!-- end grid -->
 	</div><!-- end container -->
 	</div><!-- end container -->
 {{end}}
 {{end}}
+{{template "repo/header_gin" .}}
 {{if not .IsDiffCompare}}
 {{if not .IsDiffCompare}}
 	<div class="ui tabs container">
 	<div class="ui tabs container">
 		<div class="ui tabular menu navbar">
 		<div class="ui tabular menu navbar">

+ 37 - 0
templates/repo/header_gin.tmpl

@@ -0,0 +1,37 @@
+<div class="ui container"><!-- start container -->
+	<div class="ui vertically padded grid head"><!-- start grid -->
+		<div class="column"><!-- start column -->
+			<div class="ui header">
+				{{if not $.IsGuest}}
+					<div class="ui right">
+						{{if $.IsRepositoryAdmin}}
+							{{if $.IsDOIReady}} {{/* Ready to (re)register: Show button */}}
+							<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 not $.DOI}} {{/*Link to registration instructions*/}}
+								<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/DOI">
+										<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 registration button */}}
+						{{end}} {{/* Admin section */}}
+							
+						{{if $.DOI}} {{/* Registered repo: Show DOI badge */}}
+							<div class="nobg ui image label">
+								<a href="https://doi.org/{{$.DOI}}">
+									<div class="gin doi">DOI</div>
+								</a>
+								<div class="gin doinr">{{$.DOI}}</div>
+							</div>
+						{{end}} {{/* End DOI badge */}}
+					</div>
+				{{end}}
+			</div>
+		</div>
+	</div>
+</div>