Просмотр исходного кода

Implemented Verified Repository and Closes #106

Yoginth 7 лет назад
Родитель
Сommit
78e73481c5
5 измененных файлов с 17 добавлено и 3 удалено
  1. 1 0
      models/repo.go
  2. 1 0
      pkg/form/repo.go
  3. 1 0
      routes/repo/setting.go
  4. 2 0
      templates/repo/header.tmpl
  5. 12 3
      templates/repo/settings/options.tmpl

+ 1 - 0
models/repo.go

@@ -182,6 +182,7 @@ type Repository struct {
 	DefaultBranch   string
 	Size            int64 `xorm:"NOT NULL DEFAULT 0"`
 	UseCustomAvatar bool
+	IsVerified      bool
 
 	// Counters
 	NumWatches          int

+ 1 - 0
pkg/form/repo.go

@@ -85,6 +85,7 @@ type RepoSetting struct {
 	MirrorAddress string
 	Private       bool
 	EnablePrune   bool
+	IsVerified    bool
 
 	// Advanced settings
 	EnableWiki            bool

+ 1 - 0
routes/repo/setting.go

@@ -104,6 +104,7 @@ func SettingsPost(c *context.Context, f form.RepoSetting) {
 		repo.Website = f.Website
 		repo.DonateURL = f.DonateURL
 		repo.DonateBadge = f.DonateBadge
+		repo.IsVerified = f.IsVerified
 
 		// Visibility of forked repository is forced sync with base repository.
 		if repo.IsFork {

+ 2 - 0
templates/repo/header.tmpl

@@ -10,6 +10,7 @@
 							<a href="{{AppSubURL}}/{{.Owner.Name}}">{{.Owner.Name}}</a>
 							<div class="divider"> / </div>
 							<a href="{{$.RepoLink}}">{{.Name}}</a>
+							{{if .IsVerified}}<a class="poping up" target="_blank" href="/verified" data-content="Verified Repository" data-variation="inverted tiny" data-position="right center"><i class="verified octicon octicon-verified"></i></a>{{end}}
 							{{if .IsMirror}}<div class="fork-flag">{{$.i18n.Tr "repo.mirror_from"}} <a target="_blank" rel="noopener noreferrer" 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}}
 						{{else}}
@@ -17,6 +18,7 @@
 							<a href="{{AppSubURL}}/{{.Owner.Name}}">{{.Owner.Name}}</a>
 							<div class="divider"> / </div>
 							<a href="{{$.RepoLink}}">{{.Name}}</a>
+							{{if .IsVerified}}<a class="poping up" target="_blank" href="/verified" data-content="Verified Repository" data-variation="inverted tiny" data-position="right center"><i class="verified octicon octicon-verified"></i></a>{{end}}
 							{{if .IsMirror}}<div class="fork-flag" style="margin-left:34px !important;margin-top:7px !important">{{$.i18n.Tr "repo.mirror_from"}} <a target="_blank" rel="noopener noreferrer" href="{{$.Mirror.Address}}">{{$.Mirror.Address}}</a></div>{{end}}
 							{{if .IsFork}}<div class="fork-flag" style="margin-left:34px !important;margin-top:7px !important">{{$.i18n.Tr "repo.forked_from"}} <a href="{{.BaseRepo.Link}}">{{SubStr .BaseRepo.RelLink 1 -1}}</a></div>{{end}}
 						{{end}}

+ 12 - 3
templates/repo/settings/options.tmpl

@@ -46,6 +46,15 @@
 							</div>
 						{{end}}
 
+						{{if .IsAdmin}}
+							<div class="inline field">
+								<div class="ui checkbox">
+									<input name="is_verified" type="checkbox" {{if .Repository.IsVerified}}checked{{end}}>
+									<label><strong>This Repository is Verified</strong></label>
+								</div>
+							</div>
+						{{end}}
+
 						<div class="field">
 							<button class="ui green button">{{$.i18n.Tr "repo.settings.update_settings"}}</button>
 						</div>
@@ -75,10 +84,10 @@
 							{{.CSRFTokenHTML}}
 							<input type="hidden" name="action" value="mirror">
 							<div class="inline field {{if .Err_EnablePrune}}error{{end}}">
-							  <label>{{.i18n.Tr "repo.mirror_prune"}}</label>
+							  	<label>{{.i18n.Tr "repo.mirror_prune"}}</label>
 								<div class="ui checkbox">
-					        <input id="enable_prune" name="enable_prune" type="checkbox" {{if .MirrorEnablePrune}}checked{{end}}>
-					        <label>{{.i18n.Tr "repo.mirror_prune_desc"}}</label>
+									<input id="enable_prune" name="enable_prune" type="checkbox" {{if .MirrorEnablePrune}}checked{{end}}>
+									<label>{{.i18n.Tr "repo.mirror_prune_desc"}}</label>
 								</div>
 							</div>
 							<div class="inline field {{if .Err_Interval}}error{{end}}">