1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-21 12:44:49 -05:00

Web editor: disallow edit mirror repository

This commit is contained in:
Unknwon 2016-08-28 04:56:41 -07:00
parent ba27d71abe
commit 579e5e4fee
7 changed files with 36 additions and 25 deletions

View file

@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true) ![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
##### Current tip version: 0.9.91 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions) ##### Current tip version: 0.9.92 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
| Web | UI | Preview | | Web | UI | Preview |
|:-------------:|:-------:|:-------:| |:-------------:|:-------:|:-------:|

View file

@ -511,7 +511,7 @@ func runWeb(ctx *cli.Context) error {
// m.Post("/upload-file", repo.UploadFileToServer) // m.Post("/upload-file", repo.UploadFileToServer)
// m.Post("/upload-remove", bindIgnErr(auth.RemoveUploadFileForm{}), repo.RemoveUploadFileFromServer) // m.Post("/upload-remove", bindIgnErr(auth.RemoveUploadFileForm{}), repo.RemoveUploadFileFromServer)
}, reqRepoWriter, context.RepoRef(), func(ctx *context.Context) { }, reqRepoWriter, context.RepoRef(), func(ctx *context.Context) {
if ctx.Repo.IsViewCommit { if !ctx.Repo.Repository.CanEnableEditor() || ctx.Repo.IsViewCommit {
ctx.Handle(404, "", nil) ctx.Handle(404, "", nil)
return return
} }

View file

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.9.91.0828" const APP_VER = "0.9.92.0828"
func init() { func init() {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())

View file

@ -444,6 +444,11 @@ func (repo *Repository) AllowsPulls() bool {
return repo.CanEnablePulls() && repo.EnablePulls return repo.CanEnablePulls() && repo.EnablePulls
} }
// CanEnableEditor returns true if repository meets the requirements of web editor.
func (repo *Repository) CanEnableEditor() bool {
return !repo.IsMirror
}
// FIXME: should have a mutex to prevent producing same index for two issues that are created // FIXME: should have a mutex to prevent producing same index for two issues that are created
// closely enough. // closely enough.
func (repo *Repository) NextIssueIndex() int64 { func (repo *Repository) NextIssueIndex() int64 {

View file

@ -1 +1 @@
0.9.91.0828 0.9.92.0828

View file

@ -33,18 +33,22 @@
</div> </div>
</div> </div>
<div class="right fitted item"> <div class="right fitted item">
<div id="file-buttons" class="ui tiny buttons"> {{if .Repository.CanEnableEditor}}
{{if .CanAddFile}} <div id="file-buttons" class="ui tiny buttons">
<a href="{{.RepoLink}}/_new/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}" class="ui button"> {{if .CanAddFile}}
{{.i18n.Tr "repo.editor.new_file"}} <a href="{{.RepoLink}}/_new/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}" class="ui button">
</a> {{.i18n.Tr "repo.editor.new_file"}}
{{end}} </a>
{{if .UploadFileLink}} {{end}}
<!-- <a href="{{EscapePound .UploadFileLink}}" class="ui button nowrap"> {{if .UploadFileLink}}
<i class="upload icon"></i> {{.i18n.Tr "repo.upload_file"}} <!-- <a href="{{EscapePound .UploadFileLink}}" class="ui button nowrap">
</a> --> <i class="upload icon"></i> {{.i18n.Tr "repo.upload_file"}}
{{end}} </a> -->
</div> {{end}}
</div>
{{end}}
<!-- Only show colne panel in repository home page -->
{{if eq $n 0}} {{if eq $n 0}}
<div class="ui action small input" id="clone-panel"> <div class="ui action small input" id="clone-panel">
<button class="ui basic clone button" id="repo-clone-https" data-link="{{.CloneLink.HTTPS}}"> <button class="ui basic clone button" id="repo-clone-https" data-link="{{.CloneLink.HTTPS}}">

View file

@ -20,15 +20,17 @@
<a class="ui button" href="{{.RepoLink}}/commits/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.file_history"}}</a> <a class="ui button" href="{{.RepoLink}}/commits/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.file_history"}}</a>
<a class="ui button" href="{{EscapePound .FileLink}}">{{.i18n.Tr "repo.file_raw"}}</a> <a class="ui button" href="{{EscapePound .FileLink}}">{{.i18n.Tr "repo.file_raw"}}</a>
</div> </div>
{{if .CanEditFile}} {{if .Repository.CanEnableEditor}}
<a href="{{.RepoLink}}/_edit/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}"><i class="octicon octicon-pencil btn-octicon poping up" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i></a> {{if .CanEditFile}}
{{else}} <a href="{{.RepoLink}}/_edit/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}"><i class="octicon octicon-pencil btn-octicon poping up" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i></a>
<i class="octicon octicon-pencil btn-octicon poping up disabled" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i> {{else}}
{{end}} <i class="octicon octicon-pencil btn-octicon poping up disabled" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i>
{{if .CanDeleteFile}} {{end}}
<a href="{{.RepoLink}}/_delete/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}"><i class="octicon octicon-trashcan btn-octicon btn-octicon-danger poping up" data-content="{{.DeleteFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i></a> {{if .CanDeleteFile}}
{{else}} <a href="{{.RepoLink}}/_delete/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}"><i class="octicon octicon-trashcan btn-octicon btn-octicon-danger poping up" data-content="{{.DeleteFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i></a>
<i class="octicon octicon-trashcan btn-octicon poping up disabled" data-content="{{.DeleteFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i> {{else}}
<i class="octicon octicon-trashcan btn-octicon poping up disabled" data-content="{{.DeleteFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i>
{{end}}
{{end}} {{end}}
</div> </div>
{{end}} {{end}}