0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-10-16 18:34:19 -04:00

Fix code tag style problem and LFS view bug (#35628) (#35636)

Backport #35628 by lutinglt

Signed-off-by: 鲁汀 <131967983+lutinglt@users.noreply.github.com>
Co-authored-by: 鲁汀 <131967983+lutinglt@users.noreply.github.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Giteabot
2025-10-12 04:25:03 +08:00
committed by GitHub
parent a3458c669a
commit f4512426a1
11 changed files with 33 additions and 25 deletions

View File

@@ -270,8 +270,7 @@ func LFSFileGet(ctx *context.Context) {
// FIXME: there is no IsPlainText set, but template uses it // FIXME: there is no IsPlainText set, but template uses it
ctx.Data["IsTextFile"] = st.IsText() ctx.Data["IsTextFile"] = st.IsText()
ctx.Data["FileSize"] = meta.Size ctx.Data["FileSize"] = meta.Size
// FIXME: the last field is the URL-base64-encoded filename, it should not be "direct" ctx.Data["RawFileLink"] = fmt.Sprintf("%s/%s/%s.git/info/lfs/objects/%s", setting.AppSubURL, url.PathEscape(ctx.Repo.Repository.OwnerName), url.PathEscape(ctx.Repo.Repository.Name), url.PathEscape(meta.Oid))
ctx.Data["RawFileLink"] = fmt.Sprintf("%s%s/%s.git/info/lfs/objects/%s/%s", setting.AppURL, url.PathEscape(ctx.Repo.Repository.OwnerName), url.PathEscape(ctx.Repo.Repository.Name), url.PathEscape(meta.Oid), "direct")
switch { switch {
case st.IsRepresentableAsText(): case st.IsRepresentableAsText():
if meta.Size >= setting.UI.MaxDisplayFileSize { if meta.Size >= setting.UI.MaxDisplayFileSize {

View File

@@ -252,9 +252,9 @@
{{end}} {{end}}
{{if .CacheConn}} {{if .CacheConn}}
<dt>{{ctx.Locale.Tr "admin.config.cache_conn"}}</dt> <dt>{{ctx.Locale.Tr "admin.config.cache_conn"}}</dt>
<dd><code>{{.CacheConn}}</code></dd> <dd>{{.CacheConn}}</dd>
<dt>{{ctx.Locale.Tr "admin.config.cache_item_ttl"}}</dt> <dt>{{ctx.Locale.Tr "admin.config.cache_item_ttl"}}</dt>
<dd><code>{{.CacheItemTTL}}</code></dd> <dd>{{.CacheItemTTL}}</dd>
{{end}} {{end}}
<div class="divider"></div> <div class="divider"></div>
<dt class="tw-py-1 tw-flex tw-items-center">{{ctx.Locale.Tr "admin.config.cache_test"}}</dt> <dt class="tw-py-1 tw-flex tw-items-center">{{ctx.Locale.Tr "admin.config.cache_test"}}</dt>
@@ -275,7 +275,7 @@
<dt>{{ctx.Locale.Tr "admin.config.session_provider"}}</dt> <dt>{{ctx.Locale.Tr "admin.config.session_provider"}}</dt>
<dd>{{.SessionConfig.Provider}}</dd> <dd>{{.SessionConfig.Provider}}</dd>
<dt>{{ctx.Locale.Tr "admin.config.provider_config"}}</dt> <dt>{{ctx.Locale.Tr "admin.config.provider_config"}}</dt>
<dd><code>{{if .SessionConfig.ProviderConfig}}{{.SessionConfig.ProviderConfig}}{{else}}-{{end}}</code></dd> <dd>{{if .SessionConfig.ProviderConfig}}{{.SessionConfig.ProviderConfig}}{{else}}-{{end}}</dd>
<dt>{{ctx.Locale.Tr "admin.config.cookie_name"}}</dt> <dt>{{ctx.Locale.Tr "admin.config.cookie_name"}}</dt>
<dd>{{.SessionConfig.CookieName}}</dd> <dd>{{.SessionConfig.CookieName}}</dd>
<dt>{{ctx.Locale.Tr "admin.config.gc_interval_time"}}</dt> <dt>{{ctx.Locale.Tr "admin.config.gc_interval_time"}}</dt>
@@ -301,7 +301,7 @@
<dt>{{ctx.Locale.Tr "admin.config.git_max_diff_files"}}</dt> <dt>{{ctx.Locale.Tr "admin.config.git_max_diff_files"}}</dt>
<dd>{{.Git.MaxGitDiffFiles}}</dd> <dd>{{.Git.MaxGitDiffFiles}}</dd>
<dt>{{ctx.Locale.Tr "admin.config.git_gc_args"}}</dt> <dt>{{ctx.Locale.Tr "admin.config.git_gc_args"}}</dt>
<dd><code>{{.Git.GCArgs}}</code></dd> <dd>{{.Git.GCArgs}}</dd>
<div class="divider"></div> <div class="divider"></div>
@@ -330,7 +330,7 @@
{{if .Loggers.access.IsEnabled}} {{if .Loggers.access.IsEnabled}}
<dt>{{ctx.Locale.Tr "admin.config.access_log_template"}}</dt> <dt>{{ctx.Locale.Tr "admin.config.access_log_template"}}</dt>
<dd><code>{{$.AccessLogTemplate}}</code></dd> <dd>{{$.AccessLogTemplate}}</dd>
{{end}} {{end}}
{{range $loggerName, $loggerDetail := .Loggers}} {{range $loggerName, $loggerDetail := .Loggers}}

View File

@@ -46,8 +46,8 @@
<div class="item tw-flex tw-items-center"> <div class="item tw-flex tw-items-center">
<span class="icon tw-mr-4">{{svg "octicon-dot-fill" 16}}</span> <span class="icon tw-mr-4">{{svg "octicon-dot-fill" 16}}</span>
<div class="content tw-flex-1"> <div class="content tw-flex-1">
<div class="header"><code>{{.Function}}</code></div> <div class="header">{{.Function}}</div>
<div class="description"><code>{{.File}}:{{.Line}}</code></div> <div class="description">{{.File}}:{{.Line}}</div>
</div> </div>
</div> </div>
{{end}} {{end}}

View File

@@ -2,7 +2,7 @@
{{if .Details}} {{if .Details}}
<details> <details>
<summary>{{.Summary}}</summary> <summary>{{.Summary}}</summary>
<code>{{.Details | SanitizeHTML}}</code> {{.Details | SanitizeHTML}}
</details> </details>
{{else}} {{else}}
<div> <div>

View File

@@ -65,7 +65,9 @@
</div> </div>
<div class="ui container project-description"> <div class="ui container project-description">
{{$.Project.RenderedContent}} <div class="render-content markup">
{{$.Project.RenderedContent}}
</div>
<div class="divider"></div> <div class="divider"></div>
</div> </div>

View File

@@ -39,7 +39,7 @@
<tbody> <tbody>
<tr> <tr>
<td class="lines-num">{{.LineNums}}</td> <td class="lines-num">{{.LineNums}}</td>
<td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol>{{.FileContent}}</ol></code></pre></td> <td class="lines-code"><pre>{{.FileContent}}</pre></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@@ -68,7 +68,7 @@
{{range $key, $val := .RequestInfo.Headers}}<strong>{{$key}}:</strong> {{$val}} {{range $key, $val := .RequestInfo.Headers}}<strong>{{$key}}:</strong> {{$val}}
{{end}}</pre> {{end}}</pre>
<h5>{{ctx.Locale.Tr "repo.settings.webhook.payload"}}</h5> <h5>{{ctx.Locale.Tr "repo.settings.webhook.payload"}}</h5>
<pre class="webhook-info"><code class="json">{{or .RequestInfo.Body .PayloadContent}}</code></pre> <pre class="webhook-info">{{or .RequestInfo.Body .PayloadContent}}</pre>
{{else}} {{else}}
- -
{{end}} {{end}}
@@ -79,7 +79,7 @@
<pre class="webhook-info">{{range $key, $val := .ResponseInfo.Headers}}<strong>{{$key}}:</strong> {{$val}} <pre class="webhook-info">{{range $key, $val := .ResponseInfo.Headers}}<strong>{{$key}}:</strong> {{$val}}
{{end}}</pre> {{end}}</pre>
<h5>{{ctx.Locale.Tr "repo.settings.webhook.body"}}</h5> <h5>{{ctx.Locale.Tr "repo.settings.webhook.body"}}</h5>
<pre class="webhook-info"><code>{{.ResponseInfo.Body}}</code></pre> <pre class="webhook-info">{{.ResponseInfo.Body}}</pre>
{{else}} {{else}}
- -
{{end}} {{end}}

View File

@@ -21,8 +21,8 @@
<label for="token">{{ctx.Locale.Tr "settings.gpg_token"}}</label> <label for="token">{{ctx.Locale.Tr "settings.gpg_token"}}</label>
<input readonly="" value="{{.TokenToSign}}"> <input readonly="" value="{{.TokenToSign}}">
<div class="help"> <div class="help">
<p>{{ctx.Locale.Tr "settings.gpg_token_help"}}</p> {{ctx.Locale.Tr "settings.gpg_token_help"}}
<p><code>{{printf `echo "%s" | gpg -a --default-key %s --detach-sig` .TokenToSign .PaddedKeyID}}</code></p> <pre class="command-block">{{printf `echo "%s" | gpg -a --default-key %s --detach-sig` .TokenToSign .PaddedKeyID}}</pre>
</div> </div>
</div> </div>
<div class="field"> <div class="field">
@@ -89,8 +89,8 @@
<label for="token">{{ctx.Locale.Tr "settings.gpg_token"}}</label> <label for="token">{{ctx.Locale.Tr "settings.gpg_token"}}</label>
<input readonly="" value="{{$.TokenToSign}}"> <input readonly="" value="{{$.TokenToSign}}">
<div class="help"> <div class="help">
<p>{{ctx.Locale.Tr "settings.gpg_token_help"}}</p> {{ctx.Locale.Tr "settings.gpg_token_help"}}
<p><code>{{printf `echo "%s" | gpg -a --default-key %s --detach-sig` $.TokenToSign .PaddedKeyID}}</code></p> <pre class="command-block">{{printf `echo "%s" | gpg -a --default-key %s --detach-sig` $.TokenToSign .PaddedKeyID}}</pre>
</div> </div>
<br> <br>
</div> </div>

View File

@@ -77,16 +77,15 @@
<label for="token">{{ctx.Locale.Tr "settings.ssh_token"}}</label> <label for="token">{{ctx.Locale.Tr "settings.ssh_token"}}</label>
<input readonly="" value="{{$.TokenToSign}}"> <input readonly="" value="{{$.TokenToSign}}">
<div class="help"> <div class="help">
<p>{{ctx.Locale.Tr "settings.ssh_token_help"}}</p> {{ctx.Locale.Tr "settings.ssh_token_help"}}
<p><code>echo -n '{{$.TokenToSign}}' | ssh-keygen -Y sign -n gitea -f /path_to_PrivateKey_or_RelatedPublicKey</code></p> <pre class="command-block">echo -n '{{$.TokenToSign}}' | ssh-keygen -Y sign -n gitea -f /path_to_PrivateKey_or_RelatedPublicKey</pre>
<details> <details>
<summary>Windows PowerShell</summary> <summary>Windows PowerShell</summary>
<p><code>cmd /c "&lt;NUL set /p=`"{{$.TokenToSign}}`"| ssh-keygen -Y sign -n gitea -f /path_to_PrivateKey_or_RelatedPublicKey"</code></p> <pre class="command-block">cmd /c "&lt;NUL set /p=`"{{$.TokenToSign}}`"| ssh-keygen -Y sign -n gitea -f /path_to_PrivateKey_or_RelatedPublicKey"</pre>
</details> </details>
<br>
<details> <details>
<summary>Windows CMD</summary> <summary>Windows CMD</summary>
<p><code>set /p={{$.TokenToSign}}| ssh-keygen -Y sign -n gitea -f /path_to_PrivateKey_or_RelatedPublicKey</code></p> <pre class="command-block">set /p={{$.TokenToSign}}| ssh-keygen -Y sign -n gitea -f /path_to_PrivateKey_or_RelatedPublicKey</pre>
</details> </details>
</div> </div>
<br> <br>

View File

@@ -101,11 +101,13 @@ samp,
font-size: 0.95em; /* compensate for monospace fonts being usually slightly larger */ font-size: 0.95em; /* compensate for monospace fonts being usually slightly larger */
} }
code { /* there are many <code> blocks in non-markup(.markup code) / non-code-diff(code.code-inner) containers (for example: translation strings, etc),
so we need to make <code> have default global styles, ".markup code" has its own styles and doesn't conflict, but `.code-inner` is special.
TODO: in the future, we should use `div` instead of `code` for `.code-inner` because it is a container for highlighted code line */
code:not(.code-inner) {
padding: 1px 4px; padding: 1px 4px;
border-radius: var(--border-radius); border-radius: var(--border-radius);
background-color: var(--color-label-bg); background-color: var(--color-label-bg);
color: var(--color-label-text);
} }
b, b,

View File

@@ -228,6 +228,12 @@ textarea:focus,
color: var(--color-text-light-1); color: var(--color-text-light-1);
} }
.form .help pre.command-block {
white-space: pre-wrap;
overflow-wrap: anywhere;
margin: 0.25em 0 0.25em 1em;
}
.m-captcha-style { .m-captcha-style {
width: 100%; width: 100%;
height: 5em; height: 5em;