From 85f3da9d287a138405493d23251f155684ccedcd Mon Sep 17 00:00:00 2001 From: hiifong Date: Wed, 15 Jan 2025 11:38:33 +0800 Subject: [PATCH 01/20] Feat: Star List --- models/repo/star_list.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 models/repo/star_list.go diff --git a/models/repo/star_list.go b/models/repo/star_list.go new file mode 100644 index 0000000000000..89cb7118869f0 --- /dev/null +++ b/models/repo/star_list.go @@ -0,0 +1,25 @@ +// Copyright 2025 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package repo + +import ( + "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/modules/timeutil" +) + +// StarList ... +type StarList struct { + ID int64 `xorm:"pk autoincr"` + UID int64 `xorm:INDEX uid` + SID int64 `xorm:INDEX sid` + Name string + Desc string + + CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` + UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` +} + +func init() { + db.RegisterModel(new(StarList)) +} From 83cd897d46bb5b7566ebf56cb18e35a3f3080f74 Mon Sep 17 00:00:00 2001 From: hiifong Date: Mon, 20 Jan 2025 11:07:38 +0800 Subject: [PATCH 02/20] Update --- models/repo/star_list.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/models/repo/star_list.go b/models/repo/star_list.go index 89cb7118869f0..8f4a849da7421 100644 --- a/models/repo/star_list.go +++ b/models/repo/star_list.go @@ -10,10 +10,10 @@ import ( // StarList ... type StarList struct { - ID int64 `xorm:"pk autoincr"` - UID int64 `xorm:INDEX uid` - SID int64 `xorm:INDEX sid` - Name string + ID int64 `xorm:"pk autoincr"` + UID int64 `xorm:"INDEX NOT NULL"` + SID int64 `xorm:"INDEX NOT NULL"` + Name string `xorm:"NOT NULL"` Desc string CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` From a53041966c43f541ef70731754dc4c1845d34de3 Mon Sep 17 00:00:00 2001 From: hiifong Date: Tue, 4 Feb 2025 15:26:10 +0800 Subject: [PATCH 03/20] fix model --- models/repo/star_list.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/repo/star_list.go b/models/repo/star_list.go index 89cb7118869f0..f04654f92ec8d 100644 --- a/models/repo/star_list.go +++ b/models/repo/star_list.go @@ -11,8 +11,8 @@ import ( // StarList ... type StarList struct { ID int64 `xorm:"pk autoincr"` - UID int64 `xorm:INDEX uid` - SID int64 `xorm:INDEX sid` + UID int64 `xorm:"INDEX"` + SID int64 `xorm:"INDEX"` Name string Desc string From f1d9ba1f879587c4ff3af637c64774cfdf5f1a04 Mon Sep 17 00:00:00 2001 From: hiifong Date: Tue, 4 Feb 2025 22:06:36 +0800 Subject: [PATCH 04/20] save --- models/migrations/migrations.go | 1 + models/migrations/v1_24/v314.go | 46 +++++++++++++++++++++++++++++++++ models/repo/star.go | 1 + models/repo/star_list.go | 44 ++++++++++++++++++++++++++++++- 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 models/migrations/v1_24/v314.go diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 95364ab705751..4b035fdd95b29 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -373,6 +373,7 @@ func prepareMigrationTasks() []*migration { // Gitea 1.23.0-rc0 ends at migration ID number 311 (database version 312) newMigration(312, "Add DeleteBranchAfterMerge to AutoMerge", v1_24.AddDeleteBranchAfterMergeForAutoMerge), + newMigration(314, "Add star_list table", v1_24.AddStarList), } return preparedMigrations } diff --git a/models/migrations/v1_24/v314.go b/models/migrations/v1_24/v314.go new file mode 100644 index 0000000000000..182ea4dfaadf6 --- /dev/null +++ b/models/migrations/v1_24/v314.go @@ -0,0 +1,46 @@ +// Copyright 2025 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package v1_24 //nolint + +import ( + "code.gitea.io/gitea/modules/timeutil" + + "xorm.io/xorm" +) + +type Star struct { + StarListID int64 `xorm:"UNIQUE(s)"` +} + +type StarList struct { + ID int64 `xorm:"pk autoincr"` + UID int64 `xorm:"INDEX"` + Name string + Desc string + + CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` + UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` +} + +// TableName return database table name for xorm +func (StarList) TableName() string { + return "star_list" +} + +func AddStarList(x *xorm.Engine) error { + sess := x.NewSession() + defer sess.Close() + if err := sess.Begin(); err != nil { + return err + } + err := sess.Sync(new(Star)) + if err != nil { + return err + } + err = sess.Sync(new(StarList)) + if err != nil { + return err + } + return sess.Commit() +} diff --git a/models/repo/star.go b/models/repo/star.go index 4c66855525fa6..62d242fb7c31a 100644 --- a/models/repo/star.go +++ b/models/repo/star.go @@ -16,6 +16,7 @@ type Star struct { ID int64 `xorm:"pk autoincr"` UID int64 `xorm:"UNIQUE(s)"` RepoID int64 `xorm:"UNIQUE(s)"` + StarListID int64 `xorm:"UNIQUE(s)"` CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` } diff --git a/models/repo/star_list.go b/models/repo/star_list.go index f04654f92ec8d..f9a6df297cefc 100644 --- a/models/repo/star_list.go +++ b/models/repo/star_list.go @@ -4,6 +4,8 @@ package repo import ( + "context" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" ) @@ -12,10 +14,12 @@ import ( type StarList struct { ID int64 `xorm:"pk autoincr"` UID int64 `xorm:"INDEX"` - SID int64 `xorm:"INDEX"` Name string Desc string + StarIDs []int64 `xorm:"-"` + Repos []Repository `xorm:"-"` + CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` } @@ -23,3 +27,41 @@ type StarList struct { func init() { db.RegisterModel(new(StarList)) } + +func (list *StarList) GetCount() int64 { + var star Star + count, err := db.GetEngine(context.Background()).Where("star_list_id = ?", list.ID).Count(star) + if err != nil { + return 0 + } + return count +} + +func (list *StarList) LoadStars() { + var star []Star + err := db.GetEngine(context.Background()).Where("star_list_id = ?", list.ID).Find(&star) + if err != nil { + return + } + for _, star := range star { + list.StarIDs = append(list.StarIDs, star.ID) + } +} + +func GetStarListByUID(ctx context.Context, uid int64) ([]*StarList, error) { + var list []*StarList + err := db.GetEngine(ctx).Where("uid = ?", uid).Find(&list) + if err != nil { + return nil, err + } + return list, nil +} + +func GetReposByStarListID(ctx context.Context, starListID int64) ([]*Repository, error) { + repos := make([]*Repository, 0, 100) + err := db.GetEngine(ctx).Where("star_list_id = ?", starListID).Find(&repos) + if err != nil { + return nil, err + } + return repos, nil +} From eeefd0f75f9726045d8539d34a8b90da88d54efd Mon Sep 17 00:00:00 2001 From: hiifong Date: Thu, 6 Feb 2025 00:21:32 +0800 Subject: [PATCH 05/20] Update --- models/migrations/v1_24/v314.go | 14 +++++---- models/repo/issue.go | 7 ----- models/repo/repo.go | 7 ----- models/repo/star.go | 1 - models/repo/star_list.go | 53 ++++++++++++++------------------ models/repo/star_list_repo.go | 54 +++++++++++++++++++++++++++++++++ 6 files changed, 84 insertions(+), 52 deletions(-) create mode 100644 models/repo/star_list_repo.go diff --git a/models/migrations/v1_24/v314.go b/models/migrations/v1_24/v314.go index 182ea4dfaadf6..98d065b2ad87e 100644 --- a/models/migrations/v1_24/v314.go +++ b/models/migrations/v1_24/v314.go @@ -9,10 +9,6 @@ import ( "xorm.io/xorm" ) -type Star struct { - StarListID int64 `xorm:"UNIQUE(s)"` -} - type StarList struct { ID int64 `xorm:"pk autoincr"` UID int64 `xorm:"INDEX"` @@ -23,6 +19,12 @@ type StarList struct { UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` } +type StarListRepo struct { + UID int64 `xorm:"UNIQUE(s)"` + StarListID int64 `xorm:"UNIQUE(s)"` + RepoID int64 `xorm:"UNIQUE(s)"` +} + // TableName return database table name for xorm func (StarList) TableName() string { return "star_list" @@ -34,11 +36,11 @@ func AddStarList(x *xorm.Engine) error { if err := sess.Begin(); err != nil { return err } - err := sess.Sync(new(Star)) + err := sess.Sync(new(StarList)) if err != nil { return err } - err = sess.Sync(new(StarList)) + err = sess.Sync(new(StarListRepo)) if err != nil { return err } diff --git a/models/repo/issue.go b/models/repo/issue.go index 0dd4fd5ed480e..4f186aae9cc9b 100644 --- a/models/repo/issue.go +++ b/models/repo/issue.go @@ -11,13 +11,6 @@ import ( "code.gitea.io/gitea/modules/setting" ) -// ___________.__ ___________ __ -// \__ ___/|__| _____ ___\__ ___/___________ ____ | | __ ___________ -// | | | |/ \_/ __ \| | \_ __ \__ \ _/ ___\| |/ // __ \_ __ \ -// | | | | Y Y \ ___/| | | | \// __ \\ \___| <\ ___/| | \/ -// |____| |__|__|_| /\___ >____| |__| (____ /\___ >__|_ \\___ >__| -// \/ \/ \/ \/ \/ \/ - // CanEnableTimetracker returns true when the server admin enabled time tracking // This overrules IsTimetrackerEnabled func (repo *Repository) CanEnableTimetracker() bool { diff --git a/models/repo/repo.go b/models/repo/repo.go index 4e27dbaf1467e..478c490444e07 100644 --- a/models/repo/repo.go +++ b/models/repo/repo.go @@ -732,13 +732,6 @@ func (repo *Repository) MustNotBeArchived() error { return nil } -// __________ .__ __ -// \______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__. -// | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | | -// | | \ ___/| |_> > <_> )___ \| || | ( <_> ) | \/\___ | -// |____|_ /\___ > __/ \____/____ >__||__| \____/|__| / ____| -// \/ \/|__| \/ \/ - // ErrRepoNotExist represents a "RepoNotExist" kind of error. type ErrRepoNotExist struct { ID int64 diff --git a/models/repo/star.go b/models/repo/star.go index 62d242fb7c31a..4c66855525fa6 100644 --- a/models/repo/star.go +++ b/models/repo/star.go @@ -16,7 +16,6 @@ type Star struct { ID int64 `xorm:"pk autoincr"` UID int64 `xorm:"UNIQUE(s)"` RepoID int64 `xorm:"UNIQUE(s)"` - StarListID int64 `xorm:"UNIQUE(s)"` CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` } diff --git a/models/repo/star_list.go b/models/repo/star_list.go index f9a6df297cefc..8cfbe293cd4e5 100644 --- a/models/repo/star_list.go +++ b/models/repo/star_list.go @@ -10,15 +10,13 @@ import ( "code.gitea.io/gitea/modules/timeutil" ) -// StarList ... type StarList struct { ID int64 `xorm:"pk autoincr"` UID int64 `xorm:"INDEX"` Name string Desc string - StarIDs []int64 `xorm:"-"` - Repos []Repository `xorm:"-"` + Repos []Repository `xorm:"-"` CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` @@ -28,40 +26,33 @@ func init() { db.RegisterModel(new(StarList)) } -func (list *StarList) GetCount() int64 { - var star Star - count, err := db.GetEngine(context.Background()).Where("star_list_id = ?", list.ID).Count(star) - if err != nil { - return 0 - } - return count +func InsertStarList(ctx context.Context, starList *StarList) error { + _, err := db.GetEngine(ctx).Insert(starList) + return err } -func (list *StarList) LoadStars() { - var star []Star - err := db.GetEngine(context.Background()).Where("star_list_id = ?", list.ID).Find(&star) - if err != nil { - return - } - for _, star := range star { - list.StarIDs = append(list.StarIDs, star.ID) - } +func UpdateStarList(ctx context.Context, starList *StarList) error { + _, err := db.GetEngine(ctx).Where("id = ?", starList.ID).AllCols().Update(starList) + return err } -func GetStarListByUID(ctx context.Context, uid int64) ([]*StarList, error) { - var list []*StarList - err := db.GetEngine(ctx).Where("uid = ?", uid).Find(&list) - if err != nil { - return nil, err - } - return list, nil +func DeleteStarListByID(ctx context.Context, id int64) error { + _, err := db.GetEngine(ctx).Delete(&StarList{ID: id}) + return err } -func GetReposByStarListID(ctx context.Context, starListID int64) ([]*Repository, error) { - repos := make([]*Repository, 0, 100) - err := db.GetEngine(ctx).Where("star_list_id = ?", starListID).Find(&repos) - if err != nil { +func GetStarListByID(ctx context.Context, id int64) (*StarList, error) { + starList := new(StarList) + if has, err := db.GetEngine(ctx).Where("id = ?", id).Get(starList); err != nil { return nil, err + } else if !has { + return nil, nil } - return repos, nil + return starList, nil +} + +func GetStarListsForUser(ctx context.Context, id int64) ([]*StarList, error) { + starLists := make([]*StarList, 0, 10) + err := db.GetEngine(ctx).Where("uid = ?", id).Find(&starLists) + return starLists, err } diff --git a/models/repo/star_list_repo.go b/models/repo/star_list_repo.go new file mode 100644 index 0000000000000..e1861d870aaf1 --- /dev/null +++ b/models/repo/star_list_repo.go @@ -0,0 +1,54 @@ +package repo + +import ( + "context" + + "code.gitea.io/gitea/models/db" +) + +type StarListRepo struct { + UID int64 `xorm:"UNIQUE(s)"` + StarListID int64 `xorm:"UNIQUE(s)"` + RepoID int64 `xorm:"UNIQUE(s)"` +} + +func init() { + db.RegisterModel(new(StarListRepo)) +} + +func StarLists(ctx context.Context, uid, repoID int64, ids []int64) error { + starListRepos := make([]*StarListRepo, 0, len(ids)) + for _, id := range ids { + starListRepos = append(starListRepos, &StarListRepo{ + UID: uid, + StarListID: id, + RepoID: repoID, + }) + } + + ctx, committer, err := db.TxContext(ctx) + if err != nil { + return err + } + defer committer.Close() + + _, err = db.GetEngine(ctx).Insert(&starListRepos) + if err != nil { + return err + } + + _, err = db.GetEngine(ctx).Where("uid = ? AND repo_id = ? AND star_list_id NOT IN (?)", uid, repoID, ids).Delete(new(StarListRepo)) + if err != nil { + return err + } + + return committer.Commit() +} + +func UnStarLists(ctx context.Context, uid, repoID int64, ids []int64) error { + _, err := db.GetEngine(ctx).Where("uid = ? AND repo_id = ? AND star_list_id NOT IN (?)", uid, repoID, ids).Delete(new(StarListRepo)) + if err != nil { + return err + } + return nil +} From 81cff53c928fbe95a2657c518ceb0fed1d245aa4 Mon Sep 17 00:00:00 2001 From: hiifong Date: Thu, 6 Feb 2025 00:23:46 +0800 Subject: [PATCH 06/20] Update --- models/migrations/v1_24/v314.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/models/migrations/v1_24/v314.go b/models/migrations/v1_24/v314.go index 98d065b2ad87e..368fdad21a935 100644 --- a/models/migrations/v1_24/v314.go +++ b/models/migrations/v1_24/v314.go @@ -25,11 +25,6 @@ type StarListRepo struct { RepoID int64 `xorm:"UNIQUE(s)"` } -// TableName return database table name for xorm -func (StarList) TableName() string { - return "star_list" -} - func AddStarList(x *xorm.Engine) error { sess := x.NewSession() defer sess.Close() From f99f9196f2fe5edcac9a1ffa6c137187835dbbef Mon Sep 17 00:00:00 2001 From: hiifong Date: Fri, 21 Feb 2025 23:46:17 +0800 Subject: [PATCH 07/20] Update --- models/migrations/migrations.go | 2 +- models/migrations/v1_24/{v314.go => v313.go} | 0 routers/web/shared/starlists/star_lists.go | 27 +++++++++++ routers/web/web.go | 13 ++++++ templates/user/profile.tmpl | 1 + templates/user/star_list.tmpl | 48 ++++++++++++++++++++ web_src/css/user.css | 17 +++++++ 7 files changed, 107 insertions(+), 1 deletion(-) rename models/migrations/v1_24/{v314.go => v313.go} (100%) create mode 100644 routers/web/shared/starlists/star_lists.go create mode 100644 templates/user/star_list.tmpl diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 4b035fdd95b29..b8fb2d61c7e42 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -373,7 +373,7 @@ func prepareMigrationTasks() []*migration { // Gitea 1.23.0-rc0 ends at migration ID number 311 (database version 312) newMigration(312, "Add DeleteBranchAfterMerge to AutoMerge", v1_24.AddDeleteBranchAfterMergeForAutoMerge), - newMigration(314, "Add star_list table", v1_24.AddStarList), + newMigration(313, "Add star_list, star_list_repo table", v1_24.AddStarList), } return preparedMigrations } diff --git a/models/migrations/v1_24/v314.go b/models/migrations/v1_24/v313.go similarity index 100% rename from models/migrations/v1_24/v314.go rename to models/migrations/v1_24/v313.go diff --git a/routers/web/shared/starlists/star_lists.go b/routers/web/shared/starlists/star_lists.go new file mode 100644 index 0000000000000..d86057c5fae38 --- /dev/null +++ b/routers/web/shared/starlists/star_lists.go @@ -0,0 +1,27 @@ +package starlists + +import "code.gitea.io/gitea/services/context" + +func GetByName(ctx *context.Context) { + +} + +func Create(ctx *context.Context) { + +} + +func UpdateByName(ctx *context.Context) { + +} + +func DeleteByName(ctx *context.Context) { + +} + +func List(ctx *context.Context) { + +} + +func UpdateListRepos(ctx *context.Context) { + +} diff --git a/routers/web/web.go b/routers/web/web.go index 0963565c6adb0..cf02d4e5103f1 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -38,6 +38,7 @@ import ( "code.gitea.io/gitea/routers/web/repo/actions" repo_setting "code.gitea.io/gitea/routers/web/repo/setting" "code.gitea.io/gitea/routers/web/shared/project" + "code.gitea.io/gitea/routers/web/shared/starlists" "code.gitea.io/gitea/routers/web/user" user_setting "code.gitea.io/gitea/routers/web/user/setting" "code.gitea.io/gitea/routers/web/user/setting/security" @@ -1609,6 +1610,18 @@ func registerRoutes(m *web.Router) { m.Post("/action/{action:accept_transfer|reject_transfer}", reqSignIn, repo.ActionTransfer) }, optSignIn, context.RepoAssignment) + m.Group("/stars/{username}/lists", func() { + m.Post("", starlists.Create) // 创建一个新的list + m.Get("/{listname}", starlists.GetByName) // 获取当前listname的所有repo + m.Post("/{listname}", starlists.UpdateByName) // 更新当前listname的所有repo + m.Delete("/{listname}", starlists.DeleteByName) // 删除当前listname + }) + + m.Group("/{username}/{reponame}", func() { + m.Get("/lists", starlists.List) // List the repo in all star lists + m.Post("/lists", starlists.UpdateListRepos) // Update the repo star lists + }) + common.AddOwnerRepoGitLFSRoutes(m, optSignInIgnoreCsrf, lfsServerEnabled) // "/{username}/{reponame}/{lfs-paths}": git-lfs support addOwnerRepoGitHTTPRouters(m) // "/{username}/{reponame}/{git-paths}": git http support diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 345872b00d17e..83bd88891acee 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -17,6 +17,7 @@ {{template "user/dashboard/feeds" .}} {{else if eq .TabName "stars"}}
+ {{template "user/star_list" .}} {{template "shared/repo_search" .}} {{template "explore/repo_list" .}} {{template "base/paginate" .}} diff --git a/templates/user/star_list.tmpl b/templates/user/star_list.tmpl new file mode 100644 index 0000000000000..b8bfa5d4ea9f2 --- /dev/null +++ b/templates/user/star_list.tmpl @@ -0,0 +1,48 @@ +
+ +
+
+ Lists(26) +
+
+ +
+
+ +
+
+ + +
+
+ + + +
diff --git a/web_src/css/user.css b/web_src/css/user.css index caabf1834cbb2..04a0cfa0ca851 100644 --- a/web_src/css/user.css +++ b/web_src/css/user.css @@ -101,6 +101,23 @@ object-fit: contain; } +.star-list .box { + background-color: var(--color-body); + border-color: #d1d9e0; + border-radius: 0.375rem; + border-style: solid; + border-width: 0.0625rem; +} +.test-1 { + height: 36px; +} + +#profile-lists-container .box > a,a:link,a:visited,a:hover,a:active { + display: block; + text-decoration: none; + color: inherit; +} + #readme_profile { padding: 1em 2em; border-radius: var(--border-radius); From 05c56b2867119627de59a79e0cb67799268d3f63 Mon Sep 17 00:00:00 2001 From: hiifong Date: Sat, 22 Feb 2025 11:30:38 +0800 Subject: [PATCH 08/20] Update --- templates/user/star_list.tmpl | 38 +++++++++++++++------- web_src/css/user.css | 60 +++++++++++++++++++++++++++++++---- 2 files changed, 81 insertions(+), 17 deletions(-) diff --git a/templates/user/star_list.tmpl b/templates/user/star_list.tmpl index b8bfa5d4ea9f2..c998a55b2834f 100644 --- a/templates/user/star_list.tmpl +++ b/templates/user/star_list.tmpl @@ -1,12 +1,12 @@
-
+
- Lists(26) + Lists(26)
-
+
-
+
-
+
- - diff --git a/web_src/css/user.css b/web_src/css/user.css index 04a0cfa0ca851..e9f9826a53f89 100644 --- a/web_src/css/user.css +++ b/web_src/css/user.css @@ -101,21 +101,69 @@ object-fit: contain; } -.star-list .box { +.star-list .top { + height: 43.75px; + line-height: 43.75px; + display: flex; + justify-content: space-between; +} + +.star-list .top-right { + display: flex; + justify-content: space-between; +} + +#profile-lists-container .box { + margin-top: 10px; background-color: var(--color-body); border-color: #d1d9e0; border-radius: 0.375rem; border-style: solid; border-width: 0.0625rem; } -.test-1 { - height: 36px; -} -#profile-lists-container .box > a,a:link,a:visited,a:hover,a:active { +#profile-lists-container .box-row,.box-row:link,.box-row:visited,.box-row:hover,.box-row:active { display: block; + height: 42px; + line-height: 42px; text-decoration: none; - color: inherit; + display: flex; + justify-content: space-between; +} + +#profile-lists-container .box-row:hover { + background-color: #f6f8fa; +} + +#profile-lists-container .box-row { + border-bottom: 0.0625rem solid #d1d9e0; +} + +#profile-lists-container .box-row:first-of-type { + border-top-left-radius: 0.375rem; + border-top-right-radius: 0.375rem; +} + +#profile-lists-container .box-row:last-of-type { + border-bottom: none; + border-bottom-left-radius: 0.375rem; + border-bottom-right-radius: 0.375rem; +} + +#profile-lists-container h3 { + line-height: inherit; + margin: 0; + padding: 0; +} + +#profile-lists-container .name { + margin-left: 10px; + color: var(--color-text-dark); +} + +#profile-lists-container .repositories { + color: #5b6167; + margin-right: 10px; } #readme_profile { From 975867f29c334bbda90bbc31d0ad5af5a4c1677a Mon Sep 17 00:00:00 2001 From: hiifong Date: Sat, 22 Feb 2025 11:34:42 +0800 Subject: [PATCH 09/20] Update --- models/migrations/migrations.go | 2 +- models/migrations/v1_24/{v313.go => v314.go} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename models/migrations/v1_24/{v313.go => v314.go} (100%) diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index b8fb2d61c7e42..b7ec50e47590e 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -373,7 +373,7 @@ func prepareMigrationTasks() []*migration { // Gitea 1.23.0-rc0 ends at migration ID number 311 (database version 312) newMigration(312, "Add DeleteBranchAfterMerge to AutoMerge", v1_24.AddDeleteBranchAfterMergeForAutoMerge), - newMigration(313, "Add star_list, star_list_repo table", v1_24.AddStarList), + newMigration(314, "Add star_list, star_list_repo table", v1_24.AddStarList), } return preparedMigrations } diff --git a/models/migrations/v1_24/v313.go b/models/migrations/v1_24/v314.go similarity index 100% rename from models/migrations/v1_24/v313.go rename to models/migrations/v1_24/v314.go From ef245af10a48944ec3d7bf6f15991eb366a29914 Mon Sep 17 00:00:00 2001 From: hiifong Date: Mon, 24 Feb 2025 15:01:14 +0800 Subject: [PATCH 10/20] Update --- templates/user/star_list.tmpl | 35 ++++++++++++++ web_src/css/user.css | 90 +++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) diff --git a/templates/user/star_list.tmpl b/templates/user/star_list.tmpl index c998a55b2834f..747dd6ab59dbe 100644 --- a/templates/user/star_list.tmpl +++ b/templates/user/star_list.tmpl @@ -1,3 +1,4 @@ +{{if .IsStarList }}
@@ -62,3 +63,37 @@
+{{else if true }} +
+
+

Test

+
+
+ Edit list + +
+
+

Edit list

+ +
+
+ + + +
+
+ +
+
+ +
+
+ +
+
+
+
+
Test
+
1 repositories
+
+{{end}} \ No newline at end of file diff --git a/web_src/css/user.css b/web_src/css/user.css index e9f9826a53f89..46d29712382b6 100644 --- a/web_src/css/user.css +++ b/web_src/css/user.css @@ -166,6 +166,96 @@ margin-right: 10px; } +.star-list-repos .top { + height: 37.75px; + line-height: 37.75px; + display: flex; + justify-content: space-between; +} + +.star-list-repos h2 { + display: block; + margin: 0; + padding: 0; + height: inherit; + line-height: inherit; +} + +.star-list-repos .btn { + padding: 5px 16px; + color: #25292e; + background-color: #f6f8fa; + list-style: none; + box-shadow: 0px 1px 0px 0px #1f232880a; + border-radius: 6px; + font-size: 16px; + border: 1px solid #d1d9e0; + line-height: 20px; +} + +.star-list-repos details>summary { + transition: 80ms cubic-bezier(0.33, 1, 0.68, 1); + transition-property: color, background-color, box-shadow, border-color; +} + +.star-list-repos .box { + width: 448px; + border-color: #d1d9e0; + border-radius: 0.375rem; + border-style: solid; + border-width: 0.0625rem; +} + +.star-list-repos details-dialog { + position: fixed; + margin: 10vh auto; + top: 0; + left: 50%; + transform: translateX(-50%); + z-index: 999; + max-height: 80vh; + max-width: 90vw; + overflow: auto; + border-shadow: 3px 3px 3px 3px 5px black; +} + +.star-list-repos .box-header { + background-color: #f6f8fa; + height: 37.75px; +} + +.star-list-repos h1 { + margin-left: 10px; + font-size: 0.875rem; + font-weight: 600; + height: 37.75px; + line-height: 37.75px; +} + +.star-list-repos .box-title { + height: 37.75px; + line-height: 37.75px; + font-size: 0.875rem; + font-weight: 600; + display: flex; + justify-content: space-between; +} + +.star-list-repos .btn-group { + display: flex; + justify-content: space-between; +} + +.star-list-repos .description { + font-size: 16px; + margin-top: 8px; + margin-bottom: 16px; +} + +.star-list-repos .repositories { + color: #59536e; +} + #readme_profile { padding: 1em 2em; border-radius: var(--border-radius); From c78adb4aec7cd242796d5502283864c14fdcec5f Mon Sep 17 00:00:00 2001 From: hiifong Date: Mon, 24 Feb 2025 15:47:24 +0800 Subject: [PATCH 11/20] Update --- templates/user/star_list.tmpl | 28 +++++++++++++++++--- web_src/css/user.css | 50 ++++++++++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 4 deletions(-) diff --git a/templates/user/star_list.tmpl b/templates/user/star_list.tmpl index 747dd6ab59dbe..de323e7cecbef 100644 --- a/templates/user/star_list.tmpl +++ b/templates/user/star_list.tmpl @@ -1,4 +1,4 @@ -{{if .IsStarList }} +{{if false }}
@@ -28,14 +28,36 @@
- Create list +
+ Create list + +
+
+

Create list

+ +
+
+
+ + +
+
+ +
+
+ +
+
+
+
+
-
+

Vim

diff --git a/web_src/css/user.css b/web_src/css/user.css index 46d29712382b6..387c9a6833c28 100644 --- a/web_src/css/user.css +++ b/web_src/css/user.css @@ -113,7 +113,55 @@ justify-content: space-between; } -#profile-lists-container .box { +.star-list details>summary { + transition: 80ms cubic-bezier(0.33, 1, 0.68, 1); + transition-property: color, background-color, box-shadow, border-color; +} + +.star-list .box { + width: 448px; + border-color: #d1d9e0; + border-radius: 0.375rem; + border-style: solid; + border-width: 0.0625rem; +} + +.star-list details-dialog { + position: fixed; + margin: 10vh auto; + top: 0; + left: 50%; + transform: translateX(-50%); + z-index: 999; + max-height: 80vh; + max-width: 90vw; + overflow: auto; + border-shadow: 3px 3px 3px 3px 5px black; +} + +.star-list .box-header { + background-color: #f6f8fa; + height: 37.75px; +} + +.star-list h1 { + margin-left: 10px; + font-size: 0.875rem; + font-weight: 600; + height: 37.75px; + line-height: 37.75px; +} + +.star-list .box-title { + height: 37.75px; + line-height: 37.75px; + font-size: 0.875rem; + font-weight: 600; + display: flex; + justify-content: space-between; +} + +#profile-lists-container .list-box { margin-top: 10px; background-color: var(--color-body); border-color: #d1d9e0; From 7306b548ebc503e1ad60b9b28c51799faf7522b7 Mon Sep 17 00:00:00 2001 From: hiifong Date: Mon, 24 Feb 2025 23:24:43 +0800 Subject: [PATCH 12/20] Update --- templates/shared/create_star_list_dialog.tmpl | 22 ++++ templates/shared/edit_star_list_dialog.tmpl | 22 ++++ templates/{user => shared}/star_list.tmpl | 59 ++--------- templates/user/profile.tmpl | 2 +- web_src/css/user.css | 100 ------------------ 5 files changed, 53 insertions(+), 152 deletions(-) create mode 100644 templates/shared/create_star_list_dialog.tmpl create mode 100644 templates/shared/edit_star_list_dialog.tmpl rename templates/{user => shared}/star_list.tmpl (59%) diff --git a/templates/shared/create_star_list_dialog.tmpl b/templates/shared/create_star_list_dialog.tmpl new file mode 100644 index 0000000000000..a2dbf8405e4fc --- /dev/null +++ b/templates/shared/create_star_list_dialog.tmpl @@ -0,0 +1,22 @@ + diff --git a/templates/shared/edit_star_list_dialog.tmpl b/templates/shared/edit_star_list_dialog.tmpl new file mode 100644 index 0000000000000..5ad420099d8fa --- /dev/null +++ b/templates/shared/edit_star_list_dialog.tmpl @@ -0,0 +1,22 @@ + diff --git a/templates/user/star_list.tmpl b/templates/shared/star_list.tmpl similarity index 59% rename from templates/user/star_list.tmpl rename to templates/shared/star_list.tmpl index de323e7cecbef..1ef53a2bb9d86 100644 --- a/templates/user/star_list.tmpl +++ b/templates/shared/star_list.tmpl @@ -1,4 +1,4 @@ -{{if false }} +{{if true }}
@@ -28,29 +28,7 @@
-
- Create list - -
-
-

Create list

- -
-
-
- - -
-
- -
-
- -
-
-
-
-
+
@@ -85,37 +63,16 @@
-{{else if true }} +{{else if false }} -{{end}} \ No newline at end of file +{{end}} + +{{template "shared/create_star_list_dialog" .}} +{{template "shared/edit_star_list_dialog" .}} diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 83bd88891acee..a6036d3f6f297 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -17,7 +17,7 @@ {{template "user/dashboard/feeds" .}} {{else if eq .TabName "stars"}}
- {{template "user/star_list" .}} + {{template "shared/star_list" .}} {{template "shared/repo_search" .}} {{template "explore/repo_list" .}} {{template "base/paginate" .}} diff --git a/web_src/css/user.css b/web_src/css/user.css index 387c9a6833c28..f3855b2028354 100644 --- a/web_src/css/user.css +++ b/web_src/css/user.css @@ -113,54 +113,6 @@ justify-content: space-between; } -.star-list details>summary { - transition: 80ms cubic-bezier(0.33, 1, 0.68, 1); - transition-property: color, background-color, box-shadow, border-color; -} - -.star-list .box { - width: 448px; - border-color: #d1d9e0; - border-radius: 0.375rem; - border-style: solid; - border-width: 0.0625rem; -} - -.star-list details-dialog { - position: fixed; - margin: 10vh auto; - top: 0; - left: 50%; - transform: translateX(-50%); - z-index: 999; - max-height: 80vh; - max-width: 90vw; - overflow: auto; - border-shadow: 3px 3px 3px 3px 5px black; -} - -.star-list .box-header { - background-color: #f6f8fa; - height: 37.75px; -} - -.star-list h1 { - margin-left: 10px; - font-size: 0.875rem; - font-weight: 600; - height: 37.75px; - line-height: 37.75px; -} - -.star-list .box-title { - height: 37.75px; - line-height: 37.75px; - font-size: 0.875rem; - font-weight: 600; - display: flex; - justify-content: space-between; -} - #profile-lists-container .list-box { margin-top: 10px; background-color: var(--color-body); @@ -171,7 +123,6 @@ } #profile-lists-container .box-row,.box-row:link,.box-row:visited,.box-row:hover,.box-row:active { - display: block; height: 42px; line-height: 42px; text-decoration: none; @@ -221,52 +172,6 @@ justify-content: space-between; } -.star-list-repos h2 { - display: block; - margin: 0; - padding: 0; - height: inherit; - line-height: inherit; -} - -.star-list-repos .btn { - padding: 5px 16px; - color: #25292e; - background-color: #f6f8fa; - list-style: none; - box-shadow: 0px 1px 0px 0px #1f232880a; - border-radius: 6px; - font-size: 16px; - border: 1px solid #d1d9e0; - line-height: 20px; -} - -.star-list-repos details>summary { - transition: 80ms cubic-bezier(0.33, 1, 0.68, 1); - transition-property: color, background-color, box-shadow, border-color; -} - -.star-list-repos .box { - width: 448px; - border-color: #d1d9e0; - border-radius: 0.375rem; - border-style: solid; - border-width: 0.0625rem; -} - -.star-list-repos details-dialog { - position: fixed; - margin: 10vh auto; - top: 0; - left: 50%; - transform: translateX(-50%); - z-index: 999; - max-height: 80vh; - max-width: 90vw; - overflow: auto; - border-shadow: 3px 3px 3px 3px 5px black; -} - .star-list-repos .box-header { background-color: #f6f8fa; height: 37.75px; @@ -289,11 +194,6 @@ justify-content: space-between; } -.star-list-repos .btn-group { - display: flex; - justify-content: space-between; -} - .star-list-repos .description { font-size: 16px; margin-top: 8px; From da0b2e6ad57d4a663939c51063ae996a152b731d Mon Sep 17 00:00:00 2001 From: hiifong Date: Tue, 25 Feb 2025 22:52:15 +0800 Subject: [PATCH 13/20] Update --- models/migrations/v1_24/v314.go | 1 + models/repo/star_list_repo.go | 1 + routers/web/user/profile.go | 6 +++++ templates/shared/star_list.tmpl | 45 ++++++++++++++++----------------- 4 files changed, 30 insertions(+), 23 deletions(-) diff --git a/models/migrations/v1_24/v314.go b/models/migrations/v1_24/v314.go index 368fdad21a935..02223ab6ec35c 100644 --- a/models/migrations/v1_24/v314.go +++ b/models/migrations/v1_24/v314.go @@ -20,6 +20,7 @@ type StarList struct { } type StarListRepo struct { + ID int64 `xorm:"pk autoincr"` UID int64 `xorm:"UNIQUE(s)"` StarListID int64 `xorm:"UNIQUE(s)"` RepoID int64 `xorm:"UNIQUE(s)"` diff --git a/models/repo/star_list_repo.go b/models/repo/star_list_repo.go index e1861d870aaf1..9c28e863d01e0 100644 --- a/models/repo/star_list_repo.go +++ b/models/repo/star_list_repo.go @@ -7,6 +7,7 @@ import ( ) type StarListRepo struct { + ID int64 `xorm:"pk autoincr"` UID int64 `xorm:"UNIQUE(s)"` StarListID int64 `xorm:"UNIQUE(s)"` RepoID int64 `xorm:"UNIQUE(s)"` diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index 39f066a53c904..ecd9b8a139317 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -190,6 +190,12 @@ func prepareUserProfileTabData(ctx *context.Context, showPrivate bool, profileDb total = int(count) case "stars": ctx.Data["PageIsProfileStarList"] = true + starList, err := repo_model.GetStarListsForUser(ctx, ctx.ContextUser.ID) + if err != nil { + ctx.ServerError("SearchStarList", err) + return + } + ctx.Data["StarList"] = starList repos, count, err = repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{ ListOptions: db.ListOptions{ PageSize: pagingNum, diff --git a/templates/shared/star_list.tmpl b/templates/shared/star_list.tmpl index 1ef53a2bb9d86..1c88ba5dc1cc8 100644 --- a/templates/shared/star_list.tmpl +++ b/templates/shared/star_list.tmpl @@ -1,7 +1,7 @@ -{{if true }} +{{if .PageIsProfileStarList }}
-
+
Lists(26)
@@ -28,49 +28,48 @@
- +
-{{else if false }} +{{else }}

Test

Edit list
Test
-
1 repositories
+
+ {{svg "octicon-repo"}} 12 {{ctx.Locale.Tr "user.repositories"}} +
{{end}} From 0d6eba4e315cbe253ada2af6689b2f07000ee58d Mon Sep 17 00:00:00 2001 From: hiifong Date: Tue, 25 Feb 2025 23:23:12 +0800 Subject: [PATCH 14/20] Update --- routers/web/shared/starlists/star_lists.go | 22 +++++++++++++++++++++- routers/web/web.go | 10 +++++----- services/forms/star_list_form.go | 22 ++++++++++++++++++++++ 3 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 services/forms/star_list_form.go diff --git a/routers/web/shared/starlists/star_lists.go b/routers/web/shared/starlists/star_lists.go index d86057c5fae38..ea51bd0e62584 100644 --- a/routers/web/shared/starlists/star_lists.go +++ b/routers/web/shared/starlists/star_lists.go @@ -1,13 +1,33 @@ package starlists -import "code.gitea.io/gitea/services/context" +import ( + repo_model "code.gitea.io/gitea/models/repo" + "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/web" + "code.gitea.io/gitea/services/context" + "code.gitea.io/gitea/services/forms" +) func GetByName(ctx *context.Context) { } func Create(ctx *context.Context) { + form := web.GetForm(ctx).(*forms.StarListForm) + log.Info("form: %+v", *form) + + err := repo_model.InsertStarList(ctx, &repo_model.StarList{ + UID: ctx.Doer.ID, + Name: form.Name, + Desc: form.Desc, + }) + if err != nil { + ctx.ServerError("InsertStarList", err) + return + } + + ctx.Redirect(ctx.Doer.HomeLink() + "?tab=stars") } func UpdateByName(ctx *context.Context) { diff --git a/routers/web/web.go b/routers/web/web.go index 8599f21ad800e..0e15d8ac80ef1 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1613,11 +1613,11 @@ func registerRoutes(m *web.Router) { m.Post("/action/{action:accept_transfer|reject_transfer}", reqSignIn, repo.ActionTransfer) }, optSignIn, context.RepoAssignment) - m.Group("/stars/{username}/lists", func() { - m.Post("", starlists.Create) // 创建一个新的list - m.Get("/{listname}", starlists.GetByName) // 获取当前listname的所有repo - m.Post("/{listname}", starlists.UpdateByName) // 更新当前listname的所有repo - m.Delete("/{listname}", starlists.DeleteByName) // 删除当前listname + m.Group("/stars/lists", func() { + m.Post("", web.Bind(forms.StarListForm{}), starlists.Create) // 创建一个新的list + m.Get("/{listname}", starlists.GetByName) // 获取当前listname的所有repo + m.Post("/{listname}", starlists.UpdateByName) // 更新当前listname的所有repo + m.Delete("/{listname}", starlists.DeleteByName) // 删除当前listname }) m.Group("/{username}/{reponame}", func() { diff --git a/services/forms/star_list_form.go b/services/forms/star_list_form.go new file mode 100644 index 0000000000000..b341df78a2cb9 --- /dev/null +++ b/services/forms/star_list_form.go @@ -0,0 +1,22 @@ +package forms + +import ( + "net/http" + + "code.gitea.io/gitea/modules/web/middleware" + "code.gitea.io/gitea/services/context" + "gitea.com/go-chi/binding" +) + +type StarListForm struct { + Action string `binding:"Required"` + ID int64 `binding:"OmitEmpty"` + UID int64 `binding:"Required"` + Name string `binding:"Required;MaxSize(50)"` + Desc string `binding:"OmitEmpty"` +} + +func (s *StarListForm) Validate(req *http.Request, errs binding.Errors) binding.Errors { + ctx := context.GetValidateContext(req) + return middleware.Validate(errs, ctx.Data, s, ctx.Locale) +} From 67306f8363efb37d675da19fe40abd89e240e309 Mon Sep 17 00:00:00 2001 From: hiifong Date: Wed, 26 Feb 2025 00:21:07 +0800 Subject: [PATCH 15/20] Update --- templates/shared/delete_star_list_dialog.tmpl | 17 +++++++++++++++++ templates/shared/edit_star_list_dialog.tmpl | 2 +- templates/shared/star_list.tmpl | 3 ++- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 templates/shared/delete_star_list_dialog.tmpl diff --git a/templates/shared/delete_star_list_dialog.tmpl b/templates/shared/delete_star_list_dialog.tmpl new file mode 100644 index 0000000000000..c26e6e040655b --- /dev/null +++ b/templates/shared/delete_star_list_dialog.tmpl @@ -0,0 +1,17 @@ + diff --git a/templates/shared/edit_star_list_dialog.tmpl b/templates/shared/edit_star_list_dialog.tmpl index 5ad420099d8fa..c1508110aafca 100644 --- a/templates/shared/edit_star_list_dialog.tmpl +++ b/templates/shared/edit_star_list_dialog.tmpl @@ -14,7 +14,7 @@
- +
diff --git a/templates/shared/star_list.tmpl b/templates/shared/star_list.tmpl index 1c88ba5dc1cc8..b4e85aa080c82 100644 --- a/templates/shared/star_list.tmpl +++ b/templates/shared/star_list.tmpl @@ -47,7 +47,7 @@ {{end}}
{{else}} -
+
{{svg "octicon-star"}}
Create your first list
@@ -75,3 +75,4 @@ {{template "shared/create_star_list_dialog" .}} {{template "shared/edit_star_list_dialog" .}} +{{template "shared/delete_star_list_dialog" .}} From ac96f3faf8304ad4dfe2171a524907286c52d04b Mon Sep 17 00:00:00 2001 From: hiifong Date: Thu, 27 Feb 2025 00:06:00 +0800 Subject: [PATCH 16/20] Update --- templates/repo/home_sidebar_top.tmpl | 9 ++ templates/repo/star_unstar.tmpl | 7 +- templates/shared/create_star_list_dialog.tmpl | 22 ----- templates/shared/delete_star_list_dialog.tmpl | 17 ---- templates/shared/edit_star_list_dialog.tmpl | 22 ----- templates/shared/star_list.tmpl | 4 +- templates/shared/star_list_dialog.tmpl | 85 +++++++++++++++++++ 7 files changed, 100 insertions(+), 66 deletions(-) delete mode 100644 templates/shared/create_star_list_dialog.tmpl delete mode 100644 templates/shared/delete_star_list_dialog.tmpl delete mode 100644 templates/shared/edit_star_list_dialog.tmpl create mode 100644 templates/shared/star_list_dialog.tmpl diff --git a/templates/repo/home_sidebar_top.tmpl b/templates/repo/home_sidebar_top.tmpl index 8d3d7c6f86974..18e3d8289566e 100644 --- a/templates/repo/home_sidebar_top.tmpl +++ b/templates/repo/home_sidebar_top.tmpl @@ -67,6 +67,15 @@ {{$fileSizeFields := StringUtils.Split $fileSizeFormatted " "}} {{svg "octicon-database"}} {{ctx.Locale.PrettyNumber (index $fileSizeFields 0)}} {{index $fileSizeFields 1}} + + {{svg "octicon-star"}} {{CountFmt .Repository.NumStars}} {{ctx.Locale.Tr "repo.stars"}} + + + {{svg "octicon-eye"}} {{CountFmt .Repository.NumWatches}} {{ctx.Locale.Tr "repo.watchers"}} + + + {{svg "octicon-repo-forked"}} {{CountFmt .Repository.NumForks}} {{ctx.Locale.Tr "repo.forks"}} +
diff --git a/templates/repo/star_unstar.tmpl b/templates/repo/star_unstar.tmpl index 9234a0d19616c..617dab8c4059a 100644 --- a/templates/repo/star_unstar.tmpl +++ b/templates/repo/star_unstar.tmpl @@ -5,9 +5,12 @@ - - {{CountFmt .Repository.NumStars}} + + {{svg "octicon-triangle-down"}}
+ +{{template "shared/star_list_dialog" .}} diff --git a/templates/shared/create_star_list_dialog.tmpl b/templates/shared/create_star_list_dialog.tmpl deleted file mode 100644 index a2dbf8405e4fc..0000000000000 --- a/templates/shared/create_star_list_dialog.tmpl +++ /dev/null @@ -1,22 +0,0 @@ - diff --git a/templates/shared/delete_star_list_dialog.tmpl b/templates/shared/delete_star_list_dialog.tmpl deleted file mode 100644 index c26e6e040655b..0000000000000 --- a/templates/shared/delete_star_list_dialog.tmpl +++ /dev/null @@ -1,17 +0,0 @@ - diff --git a/templates/shared/edit_star_list_dialog.tmpl b/templates/shared/edit_star_list_dialog.tmpl deleted file mode 100644 index c1508110aafca..0000000000000 --- a/templates/shared/edit_star_list_dialog.tmpl +++ /dev/null @@ -1,22 +0,0 @@ - diff --git a/templates/shared/star_list.tmpl b/templates/shared/star_list.tmpl index b4e85aa080c82..10ccc0d74af31 100644 --- a/templates/shared/star_list.tmpl +++ b/templates/shared/star_list.tmpl @@ -73,6 +73,4 @@
{{end}} -{{template "shared/create_star_list_dialog" .}} -{{template "shared/edit_star_list_dialog" .}} -{{template "shared/delete_star_list_dialog" .}} +{{template "shared/star_list_dialog" .}} diff --git a/templates/shared/star_list_dialog.tmpl b/templates/shared/star_list_dialog.tmpl new file mode 100644 index 0000000000000..d2459c14dbda3 --- /dev/null +++ b/templates/shared/star_list_dialog.tmpl @@ -0,0 +1,85 @@ + + + + + + + From 02a2ea5c7d269366b586f1f1a13cd3570d4ca88f Mon Sep 17 00:00:00 2001 From: hiifong Date: Thu, 27 Feb 2025 00:12:45 +0800 Subject: [PATCH 17/20] Update --- templates/repo/header.tmpl | 3 ++- templates/repo/watch_unwatch.tmpl | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 8c2a0da8d0362..3a4d2531c3b28 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -90,9 +90,10 @@ {{end}} > {{svg "octicon-repo-forked"}}{{ctx.Locale.Tr "repo.fork"}} + {{CountFmt .NumForks}} - {{CountFmt .NumForks}} + {{svg "octicon-triangle-down"}}
From 884a4705cae8c04cdd4a93f7f030344774cdc6b3 Mon Sep 17 00:00:00 2001 From: hiifong Date: Thu, 27 Feb 2025 19:48:41 +0800 Subject: [PATCH 18/20] Update --- templates/repo/star_unstar.tmpl | 6 ++++++ templates/shared/star_list.tmpl | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/templates/repo/star_unstar.tmpl b/templates/repo/star_unstar.tmpl index 617dab8c4059a..4c28788eb627f 100644 --- a/templates/repo/star_unstar.tmpl +++ b/templates/repo/star_unstar.tmpl @@ -7,9 +7,15 @@ {{CountFmt .Repository.NumStars}} + {{if .SignedUserID .ContextUser.ID}} {{svg "octicon-triangle-down"}} + {{else}} + + {{svg "octicon-triangle-down"}} + + {{end}}
diff --git a/templates/shared/star_list.tmpl b/templates/shared/star_list.tmpl index 10ccc0d74af31..10f4ea3e9e9c7 100644 --- a/templates/shared/star_list.tmpl +++ b/templates/shared/star_list.tmpl @@ -3,7 +3,7 @@
- Lists(26) + Lists({{len .StarList}})
@@ -27,9 +27,11 @@
+ {{if eq .SignedUserID .ContextUser.ID}}
+ {{end}}
@@ -46,7 +48,7 @@ {{end}}
- {{else}} + {{else if eq .SignedUserID .ContextUser.ID}}
{{svg "octicon-star"}}
@@ -60,11 +62,13 @@ {{end}}
-{{else }} +{{else}}

Test

+ {{if .SignedUserID .ContextUser.ID}} Edit list + {{end}}
Test
From ba8fad936cc65a8bd41700cb1213e6795d359b3a Mon Sep 17 00:00:00 2001 From: hiifong Date: Mon, 7 Apr 2025 14:54:58 +0800 Subject: [PATCH 19/20] rename --- models/migrations/v1_24/{v314.go => v319.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename models/migrations/v1_24/{v314.go => v319.go} (100%) diff --git a/models/migrations/v1_24/v314.go b/models/migrations/v1_24/v319.go similarity index 100% rename from models/migrations/v1_24/v314.go rename to models/migrations/v1_24/v319.go From 5b0ca5f6b1b1d38e92f016dd05242549776520af Mon Sep 17 00:00:00 2001 From: hiifong Date: Mon, 7 Apr 2025 16:47:06 +0800 Subject: [PATCH 20/20] Update --- routers/web/repo/view_home.go | 8 ++++++++ templates/repo/star_unstar.tmpl | 2 +- templates/shared/star_list.tmpl | 2 +- templates/shared/star_list_dialog.tmpl | 18 +++++++++--------- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/routers/web/repo/view_home.go b/routers/web/repo/view_home.go index 3b053821ee751..70b79b7b91a2e 100644 --- a/routers/web/repo/view_home.go +++ b/routers/web/repo/view_home.go @@ -434,6 +434,14 @@ func Home(ctx *context.Context) { ctx.Data["ParentPath"] = "/" + paths[len(paths)-2] } } + + starList, err := repo_model.GetStarListsForUser(ctx, ctx.Doer.ID) + if err != nil { + ctx.ServerError("SearchStarList", err) + return + } + log.Error("=============================") + ctx.Data["StarList"] = starList ctx.Data["Paths"] = paths ctx.Data["TreeLink"] = treeLink ctx.Data["TreeNames"] = treeNames diff --git a/templates/repo/star_unstar.tmpl b/templates/repo/star_unstar.tmpl index 4c28788eb627f..384fc41b01fbf 100644 --- a/templates/repo/star_unstar.tmpl +++ b/templates/repo/star_unstar.tmpl @@ -7,7 +7,7 @@ {{CountFmt .Repository.NumStars}} - {{if .SignedUserID .ContextUser.ID}} + {{if and .IsSigned (gt .ContextUser.ID 0)}} {{svg "octicon-triangle-down"}} diff --git a/templates/shared/star_list.tmpl b/templates/shared/star_list.tmpl index 10f4ea3e9e9c7..5c83e307b047f 100644 --- a/templates/shared/star_list.tmpl +++ b/templates/shared/star_list.tmpl @@ -40,7 +40,7 @@ {{if gt (len .StarList) 0}}