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

Prevent Firefox from using apple-touch-icon #10402

Merged
merged 3 commits into from
Feb 23, 2020
Merged

Conversation

silverwind
Copy link
Member

@silverwind silverwind commented Feb 21, 2020

The opaque background does not work well in Firefox which uses the icon as a "rich icon". Prevent this by not specifying it in HTML. Real Apple devices will still request the icon on the static path.

Fixes: #10394

@codecov-io
Copy link

codecov-io commented Feb 21, 2020

Codecov Report

Merging #10402 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10402      +/-   ##
==========================================
- Coverage    43.7%   43.68%   -0.02%     
==========================================
  Files         586      586              
  Lines       81354    81354              
==========================================
- Hits        35552    35540      -12     
- Misses      41401    41412      +11     
- Partials     4401     4402       +1
Impacted Files Coverage Δ
modules/indexer/stats/queue.go 62.5% <0%> (-18.75%) ⬇️
modules/indexer/stats/db.go 40.62% <0%> (-9.38%) ⬇️
services/pull/temp_repo.go 29.05% <0%> (-2.57%) ⬇️
services/pull/patch.go 60.37% <0%> (-2.52%) ⬇️
modules/queue/workerpool.go 56.93% <0%> (-2.14%) ⬇️
modules/queue/unique_queue_disk_channel.go 53.84% <0%> (-1.93%) ⬇️
models/error.go 29.49% <0%> (+0.52%) ⬆️
services/pull/check.go 53.04% <0%> (+2.43%) ⬆️
modules/git/command.go 89.56% <0%> (+2.6%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2875674...20f2b19. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 21, 2020
@@ -1002,6 +1002,12 @@ func RegisterRoutes(m *macaron.Macaron) {
}
})

m.Get("/apple-touch-icon.png", func(ctx *context.Context) {
file := path.Join(setting.StaticRootPath, "public/img/apple-touch-icon.png")
Copy link
Member

Choose a reason for hiding this comment

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

This is not right because the file maybe embedded into binary. You should use functions from modules/public to serve file.

Copy link
Member Author

@silverwind silverwind Feb 21, 2020

Choose a reason for hiding this comment

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

Changed it to a redirect. Ideally, it should be a "rewrite" but I'm not sure how I would do that. I would like to avoid having to set all the caching headers and such which seems to be needed with public.Asset which only returns bytes without metadata.

Copy link
Member Author

Choose a reason for hiding this comment

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

Open to suggestions on how to delegate the request directly to the static file hander.

@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 Feb 21, 2020
@jolheiser jolheiser added this to the 1.12.0 milestone Feb 21, 2020
@jolheiser jolheiser added the topic/ui Change the appearance of the Gitea UI label Feb 21, 2020
@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 Feb 23, 2020
@lunny
Copy link
Member

lunny commented Feb 23, 2020

Maybe you should change appsuburl to StaticUrlPrefix so that it's possible to be serve by CDN.

@silverwind
Copy link
Member Author

What's the difference between AppSubUrl and StaticUrlPrefix exactly? On a default installation, both are empty string and on gitea.com StaticUrlPrefix is on a second domain. Both seem to serve assets fine.

@lunny
Copy link
Member

lunny commented Feb 23, 2020

@silverwind on gitea.com StaticUrlPrefix == s.gitea.com will be served by CDN, but AppSubUrl == gitea.com will be served by original site.

The opaque background does not work well in Firefox which uses the icon
as a "rich icon". Prevent this by not specifying it in HTML. Real Apple
devices will still request the icon on the static path.

Fixes: go-gitea#10394

Also adjust gitignore so app.ini.sample becomes searchable and fixed a
variable name in app.ini.sample.
@silverwind
Copy link
Member Author

silverwind commented Feb 23, 2020

Ok, using StaticUrlPrefix.

Pushed two additional tweaks:

  • Remove custom/conf/app.ini.sample from .gitignore as that file is tracked in git which makes it searchable via tools like ag.
  • Fixed wrong variable name in app.ini.sample

.gitignore Outdated Show resolved Hide resolved
@silverwind
Copy link
Member Author

gitignore fixed, it needs to be a bit verbose to work (taken from https://stackoverflow.com/a/16318111/808699).

Comment on lines +52 to +55
/custom/*
!/custom/conf
/custom/conf/*
!/custom/conf/app.ini.sample
Copy link
Contributor

Choose a reason for hiding this comment

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

Why add those to .gitignore?

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. /custom/conf/app.ini.sample is tracked in git so should not be in .gitignore
  2. so I can search /custom/conf/app.ini.sample using ag or rg tools which respect .gitignore

Copy link
Member Author

Choose a reason for hiding this comment

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

And no, these 4 lines can not be reduced to 2 because of how .gitignore works.

Copy link
Contributor

Choose a reason for hiding this comment

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

@silverwind so those lines are required?

Copy link
Member Author

@silverwind silverwind Feb 23, 2020

Choose a reason for hiding this comment

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

Yes, it will not work with just 2 lines, that was my first failed attempt.

Those 4 lines essentially say "exclude everything in /custom except /custom/conf/app.ini.sample"

@@ -217,7 +217,7 @@ FILE_EXTENSIONS = .md,.markdown,.mdown,.mkd
PROTOCOL = http
DOMAIN = localhost
ROOT_URL = %(PROTOCOL)s:https://%(DOMAIN)s:%(HTTP_PORT)s/
; when STATIC_URL_PREFIX is empty it will follow APP_URL
; when STATIC_URL_PREFIX is empty it will follow ROOT_URL
Copy link
Contributor

Choose a reason for hiding this comment

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

Why following ROOT_URL instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

ROOT_URL is correct in config file context. The name AppURL is only used in code:

AppURL = sec.Key("ROOT_URL").MustString(defaultAppURL)

@6543
Copy link
Member

6543 commented Feb 23, 2020

I would say ready for merge?

@jolheiser jolheiser merged commit 71d5a09 into go-gitea:master Feb 23, 2020
@silverwind silverwind deleted the ati branch February 23, 2020 14:39
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
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. topic/ui Change the appearance of the Gitea UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Firefox uses apple-touch-icon in Urlbar history
9 participants