Skip to content

Commit b029ad4

Browse files
lutingltwxiaoguang
andauthored
Fix code tag style problem and LFS view bug (go-gitea#35628)
Fix go-gitea#35567 --------- Signed-off-by: 鲁汀 <[email protected]> Co-authored-by: wxiaoguang <[email protected]>
1 parent 40f71bc commit b029ad4

File tree

11 files changed

+33
-25
lines changed

11 files changed

+33
-25
lines changed

routers/web/repo/setting/lfs.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,7 @@ func LFSFileGet(ctx *context.Context) {
270270
// FIXME: there is no IsPlainText set, but template uses it
271271
ctx.Data["IsTextFile"] = st.IsText()
272272
ctx.Data["FileSize"] = meta.Size
273-
// FIXME: the last field is the URL-base64-encoded filename, it should not be "direct"
274-
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")
273+
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))
275274
switch {
276275
case st.IsRepresentableAsText():
277276
if meta.Size >= setting.UI.MaxDisplayFileSize {

templates/admin/config.tmpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@
252252
{{end}}
253253
{{if .CacheConn}}
254254
<dt>{{ctx.Locale.Tr "admin.config.cache_conn"}}</dt>
255-
<dd><code>{{.CacheConn}}</code></dd>
255+
<dd>{{.CacheConn}}</dd>
256256
<dt>{{ctx.Locale.Tr "admin.config.cache_item_ttl"}}</dt>
257-
<dd><code>{{.CacheItemTTL}}</code></dd>
257+
<dd>{{.CacheItemTTL}}</dd>
258258
{{end}}
259259
<div class="divider"></div>
260260
<dt class="tw-py-1 tw-flex tw-items-center">{{ctx.Locale.Tr "admin.config.cache_test"}}</dt>
@@ -275,7 +275,7 @@
275275
<dt>{{ctx.Locale.Tr "admin.config.session_provider"}}</dt>
276276
<dd>{{.SessionConfig.Provider}}</dd>
277277
<dt>{{ctx.Locale.Tr "admin.config.provider_config"}}</dt>
278-
<dd><code>{{if .SessionConfig.ProviderConfig}}{{.SessionConfig.ProviderConfig}}{{else}}-{{end}}</code></dd>
278+
<dd>{{if .SessionConfig.ProviderConfig}}{{.SessionConfig.ProviderConfig}}{{else}}-{{end}}</dd>
279279
<dt>{{ctx.Locale.Tr "admin.config.cookie_name"}}</dt>
280280
<dd>{{.SessionConfig.CookieName}}</dd>
281281
<dt>{{ctx.Locale.Tr "admin.config.gc_interval_time"}}</dt>
@@ -301,7 +301,7 @@
301301
<dt>{{ctx.Locale.Tr "admin.config.git_max_diff_files"}}</dt>
302302
<dd>{{.Git.MaxGitDiffFiles}}</dd>
303303
<dt>{{ctx.Locale.Tr "admin.config.git_gc_args"}}</dt>
304-
<dd><code>{{.Git.GCArgs}}</code></dd>
304+
<dd>{{.Git.GCArgs}}</dd>
305305

306306
<div class="divider"></div>
307307

@@ -330,7 +330,7 @@
330330

331331
{{if .Loggers.access.IsEnabled}}
332332
<dt>{{ctx.Locale.Tr "admin.config.access_log_template"}}</dt>
333-
<dd><code>{{$.AccessLogTemplate}}</code></dd>
333+
<dd>{{$.AccessLogTemplate}}</dd>
334334
{{end}}
335335

336336
{{range $loggerName, $loggerDetail := .Loggers}}

templates/admin/stacktrace-row.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
<div class="item tw-flex tw-items-center">
4747
<span class="icon tw-mr-4">{{svg "octicon-dot-fill" 16}}</span>
4848
<div class="content tw-flex-1">
49-
<div class="header"><code>{{.Function}}</code></div>
50-
<div class="description"><code>{{.File}}:{{.Line}}</code></div>
49+
<div class="header">{{.Function}}</div>
50+
<div class="description">{{.File}}:{{.Line}}</div>
5151
</div>
5252
</div>
5353
{{end}}

templates/base/alert_details.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{if .Details}}
33
<details>
44
<summary>{{.Summary}}</summary>
5-
<code>{{.Details | SanitizeHTML}}</code>
5+
{{.Details | SanitizeHTML}}
66
</details>
77
{{else}}
88
<div>

templates/projects/view.tmpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@
6565
</div>
6666

6767
<div class="ui container project-description">
68-
{{$.Project.RenderedContent}}
68+
<div class="render-content markup">
69+
{{$.Project.RenderedContent}}
70+
</div>
6971
<div class="divider"></div>
7072
</div>
7173

templates/repo/settings/lfs_file.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<tbody>
4040
<tr>
4141
<td class="lines-num">{{.LineNums}}</td>
42-
<td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol>{{.FileContent}}</ol></code></pre></td>
42+
<td class="lines-code"><pre>{{.FileContent}}</pre></td>
4343
</tr>
4444
</tbody>
4545
</table>

templates/repo/settings/webhook/history.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
{{range $key, $val := .RequestInfo.Headers}}<strong>{{$key}}:</strong> {{$val}}
6969
{{end}}</pre>
7070
<h5>{{ctx.Locale.Tr "repo.settings.webhook.payload"}}</h5>
71-
<pre class="webhook-info"><code class="json">{{or .RequestInfo.Body .PayloadContent}}</code></pre>
71+
<pre class="webhook-info">{{or .RequestInfo.Body .PayloadContent}}</pre>
7272
{{else}}
7373
-
7474
{{end}}
@@ -79,7 +79,7 @@
7979
<pre class="webhook-info">{{range $key, $val := .ResponseInfo.Headers}}<strong>{{$key}}:</strong> {{$val}}
8080
{{end}}</pre>
8181
<h5>{{ctx.Locale.Tr "repo.settings.webhook.body"}}</h5>
82-
<pre class="webhook-info"><code>{{.ResponseInfo.Body}}</code></pre>
82+
<pre class="webhook-info">{{.ResponseInfo.Body}}</pre>
8383
{{else}}
8484
-
8585
{{end}}

templates/user/settings/keys_gpg.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<label for="token">{{ctx.Locale.Tr "settings.gpg_token"}}</label>
2222
<input readonly="" value="{{.TokenToSign}}">
2323
<div class="help">
24-
<p>{{ctx.Locale.Tr "settings.gpg_token_help"}}</p>
25-
<p><code>{{printf `echo "%s" | gpg -a --default-key %s --detach-sig` .TokenToSign .PaddedKeyID}}</code></p>
24+
{{ctx.Locale.Tr "settings.gpg_token_help"}}
25+
<pre class="command-block">{{printf `echo "%s" | gpg -a --default-key %s --detach-sig` .TokenToSign .PaddedKeyID}}</pre>
2626
</div>
2727
</div>
2828
<div class="field">
@@ -89,8 +89,8 @@
8989
<label for="token">{{ctx.Locale.Tr "settings.gpg_token"}}</label>
9090
<input readonly="" value="{{$.TokenToSign}}">
9191
<div class="help">
92-
<p>{{ctx.Locale.Tr "settings.gpg_token_help"}}</p>
93-
<p><code>{{printf `echo "%s" | gpg -a --default-key %s --detach-sig` $.TokenToSign .PaddedKeyID}}</code></p>
92+
{{ctx.Locale.Tr "settings.gpg_token_help"}}
93+
<pre class="command-block">{{printf `echo "%s" | gpg -a --default-key %s --detach-sig` $.TokenToSign .PaddedKeyID}}</pre>
9494
</div>
9595
<br>
9696
</div>

templates/user/settings/keys_ssh.tmpl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,15 @@
7777
<label for="token">{{ctx.Locale.Tr "settings.ssh_token"}}</label>
7878
<input readonly="" value="{{$.TokenToSign}}">
7979
<div class="help">
80-
<p>{{ctx.Locale.Tr "settings.ssh_token_help"}}</p>
81-
<p><code>echo -n '{{$.TokenToSign}}' | ssh-keygen -Y sign -n gitea -f /path_to_PrivateKey_or_RelatedPublicKey</code></p>
80+
{{ctx.Locale.Tr "settings.ssh_token_help"}}
81+
<pre class="command-block">echo -n '{{$.TokenToSign}}' | ssh-keygen -Y sign -n gitea -f /path_to_PrivateKey_or_RelatedPublicKey</pre>
8282
<details>
8383
<summary>Windows PowerShell</summary>
84-
<p><code>cmd /c "&lt;NUL set /p=`"{{$.TokenToSign}}`"| ssh-keygen -Y sign -n gitea -f /path_to_PrivateKey_or_RelatedPublicKey"</code></p>
84+
<pre class="command-block">cmd /c "&lt;NUL set /p=`"{{$.TokenToSign}}`"| ssh-keygen -Y sign -n gitea -f /path_to_PrivateKey_or_RelatedPublicKey"</pre>
8585
</details>
86-
<br>
8786
<details>
8887
<summary>Windows CMD</summary>
89-
<p><code>set /p={{$.TokenToSign}}| ssh-keygen -Y sign -n gitea -f /path_to_PrivateKey_or_RelatedPublicKey</code></p>
88+
<pre class="command-block">set /p={{$.TokenToSign}}| ssh-keygen -Y sign -n gitea -f /path_to_PrivateKey_or_RelatedPublicKey</pre>
9089
</details>
9190
</div>
9291
<br>

web_src/css/base.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,13 @@ samp,
101101
font-size: 0.95em; /* compensate for monospace fonts being usually slightly larger */
102102
}
103103

104-
code {
104+
/* there are many <code> blocks in non-markup(.markup code) / non-code-diff(code.code-inner) containers (for example: translation strings, etc),
105+
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.
106+
TODO: in the future, we should use `div` instead of `code` for `.code-inner` because it is a container for highlighted code line */
107+
code:not(.code-inner) {
105108
padding: 1px 4px;
106109
border-radius: var(--border-radius);
107110
background-color: var(--color-label-bg);
108-
color: var(--color-label-text);
109111
}
110112

111113
b,

0 commit comments

Comments
 (0)