forgejo/templates/repo/editor/upload.tmpl
Giteabot 889469fb74
Convert max file name length to 255 (#30489) (#30504)
Backport #30489 by @yp05327

Quick/Partly fix #29907

In Linux and MacOS, by default the max file name length is 255.
In windows, it depends on the version and settings, and has no file name
length limitation, but has path length limitation.
By default it is 260, considering path length is longer than filename,
so I think it is ok to do this.

For Windows, see
https://learn.microsoft.com/windows/win32/fileio/maximum-file-path-limitation?tabs=registry
For Linux, see
https://github.com/torvalds/linux/blob/master/include/uapi/linux/limits.h#L12-L13
For MacOS, see
https://discussions.apple.com/thread/254788848?sortBy=best

Co-authored-by: yp05327 <576951401@qq.com>
(cherry picked from commit f52b1db305f887c917e6c875b8ac4f8b784b825b)
2024-04-21 18:06:23 +02:00

33 lines
1.5 KiB
Go HTML Template

{{template "base/head" .}}
<div role="main" aria-label="{{.Title}}" class="page-content repository file editor upload">
{{template "repo/header" .}}
<div class="ui container">
{{template "base/alert" .}}
<form class="ui comment form" method="post">
{{.CsrfTokenHtml}}
<div class="repo-editor-header">
<div class="ui breadcrumb field {{if .Err_TreePath}}error{{end}}">
<a class="section" href="{{$.BranchLink}}">{{.Repository.Name}}</a>
{{$n := len .TreeNames}}
{{$l := Eval $n "-" 1}}
{{range $i, $v := .TreeNames}}
<div class="breadcrumb-divider">/</div>
{{if eq $i $l}}
<input type="text" id="file-name" maxlength="255" value="{{$v}}" placeholder="{{ctx.Locale.Tr "repo.editor.add_subdir"}}" autofocus>
<span data-tooltip-content="{{ctx.Locale.Tr "repo.editor.filename_help"}}">{{svg "octicon-info"}}</span>
{{else}}
<span class="section"><a href="{{$.BranchLink}}/{{index $.TreePaths $i | PathEscapeSegments}}">{{$v}}</a></span>
{{end}}
{{end}}
<span>{{ctx.Locale.Tr "repo.editor.or"}} <a href="{{$.BranchLink}}{{if not .IsNewFile}}/{{.TreePath | PathEscapeSegments}}{{end}}">{{ctx.Locale.Tr "repo.editor.cancel_lower"}}</a></span>
<input type="hidden" id="tree_path" name="tree_path" value="{{.TreePath}}" required>
</div>
</div>
<div class="field">
{{template "repo/upload" .}}
</div>
{{template "repo/editor/commit_form" .}}
</form>
</div>
</div>
{{template "base/footer" .}}