diff --git a/modules/structs/repo.go b/modules/structs/repo.go index 70de9b7469..07be4aec24 100644 --- a/modules/structs/repo.go +++ b/modules/structs/repo.go @@ -5,6 +5,7 @@ package structs import ( + "html/template" "time" ) @@ -75,6 +76,7 @@ type Repository struct { Created time.Time `json:"created_at"` // swagger:strfmt date-time Updated time.Time `json:"updated_at"` + TimeSinceUnixUpdatedHtml template.HTML `json:"timeSinceUnixUpdatedHtml"` Permissions *Permission `json:"permissions,omitempty"` HasIssues bool `json:"has_issues"` InternalTracker *InternalTracker `json:"internal_tracker,omitempty"` @@ -88,6 +90,8 @@ type Repository struct { AllowRebaseMerge bool `json:"allow_rebase_explicit"` AllowSquash bool `json:"allow_squash_merge"` AvatarURL string `json:"avatar_url"` + PrimaryLanguage string `json:"primaryLanguage"` + PrimaryLanguageColor string `json:"primaryLanguageColor"` } // CreateRepoOption options when creating repository diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index a724ebcc37..0258676ad5 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -6,20 +6,20 @@ package repo import ( - "fmt" - "net/http" - "strings" - "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" + "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/validation" "code.gitea.io/gitea/routers/api/v1/utils" repo_service "code.gitea.io/gitea/services/repository" + "fmt" + "net/http" + "strings" ) var searchOrderByMap = map[string]map[string]models.SearchOrderBy{ @@ -199,6 +199,7 @@ func Search(ctx *context.APIContext) { } results := make([]*api.Repository, len(repos)) + for i, repo := range repos { if err = repo.GetOwner(); err != nil { ctx.JSON(http.StatusInternalServerError, api.SearchError{ @@ -215,6 +216,11 @@ func Search(ctx *context.APIContext) { }) } results[i] = repo.APIFormat(accessMode) + results[i].TimeSinceUnixUpdatedHtml = timeutil.TimeSinceUnix(repo.UpdatedUnix,ctx.Language()) + if repo.PrimaryLanguage != nil { + results[i].PrimaryLanguage = repo.PrimaryLanguage.Language + results[i].PrimaryLanguageColor = repo.PrimaryLanguage.Color + } } ctx.SetLinkHeader(int(count), opts.PageSize) diff --git a/templates/user/dashboard/repo_list_dashboard.tmpl b/templates/user/dashboard/repo_list_dashboard.tmpl index 89be6fc746..a4fa2e5905 100755 --- a/templates/user/dashboard/repo_list_dashboard.tmpl +++ b/templates/user/dashboard/repo_list_dashboard.tmpl @@ -4,7 +4,7 @@
+
+ {{$.i18n.Tr "explore.repo_no_results"}} +
diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 4b1619f0c8..12c35fd7c3 100755 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -141,8 +141,7 @@ {{template "explore/dataset_list" .}} {{template "base/paginate" .}} {{else}} - {{template "user/dashboard/repo_list_dashboard" .}} - {{template "base/paginate" .}} + {{template "user/dashboard/repo_list_dashboard" .}} {{end}} diff --git a/web_src/js/index.js b/web_src/js/index.js index ddb69f701e..e1078db4e5 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -3324,7 +3324,16 @@ function initVueComponents() { self.$refs.search.focus(); }); }, - + updated: function () { + $('.time-since').each(function () { + $(this) + .addClass('poping up') + .attr('data-content', $(this).attr('title')) + .attr('data-variation', 'inverted tiny') + .attr('title', ''); + }); + $('.poping.up').popup(); + }, methods: { changeTab(t) { this.tab = t;