Support Editorconfig on web editor (#3512)
This commit is contained in:
commit
cd9b926af7
7 changed files with 53 additions and 3 deletions
|
@ -290,6 +290,7 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||
Patch(reqRepoWriter(), bind(api.EditMilestoneOption{}), repo.EditMilestone).
|
||||
Delete(reqRepoWriter(), repo.DeleteMilestone)
|
||||
})
|
||||
m.Get("/editorconfig/:filename", context.RepoRef(), repo.GetEditorconfig)
|
||||
}, repoAssignment())
|
||||
}, reqToken())
|
||||
|
||||
|
|
|
@ -45,3 +45,23 @@ func GetArchive(ctx *context.APIContext) {
|
|||
|
||||
repo.Download(ctx.Context)
|
||||
}
|
||||
|
||||
func GetEditorconfig(ctx *context.APIContext) {
|
||||
ec, err := ctx.Repo.GetEditorconfig()
|
||||
if err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
ctx.Error(404, "GetEditorconfig", err)
|
||||
} else {
|
||||
ctx.Error(500, "GetEditorconfig", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fileName := ctx.Params("filename")
|
||||
def := ec.GetDefinitionForFilename(fileName)
|
||||
if def == nil {
|
||||
ctx.Error(404, "GetDefinitionForFilename", err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(200, def)
|
||||
}
|
||||
|
|
|
@ -98,6 +98,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
|||
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["EditorconfigURLPrefix"] = fmt.Sprintf("%s/api/v1/repos/%s/editorconfig/", setting.AppSubUrl, ctx.Repo.Repository.FullName())
|
||||
|
||||
ctx.HTML(200, EDIT_FILE)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue