-
Notifications
You must be signed in to change notification settings - Fork 242
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
Fix favicon "not found" error on non-homepage pages #617
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,24 @@ $(document).ready(function () { | |
if (logoID < 10) { | ||
logoID = "0" + logoID; | ||
} | ||
document.querySelector('#defaultIcon1').href = 'https://www.sugarlabs.org/assets/favicon_' + logoID + '.png'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code you are removing has nothing to do with the issue; the issue and my tests of master branch just now show the error to be a reference to press/assets/favicon_06.png and this line you are removing is an absolute link without press. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have simplified the favicon logic by making the path relative to var defaultIcon = document.querySelector('#defaultIcon1');
if (defaultIcon) {
var logoID = colorIndex + 1;
if (logoID < 10) {
logoID = "0" + logoID;
}
defaultIcon.href = '/press/assets/favicon_' + logoID + '.png';
} Also, I have removed the testing and existence checks. Is this approach fine? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You've lost me here. Why would the path be made absolute from /press/? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I think relative path will be better for this like: var defaultIcon = document.querySelector('#defaultIcon1');
if (defaultIcon) {
var logoID = colorIndex + 1;
if (logoID < 10) {
logoID = "0" + logoID;
}
defaultIcon.href = 'assets/favicon_' + logoID + '.png';
} Now it's pointing to the |
||
|
||
var defaultIcon = document.querySelector('#defaultIcon1'); | ||
if (defaultIcon) { | ||
// Use absolute path for favicon | ||
var faviconPath = '/assets/favicon_' + logoID + '.png'; | ||
|
||
// Test if favicon exists before setting | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see why we need to test if it exists. We know exactly how many files we have, what their names are, and we know the code above this section in js/main.js. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I'll remove the favicon test since we already know the number and names of the images. |
||
var img = new Image(); | ||
img.onload = function() { | ||
defaultIcon.href = faviconPath; | ||
}; | ||
img.onerror = function() { | ||
// Fallback to default favicon | ||
defaultIcon.href = '/assets/favicon.png'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no file assets/favicon.png There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since there is no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok sure. |
||
}; | ||
img.src = faviconPath; | ||
} | ||
|
||
var h = document.querySelector('.logo1').innerHTML; | ||
h = h.replace(/033cd2/g, selectedColors[0]); | ||
h = h.replace(/78e600/g, selectedColors[1]); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is site.baseurl removed?
Why is there no file assets/favicon.png yet you link to it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will revert the changes in
_layouts/base.html
to the previous version.Since there is no
/favicon.png
, should I refer to/assets/favicon_06.png
here instead as before?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't mind either way, just that it should refer to something that exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, then I will change it to
{{ site.baseurl }}/assets/favicon_06.png
.