فهرست منبع

[GinR] Unlist repository option

Adds an option to unlist a repository from the explore list
cgars 7 سال پیش
والد
کامیت
ce25c0d20b
6فایلهای تغییر یافته به همراه15 افزوده شده و 3 حذف شده
  1. 3 1
      conf/locale/locale_en-US.ini
  2. 1 0
      models/repo.go
  3. 1 0
      pkg/form/repo.go
  4. 1 2
      routes/home.go
  5. 2 0
      routes/repo/setting.go
  6. 7 0
      templates/repo/settings/options.tmpl

+ 3 - 1
conf/locale/locale_en-US.ini

@@ -398,6 +398,8 @@ visibility = Visibility
 visiblity_helper = This repository is <span class="ui red text">Private</span>
 visiblity_helper_forced = Site admin has forced all new repositories to be <span class="ui red text">Private</span>
 visiblity_fork_helper = (Change of this value will affect all forks)
+listed = Listed
+listed_helper = Is this repository listed on Explore?
 clone_helper = Need help cloning? Visit <a target="_blank" href="%s">Help</a>!
 fork_repo = Fork Repository
 fork_from = Fork From
@@ -780,7 +782,7 @@ settings.remove_collaborator_success = Collaborator has been removed.
 settings.search_user_placeholder = Search user...
 settings.invite_collaborator=Invite Collaborator
 settings.invite_placeholder=Enter mail adress to invite
-settings.invite_collaborator_warn=Be aware! This will send out invitation mails!
+settings.invite_collaborator_warn=Be aware that this will send out invitation mails!
 settings.org_not_allowed_to_be_collaborator = Organization is not allowed to be added as a collaborator.
 settings.add_webhook = Add Webhook
 settings.hooks_desc = Webhooks are much like basic HTTP POST event triggers. Whenever something occurs in GIN, we will handle the notification to the target host you specify. Learn more in this <a target="_blank" href="%s">Webhooks Guide</a>.

+ 1 - 0
models/repo.go

@@ -167,6 +167,7 @@ type Repository struct {
 
 	IsPrivate bool
 	IsBare    bool
+	Unlisted  bool
 
 	IsMirror bool
 	*Mirror  `xorm:"-"`

+ 1 - 0
pkg/form/repo.go

@@ -88,6 +88,7 @@ type RepoSetting struct {
 	Interval      int
 	MirrorAddress string
 	Private       bool
+	Listed      bool
 	EnablePrune   bool
 
 	// Advanced settings

+ 1 - 2
routes/home.go

@@ -11,7 +11,6 @@ import (
 	"github.com/G-Node/gogs/pkg/context"
 	"github.com/G-Node/gogs/pkg/setting"
 	"github.com/G-Node/gogs/routes/user"
-	"strings"
 )
 
 const (
@@ -76,7 +75,7 @@ func ExploreRepos(c *context.Context) {
 	// filter repos we eant to not show in list
 	var showRep []*models.Repository
 	for _, repo := range repos {
-		if !strings.Contains(repo.Name, "hideme") && !strings.Contains(repo.Name, "unlisted") {
+		if !repo.Unlisted {
 			showRep = append(showRep, repo)
 		}
 	}

+ 2 - 0
routes/repo/setting.go

@@ -90,6 +90,8 @@ func SettingsPost(c *context.Context, f form.RepoSetting) {
 
 		visibilityChanged := repo.IsPrivate != f.Private
 		repo.IsPrivate = f.Private
+
+		repo.Unlisted = !f.Listed
 		if err := models.UpdateRepository(repo, visibilityChanged); err != nil {
 			c.ServerError("UpdateRepository", err)
 			return

+ 7 - 0
templates/repo/settings/options.tmpl

@@ -34,6 +34,13 @@
 									<label>{{.i18n.Tr "repo.visiblity_helper" | Safe}} {{if .Repository.NumForks}}<span class="text red">{{.i18n.Tr "repo.visiblity_fork_helper"}}</span>{{end}}</label>
 								</div>
 							</div>
+						<div class="inline field">
+							<label>{{.i18n.Tr "repo.listed"}}</label>
+							<div class="ui checkbox">
+								<input name="listed" type="checkbox" {{if not .Repository.Unlisted}}checked{{end}}>
+								<label>{{.i18n.Tr "repo.listed_helper" | Safe}}</label>
+							</div>
+						</div>
 						{{end}}
 
 						<div class="field">