mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-04 17:04:59 +03:00
e06547ae78
closes #8126 * Remove default template dependency on client side CSS See Issue #8126 Adds these files under /shared - normalizer.css - error.css - extracted.css (for subscribers.css and private.css) Also makes these files available as public static content * Remove default template dependency on client CSS closes #8126 needs e3acd3c This is a replacement PR of #8217 (thanks @TienSFU25 for the whole work 🤗), because these changes are needed urgently and blocking other work. Adds a new `ghost.css` file in `/core/shared/` to be used for server side template rendering (`error.hbs`, `subscribe.hbs` and `private.hbs`).
53 lines
1.7 KiB
JavaScript
53 lines
1.7 KiB
JavaScript
var config = require('../../config'),
|
|
settingsCache = require('../../settings/cache'),
|
|
utils = require('../../utils');
|
|
|
|
function getAssetUrl(path, isAdmin, minify) {
|
|
var output = '';
|
|
|
|
output += utils.url.urlJoin(utils.url.getSubdir(), '/');
|
|
|
|
if (!path.match(/^favicon\.(ico|png)$/) && !path.match(/^shared/) && !path.match(/^asset/)) {
|
|
if (isAdmin) {
|
|
output = utils.url.urlJoin(output, 'ghost/');
|
|
}
|
|
|
|
output = utils.url.urlJoin(output, 'assets/');
|
|
}
|
|
// Serve either uploaded favicon or default
|
|
// for favicon, we don't care anymore about the `/` leading slash, as we don't support theme favicons
|
|
if (path.match(/\/?favicon\.(ico|png)$/)) {
|
|
if (isAdmin) {
|
|
output = utils.url.urlJoin(utils.url.getSubdir(), '/favicon.ico');
|
|
} else {
|
|
if (settingsCache.get('icon')) {
|
|
output = utils.url.urlJoin(utils.url.getSubdir(), utils.url.urlFor('image', {image: settingsCache.get('icon')}));
|
|
} else {
|
|
output = utils.url.urlJoin(utils.url.getSubdir(), '/favicon.ico');
|
|
}
|
|
}
|
|
}
|
|
// Get rid of any leading slash on the path
|
|
path = path.replace(/^\//, '');
|
|
|
|
// replace ".foo" with ".min.foo" in production
|
|
if (minify) {
|
|
path = path.replace(/\.([^\.]*)$/, '.min.$1');
|
|
}
|
|
|
|
if (!path.match(/^favicon\.(ico|png)$/)) {
|
|
// we don't want to concat the path with our favicon url
|
|
output += path;
|
|
|
|
if (!config.get('assetHash')) {
|
|
config.set('assetHash', utils.generateAssetHash());
|
|
}
|
|
|
|
output = output + '?v=' + config.get('assetHash');
|
|
}
|
|
|
|
return output;
|
|
}
|
|
|
|
module.exports = getAssetUrl;
|