Merge branch 'develop'
This commit is contained in:
commit
c04df49a78
|
@ -22,6 +22,7 @@ type BatchFileResponse struct {
|
||||||
|
|
||||||
type ContentsResponse struct {
|
type ContentsResponse struct {
|
||||||
*gitea_api.ContentsResponse
|
*gitea_api.ContentsResponse
|
||||||
|
IsTextFile bool `json:"is_text_file"`
|
||||||
LatestCommit ContentsResponseCommit `json:"latest_commit"`
|
LatestCommit ContentsResponseCommit `json:"latest_commit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,12 +137,12 @@ func GetReadmeContents(ctx *context.APIContext) {
|
||||||
readmeSortArr := []string{"readme", "readme.en.md", "readme_en.md", "readme.md", "readme.ch.md", "readme_ch.md", "readme.zh.md", "readme_zh.md", "readme.cn.md", "readme_cn.md"}
|
readmeSortArr := []string{"readme", "readme.en.md", "readme_en.md", "readme.md", "readme.ch.md", "readme_ch.md", "readme.zh.md", "readme_zh.md", "readme.cn.md", "readme_cn.md"}
|
||||||
readmePath := ""
|
readmePath := ""
|
||||||
readmePathInArrIndex := 0
|
readmePathInArrIndex := 0
|
||||||
filesListInterface, err := files_service.GetContentsOrList(ctx, ctx.Repo.Repository, "", ref)
|
filesListInterface, err := hat_files_service.GetContentsOrList(ctx, ctx.Repo.Repository, "", ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "GetContentsOrList", err)
|
ctx.Error(http.StatusInternalServerError, "GetContentsOrList", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
filesList, ok := filesListInterface.([]*api.ContentsResponse)
|
filesList, ok := filesListInterface.([]*hat_api.ContentsResponse)
|
||||||
if ok {
|
if ok {
|
||||||
for _, file := range filesList {
|
for _, file := range filesList {
|
||||||
for i, sortItem := range readmeSortArr {
|
for i, sortItem := range readmeSortArr {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
gitea_api "code.gitea.io/gitea/modules/structs"
|
gitea_api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/typesniffer"
|
||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
gitea_files_service "code.gitea.io/gitea/services/repository/files"
|
gitea_files_service "code.gitea.io/gitea/services/repository/files"
|
||||||
hat_api "code.gitlink.org.cn/Gitlink/gitea_hat.git/modules/structs"
|
hat_api "code.gitlink.org.cn/Gitlink/gitea_hat.git/modules/structs"
|
||||||
|
@ -133,6 +134,24 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
var isTextFile = false
|
||||||
|
|
||||||
|
if !entry.IsSubModule() {
|
||||||
|
blob, err := gitRepo.GetBlob(entry.ID.String())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
dataRc, err := blob.DataAsync()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
buf := make([]byte, 1024)
|
||||||
|
n, _ := util.ReadAtMost(dataRc, buf)
|
||||||
|
buf = buf[:n]
|
||||||
|
|
||||||
|
st := typesniffer.DetectContentType(buf)
|
||||||
|
isTextFile = st.IsText()
|
||||||
|
}
|
||||||
|
|
||||||
contentsResponse := &hat_api.ContentsResponse{
|
contentsResponse := &hat_api.ContentsResponse{
|
||||||
ContentsResponse: &gitea_api.ContentsResponse{
|
ContentsResponse: &gitea_api.ContentsResponse{
|
||||||
|
@ -146,6 +165,7 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref
|
||||||
Self: &selfURLString,
|
Self: &selfURLString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
IsTextFile: isTextFile,
|
||||||
LatestCommit: hat_api.ContentsResponseCommit{
|
LatestCommit: hat_api.ContentsResponseCommit{
|
||||||
Message: lastCommit.CommitMessage,
|
Message: lastCommit.CommitMessage,
|
||||||
Sha: lastCommit.ID.String(),
|
Sha: lastCommit.ID.String(),
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<span class="text red hide" id="name-change-prompt"> {{.locale.Tr "settings.change_username_prompt"}}</span>
|
<span class="text red hide" id="name-change-prompt"> {{.locale.Tr "settings.change_username_prompt"}}</span>
|
||||||
<span class="text red hide" id="name-change-redirect-prompt"> {{.locale.Tr "settings.change_username_redirect_prompt"}}</span>
|
<span class="text red hide" id="name-change-redirect-prompt"> {{.locale.Tr "settings.change_username_redirect_prompt"}}</span>
|
||||||
</label>
|
</label>
|
||||||
<input id="username" name="name" value="{{.SignedUser.Name}}" data-name="{{.SignedUser.Name}}" autofocus required {{if or (not .SignedUser.IsLocal) .IsReverseProxy}}disabled{{end}}>
|
<input id="username" name="name" value="{{.SignedUser.Name}}" data-name="{{.SignedUser.Name}}" autofocus required disabled {{if or (not .SignedUser.IsLocal) .IsReverseProxy}}disabled{{end}}>
|
||||||
{{if or (not .SignedUser.IsLocal) .IsReverseProxy}}
|
{{if or (not .SignedUser.IsLocal) .IsReverseProxy}}
|
||||||
<p class="help text blue">{{$.locale.Tr "settings.password_username_disabled"}}</p>
|
<p class="help text blue">{{$.locale.Tr "settings.password_username_disabled"}}</p>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in New Issue