mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-29 15:13:53 +03:00
Code clean up for new config options
This commit is contained in:
parent
d0a0239bac
commit
15845cb287
17 changed files with 87 additions and 110 deletions
|
@ -510,7 +510,7 @@ func runWeb(ctx *cli.Context) error {
|
||||||
m.Post("/branches", bindIgnErr(auth.NewBranchForm{}), repo.NewBranchPost)
|
m.Post("/branches", bindIgnErr(auth.NewBranchForm{}), repo.NewBranchPost)
|
||||||
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)
|
||||||
}, context.RepoRef(), context.RepoAssignment(), reqRepoWriter)
|
}, reqRepoWriter, context.RepoRef())
|
||||||
}, reqSignIn, context.RepoAssignment(), repo.MustBeNotBare)
|
}, reqSignIn, context.RepoAssignment(), repo.MustBeNotBare)
|
||||||
|
|
||||||
m.Group("/:username/:reponame", func() {
|
m.Group("/:username/:reponame", func() {
|
||||||
|
|
10
conf/app.ini
10
conf/app.ini
|
@ -20,17 +20,17 @@ MAX_CREATION_LIMIT = -1
|
||||||
; Patch test queue length, make it as large as possible
|
; Patch test queue length, make it as large as possible
|
||||||
PULL_REQUEST_QUEUE_LENGTH = 10000
|
PULL_REQUEST_QUEUE_LENGTH = 10000
|
||||||
|
|
||||||
[editor]
|
[repository.editor]
|
||||||
; List of file extensions that should have line wraps in the CodeMirror 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
|
; Separate extensions with a comma. To line wrap files w/o extension, just put a comma
|
||||||
LINE_WRAP_EXTENSIONS = .txt,.md,.markdown,.mdown,.mkd,
|
LINE_WRAP_EXTENSIONS = .txt,.md,.markdown,.mdown,.mkd,
|
||||||
; Valid file modes that have a preview API associated with them, such as api/v1/markdown
|
; 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
|
; 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`
|
; 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)
|
; Path for uploads. Defaults to `data/tmp/uploads` (tmp gets deleted on gogs restart)
|
||||||
TEMP_PATH = data/tmp/uploads
|
TEMP_PATH = data/tmp/uploads
|
||||||
; One or more allowed types, e.g. image/jpeg|image/png. Nothing means any file type
|
; 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 =
|
CUSTOM_URL_SCHEMES =
|
||||||
; List of file extensions that should be rendered/edited as Markdown
|
; 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
|
; 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]
|
[server]
|
||||||
PROTOCOL = http
|
PROTOCOL = http
|
||||||
|
|
|
@ -427,7 +427,7 @@ func IsErrRepoFileAlreadyExist(err error) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (err ErrRepoFileAlreadyExist) Error() string {
|
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 {
|
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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -645,12 +645,12 @@ func newIssue(e *xorm.Session, repo *Repository, issue *Issue, labelIDs []int64,
|
||||||
if IsErrAttachmentNotExist(err) {
|
if IsErrAttachmentNotExist(err) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return fmt.Errorf("getAttachmentByUUID[%s]: %v", uuid, err)
|
return fmt.Errorf("getAttachmentByUUID [%s]: %v", uuid, err)
|
||||||
}
|
}
|
||||||
attachment.IssueID = issue.ID
|
attachment.IssueID = issue.ID
|
||||||
// No assign value could be 0, so ignore AllCols().
|
// No assign value could be 0, so ignore AllCols().
|
||||||
if _, err = e.Id(attachment.ID).Update(attachment); err != nil {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.
|
// UploadLocalPath returns where uploads is stored in local file system based on given UUID.
|
||||||
func UploadLocalPath(uuid string) string {
|
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.
|
// LocalPath returns where uploads are temporarily stored in local file system.
|
||||||
|
|
|
@ -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"},
|
"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-256": {"ecdsa", 256, "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFQacN3PrOll7PXmN5B/ZNVahiUIqI05nbBlZk1KXsO3d06ktAWqbNflv2vEmA38bTFTfJ2sbn2B5ksT52cDDbA= nocomment"},
|
||||||
"ecdsa-384": {"ecdsa", 384, "ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBINmioV+XRX1Fm9Qk2ehHXJ2tfVxW30ypUWZw670Zyq5GQfBAH6xjygRsJ5wWsHXBsGYgFUXIHvMKVAG1tpw7s6ax9oA+dJOJ7tj+vhn8joFqT+sg3LYHgZkHrfqryRasQ== 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() {
|
Convey("Parse public keys in both native and ssh-keygen", t, func() {
|
||||||
|
|
|
@ -47,6 +47,19 @@ func DeleteUpdateTaskByUUID(uuid string) error {
|
||||||
return err
|
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 {
|
func ListToPushCommits(l *list.List) *PushCommits {
|
||||||
commits := make([]*PushCommit, 0)
|
commits := make([]*PushCommit, 0)
|
||||||
var actEmail string
|
var actEmail string
|
||||||
|
@ -55,16 +68,7 @@ func ListToPushCommits(l *list.List) *PushCommits {
|
||||||
if actEmail == "" {
|
if actEmail == "" {
|
||||||
actEmail = commit.Committer.Email
|
actEmail = commit.Committer.Email
|
||||||
}
|
}
|
||||||
commits = append(commits,
|
commits = append(commits, CommitToPushCommit(commit))
|
||||||
&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,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return &PushCommits{l.Len(), commits, "", nil}
|
return &PushCommits{l.Len(), commits, "", nil}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -54,7 +54,7 @@ func isLink(link []byte) bool {
|
||||||
// based on its extension.
|
// based on its extension.
|
||||||
func IsMarkdownFile(name string) bool {
|
func IsMarkdownFile(name string) bool {
|
||||||
extension := strings.ToLower(filepath.Ext(name))
|
extension := strings.ToLower(filepath.Ext(name))
|
||||||
for _, ext := range setting.Markdown.MdFileExtensions {
|
for _, ext := range setting.Markdown.FileExtensions {
|
||||||
if strings.ToLower(ext) == extension {
|
if strings.ToLower(ext) == extension {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,16 +114,25 @@ var (
|
||||||
ForcePrivate bool
|
ForcePrivate bool
|
||||||
MaxCreationLimit int
|
MaxCreationLimit int
|
||||||
PullRequestQueueLength 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
|
RepoRootPath string
|
||||||
ScriptType string
|
ScriptType string
|
||||||
|
|
||||||
// Repo editor settings
|
|
||||||
Editor struct {
|
|
||||||
LineWrapExtensions []string
|
|
||||||
PreviewTabApis []string
|
|
||||||
}
|
|
||||||
|
|
||||||
// UI settings
|
// UI settings
|
||||||
UI struct {
|
UI struct {
|
||||||
ExplorePagingNum int
|
ExplorePagingNum int
|
||||||
|
@ -147,7 +156,7 @@ var (
|
||||||
Markdown struct {
|
Markdown struct {
|
||||||
EnableHardLineBreak bool
|
EnableHardLineBreak bool
|
||||||
CustomURLSchemes []string `ini:"CUSTOM_URL_SCHEMES"`
|
CustomURLSchemes []string `ini:"CUSTOM_URL_SCHEMES"`
|
||||||
MdFileExtensions []string
|
FileExtensions []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Picture settings
|
// Picture settings
|
||||||
|
@ -169,13 +178,6 @@ var (
|
||||||
AttachmentMaxFiles int
|
AttachmentMaxFiles int
|
||||||
AttachmentEnabled bool
|
AttachmentEnabled bool
|
||||||
|
|
||||||
// Repo Upload settings
|
|
||||||
UploadTempPath string
|
|
||||||
UploadAllowedTypes string
|
|
||||||
UploadMaxSize int64
|
|
||||||
UploadMaxFiles int
|
|
||||||
UploadEnabled bool
|
|
||||||
|
|
||||||
// Time settings
|
// Time settings
|
||||||
TimeFormat string
|
TimeFormat string
|
||||||
|
|
||||||
|
@ -494,17 +496,15 @@ func NewContext() {
|
||||||
ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
|
ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
|
||||||
if err = Cfg.Section("repository").MapTo(&Repository); err != nil {
|
if err = Cfg.Section("repository").MapTo(&Repository); err != nil {
|
||||||
log.Fatal(4, "Fail to map Repository settings: %v", err)
|
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")
|
if !filepath.IsAbs(Repository.Upload.TempPath) {
|
||||||
UploadTempPath = sec.Key("UPLOAD_TEMP_PATH").MustString(path.Join(AppDataPath, "tmp/uploads"))
|
Repository.Upload.TempPath = path.Join(workDir, Repository.Upload.TempPath)
|
||||||
if !filepath.IsAbs(UploadTempPath) {
|
|
||||||
UploadTempPath = path.Join(workDir, UploadTempPath)
|
|
||||||
}
|
}
|
||||||
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")
|
sec = Cfg.Section("picture")
|
||||||
AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString(path.Join(AppDataPath, "avatars"))
|
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 {
|
} else if err = Cfg.Section("git").MapTo(&Git); err != nil {
|
||||||
log.Fatal(4, "Fail to map Git settings: %v", err)
|
log.Fatal(4, "Fail to map Git settings: %v", err)
|
||||||
} else if err = Cfg.Section("mirror").MapTo(&Mirror); err != nil {
|
} 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 {
|
} else if err = Cfg.Section("api").MapTo(&API); err != nil {
|
||||||
log.Fatal(4, "Fail to map API settings: %v", err)
|
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 {
|
if Mirror.DefaultInterval <= 0 {
|
||||||
|
@ -572,10 +570,6 @@ func NewContext() {
|
||||||
ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool()
|
ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool()
|
||||||
|
|
||||||
HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
|
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 {
|
var Service struct {
|
||||||
|
|
|
@ -29,7 +29,7 @@ function initCommentPreviewTab($form) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var previewTab;
|
var previewTab;
|
||||||
var previewTabApis;
|
var previewFileModes;
|
||||||
|
|
||||||
function initEditPreviewTab($form) {
|
function initEditPreviewTab($form) {
|
||||||
var $tab_menu = $form.find('.tabular.menu');
|
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') + '"]');
|
previewTab = $tab_menu.find('.item[data-tab="' + $tab_menu.data('preview') + '"]');
|
||||||
|
|
||||||
if (previewTab.length) {
|
if (previewTab.length) {
|
||||||
previewTabApis = previewTab.data('preview-apis').split(',');
|
previewFileModes = previewTab.data('preview-file-modes').split(',');
|
||||||
previewTab.click(function () {
|
previewTab.click(function () {
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
$.post($this.data('url'), {
|
$.post($this.data('url'), {
|
||||||
|
@ -662,7 +662,7 @@ var editArea;
|
||||||
var editFilename;
|
var editFilename;
|
||||||
var smdEditor;
|
var smdEditor;
|
||||||
var cmEditor;
|
var cmEditor;
|
||||||
var mdFileExtensions;
|
var markdownFileExts;
|
||||||
var lineWrapExtensions;
|
var lineWrapExtensions;
|
||||||
|
|
||||||
// For IE
|
// For IE
|
||||||
|
@ -740,7 +740,7 @@ function initEditor() {
|
||||||
if (!editArea.length)
|
if (!editArea.length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mdFileExtensions = editArea.data("md-file-extensions").split(",");
|
markdownFileExts = editArea.data("markdown-file-exts").split(",");
|
||||||
lineWrapExtensions = editArea.data("line-wrap-extensions").split(",");
|
lineWrapExtensions = editArea.data("line-wrap-extensions").split(",");
|
||||||
|
|
||||||
editFilename.on("keyup", function (e) {
|
editFilename.on("keyup", function (e) {
|
||||||
|
@ -762,7 +762,7 @@ function initEditor() {
|
||||||
apiCall = extension
|
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');
|
dataUrl = previewLink.data('url');
|
||||||
previewLink.data('url', dataUrl.replace(/(.*)\/.*/i, '$1/' + mode));
|
previewLink.data('url', dataUrl.replace(/(.*)\/.*/i, '$1/' + mode));
|
||||||
previewLink.show();
|
previewLink.show();
|
||||||
|
@ -772,7 +772,7 @@ function initEditor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this file is a Markdown extensions, we will load that editor and return
|
// 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()) {
|
if (setSimpleMDE()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,12 +65,7 @@ func NewBranchPost(ctx *context.Context, form auth.NewBranchForm) {
|
||||||
} else {
|
} else {
|
||||||
pc := &models.PushCommits{
|
pc := &models.PushCommits{
|
||||||
Len: 1,
|
Len: 1,
|
||||||
Commits: []*models.PushCommit{&models.PushCommit{
|
Commits: []*models.PushCommit{models.CommitToPushCommit(commit)},
|
||||||
commit.ID.String(),
|
|
||||||
commit.Message(),
|
|
||||||
commit.Author.Email,
|
|
||||||
commit.Author.Name,
|
|
||||||
}},
|
|
||||||
}
|
}
|
||||||
oldCommitID := "0000000000000000000000000000000000000000" // New Branch so we use all 0s
|
oldCommitID := "0000000000000000000000000000000000000000" // New Branch so we use all 0s
|
||||||
newCommitID := commit.ID.String()
|
newCommitID := commit.ID.String()
|
||||||
|
|
|
@ -33,12 +33,7 @@ func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) {
|
||||||
} else {
|
} else {
|
||||||
pc := &models.PushCommits{
|
pc := &models.PushCommits{
|
||||||
Len: 1,
|
Len: 1,
|
||||||
Commits: []*models.PushCommit{&models.PushCommit{
|
Commits: []*models.PushCommit{models.CommitToPushCommit(commit)},
|
||||||
commit.ID.String(),
|
|
||||||
commit.Message(),
|
|
||||||
commit.Author.Email,
|
|
||||||
commit.Author.Name,
|
|
||||||
}},
|
|
||||||
}
|
}
|
||||||
oldCommitID := ctx.Repo.CommitID
|
oldCommitID := ctx.Repo.CommitID
|
||||||
newCommitID := commit.ID.String()
|
newCommitID := commit.ID.String()
|
||||||
|
|
|
@ -89,7 +89,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
||||||
d, _ := ioutil.ReadAll(dataRc)
|
d, _ := ioutil.ReadAll(dataRc)
|
||||||
buf = append(buf, d...)
|
buf = append(buf, d...)
|
||||||
|
|
||||||
if err, content := template.ToUtf8WithErr(buf); err != nil {
|
if err, content := template.ToUTF8WithErr(buf); err != nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(4, "Convert content encoding: %s", err)
|
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["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["CreateNewBranch"] = ctx.Tr("repo.create_new_branch", "<strong>"+ctx.Tr("repo.new_branch")+"</strong>")
|
||||||
ctx.Data["LastCommit"] = ctx.Repo.Commit.ID
|
ctx.Data["LastCommit"] = ctx.Repo.Commit.ID
|
||||||
ctx.Data["MdFileExtensions"] = strings.Join(setting.Markdown.MdFileExtensions, ",")
|
ctx.Data["MarkdownFileExts"] = strings.Join(setting.Markdown.FileExtensions, ",")
|
||||||
ctx.Data["LineWrapExtensions"] = strings.Join(setting.Editor.LineWrapExtensions, ",")
|
ctx.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",")
|
||||||
ctx.Data["PreviewTabApis"] = strings.Join(setting.Editor.PreviewTabApis, ",")
|
ctx.Data["PreviewableFileModes"] = strings.Join(setting.Repository.Editor.PreviewableFileModes, ",")
|
||||||
ctx.Data["PreviewDiffUrl"] = ctx.Repo.RepoLink + "/preview/" + branchName + "/" + treeName
|
ctx.Data["PreviewDiffURL"] = ctx.Repo.RepoLink + "/preview/" + branchName + "/" + treeName
|
||||||
|
|
||||||
ctx.HTML(200, EDIT)
|
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["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["CreateNewBranch"] = ctx.Tr("repo.create_new_branch", "<strong>"+ctx.Tr("repo.new_branch")+"</strong>")
|
||||||
ctx.Data["LastCommit"] = ctx.Repo.Commit.ID
|
ctx.Data["LastCommit"] = ctx.Repo.Commit.ID
|
||||||
ctx.Data["MdFileExtensions"] = strings.Join(setting.Markdown.MdFileExtensions, ",")
|
ctx.Data["MarkdownFileExts"] = strings.Join(setting.Markdown.FileExtensions, ",")
|
||||||
ctx.Data["LineWrapExtensions"] = strings.Join(setting.Editor.LineWrapExtensions, ",")
|
ctx.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",")
|
||||||
ctx.Data["PreviewTabApis"] = strings.Join(setting.Editor.PreviewTabApis, ",")
|
ctx.Data["PreviewableFileModes"] = strings.Join(setting.Repository.Editor.PreviewableFileModes, ",")
|
||||||
ctx.Data["PreviewDiffUrl"] = ctx.Repo.RepoLink + "/preview/" + branchName + "/" + treeName
|
ctx.Data["PreviewDiffURL"] = ctx.Repo.RepoLink + "/preview/" + branchName + "/" + treeName
|
||||||
|
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
ctx.HTML(200, EDIT)
|
ctx.HTML(200, EDIT)
|
||||||
|
@ -294,12 +294,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||||
} else {
|
} else {
|
||||||
pc := &models.PushCommits{
|
pc := &models.PushCommits{
|
||||||
Len: 1,
|
Len: 1,
|
||||||
Commits: []*models.PushCommit{&models.PushCommit{
|
Commits: []*models.PushCommit{models.CommitToPushCommit(commit)},
|
||||||
commit.ID.String(),
|
|
||||||
commit.Message(),
|
|
||||||
commit.Author.Email,
|
|
||||||
commit.Author.Name,
|
|
||||||
}},
|
|
||||||
}
|
}
|
||||||
oldCommitID := ctx.Repo.CommitID
|
oldCommitID := ctx.Repo.CommitID
|
||||||
newCommitID := commit.ID.String()
|
newCommitID := commit.ID.String()
|
||||||
|
|
|
@ -24,10 +24,10 @@ const (
|
||||||
|
|
||||||
func renderUploadSettings(ctx *context.Context) {
|
func renderUploadSettings(ctx *context.Context) {
|
||||||
ctx.Data["RequireDropzone"] = true
|
ctx.Data["RequireDropzone"] = true
|
||||||
ctx.Data["IsUploadEnabled"] = setting.UploadEnabled
|
ctx.Data["IsUploadEnabled"] = setting.Repository.Upload.Enabled
|
||||||
ctx.Data["UploadAllowedTypes"] = setting.UploadAllowedTypes
|
ctx.Data["UploadAllowedTypes"] = strings.Join(setting.Repository.Upload.AllowedTypes, ",")
|
||||||
ctx.Data["UploadMaxSize"] = setting.UploadMaxSize
|
ctx.Data["UploadMaxSize"] = setting.Repository.Upload.FileMaxSize
|
||||||
ctx.Data["UploadMaxFiles"] = setting.UploadMaxFiles
|
ctx.Data["UploadMaxFiles"] = setting.Repository.Upload.MaxFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
func UploadFile(ctx *context.Context) {
|
func UploadFile(ctx *context.Context) {
|
||||||
|
@ -155,12 +155,7 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) {
|
||||||
} else {
|
} else {
|
||||||
pc := &models.PushCommits{
|
pc := &models.PushCommits{
|
||||||
Len: 1,
|
Len: 1,
|
||||||
Commits: []*models.PushCommit{&models.PushCommit{
|
Commits: []*models.PushCommit{models.CommitToPushCommit(commit)},
|
||||||
commit.ID.String(),
|
|
||||||
commit.Message(),
|
|
||||||
commit.Author.Email,
|
|
||||||
commit.Author.Name,
|
|
||||||
}},
|
|
||||||
}
|
}
|
||||||
oldCommitID := ctx.Repo.CommitID
|
oldCommitID := ctx.Repo.CommitID
|
||||||
newCommitID := commit.ID.String()
|
newCommitID := commit.ID.String()
|
||||||
|
@ -184,7 +179,7 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func UploadFileToServer(ctx *context.Context) {
|
func UploadFileToServer(ctx *context.Context) {
|
||||||
if !setting.UploadEnabled {
|
if !setting.Repository.Upload.Enabled {
|
||||||
ctx.Error(404, "upload is not enabled")
|
ctx.Error(404, "upload is not enabled")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -203,10 +198,9 @@ func UploadFileToServer(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
fileType := http.DetectContentType(buf)
|
fileType := http.DetectContentType(buf)
|
||||||
|
|
||||||
if len(setting.UploadAllowedTypes) > 0 {
|
if len(setting.Repository.Upload.AllowedTypes) > 0 {
|
||||||
allowedTypes := strings.Split(setting.UploadAllowedTypes, ",")
|
|
||||||
allowed := false
|
allowed := false
|
||||||
for _, t := range allowedTypes {
|
for _, t := range setting.Repository.Upload.AllowedTypes {
|
||||||
t := strings.Trim(t, " ")
|
t := strings.Trim(t, " ")
|
||||||
if t == "*/*" || t == fileType {
|
if t == "*/*" || t == fileType {
|
||||||
allowed = true
|
allowed = true
|
||||||
|
@ -233,7 +227,7 @@ func UploadFileToServer(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func RemoveUploadFileFromServer(ctx *context.Context, form auth.RemoveUploadFileForm) {
|
func RemoveUploadFileFromServer(ctx *context.Context, form auth.RemoveUploadFileForm) {
|
||||||
if !setting.UploadEnabled {
|
if !setting.Repository.Upload.Enabled {
|
||||||
ctx.Error(404, "upload is not enabled")
|
ctx.Error(404, "upload is not enabled")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ func Home(ctx *context.Context) {
|
||||||
ctx.Data["LastCommitUser"] = models.ValidateCommitWithEmail(lastCommit)
|
ctx.Data["LastCommitUser"] = models.ValidateCommitWithEmail(lastCommit)
|
||||||
if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch {
|
if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch {
|
||||||
ctx.Data["NewFileLink"] = newFileLink + "/" + treename
|
ctx.Data["NewFileLink"] = newFileLink + "/" + treename
|
||||||
if setting.UploadEnabled {
|
if !setting.Repository.Upload.Enabled {
|
||||||
ctx.Data["UploadFileLink"] = uploadFileLink + "/" + treename
|
ctx.Data["UploadFileLink"] = uploadFileLink + "/" + treename
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,14 +30,14 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="ui top attached tabular menu" data-write="write" data-preview="preview" data-diff="diff">
|
<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="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="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>
|
<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>
|
||||||
<div class="ui bottom attached active tab segment" data-tab="write">
|
<div class="ui bottom attached active tab segment" data-tab="write">
|
||||||
<textarea id="edit_area" name="content" data-id="repo-{{.Repository.Name}}-{{.TreeName}}"
|
<textarea id="edit_area" name="content" data-id="repo-{{.Repository.Name}}-{{.TreeName}}"
|
||||||
data-url="{{AppSubUrl}}/api/v1/markdown"
|
data-url="{{AppSubUrl}}/api/v1/markdown"
|
||||||
data-context="{{.RepoLink}}"
|
data-context="{{.RepoLink}}"
|
||||||
data-md-file-extensions="{{.MdFileExtensions}}"
|
data-markdown-file-exts="{{.MarkdownFileExts}}"
|
||||||
data-line-wrap-extensions="{{.LineWrapExtensions}}">
|
data-line-wrap-extensions="{{.LineWrapExtensions}}">
|
||||||
{{.FileContent}}</textarea required>
|
{{.FileContent}}</textarea required>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue