mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
✨ Find favicon in Ghost (#7713)
refs #7688 Adds logic in theme settings api to either serve an uploaded favicon and give it the type `upload` or use the default settings `default`, which will serve the favicon from our shared directory. TODOs for #7688: - [X] Figure out, which favicon should be used (uploaded or default) -> this PR - [ ] Serve and redirect the favicon for any browser requests, incl. redirects - [ ] Upload favicon via `general/settings` and implement basic admin validations -> [WIP] TryGhost/Ghost-Admin#397 - [ ] Built server side validations
This commit is contained in:
parent
503148058c
commit
7cb57bff3d
5 changed files with 58 additions and 3 deletions
|
@ -67,6 +67,9 @@ updateConfigCache = function () {
|
|||
config.set('theme:timezone', (settingsCache.activeTimezone && settingsCache.activeTimezone.value) || config.get('theme').timezone);
|
||||
config.set('theme:url', globalUtils.url.urlFor('home', true));
|
||||
config.set('theme:amp', (settingsCache.amp && settingsCache.amp.value === 'true'));
|
||||
config.set('theme:favicon', (settingsCache.favicon && settingsCache.favicon.value) ?
|
||||
{type: 'upload', url: (settingsCache.favicon && settingsCache.favicon.value)} :
|
||||
{type: 'default', url: config.get('theme:favicon')});
|
||||
|
||||
_.each(labsValue, function (value, key) {
|
||||
config.set('labs:' + key, value);
|
||||
|
|
|
@ -60,7 +60,11 @@
|
|||
"publishAPostBySchedulerToleranceInMinutes": 2
|
||||
},
|
||||
"theme": {
|
||||
"timezone": "Etc/UTC"
|
||||
"timezone": "Etc/UTC",
|
||||
"favicon": {
|
||||
"type": "default",
|
||||
"url": "core/shared/favicon.ico"
|
||||
}
|
||||
},
|
||||
"maintenance": {
|
||||
"enabled": false
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
"cover": {
|
||||
"defaultValue": ""
|
||||
},
|
||||
"favicon": {
|
||||
"defaultValue": ""
|
||||
},
|
||||
"defaultLang": {
|
||||
"defaultValue": "en_US",
|
||||
"validations": {
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 15 KiB |
|
@ -36,7 +36,11 @@ describe('Config', function () {
|
|||
description: 'casper',
|
||||
logo: 'casper',
|
||||
cover: 'casper',
|
||||
timezone: 'Etc/UTC'
|
||||
timezone: 'Etc/UTC',
|
||||
favicon: {
|
||||
type: 'default',
|
||||
url: 'core/shared/favicon.ico'
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -45,7 +49,7 @@ describe('Config', function () {
|
|||
var themeConfig = config.get('theme');
|
||||
|
||||
// This will fail if there are any extra keys
|
||||
themeConfig.should.have.keys('title', 'description', 'logo', 'cover', 'timezone');
|
||||
themeConfig.should.have.keys('title', 'description', 'logo', 'cover', 'timezone', 'favicon');
|
||||
});
|
||||
|
||||
it('should have the correct values for each key', function () {
|
||||
|
@ -57,6 +61,10 @@ describe('Config', function () {
|
|||
themeConfig.should.have.property('logo', 'casper');
|
||||
themeConfig.should.have.property('cover', 'casper');
|
||||
themeConfig.should.have.property('timezone', 'Etc/UTC');
|
||||
themeConfig.should.have.property('favicon', {
|
||||
type: 'default',
|
||||
url: 'core/shared/favicon.ico'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -85,6 +93,43 @@ describe('Config', function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Favicon default', function () {
|
||||
it('should use uploaded favicon', function () {
|
||||
var themeConfig = config.get('theme');
|
||||
|
||||
// Check values are as we expect
|
||||
themeConfig.should.have.property('favicon', {
|
||||
type: 'default',
|
||||
url: 'core/shared/favicon.ico'
|
||||
});
|
||||
|
||||
configUtils.set({
|
||||
theme: {
|
||||
favicon: {
|
||||
type: 'upload',
|
||||
url: 'content/images/favicon.ico'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
config.get('theme').should.have.property('favicon', {
|
||||
type: 'upload',
|
||||
url: 'content/images/favicon.ico'
|
||||
});
|
||||
});
|
||||
|
||||
it('should set theme object with default favicon', function () {
|
||||
var themeConfig = configUtils.defaultConfig;
|
||||
|
||||
// Check values are as we expect
|
||||
themeConfig.should.have.property('theme');
|
||||
themeConfig.theme.should.have.property('favicon', {
|
||||
type: 'default',
|
||||
url: 'core/shared/favicon.ico'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Index', function () {
|
||||
it('should have exactly the right keys', function () {
|
||||
var pathConfig = config.get('paths');
|
||||
|
|
Loading…
Add table
Reference in a new issue