#97 optimization-repo-list

Merged
lewis merged 4 commits from optimization-repo-list into develop 2 years ago
  1. +4
    -0
      modules/structs/repo.go
  2. +10
    -4
      routers/api/v1/repo/repo.go
  3. +30
    -31
      templates/user/dashboard/repo_list_dashboard.tmpl
  4. +1
    -2
      templates/user/profile.tmpl
  5. +10
    -1
      web_src/js/index.js

+ 4
- 0
modules/structs/repo.go View File

@@ -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


+ 10
- 4
routers/api/v1/repo/repo.go View File

@@ -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)


+ 30
- 31
templates/user/dashboard/repo_list_dashboard.tmpl View File

@@ -4,7 +4,7 @@
<div class="ui clearing divider"></div>
<div id="app" class="six wide column">
<repo-search
:search-limit="searchLimit"
:search-limit=100
:suburl="suburl"
:uid="uid"
:more-repos-link="'{{.ContextUser.HomeLink}}'"
@@ -90,39 +90,38 @@
</div>
<div class="ui attached table segment">
<ul class="repo-owner-name-list">
<li v-for="repo in repos" :class="{'private': repo.private}" v-show="showRepo(repo)">
<a :href="suburl + '/' + repo.full_name">
<svg :class="'svg ' + repoClass(repo)" width="16" height="16" aria-hidden="true"><use :xlink:href="'#' + repoClass(repo)" /></svg>
<strong class="text truncate item-name">${repo.full_name}</strong>
<i v-if="repo.archived" class="archive icon archived-icon"></i>
<span class="ui right text light grey">
${repo.stars_count} <span class="rear">{{svg "octicon-star" 16}}</span>
</span>
</a>
</li>
<li v-if="showMoreReposLink">
<div class="center">
<div class="ui borderless pagination menu narrow">
<a class="item navigation" :class="{'disabled': page === 1}"
@click="changePage(1)" title="{{$.i18n.Tr "admin.first_page"}}">
<i class="angle double left icon"></i>
</a>
<a class="item navigation" :class="{'disabled': page === 1}"
@click="changePage(page - 1)" title="{{$.i18n.Tr "repo.issues.previous"}}">
<i class="left arrow icon"></i>
</a>
<a class="active item">${page}</a>
<a class="item navigation" :class="{'disabled': page === finalPage}"
@click="changePage(page + 1)" title="{{$.i18n.Tr "repo.issues.next"}}">
<i class="icon right arrow"></i>
</a>
<a class="item navigation" :class="{'disabled': page === finalPage}"
@click="changePage(finalPage)" title="{{$.i18n.Tr "admin.last_page"}}">
<i class="angle double right icon"></i>
<div class="ui repository list" v-for="repo in repos">
<div class="item">
<div class="ui header">
{{if .RelAvatarLink}}
<img class="ui avatar image" src="{{.RelAvatarLink}}">
{{end}}
<a class="name" :href="repo.html_url">
${repo.full_name}
<i v-if="repo.archived" class="archive icon archived-icon"></i>
</a>
<span v-if="repo.private" class="middle text gold">{{svg "octicon-lock" 16}}</span>
<span v-if="repo.fork" class="middle">{{svg "octicon-repo-forked" 16}}</span>
<span v-if="repo.mirror" class="middle">{{svg "octicon-repo-clone" 16}}</span>
<div class="ui right metas">
<span v-if="repo.primaryLanguage" class="text grey">
<i class="color-icon" v-bind:style="{backgroundColor: repo.primaryLanguageColor}"></i>
${repo.primaryLanguage}
</span>
<span class="text grey">{{svg "octicon-star" 16}} ${repo.stars_count}</span>
<span class="text grey">{{svg "octicon-git-branch" 16}} ${repo.forks_count}</span>
</div>
</div>
<div class="description">
<p v-if="repo.description" class="has-emoji">${repo.description}</p>
<p class="time" >{{$.i18n.Tr "org.repo_updated"}}<span v-html="repo.timeSinceUnixUpdatedHtml"></span>
</p>
</div>
</div>
</li>
</div>
<div v-if="repos.length==0">
{{$.i18n.Tr "explore.repo_no_results"}}
</div>
</ul>
</div>
</div>


+ 1
- 2
templates/user/profile.tmpl View File

@@ -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}}
</div>
</div>


+ 10
- 1
web_src/js/index.js View File

@@ -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;


Loading…
Cancel
Save