Code clean up for new config options

This commit is contained in:
Unknwon committed 2016-08-14 23:52:24 -07:00
1 parent d0a0239bac
commit 15845cb287
17 files changed
+87 -110

No files matched your search

+1 -1
View File
@@ -510,7 +510,7 @@ func runWeb(ctx *cli.Context) error {
m.Post("/branches", bindIgnErr(auth.NewBranchForm{}), repo.NewBranchPost)
m.Post("/upload-file", repo.UploadFileToServer)
m.Post("/upload-remove", bindIgnErr(auth.RemoveUploadFileForm{}), repo.RemoveUploadFileFromServer)
}, context.RepoRef(), context.RepoAssignment(), reqRepoWriter)
}, reqRepoWriter, context.RepoRef())
}, reqSignIn, context.RepoAssignment(), repo.MustBeNotBare)
m.Group("/:username/:reponame", func() {
+5 -5
View File
@@ -20,17 +20,17 @@ MAX_CREATION_LIMIT = -1
; Patch test queue length, make it as large as possible
PULL_REQUEST_QUEUE_LENGTH = 10000
[editor]
[repository.editor]
; List of file extensions that should have line wraps in the CodeMirror editor
; Separate extensions with a comma. To line wrap files w/o extension, just put a comma
LINE_WRAP_EXTENSIONS = .txt,.md,.markdown,.mdown,.mkd,
; Valid file modes that have a preview API associated with them, such as api/v1/markdown
; Separate values by commas. Preview tab in edit mode won't show if the file extension doesn't match
PREVIEW_TAB_APIS = markdown
PREVIEWABLE_FILE_MODES = markdown
[upload]
[repository.upload]
; Whether repository file uploads are enabled. Defaults to `true`
ENABLE_UPLOADS = true
ENABLED = true
; Path for uploads. Defaults to `data/tmp/uploads` (tmp gets deleted on gogs restart)
TEMP_PATH = data/tmp/uploads
; One or more allowed types, e.g. image/jpeg|image/png. Nothing means any file type
@@ -76,7 +76,7 @@ ENABLE_HARD_LINE_BREAK = false
CUSTOM_URL_SCHEMES =
; List of file extensions that should be rendered/edited as Markdown
; Separate extensions with a comma. To render files w/o extension as markdown, just put a comma
MD_FILE_EXTENSIONS = .md,.markdown,.mdown,.mkd
FILE_EXTENSIONS = .md,.markdown,.mdown,.mkd
[server]
PROTOCOL = http
+2 -2
View File
@@ -427,7 +427,7 @@ func IsErrRepoFileAlreadyExist(err error) bool {
}
func (err ErrRepoFileAlreadyExist) Error() string {
return fmt.Sprintf("repository file already exists [file name: %s]", err.FileName)
return fmt.Sprintf("repository file already exists [file_name: %s]", err.FileName)
}
// __________ .__
@@ -663,5 +663,5 @@ func IsErrUploadNotExist(err error) bool {
}
func (err ErrUploadNotExist) Error() string {
return fmt.Sprintf("attachment does not exist [id: %d, uuid: %s]", err.ID, err.UUID)
return fmt.Sprintf("attachment does not exist [id: %d, uuid: %s, user_id: %d, repo_id: %d]", err.ID, err.UUID, err.UserID, err.RepoID)
}
+2 -2
View File
@@ -645,12 +645,12 @@ func newIssue(e *xorm.Session, repo *Repository, issue *Issue, labelIDs []int64,
if IsErrAttachmentNotExist(err) {
continue
}
return fmt.Errorf("getAttachmentByUUID[%s]: %v", uuid, err)
return fmt.Errorf("getAttachmentByUUID [%s]: %v", uuid, err)
}
attachment.IssueID = issue.ID
// No assign value could be 0, so ignore AllCols().
if _, err = e.Id(attachment.ID).Update(attachment); err != nil {
return fmt.Errorf("update attachment[%d]: %v", attachment.ID, err)
return fmt.Errorf("update attachment [%d]: %v", attachment.ID, err)
}
}
+1 -1
View File
@@ -2557,7 +2557,7 @@ func (u *Upload) AfterSet(colName string, _ xorm.Cell) {
// UploadLocalPath returns where uploads is stored in local file system based on given UUID.
func UploadLocalPath(uuid string) string {
return path.Join(setting.UploadTempPath, uuid[0:1], uuid[1:2], uuid)
return path.Join(setting.Repository.Upload.TempPath, uuid[0:1], uuid[1:2], uuid)
}
// LocalPath returns where uploads are temporarily stored in local file system.
+1 -1
View File
@@ -29,7 +29,7 @@ func Test_SSHParsePublicKey(t *testing.T) {
"rsa-2048": {"rsa", 2048, "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDMZXh+1OBUwSH9D45wTaxErQIN9IoC9xl7MKJkqvTvv6O5RR9YW/IK9FbfjXgXsppYGhsCZo1hFOOsXHMnfOORqu/xMDx4yPuyvKpw4LePEcg4TDipaDFuxbWOqc/BUZRZcXu41QAWfDLrInwsltWZHSeG7hjhpacl4FrVv9V1pS6Oc5Q1NxxEzTzuNLS/8diZrTm/YAQQ/+B+mzWI3zEtF4miZjjAljWd1LTBPvU23d29DcBmmFahcZ441XZsTeAwGxG/Q6j8NgNXj9WxMeWwxXV2jeAX/EBSpZrCVlCQ1yJswT6xCp8TuBnTiGWYMBNTbOZvPC4e0WI2/yZW/s5F nocomment"},
"ecdsa-256": {"ecdsa", 256, "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFQacN3PrOll7PXmN5B/ZNVahiUIqI05nbBlZk1KXsO3d06ktAWqbNflv2vEmA38bTFTfJ2sbn2B5ksT52cDDbA= nocomment"},
"ecdsa-384": {"ecdsa", 384, "ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBINmioV+XRX1Fm9Qk2ehHXJ2tfVxW30ypUWZw670Zyq5GQfBAH6xjygRsJ5wWsHXBsGYgFUXIHvMKVAG1tpw7s6ax9oA+dJOJ7tj+vhn8joFqT+sg3LYHgZkHrfqryRasQ== nocomment"},
"ecdsa-521": {"ecdsa", 521, "ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBACGt3UG3EzRwNOI17QR84l6PgiAcvCE7v6aXPj/SC6UWKg4EL8vW9ZBcdYL9wzs4FZXh4MOV8jAzu3KRWNTwb4k2wFNUpGOt7l28MztFFEtH5BDDrtAJSPENPy8pvPLMfnPg5NhvWycqIBzNcHipem5wSJFN5PdpNOC2xMrPWKNqj+ZjQ== nocomment"},
// "ecdsa-521": {"ecdsa", 521, "ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBACGt3UG3EzRwNOI17QR84l6PgiAcvCE7v6aXPj/SC6UWKg4EL8vW9ZBcdYL9wzs4FZXh4MOV8jAzu3KRWNTwb4k2wFNUpGOt7l28MztFFEtH5BDDrtAJSPENPy8pvPLMfnPg5NhvWycqIBzNcHipem5wSJFN5PdpNOC2xMrPWKNqj+ZjQ== nocomment"},
}
Convey("Parse public keys in both native and ssh-keygen", t, func() {
+14 -10
View File
@@ -47,6 +47,19 @@ func DeleteUpdateTaskByUUID(uuid string) error {
return err
}
// CommitToPushCommit transforms a git.Commit to PushCommit type.
func CommitToPushCommit(commit *git.Commit) *PushCommit {
return &PushCommit{
Sha1: commit.ID.String(),
Message: commit.Message(),
AuthorEmail: commit.Author.Email,
AuthorName: commit.Author.Name,
CommitterEmail: commit.Committer.Email,
CommitterName: commit.Committer.Name,
Timestamp: commit.Author.When,
}
}
func ListToPushCommits(l *list.List) *PushCommits {
commits := make([]*PushCommit, 0)
var actEmail string
@@ -55,16 +68,7 @@ func ListToPushCommits(l *list.List) *PushCommits {
if actEmail == "" {
actEmail = commit.Committer.Email
}
commits = append(commits,
&PushCommit{
Sha1: commit.ID.String(),
Message: commit.Message(),
AuthorEmail: commit.Author.Email,
AuthorName: commit.Author.Name,
CommitterEmail: commit.Committer.Email,
CommitterName: commit.Committer.Name,
Timestamp: commit.Author.When,
})
commits = append(commits, CommitToPushCommit(commit))
}
return &PushCommits{l.Len(), commits, "", nil}
}
+2 -2
View File
@@ -286,7 +286,7 @@ func (fi bindataFileInfo) Sys() interface{} {
return nil
}
var _confAppIni = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xb4\x5b\x5b\x6f\x23\xc9\x75\x7e\xef\x5f\x51\xab\xcd\x66\x34\x41\x93\xd4\x65\xa4\xd1\xca\x96\xb3\x14\xd9\x94\xe8\xe1\xcd\xdd\xd4\xcc\xce\x0e\x84\x56\x8b\x5d\x24\x7b\xd5\xec\xe6\x76\x35\xa5\xd1\x22\x08\x6c\xe4\x21\x17\x20\xc8\x43\x82\x04\x01\x82\x20\x79\x48\x0c\x38\x37\x1b\x79\xb1\x13\x27\x2f\x9b\xbc\xcf\xfe\x07\x67\x1d\x3f\xf9\x2f\xe4\x3b\xa7\xaa\xc9\xa6\x46\xab\xec\xe6\xea\x15\xfb\x52\x75\xaa\xce\xfd\x3b\xa7\x7a\xde\x15\x3d\xe7\xb9\xe3\x0a\xfe\xd3\xed\x37\xdb\xad\x97\x62\x78\xda\xf6\x44\xab\xdd\x71\xac\x77\xc5\xa0\xe3\xd4\x3d\x47\x74\xeb\xcf\x1c\xd1\x38\xad\xf7\x4e\x1c\x4f\xf4\x7b\xa2\xd1\x77\x5d\xc7\x1b\xf4\x7b\xcd\x76\xef\x44\x34\xce\xbc\x61\xbf\x8b\x87\xbd\x56\xfb\x44\xcf\xb4\xbe\x21\xea\xf3\xb9\x48\x82\x99\x14\xf9\x34\xc8\x85\x9a\xa6\x37\x4a\xa4\x89\x90\xd7\x32\xbb\x15\xf3\x60\x82\x17\x51\x1e\x4b\xab\x3e\x18\xf8\xbd\x7a\xd7\x11\x47\xe2\x24\x9d\xa8\x43\xfc\x15\x27\x51\x2e\x3c\x99\x5d\x47\x23\x09\x4a\x8d\x69\x90\x60\x38\x9e\x45\x63\x71\x9b\x2e\x44\xb6\x48\x44\x9c\x8e\x82\x38\xbe\xb5\xdc\xb3\x9e\x7f\xe6\x61\xf7\x47\x62\x12\xe5\x18\xed\x44\xf9\x54\x66\x62\x23\x94\xd7\x1b\xb6\xd8\x98\x67\x69\xb8\x21\x52\x3c\xc8\xa5\xca\xf1\x24\x94\xe3\x60\x11\x83\x96\xd2\x63\x98\x02\x58\xa7\x0d\xe0\xde\xb2\x5e\x65\x72\x9e\xaa\x28\x4f\xb3\xdb\x73\xcb\xed\xf7\x87\xe2\xc8\xf2\x1a\x6e\x7b\x30\xf4\x87\x2f\x07\x34\xec\x32\x50\x53\xac\xd4\x34\x94\xea\x3d\xaf\x2d\x46\xd3\x20\x53\x32\xb7\xe8\xc6\x87\xa8\x5c\xcf\xa1\x89\xdf\x10\xad\x34\x1b\x49\xc3\x76\x22\x6f\xc4\x8a\xba\xc8\x53\x71\x29\xc5\x3c\x8b\xae\x83\x5c\x5a\xad\xbe\xdb\x70\xfc\x81\xdb\x7e\x5e\x1f\xd2\x2a\xe3\x20\x56\xc4\xfe\x49\x9c\x5e\x06\xb1\x98\x05\xaf\xa3\xd9\x62\x26\x46\x99\x0c\xf2\x08\x92\x8c\xa3\x19\x44\x92\x8e\xcb\x14\xe7\xe0\x7c\xa1\x64\x66\x8b\xca\xb6\x98\xc9\x20\x51\x22\x49\xf5\x48\xab\x5b\xff\xd0\x6f\xb8\x4e\x7d\xd8\xee\xf7\xfc\x4e\xbb\xdb\xc6\xfe\x30\x0c\x2b\x0c\x82\x7c\x34\x15\x24\x1f\xf1\xc9\x42\x2e\xa4\x88\x65\x32\xc9\xa7\x36\xd6\xbc\x62\xb9\x07\x4a\xc4\x41\x06\x1d\xe0\x02\x6b\xa9\xe8\x12\x8a\x1b\x9c\x75\x3a\xbe\xeb\x7c\xe7\xcc\xf1\x86\x3e\xfe\x9e\x39\x7e\xc7\xe9\x9d\x0c\x4f\x41\x76\x7b\x0b\xff\x07\x51\xca\x90\xf6\x75\x8e\x35\x3a\x91\xe2\xcd\x8e\xa3\x18\xd2\x78\x9d\xcb\x44\x81\x09\xb5\xb4\x8e\x45\x1c\x8a\x69\x70\x8d\xb5\xa3\x44\x8a\x9b\x2c\x98\x2b\x11\x25\x78\x2d\x45\x23\x0d\x65\x37\xca\x32\x28\x51\xd3\x03\x39\x4f\xce\x83\x0c\x52\x2b\x93\xba\x81\xe6\x45\x20\x46\xe9\x6c\x16\x54\xc5\x30\x5d\x91\xe2\x55\x31\xa0\x96\xae\xc6\xdb\xe2\xe3\x05\xb6\x34\x5f\xe4\xc5\x1c\xab\xd3\xee\x39\xfe\x0b\xb7\x3e\xf0\x9d\x0f\x87\x0e\x14\xd9\xef\x79\x60\xa6\x9a\xbf\xce\xed\xea\x2c\xc4\x7f\x41\x76\x15\xa6\x37\x09\xdd\xe9\x9f\xab\xd0\xc6\x6e\x9e\x07\x71\x14\x6a\xd6\x66\xd8\xac\xe1\x8a\xd9\x09\xa0\x5f\x79\x1d\x41\xf1\xf5\x41\x1b\xf2\x53\xe9\x28\xc2\xbe\x43\xbd\x5b\xb0\x37\xb3\x85\x5a\x40\xfc\x10\x6d\x30\x8f\x6a\xd7\xdb\xb5\x62\x95\x32\x9b\xd7\x41\xbc\x00\xdd\xcb\x5b\xbd\x55\x55\x15\x03\x43\x36\x0f\x2e\x49\x50\x24\x19\x5e\x5c\xdc\xa4\xc9\x23\xed\x70\xe4\x2f\x24\xc0\x75\x99\x8b\x30\x95\x8a\x86\xcc\x48\xed\xd6\xc0\x75\x9e\xb7\x9d\x17\xfe\xb0\x7e\xec\x63\x8b\xc4\xf0\x72\x03\xd6\xab\xc5\x3c\x4e\x83\x90\x14\xf8\x62\x2a\xd9\xb1\x4a\xd6\xc6\x74\xf5\x08\x6c\x3e\xc3\x1a\x49\x00\xcb\x08\xab\x85\x6b\x28\x32\xf1\x8b\x3c\x5b\xc8\x0b\xcb\xe9\xd5\x8f\x3b\x8e\x7f\x36\xe8\xf4\xeb\x4d\x5a\x85\x1e\x6b\xe3\x9b\x8a\x31\x74\x6b\x08\xdd\x99\x1c\x06\x79\x50\xcb\x67\xf3\x9a\x79\x7d\x21\x36\x71\x27\x26\x12\xef\x43\x19\x4b\x12\x25\x78\x9a\x20\x74\x60\x6b\x2a\x0f\xb2\xfc\xb1\x35\x74\xba\x03\x7f\x50\x67\x53\xbc\x4b\x00\x4b\xf6\x61\x16\x58\x70\x96\x62\xcb\x08\x22\xe9\x0d\x68\xe4\xb7\x73\xa9\x6c\x21\xab\x93\xaa\x88\x66\x08\x4f\xb5\x8f\xe7\x72\xf2\x1b\xfa\x72\x9e\xe0\x69\x2f\xcd\xa7\x51\x32\x31\x6e\x15\x24\x86\x7f\x9a\x68\xd5\x3b\x9d\xfe\x0b\xa7\xc9\x01\xc2\x63\xb7\xef\x06\xaf\x85\x8a\x3e\x95\x64\xf3\x32\x80\x7e\x79\x30\x14\xd5\x3d\x5e\xe7\x70\x77\xa7\x7b\x6c\x51\xd0\xf4\xc9\x41\xbd\xf6\x47\xe4\xfb\xbb\x3b\x86\x44\xb2\x98\x5d\x42\xe8\xc6\x71\x94\x76\x70\x66\x64\x9d\xca\xf6\x16\xfb\x37\xd1\xf1\xd8\xff\x48\x77\x11\xe9\xad\xb7\xa4\xb0\xd4\x5c\x54\x58\x28\xe9\x8c\x0c\x05\xfc\x63\x67\x69\x42\x56\x02\xe2\x78\x4a\x01\xda\x72\x3e\x84\xb2\x5c\xc4\xa4\xfa\x09\xe2\xbc\xdf\x3b\xeb\x82\xf4\xce\xd6\x1a\xd1\x48\xa9\xc5\x97\x93\x63\x32\x6d\xcf\x3b\xbb\x43\x64\x7b\x9d\xc8\x32\xb6\xc1\xb6\x23\x30\xb4\x4e\x24\x18\xe5\xd1\x75\x94\x43\xde\x52\x86\x56\xcb\x81\x9c\x39\x96\xf5\xbb\x88\x61\x86\xe0\x9e\xf6\xc2\x05\xcb\xfb\x82\xdc\x4a\x56\x46\x29\x58\xb9\x80\xbe\xf2\x00\x5e\x32\xb1\x29\x32\x86\xe4\x42\xf5\x24\xcc\x52\x38\xec\xb7\x30\xaf\x4a\x3b\xa9\x27\x58\xeb\x9a\x9d\x98\x27\x21\x72\x20\xf0\x6d\x24\x58\x5d\xe7\x8e\x30\x52\x64\xd9\x1b\xf0\xda\x38\xd6\x8e\x4d\x8e\x55\xe4\x12\x95\xdf\xc6\x64\xcb\x5d\x12\x5d\x94\x8c\xd3\x43\x31\xcd\xf3\xb9\x3a\xac\xd5\x90\x52\x64\x9c\x42\x6d\xaa\x3a\x49\xd3\x49\x2c\xab\x60\xb2\x76\x23\x2f\x61\x8f\x30\x4d\xa9\x6a\x3b\x5b\xdb\x4f\x6a\xdb\xdb\x35\x6f\x31\x9f\xa7\x59\x5e\x81\x2f\x54\x4a\x0c\x54\xa2\xa4\xd2\x98\x66\x29\xee\x77\xdf\xe7\x97\x66\xfb\xd6\xf0\Line truncated
var _confAppIni = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xb4\x5b\x5b\x6f\x23\xc9\x75\x7e\xef\x5f\x51\xab\xcd\x66\x34\x41\x93\xd4\x65\xa4\xd1\xca\x96\xb3\x14\xd9\x94\xe8\xe1\xcd\xdd\xd4\xcc\xce\x0e\x84\x56\x8b\x5d\x24\x7b\xd5\xec\xe6\x76\x35\xa5\xd1\x22\x08\x6c\xe4\x21\x17\x20\xc8\x43\x82\x04\x01\x82\x20\x79\x48\x0c\x38\x37\x1b\x79\xb1\x13\x27\x2f\x9b\xbc\xcf\xfe\x07\x67\x1d\x3f\xf9\x2f\xe4\x3b\xa7\xaa\xc9\xa6\x46\xab\xec\xe6\xea\x15\xfb\x52\x75\xaa\xce\xfd\x3b\xa7\x7a\xde\x15\x3d\xe7\xb9\xe3\x0a\xfe\xd3\xed\x37\xdb\xad\x97\x62\x78\xda\xf6\x44\xab\xdd\x71\xac\x77\xc5\xa0\xe3\xd4\x3d\x47\x74\xeb\xcf\x1c\xd1\x38\xad\xf7\x4e\x1c\x4f\xf4\x7b\xa2\xd1\x77\x5d\xc7\x1b\xf4\x7b\xcd\x76\xef\x44\x34\xce\xbc\x61\xbf\x8b\x87\xbd\x56\xfb\x44\xcf\xb4\xbe\x21\xea\xf3\xb9\x48\x82\x99\x14\xf9\x34\xc8\x85\x9a\xa6\x37\x4a\xa4\x89\x90\xd7\x32\xbb\x15\xf3\x60\x82\x17\x51\x1e\x4b\xab\x3e\x18\xf8\xbd\x7a\xd7\x11\x47\xe2\x24\x9d\xa8\x43\xfc\x15\x27\x51\x2e\x3c\x99\x5d\x47\x23\x09\x4a\x8d\x69\x90\x60\x38\x9e\x45\x63\x71\x9b\x2e\x44\xb6\x48\x44\x9c\x8e\x82\x38\xbe\xb5\xdc\xb3\x9e\x7f\xe6\x61\xf7\x47\x62\x12\xe5\x18\xed\x44\xf9\x54\x66\x62\x23\x94\xd7\x1b\xb6\xd8\x98\x67\x69\xb8\x21\x52\x3c\xc8\xa5\xca\xf1\x24\x94\xe3\x60\x11\x83\x96\xd2\x63\x98\x02\x58\xa7\x0d\xe0\xde\xb2\x5e\x65\x72\x9e\xaa\x28\x4f\xb3\xdb\x73\xcb\xed\xf7\x87\xe2\xc8\xf2\x1a\x6e\x7b\x30\xf4\x87\x2f\x07\x34\xec\x32\x50\x53\xac\xd4\x34\x94\xea\x3d\xaf\x2d\x46\xd3\x20\x53\x32\xb7\xe8\xc6\x87\xa8\x5c\xcf\xa1\x89\xdf\x10\xad\x34\x1b\x49\xc3\x76\x22\x6f\xc4\x8a\xba\xc8\x53\x71\x29\xc5\x3c\x8b\xae\x83\x5c\x5a\xad\xbe\xdb\x70\xfc\x81\xdb\x7e\x5e\x1f\xd2\x2a\xe3\x20\x56\xc4\xfe\x49\x9c\x5e\x06\xb1\x98\x05\xaf\xa3\xd9\x62\x26\x46\x99\x0c\xf2\x08\x92\x8c\xa3\x19\x44\x92\x8e\xcb\x14\xe7\xe0\x7c\xa1\x64\x66\x8b\xca\xb6\x98\xc9\x20\x51\x22\x49\xf5\x48\xab\x5b\xff\xd0\x6f\xb8\x4e\x7d\xd8\xee\xf7\xfc\x4e\xbb\xdb\xc6\xfe\x30\x0c\x2b\x0c\x82\x7c\x34\x15\x24\x1f\xf1\xc9\x42\x2e\xa4\x88\x65\x32\xc9\xa7\x36\xd6\xbc\x62\xb9\x07\x4a\xc4\x41\x06\x1d\xe0\x02\x6b\xa9\xe8\x12\x8a\x1b\x9c\x75\x3a\xbe\xeb\x7c\xe7\xcc\xf1\x86\x3e\xfe\x9e\x39\x7e\xc7\xe9\x9d\x0c\x4f\x41\x76\x7b\x0b\xff\xb7\x26\xca\xaa\x0c\xe9\xf7\x1c\xcb\x75\x22\xc5\xfb\x1e\x47\x31\x04\xf3\x3a\x97\x89\x02\x3f\x6a\x69\x28\x8b\x38\x14\xd3\xe0\x1a\xdb\x88\x12\x29\x6e\xb2\x60\xae\x44\x94\xe0\xb5\x14\x8d\x34\x94\xdd\x28\xcb\xa0\x4f\x4d\x0f\xe4\x3c\x39\x0f\x32\x08\xb0\x4c\xea\x06\x46\x20\x02\x31\x4a\x67\xb3\xa0\x2a\x86\xe9\x8a\x14\xaf\x8a\x01\xb5\x74\x35\xde\x16\x1f\x2f\xb0\xa5\xf9\x22\x2f\xe6\x58\x9d\x76\xcf\xf1\x5f\xb8\xf5\x81\xef\x7c\x38\x74\xa0\xd3\x7e\xcf\x03\x5f\xd5\xfc\x75\x6e\x57\x67\x21\xfe\x0b\xb2\xab\x30\xbd\x49\xe8\x4e\xff\x5c\x85\x36\x76\xf3\x3c\x88\xa3\x50\xb3\x36\xc3\x66\x0d\x57\xcc\x4e\x00\x55\xcb\xeb\x08\x36\x50\x1f\xb4\x21\x4a\x95\x8e\x22\xec\x3b\xd4\xbb\x05\x7b\x33\x5b\xa8\x05\x34\x01\x29\x07\xf3\xa8\x76\xbd\x5d\x2b\x56\x29\xb3\x79\x1d\xc4\x0b\xd0\xbd\xbc\xd5\x5b\x55\x55\x31\x30\x64\xf3\xe0\x92\x04\x45\x92\xe1\xc5\xc5\x4d\x9a\x3c\xd2\xbe\x47\xae\x43\x02\x5c\x97\xb9\x08\x53\xa9\x68\xc8\x8c\x2c\xc0\x1a\xb8\xce\xf3\xb6\xf3\xa2\x7e\xdc\x71\x7c\x72\x63\x76\x0b\x62\x7b\xb9\x8d\x35\x8d\x2e\xe6\x71\x1a\x84\xa4\xd1\x17\x53\xc9\x4e\x57\xb2\x44\x5e\x48\x8f\x00\x37\x19\x16\x4d\x02\x58\x4d\x58\x2d\xdc\x46\x91\xf9\x5f\xe4\xd9\x42\x5e\x58\x4e\x8f\xd6\x6c\x62\x25\xba\xd7\x16\x39\x15\x63\x68\xd9\x50\xb8\x33\x2b\x0c\xf2\xa0\x96\xcf\xe6\x35\xf3\xfa\x42\x6c\xe2\x4e\x4c\x24\xde\x87\x32\x96\x24\x54\x70\x37\x41\x3c\xc1\x9e\x54\x1e\x64\xf9\x63\x6b\xe8\x74\x07\xfe\xa0\xce\xf6\x79\x97\x00\x96\xec\xc3\x40\xb0\xe0\x2c\xc5\x5e\x11\x59\xd2\x1b\xd0\xc8\x6f\xe7\x52\xd9\x42\x56\x27\x55\x11\xcd\x10\xb3\x6a\x1f\xcf\xe5\xe4\x37\xf4\xe5\x3c\xc1\xd3\x5e\x9a\x4f\xa3\x64\x62\x7c\x2d\x48\x0c\xe3\x34\xd1\xaa\x77\x3a\xfd\x17\x4e\x93\xa3\x86\xc7\xb1\xa0\x1b\xbc\x16\x2a\xfa\x54\x92\xf5\xcb\x00\x9a\xe6\xc1\x50\x59\xf7\x78\x9d\xc3\xdd\x9d\xee\xb1\xa5\x55\x00\xaf\xf5\xda\x1f\x51\x40\xd8\xdd\x31\x24\x92\xc5\xec\x12\xd2\x36\x2e\xa4\xb4\xd7\x33\x23\xeb\x54\xb6\xb7\xd8\xe9\x89\x8e\xc7\x4e\x09\xfd\x2d\x22\x52\x58\x6f\x49\x61\xa9\xb2\xa8\xb0\x55\x52\x16\x99\x0c\xf8\xc7\xce\xd2\x84\xec\x05\xc4\xf1\x94\xa2\xb6\xe5\x7c\x38\xe8\xf4\x5d\x04\xaa\xfa\x09\x82\xbf\xdf\x3b\xeb\x82\xf4\xce\xd6\x1a\xd1\x48\xa9\xc5\x97\x93\x63\x32\x6d\xcf\x3b\xbb\x43\x64\x7b\x9d\xc8\x32\xe0\xc1\xca\x23\x30\xb4\x4e\x24\x18\xe5\xd1\x75\x94\x43\xde\x52\x86\x56\xcb\x81\x9c\x39\xc0\xf5\xbb\x08\x6c\x86\xe0\x9e\xf6\xc7\x05\xcb\xfb\x82\x1c\x4c\x56\x46\x29\x58\xb9\x80\xbe\xf2\x00\xfe\x32\xb1\x29\x5c\x86\xe4\x4c\xf5\x24\xcc\x52\xb8\xee\xb7\x30\xaf\x4a\x3b\xa9\x27\x58\xeb\x9a\xdd\x99\x27\x21\x86\x20\x1a\x6e\x24\x58\x5d\x27\x94\x30\x52\x64\xd2\x1b\xf0\xdf\x38\xd6\x2e\x4e\x2e\x56\x24\x18\x95\xdf\xc6\x64\xcb\x5d\x12\x5d\x94\x8c\xd3\x43\x31\xcd\xf3\xb9\x3a\xac\xd5\x90\x67\x64\x9c\x42\x6d\xaa\x3a\x49\xd3\x49\x2c\xab\x60\xb2\x76\x23\x2f\x61\x8f\x30\x4d\xa9\x6a\x3b\x5b\xdb\x4f\x6a\xdb\xdb\x35\x6f\x31\x9f\xa7\x59\x5e\x81\x2f\x54\x4a\x0c\x54\xa2\xa4\xd2\x98\x66\x29\xee\x77\xdf\xe7\x97\x66\xfb\xd6\xf0\xd4\xe9\Line truncated
func confAppIniBytes() ([]byte, error) {
return bindataRead(
@@ -301,7 +301,7 @@ func confAppIni() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "conf/app.ini", size: 13442, mode: os.FileMode(420), modTime: time.Unix(1471215870, 0)}
info := bindataFileInfo{name: "conf/app.ini", size: 13460, mode: os.FileMode(420), modTime: time.Unix(1471215929, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
+1 -1
View File
@@ -54,7 +54,7 @@ func isLink(link []byte) bool {
// based on its extension.
func IsMarkdownFile(name string) bool {
extension := strings.ToLower(filepath.Ext(name))
for _, ext := range setting.Markdown.MdFileExtensions {
for _, ext := range setting.Markdown.FileExtensions {
if strings.ToLower(ext) == extension {
return true
}
+23 -29
View File
@@ -114,16 +114,25 @@ var (
ForcePrivate bool
MaxCreationLimit int
PullRequestQueueLength int
// Repository editor settings
Editor struct {
LineWrapExtensions []string
PreviewableFileModes []string
} `ini:"-"`
// Repository upload settings
Upload struct {
Enabled bool
TempPath string
AllowedTypes []string `delim:"|"`
FileMaxSize int64
MaxFiles int
} `ini:"-"`
}
RepoRootPath string
ScriptType string
// Repo editor settings
Editor struct {
LineWrapExtensions []string
PreviewTabApis []string
}
// UI settings
UI struct {
ExplorePagingNum int
@@ -147,7 +156,7 @@ var (
Markdown struct {
EnableHardLineBreak bool
CustomURLSchemes []string `ini:"CUSTOM_URL_SCHEMES"`
MdFileExtensions []string
FileExtensions []string
}
// Picture settings
@@ -169,13 +178,6 @@ var (
AttachmentMaxFiles int
AttachmentEnabled bool
// Repo Upload settings
UploadTempPath string
UploadAllowedTypes string
UploadMaxSize int64
UploadMaxFiles int
UploadEnabled bool
// Time settings
TimeFormat string
@@ -494,17 +496,15 @@ func NewContext() {
ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
if err = Cfg.Section("repository").MapTo(&Repository); err != nil {
log.Fatal(4, "Fail to map Repository settings: %v", err)
} else if err = Cfg.Section("repository.editor").MapTo(&Repository.Editor); err != nil {
log.Fatal(4, "Fail to map Repository.Editor settings: %v", err)
} else if err = Cfg.Section("repository.upload").MapTo(&Repository.Upload); err != nil {
log.Fatal(4, "Fail to map Repository.Upload settings: %v", err)
}
sec = Cfg.Section("upload")
UploadTempPath = sec.Key("UPLOAD_TEMP_PATH").MustString(path.Join(AppDataPath, "tmp/uploads"))
if !filepath.IsAbs(UploadTempPath) {
UploadTempPath = path.Join(workDir, UploadTempPath)
if !filepath.IsAbs(Repository.Upload.TempPath) {
Repository.Upload.TempPath = path.Join(workDir, Repository.Upload.TempPath)
}
UploadAllowedTypes = strings.Replace(sec.Key("UPLOAD_ALLOWED_TYPES").MustString(""), "|", ",", -1)
UploadMaxSize = sec.Key("UPLOAD_FILE_MAX_SIZE").MustInt64(32)
UploadMaxFiles = sec.Key("UPLOAD_MAX_FILES").MustInt(10)
UploadEnabled = sec.Key("ENABLE_UPLOADS").MustBool(true)
sec = Cfg.Section("picture")
AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString(path.Join(AppDataPath, "avatars"))
@@ -553,11 +553,9 @@ func NewContext() {
} else if err = Cfg.Section("git").MapTo(&Git); err != nil {
log.Fatal(4, "Fail to map Git settings: %v", err)
} else if err = Cfg.Section("mirror").MapTo(&Mirror); err != nil {
log.Fatal(4, "Fail to map API settings: %v", err)
log.Fatal(4, "Fail to map Mirror settings: %v", err)
} else if err = Cfg.Section("api").MapTo(&API); err != nil {
log.Fatal(4, "Fail to map API settings: %v", err)
} else if err = Cfg.Section("editor").MapTo(&Editor); err != nil {
log.Fatal(4, "Fail to map Editor settings: %v", err)
}
if Mirror.DefaultInterval <= 0 {
@@ -572,10 +570,6 @@ func NewContext() {
ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool()
HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
Markdown.MdFileExtensions = Cfg.Section("markdown").Key("MD_FILE_EXTENSIONS").Strings(",")
Editor.LineWrapExtensions = Cfg.Section("editor").Key("LINE_WRAP_EXTENSIONS").Strings(",")
Editor.PreviewTabApis = Cfg.Section("editor").Key("PREVIEW_TAB_APIS").Strings(",")
}
var Service struct {
+6 -6
View File
@@ -29,7 +29,7 @@ function initCommentPreviewTab($form) {
}
var previewTab;
var previewTabApis;
var previewFileModes;
function initEditPreviewTab($form) {
var $tab_menu = $form.find('.tabular.menu');
@@ -37,7 +37,7 @@ function initEditPreviewTab($form) {
previewTab = $tab_menu.find('.item[data-tab="' + $tab_menu.data('preview') + '"]');
if (previewTab.length) {
previewTabApis = previewTab.data('preview-apis').split(',');
previewFileModes = previewTab.data('preview-file-modes').split(',');
previewTab.click(function () {
var $this = $(this);
$.post($this.data('url'), {
@@ -662,7 +662,7 @@ var editArea;
var editFilename;
var smdEditor;
var cmEditor;
var mdFileExtensions;
var markdownFileExts;
var lineWrapExtensions;
// For IE
@@ -740,7 +740,7 @@ function initEditor() {
if (!editArea.length)
return;
mdFileExtensions = editArea.data("md-file-extensions").split(",");
markdownFileExts = editArea.data("markdown-file-exts").split(",");
lineWrapExtensions = editArea.data("line-wrap-extensions").split(",");
editFilename.on("keyup", function (e) {
@@ -762,7 +762,7 @@ function initEditor() {
apiCall = extension
}
if (previewLink.length && apiCall && previewTabApis && previewTabApis.length && previewTabApis.indexOf(apiCall) >= 0) {
if (previewLink.length && apiCall && previewFileModes && previewFileModes.length && previewFileModes.indexOf(apiCall) >= 0) {
dataUrl = previewLink.data('url');
previewLink.data('url', dataUrl.replace(/(.*)\/.*/i, '$1/' + mode));
previewLink.show();
@@ -772,7 +772,7 @@ function initEditor() {
}
// If this file is a Markdown extensions, we will load that editor and return
if (mdFileExtensions.indexOf(extWithDot) >= 0) {
if (markdownFileExts.indexOf(extWithDot) >= 0) {
if (setSimpleMDE()) {
return;
}
+2 -7
View File
@@ -64,13 +64,8 @@ func NewBranchPost(ctx *context.Context, form auth.NewBranchForm) {
log.Error(4, "branch.GetCommit(): %v", err)
} else {
pc := &models.PushCommits{
Len: 1,
Commits: []*models.PushCommit{&models.PushCommit{
commit.ID.String(),
commit.Message(),
commit.Author.Email,
commit.Author.Name,
}},
Len: 1,
Commits: []*models.PushCommit{models.CommitToPushCommit(commit)},
}
oldCommitID := "0000000000000000000000000000000000000000" // New Branch so we use all 0s
newCommitID := commit.ID.String()
+2 -7
View File
@@ -32,13 +32,8 @@ func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) {
log.Error(4, "branch.GetCommit(): %v", err)
} else {
pc := &models.PushCommits{
Len: 1,
Commits: []*models.PushCommit{&models.PushCommit{
commit.ID.String(),
commit.Message(),
commit.Author.Email,
commit.Author.Name,
}},
Len: 1,
Commits: []*models.PushCommit{models.CommitToPushCommit(commit)},
}
oldCommitID := ctx.Repo.CommitID
newCommitID := commit.ID.String()
+11 -16
View File
@@ -89,7 +89,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
d, _ := ioutil.ReadAll(dataRc)
buf = append(buf, d...)
if err, content := template.ToUtf8WithErr(buf); err != nil {
if err, content := template.ToUTF8WithErr(buf); err != nil {
if err != nil {
log.Error(4, "Convert content encoding: %s", err)
}
@@ -116,10 +116,10 @@ func editFile(ctx *context.Context, isNewFile bool) {
ctx.Data["CommitDirectlyToThisBranch"] = ctx.Tr("repo.commit_directly_to_this_branch", "<strong class=\"branch-name\">"+branchName+"</strong>")
ctx.Data["CreateNewBranch"] = ctx.Tr("repo.create_new_branch", "<strong>"+ctx.Tr("repo.new_branch")+"</strong>")
ctx.Data["LastCommit"] = ctx.Repo.Commit.ID
ctx.Data["MdFileExtensions"] = strings.Join(setting.Markdown.MdFileExtensions, ",")
ctx.Data["LineWrapExtensions"] = strings.Join(setting.Editor.LineWrapExtensions, ",")
ctx.Data["PreviewTabApis"] = strings.Join(setting.Editor.PreviewTabApis, ",")
ctx.Data["PreviewDiffUrl"] = ctx.Repo.RepoLink + "/preview/" + branchName + "/" + treeName
ctx.Data["MarkdownFileExts"] = strings.Join(setting.Markdown.FileExtensions, ",")
ctx.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",")
ctx.Data["PreviewableFileModes"] = strings.Join(setting.Repository.Editor.PreviewableFileModes, ",")
ctx.Data["PreviewDiffURL"] = ctx.Repo.RepoLink + "/preview/" + branchName + "/" + treeName
ctx.HTML(200, EDIT)
}
@@ -176,10 +176,10 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
ctx.Data["CommitDirectlyToThisBranch"] = ctx.Tr("repo.commit_directly_to_this_branch", "<strong class=\"branch-name\">"+oldBranchName+"</strong>")
ctx.Data["CreateNewBranch"] = ctx.Tr("repo.create_new_branch", "<strong>"+ctx.Tr("repo.new_branch")+"</strong>")
ctx.Data["LastCommit"] = ctx.Repo.Commit.ID
ctx.Data["MdFileExtensions"] = strings.Join(setting.Markdown.MdFileExtensions, ",")
ctx.Data["LineWrapExtensions"] = strings.Join(setting.Editor.LineWrapExtensions, ",")
ctx.Data["PreviewTabApis"] = strings.Join(setting.Editor.PreviewTabApis, ",")
ctx.Data["PreviewDiffUrl"] = ctx.Repo.RepoLink + "/preview/" + branchName + "/" + treeName
ctx.Data["MarkdownFileExts"] = strings.Join(setting.Markdown.FileExtensions, ",")
ctx.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",")
ctx.Data["PreviewableFileModes"] = strings.Join(setting.Repository.Editor.PreviewableFileModes, ",")
ctx.Data["PreviewDiffURL"] = ctx.Repo.RepoLink + "/preview/" + branchName + "/" + treeName
if ctx.HasError() {
ctx.HTML(200, EDIT)
@@ -293,13 +293,8 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
log.Error(4, "branch.GetCommit(): %v", err)
} else {
pc := &models.PushCommits{
Len: 1,
Commits: []*models.PushCommit{&models.PushCommit{
commit.ID.String(),
commit.Message(),
commit.Author.Email,
commit.Author.Name,
}},
Len: 1,
Commits: []*models.PushCommit{models.CommitToPushCommit(commit)},
}
oldCommitID := ctx.Repo.CommitID
newCommitID := commit.ID.String()
+10 -16
View File
@@ -24,10 +24,10 @@ const (
func renderUploadSettings(ctx *context.Context) {
ctx.Data["RequireDropzone"] = true
ctx.Data["IsUploadEnabled"] = setting.UploadEnabled
ctx.Data["UploadAllowedTypes"] = setting.UploadAllowedTypes
ctx.Data["UploadMaxSize"] = setting.UploadMaxSize
ctx.Data["UploadMaxFiles"] = setting.UploadMaxFiles
ctx.Data["IsUploadEnabled"] = setting.Repository.Upload.Enabled
ctx.Data["UploadAllowedTypes"] = strings.Join(setting.Repository.Upload.AllowedTypes, ",")
ctx.Data["UploadMaxSize"] = setting.Repository.Upload.FileMaxSize
ctx.Data["UploadMaxFiles"] = setting.Repository.Upload.MaxFiles
}
func UploadFile(ctx *context.Context) {
@@ -154,13 +154,8 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) {
log.Error(4, "branch.GetCommit(): %v", err)
} else {
pc := &models.PushCommits{
Len: 1,
Commits: []*models.PushCommit{&models.PushCommit{
commit.ID.String(),
commit.Message(),
commit.Author.Email,
commit.Author.Name,
}},
Len: 1,
Commits: []*models.PushCommit{models.CommitToPushCommit(commit)},
}
oldCommitID := ctx.Repo.CommitID
newCommitID := commit.ID.String()
@@ -184,7 +179,7 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) {
}
func UploadFileToServer(ctx *context.Context) {
if !setting.UploadEnabled {
if !setting.Repository.Upload.Enabled {
ctx.Error(404, "upload is not enabled")
return
}
@@ -203,10 +198,9 @@ func UploadFileToServer(ctx *context.Context) {
}
fileType := http.DetectContentType(buf)
if len(setting.UploadAllowedTypes) > 0 {
allowedTypes := strings.Split(setting.UploadAllowedTypes, ",")
if len(setting.Repository.Upload.AllowedTypes) > 0 {
allowed := false
for _, t := range allowedTypes {
for _, t := range setting.Repository.Upload.AllowedTypes {
t := strings.Trim(t, " ")
if t == "*/*" || t == fileType {
allowed = true
@@ -233,7 +227,7 @@ func UploadFileToServer(ctx *context.Context) {
}
func RemoveUploadFileFromServer(ctx *context.Context, form auth.RemoveUploadFileForm) {
if !setting.UploadEnabled {
if !setting.Repository.Upload.Enabled {
ctx.Error(404, "upload is not enabled")
return
}
+1 -1
View File
@@ -257,7 +257,7 @@ func Home(ctx *context.Context) {
ctx.Data["LastCommitUser"] = models.ValidateCommitWithEmail(lastCommit)
if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch {
ctx.Data["NewFileLink"] = newFileLink + "/" + treename
if setting.UploadEnabled {
if !setting.Repository.Upload.Enabled {
ctx.Data["UploadFileLink"] = uploadFileLink + "/" + treename
}
}
+3 -3
View File
@@ -30,14 +30,14 @@
<div class="field">
<div class="ui top attached tabular menu" data-write="write" data-preview="preview" data-diff="diff">
<a class="active item" data-tab="write"><i class="octicon octicon-code"></i> {{.i18n.Tr "repo.edit_file"}}</a>
<a class="item" data-tab="preview" data-url="{{AppSubUrl}}/api/v1/markdown" data-context="{{.RepoLink}}" data-preview-apis="{{.PreviewTabApis}}"><i class="octicon octicon-eye"></i> {{.i18n.Tr "repo.release.preview"}}</a>
<a class="item" data-tab="diff" data-url="{{.PreviewDiffUrl}}" data-context="{{.BranchLink}}"><i class="octicon octicon-diff"></i> {{.i18n.Tr "repo.preview_changes"}}</a>
<a class="item" data-tab="preview" data-url="{{AppSubUrl}}/api/v1/markdown" data-context="{{.RepoLink}}" data-preview-file-modes="{{.PreviewableFileModes}}"><i class="octicon octicon-eye"></i> {{.i18n.Tr "repo.release.preview"}}</a>
<a class="item" data-tab="diff" data-url="{{.PreviewDiffURL}}" data-context="{{.BranchLink}}"><i class="octicon octicon-diff"></i> {{.i18n.Tr "repo.preview_changes"}}</a>
</div>
<div class="ui bottom attached active tab segment" data-tab="write">
<textarea id="edit_area" name="content" data-id="repo-{{.Repository.Name}}-{{.TreeName}}"
data-url="{{AppSubUrl}}/api/v1/markdown"
data-context="{{.RepoLink}}"
data-md-file-extensions="{{.MdFileExtensions}}"
data-markdown-file-exts="{{.MarkdownFileExts}}"
data-line-wrap-extensions="{{.LineWrapExtensions}}">
{{.FileContent}}</textarea required>
</div>