Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep (add if not existing) xmlns attribute for generated SVG images #23410

Merged
merged 16 commits into from
Mar 21, 2023

Conversation

wxiaoguang
Copy link
Contributor

Fix #23409

Developers could browse & preview the local SVG images files directly.

It still has clear output.

image

image

@silverwind
Copy link
Member

silverwind commented Mar 10, 2023

How about adding xmlns only when RUN_MODE=dev, at runtime only (no modification to SVG files)? That way, we avoid the perf impact in prod mode.

Generally I see this change as borderline useless, we never render SVG in standalone documents.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 10, 2023
@wxiaoguang
Copy link
Contributor Author

How about adding xmlns only when RUN_MODE=dev, at runtime only (no modification to SVG files)? That way, we avoid the perf impact in prod mode.

Generally I see this change borderline useless thought, we never render SVG in standalone documents.

The purpose is to make developers could browse local SVG images from the assets directory.

@wxiaoguang
Copy link
Contributor Author

wxiaoguang commented Mar 11, 2023

How about adding xmlns only when RUN_MODE=dev, at runtime only (no modification to SVG files)? That way, we avoid the perf impact in prod mode.

@silverwind @KN4CK3R I don't understand what does it mean, and I do not think it's related to the problem.

The purpose of this PR is to make the SVG images in $HOME/work/gitea/public/img/svg could be viewed locally & directly.

At the moment, when I am working with SVG images in Gitea, I even can't know what a image looks like, it's difficult to manage/confirm these SVG files, and it's difficult to pick/choose a SVG image.

You can open your local $HOME/work/gitea/public/img/svg directory to check.

@wxiaoguang
Copy link
Contributor Author

@silverwind @KN4CK3R how do you think? This PR:

  • makes the SVG images in $HOME/work/gitea/public/img/svg could be viewed locally & directly.
  • doesn't affect HTML output, the generated HTML code is still clear (the same as before).

@KN4CK3R
Copy link
Member

KN4CK3R commented Mar 13, 2023

My image viewer is able to display the files without that change. But as this work is done only once in an Init method I think it is not harmful. First I thought you want to remove the string on the fly when serving the file but that's not the case.

@silverwind
Copy link
Member

silverwind commented Mar 15, 2023

I guess it does not hurt if it only affects the files when viewed directly in the browser, which BTW is just a side-effect, we do not use these file URLs anywhere. Their existance at that location it currently only so that the go template code can access them via bindata embed.

Thought I guess if we ever decide to make use of these files via URL, it is the right change to do because standalone documents indeed need the xmlns.

modules/svg/svg.go Outdated Show resolved Hide resolved
build/generate-svg.js Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 15, 2023
Copy link
Member

@delvh delvh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
However, I'm not sure if we should merge #23528 or this PR first, there will always be merge conflicts.
I'd rather say the other one as the chance that we forget to add the namespace for the new icons is lower then.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 16, 2023
@silverwind
Copy link
Member

Would merge the other one first and then run make svg here.

@silverwind
Copy link
Member

silverwind commented Mar 16, 2023

This change does not actually add xmlns for sources where it is missing, it just does not remove it any more. I would try using addAttributesToSVGElement to add it, just in case it is missing.

Copy link
Member

@silverwind silverwind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking as per above. The code does not do what the PR title says.

@wxiaoguang wxiaoguang changed the title Keep/add xmlns attribute for generated SVG images Keep xmlns attribute for generated SVG images Mar 17, 2023
@wxiaoguang wxiaoguang changed the title Keep xmlns attribute for generated SVG images Keep (add if not existing) xmlns attribute for generated SVG images Mar 17, 2023
@wxiaoguang
Copy link
Contributor Author

Blocking as per above. The code does not do what the PR title says.

Done in 9412e17

@wxiaoguang
Copy link
Contributor Author

However, I'm not sure if we should merge #23528 or this PR first, there will always be merge conflicts.
I'd rather say the other one as the chance that we forget to add the namespace for the new icons is lower then.

No worry, I am glad and happy to resolve necessary conflicts.

@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 17, 2023
@lunny lunny added this to the 1.20.0 milestone Mar 17, 2023
@lunny lunny added the type/enhancement An improvement of existing functionality label Mar 17, 2023
@delvh
Copy link
Member

delvh commented Mar 18, 2023

Please run make svg

@yardenshoham yardenshoham removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 18, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #23410 (eca010b) into main (f521e88) will decrease coverage by 0.01%.
The diff coverage is 32.37%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main   #23410      +/-   ##
==========================================
- Coverage   47.14%   47.13%   -0.01%     
==========================================
  Files        1149     1154       +5     
  Lines      151446   152270     +824     
==========================================
+ Hits        71397    71780     +383     
- Misses      71611    72016     +405     
- Partials     8438     8474      +36     
Impacted Files Coverage Δ
cmd/dump.go 0.67% <0.00%> (ø)
cmd/web.go 0.00% <0.00%> (ø)
models/actions/run.go 1.64% <0.00%> (-0.08%) ⬇️
models/packages/package.go 45.45% <0.00%> (-1.13%) ⬇️
models/user/search.go 77.50% <0.00%> (-6.29%) ⬇️
modules/actions/github.go 0.00% <0.00%> (ø)
modules/actions/workflows.go 0.00% <0.00%> (ø)
modules/doctor/storage.go 31.93% <0.00%> (ø)
modules/setting/git.go 45.45% <ø> (ø)
modules/storage/minio.go 1.51% <0.00%> (-0.06%) ⬇️
... and 24 more

... and 31 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 21, 2023
@lunny lunny merged commit a797b84 into go-gitea:main Mar 21, 2023
@lunny lunny removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 21, 2023
@wxiaoguang wxiaoguang deleted the keep-svg-xmlns branch March 21, 2023 05:46
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 22, 2023
* upstream/main:
  Use a general approch to improve a11y for all checkboxes and dropdowns. (go-gitea#23542)
  [skip ci] Updated translations via Crowdin
  Update PR documentation (go-gitea#23620)
  Set opaque background on markup and images (go-gitea#23578)
  Decouple the issue-template code from comment_tab.tmpl  (go-gitea#23556)
  Remove `id="comment-form"` dead code, fix tag (go-gitea#23555)
  Introduce path Clean/Join helper functions (go-gitea#23495)
  Remove conflicting CSS rules on notifications, improve notifications table (go-gitea#23565)
  Remove @metalmatze as maintainer (go-gitea#23612)
  Keep (add if not existing) xmlns attribute for generated SVG images (go-gitea#23410)
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Proposal] Keep/add xmlns attribute for generated SVG images
8 participants