diff options
author | Sergey Dryabzhinsky <sergey.dryabzhinsky@gmail.com> | 2018-06-17 15:21:52 +0300 |
---|---|---|
committer | 无闻 <u@gogs.io> | 2018-06-17 20:21:52 +0800 |
commit | 303fa37b608a4925f5a0137c89e20a906b3d9fdb (patch) | |
tree | 1642a7370034bc92173a2567d72ddc61e3e63a49 /templates | |
parent | ef02414d7e1d8cc33ece4dc3d6084ba2cd5014cc (diff) |
repo: support avatars (#5221)
* First code for repository avatars
* Last code for repository avatars
- add new option for repo avatars location on filesystem
- add route catch in web
- add new fields to repo model
- add migration
- update settings handlers
- update repo header template
* Update locale messages
* Add repo avatars to home page
* Add repo avatars to organization right panel
* Show repo avatars in repo list
* Remove AvatarEamil field, remove Gravatar support, use generic locale messages
* Fix migration
* Fix seed and not used tool
* Revert public css changes, add them to less files
* Latest lessc (2.6.0) don't put result into file but output to stdout
So redirect output to file
* Simplify things:
- migration don't needed, and table changes too
- just upload file to repo avatar storage
- or generate random image
* Fix repo image seed - name not unique
* Get rid of not needed model fields
* Class value is enough, remove height attribute
* Don't generate random avatar for repository
- use html and semantic ui icons if no avatar found
* Update styles and templates for repo
- use repo icon as default avatar
- use globe icon for public repos
- add micro style for repo avatars at dashboard
* Remvoe redundant empty line
* Fix nl2br filter - must return string
* Fix css style for micro-repo-avatar in dashboard list
* Remove `|len`, works fine w/o it.
* Update after review 2:
- use static route for repository avatar
- format images settings block in settings
* Update after review 2:
- no random avatar for repo
* Update after review 2:
- no random avatar for repo 2
- update imports
- update UploadAvatar* functions
* Update after review 2:
- update templates
* Fix trace call
* Remove unused immport since we use static route for repo avatars.
Diffstat (limited to 'templates')
-rw-r--r-- | templates/explore/repo_list.tmpl | 11 | ||||
-rw-r--r-- | templates/org/team/repositories.tmpl | 1 | ||||
-rw-r--r-- | templates/repo/header.tmpl | 3 | ||||
-rw-r--r-- | templates/repo/settings/options.tmpl | 15 | ||||
-rw-r--r-- | templates/user/dashboard/dashboard.tmpl | 8 |
5 files changed, 34 insertions, 4 deletions
diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index 43abad41..413cdc53 100644 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -1,7 +1,12 @@ <div class="ui repository list"> {{range .Repos}} <div class="item"> - <div class="ui header"> + <div class="ui grid"> + <div class="ui two wide column middle aligned"> + {{if .RelAvatarLink}}<img class="ui tiny image" src="{{.RelAvatarLink}}">{{else}}<i class="mega-octicon octicon-repo"></i>{{end}} + </div> + <div class="ui fourteen wide column"> + <div class="ui header"> <a class="name" href="{{AppSubURL}}/{{if .Owner}}{{.Owner.Name}}{{else if $.Org}}{{$.Org.Name}}{{else}}{{$.Owner.Name}}{{end}}/{{.Name}}">{{if $.PageIsExplore}}{{.Owner.Name}} / {{end}}{{.Name}}</a> {{if .IsPrivate}} <span class="text gold"><i class="octicon octicon-lock"></i></span> @@ -9,6 +14,8 @@ <span><i class="octicon octicon-repo-forked"></i></span> {{else if .IsMirror}} <span><i class="octicon octicon-repo-clone"></i></span> + {{else}} + <span class="text"><i class="octicon octicon-globe"></i></span> {{end}} <div class="ui right metas"> @@ -18,6 +25,8 @@ </div> {{if .Description}}<p class="has-emoji">{{.Description | Str2html}}</p>{{end}} <p class="time">{{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Updated $.i18n.Lang}}</p> + </div> + </div> </div> {{end}} </div> diff --git a/templates/org/team/repositories.tmpl b/templates/org/team/repositories.tmpl index 4f1ad313..e2cfbe95 100644 --- a/templates/org/team/repositories.tmpl +++ b/templates/org/team/repositories.tmpl @@ -17,6 +17,7 @@ <a class="ui red small button right" href="{{$.OrgLink}}/teams/{{$.Team.LowerName}}/action/repo/remove?repoid={{.ID}}">{{$.i18n.Tr "org.teams.remove_repo"}}</a> {{end}} <a class="member" href="{{AppSubURL}}/{{$.Org.Name}}/{{.Name}}"> + <img height="16px" class="octicon" src="{{.RelAvatarLink}}" /> <i class="octicon octicon-{{if .IsPrivate}}lock{{else if .IsFork}}repo-forked{{else if .IsMirror}}repo-clone{{else}}repo{{end}}"></i> <strong>{{$.Org.Name}}/{{.Name}}</strong> </a> diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 77685c5e..1bef1903 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -5,7 +5,8 @@ <div class="column"><!-- start column --> <div class="ui header"> <div class="ui huge breadcrumb"> - <i class="mega-octicon octicon-{{if .IsPrivate}}lock{{else if .IsMirror}}repo-clone{{else if .IsFork}}repo-forked{{else}}repo{{end}}"></i> + {{if .RelAvatarLink}}<img class="ui mini spaced image" src="{{.RelAvatarLink}}">{{else}}<i class="mega-octicon octicon-repo"></i>{{end}} + <i class="mega-octicon octicon-{{if .IsPrivate}}lock{{else if .IsMirror}}repo-clone{{else if .IsFork}}repo-forked{{else}}globe{{end}}"></i> <a href="{{AppSubURL}}/{{.Owner.Name}}">{{.Owner.Name}}</a> <div class="divider"> / </div> <a href="{{$.RepoLink}}">{{.Name}}</a> diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index 83966254..8aa4a1f7 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -41,6 +41,21 @@ <div class="field"> <button class="ui green button">{{$.i18n.Tr "repo.settings.update_settings"}}</button> </div> + + </form> + + <div class="ui divider"></div> + + <form class="ui form" action="{{.Link}}/avatar" method="post" enctype="multipart/form-data"> + {{.CSRFTokenHTML}} + <div class="inline field"> + <label for="avatar">{{.i18n.Tr "settings.choose_new_avatar"}}</label> + <input name="avatar" type="file" > + </div> + <div class="field"> + <button class="ui green button">{{$.i18n.Tr "settings.update_avatar"}}</button> + <a class="ui red button delete-post" data-request-url="{{.Link}}/avatar/delete" data-done-url="{{.Link}}">{{$.i18n.Tr "settings.delete_current_avatar"}}</a> + </div> </form> </div> diff --git a/templates/user/dashboard/dashboard.tmpl b/templates/user/dashboard/dashboard.tmpl index 4a0c90a2..f9f97447 100644 --- a/templates/user/dashboard/dashboard.tmpl +++ b/templates/user/dashboard/dashboard.tmpl @@ -32,7 +32,8 @@ {{range .Repos}} <li {{if .IsPrivate}}class="private"{{end}}> <a href="{{AppSubURL}}/{{$.ContextUser.Name}}/{{.Name}}"> - <i class="octicon octicon-{{if .IsFork}}repo-forked{{else if .IsPrivate}}lock{{else if .IsMirror}}repo-clone{{else}}repo{{end}}"></i> + {{if .RelAvatarLink}}<img class="ui micro image" src="{{.RelAvatarLink}}" />{{else}}<i class="octicon octicon-repo"></i>{{end}} + <i class="octicon octicon-{{if .IsFork}}repo-forked{{else if .IsPrivate}}lock{{else if .IsMirror}}repo-clone{{else}}globe{{end}}"></i> <strong class="text truncate item-name">{{.Name}}</strong> <span class="ui right text light grey"> {{.NumStars}} <i class="octicon octicon-star rear"></i> @@ -57,7 +58,8 @@ {{range .CollaborativeRepos}} <li {{if .IsPrivate}}class="private"{{end}}> <a href="{{AppSubURL}}/{{.Owner.Name}}/{{.Name}}"> - <i class="octicon octicon-{{if .IsPrivate}}lock{{else if .IsFork}}repo-forked{{else if .IsMirror}}repo-clone{{else}}repo{{end}}"></i> + {{if .RelAvatarLink}}<img class="ui micro image" src="{{.RelAvatarLink}}" />{{else}}<i class="octicon octicon-repo"></i>{{end}} + <i class="octicon octicon-{{if .IsPrivate}}lock{{else if .IsFork}}repo-forked{{else if .IsMirror}}repo-clone{{else}}globe{{end}}"></i> <span class="text truncate owner-and-repo"> <span class="text truncate owner-name">{{.Owner.Name}}</span> / <strong>{{.Name}}</strong> </span> @@ -88,6 +90,7 @@ {{range .ContextUser.Orgs}} <li> <a href="{{AppSubURL}}/{{.Name}}"> + {{if .RelAvatarLink}}<img class="ui micro image" src="{{.RelAvatarLink}}" />{{else}}<i class="octicon octicon-repo"></i>{{end}} <i class="octicon octicon-organization"></i> <strong class="text truncate item-name">{{.Name}}</strong> <span class="ui right text light grey"> @@ -116,6 +119,7 @@ {{range .Mirrors}} <li {{if .IsPrivate}}class="private"{{end}}> <a href="{{AppSubURL}}/{{$.ContextUser.Name}}/{{.Name}}"> + {{if .RelAvatarLink}}<img class="ui micro image" src="{{.RelAvatarLink}}" />{{else}}<i class="octicon octicon-repo"></i>{{end}} <i class="octicon octicon-repo-clone"></i> <strong class="text truncate item-name">{{.Name}}</strong> <span class="ui right text light grey"> |