Переглянути джерело

Add the ability to explore organizations (#3573)

* Add ability to explore organizations

* Use right icon for org explore links
Daniel Oaks 7 роки тому
батько
коміт
b3d9ca4ccd

+ 1 - 0
cmd/web.go

@@ -214,6 +214,7 @@ func runWeb(ctx *cli.Context) error {
 		})
 		m.Get("/repos", routers.ExploreRepos)
 		m.Get("/users", routers.ExploreUsers)
+		m.Get("/organizations", routers.ExploreOrganizations)
 	}, ignSignIn)
 	m.Combo("/install", routers.InstallInit).Get(routers.Install).
 		Post(bindIgnErr(auth.InstallForm{}), routers.InstallPost)

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

@@ -137,6 +137,7 @@ issues.in_your_repos = In your repositories
 [explore]
 repos = Repositories
 users = Users
+organizations = Organizations
 search = Search
 
 [auth]

Різницю між файлами не показано, бо вона завелика
+ 6 - 6
modules/bindata/bindata.go


+ 19 - 3
routers/home.go

@@ -17,9 +17,10 @@ import (
 )
 
 const (
-	HOME          base.TplName = "home"
-	EXPLORE_REPOS base.TplName = "explore/repos"
-	EXPLORE_USERS base.TplName = "explore/users"
+	HOME                  base.TplName = "home"
+	EXPLORE_REPOS         base.TplName = "explore/repos"
+	EXPLORE_USERS         base.TplName = "explore/users"
+	EXPLORE_ORGANIZATIONS base.TplName = "explore/organizations"
 )
 
 func Home(ctx *context.Context) {
@@ -180,6 +181,21 @@ func ExploreUsers(ctx *context.Context) {
 	})
 }
 
+func ExploreOrganizations(ctx *context.Context) {
+	ctx.Data["Title"] = ctx.Tr("explore")
+	ctx.Data["PageIsExplore"] = true
+	ctx.Data["PageIsExploreOrganizations"] = true
+
+	RenderUserSearch(ctx, &UserSearchOptions{
+		Type:     models.USER_TYPE_ORGANIZATION,
+		Counter:  models.CountOrganizations,
+		Ranger:   models.Organizations,
+		PageSize: setting.UI.ExplorePagingNum,
+		OrderBy:  "updated_unix DESC",
+		TplName:  EXPLORE_ORGANIZATIONS,
+	})
+}
+
 func NotFound(ctx *context.Context) {
 	ctx.Data["Title"] = "Page Not Found"
 	ctx.Handle(404, "home.NotFound", nil)

+ 3 - 0
templates/explore/navbar.tmpl

@@ -7,5 +7,8 @@
 		<a class="{{if .PageIsExploreUsers}}active{{end}} item" href="{{AppSubUrl}}/explore/users">
 			<span class="octicon octicon-person"></span> {{.i18n.Tr "explore.users"}}
 		</a>
+		<a class="{{if .PageIsExploreOrganizations}}active{{end}} item" href="{{AppSubUrl}}/explore/organizations">
+			<span class="octicon octicon-organization"></span> {{.i18n.Tr "explore.organizations"}}
+		</a>
 	</div>
 </div>

+ 35 - 0
templates/explore/organizations.tmpl

@@ -0,0 +1,35 @@
+{{template "base/head" .}}
+<div class="explore users">
+	<div class="ui container">
+		<div class="ui grid">
+			{{template "explore/navbar" .}}
+			<div class="twelve wide column content">
+				{{template "explore/search" .}}
+
+				<div class="ui user list">
+					{{range .Users}}
+						<div class="item">
+						  <img class="ui avatar image" src="{{.RelAvatarLink}}">
+						  <div class="content">
+						  	<span class="header"><a href="{{.HomeLink}}">{{.Name}}</a> {{.FullName}}</span>
+						    <div class="description">
+									{{if .Location}}
+										<i class="octicon octicon-location"></i> {{.Location}}
+									{{end}}
+									{{if and .Website}}
+										<i class="octicon octicon-link"></i>
+										<a href="{{.Website}}" rel="nofollow">{{.Website}}</a>
+									{{end}}
+									<i class="octicon octicon-clock"></i> {{$.i18n.Tr "user.join_on"}} {{DateFmtShort .Created}}
+						    </div>
+						  </div>
+						</div>
+					{{end}}
+				</div>
+
+				{{template "explore/page" .}}
+			</div>
+		</div>
+	</div>
+</div>
+{{template "base/footer" .}}

Деякі файли не було показано, через те що забагато файлів було змінено