mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
58635b3e0a
- see core/client/lib/assets-delivery/index.js for how this is done - Turn off ember-cli fingerprinting - ember-cli 0.2.0; Update .npmignore - Fallback to old version of ember-cli-sass due to lib-sass errors - Keep ember-data at beta-14.1 until we find the dep that's breaking on snapshot.attr - Fix release task to ignore blank lines in .npmignore
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
// # Asset helper
|
|
// Usage: `{{asset "css/screen.css"}}`, `{{asset "css/screen.css" ghost="true"}}`
|
|
//
|
|
// Returns the path to the specified asset. The ghost flag outputs the asset path for the Ghost admin
|
|
|
|
var hbs = require('express-hbs'),
|
|
config = require('../config'),
|
|
utils = require('./utils'),
|
|
asset;
|
|
|
|
asset = function (context, options) {
|
|
var output = '',
|
|
isAdmin,
|
|
minify;
|
|
|
|
if (options && options.hash) {
|
|
isAdmin = options.hash.ghost;
|
|
minify = options.hash.minifyInProduction;
|
|
}
|
|
|
|
output += config.paths.subdir + '/';
|
|
|
|
if (!context.match(/^favicon\.ico$/) && !context.match(/^shared/) && !context.match(/^asset/)) {
|
|
if (isAdmin) {
|
|
output += 'ghost/';
|
|
} else {
|
|
output += 'assets/';
|
|
}
|
|
}
|
|
|
|
// Get rid of any leading slash on the context
|
|
context = context.replace(/^\//, '');
|
|
|
|
// replace ".foo" with ".min.foo" in production
|
|
if (utils.isProduction && minify) {
|
|
context = context.replace('.', '.min.');
|
|
}
|
|
|
|
output += context;
|
|
|
|
if (!context.match(/^favicon\.ico$/)) {
|
|
output = utils.assetTemplate({
|
|
source: output,
|
|
version: config.assetHash
|
|
});
|
|
}
|
|
|
|
return new hbs.handlebars.SafeString(output);
|
|
};
|
|
|
|
module.exports = asset;
|