Ghost/core/server/helpers/proxy.js
Hannah Wolfe a413d70313 Asset amends (#8294)
refs #8221

🔥 Remove ghost=true concept from asset url helper

 💯 Introduce CSS minification with cssnano
- add new grunt-cssnano dependency
- wire up grunt task to minify public/ghost.css

🎨 Rename minification config & hash params
- Change minifyInProduction -> hasMinFile
  - this means this asset should have a .min file available
- Change minifyAssets -> useMinFiles
  - this means that in this env we want to serve .min files if available

🎨 Update public/ghost.css to serve .min for prod
- add the new `hasMinFile` property

🎨 Move minified asset handling to asset_url util
- this logic should be in the util, not the asset helper
- updated tests

📖 Error handler always needs asset helper
- this removes the TODO and adds a more sensible comment
- we also need to update our theme documentation around error templates

🔥 Don't use asset helper in ghost head
- use getAssetUrl util instead!
- removed TODO

📖 Update proxy docs
🎨 Simplify asset helper & add tests
- this refactor is a step prior to moving this from metadata to being a url util
- needed to skip some new tests

🐛 Add missing handler for css file
2017-04-10 11:30:21 +02:00

81 lines
2.6 KiB
JavaScript

// This file defines everything that helpers "require"
// With the exception of modules like lodash, Bluebird
// We can later refactor to enforce this something like we do in apps
var hbs = require('../themes/engine'),
_ = require('lodash'),
settingsCache = require('../settings/cache'),
config = require('../config');
// Direct requires:
// - lodash
// - bluebird
// - downsize
// - moment-timezone
// - jsonpath
module.exports = {
hbs: hbs,
SafeString: hbs.SafeString,
escapeExpression: hbs.escapeExpression,
// TODO: Expose less of the API to make this safe
api: require('../api'),
// TODO: Only expose "get"
settingsCache: settingsCache,
// These 3 are kind of core and required all the time
errors: require('../errors'),
i18n: require('../i18n'),
logging: require('../logging'),
// This is used to detect if "isPost" is true in prevNext.
checks: require('../data/schema').checks,
// Config!
// Keys used:
// isPrivacyDisabled & referrerPolicy used in ghost_head
// Subscribe app uses routeKeywords
config: {
get: config.get.bind(config),
isPrivacyDisabled: config.isPrivacyDisabled.bind(config)
},
// Labs utils for enabling/disabling helpers
labs: require('../utils/labs'),
// System for apps to hook into one day maybe
filters: require('../filters'),
// Things required from data/meta
metaData: {
get: require('../data/meta'), // ghost_head
getAssetUrl: require('../data/meta/asset_url'), // asset
getMetaDataExcerpt: require('../data/meta/excerpt'), // excerpt
getMetaDataDescription: require('../data/meta/description'), // meta_desc
getMetaDataTitle: require('../data/meta/title'), // meta_title
getPaginatedUrl: require('../data/meta/paginated_url'), // page_url
getMetaDataUrl: require('../data/meta/url') // url
},
// The local template thing, should this be merged with the channels one?
templates: require('./template'),
// Various utils, needs cleaning up / simplifying
socialUrls: require('../utils/social-urls'),
url: require('../utils').url,
utils: {
findKey: function findKey(key /* ...objects... */) {
var objects = Array.prototype.slice.call(arguments, 1);
return _.reduceRight(objects, function (result, object) {
if (object && _.has(object, key) && !_.isEmpty(object[key])) {
result = object[key];
}
return result;
}, null);
}
},
visibility: require('../utils/visibility')
};