2017-04-04 19:07:35 +03:00
|
|
|
// 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
|
2017-12-14 05:01:23 +03:00
|
|
|
var hbs = require('../services/themes/engine'),
|
|
|
|
settingsCache = require('../services/settings/cache'),
|
2017-04-04 19:07:35 +03:00
|
|
|
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'),
|
2017-12-13 15:19:51 +03:00
|
|
|
models: require('../models'),
|
|
|
|
|
2017-04-04 19:07:35 +03:00
|
|
|
// TODO: Only expose "get"
|
|
|
|
settingsCache: settingsCache,
|
|
|
|
|
|
|
|
// These 3 are kind of core and required all the time
|
2017-12-11 22:27:09 +03:00
|
|
|
errors: require('../lib/common/errors'),
|
|
|
|
i18n: require('../lib/common/i18n'),
|
|
|
|
logging: require('../lib/common/logging'),
|
2017-04-04 19:07:35 +03:00
|
|
|
|
|
|
|
// 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
|
2017-12-14 05:01:23 +03:00
|
|
|
labs: require('../services/labs'),
|
2017-04-04 19:07:35 +03:00
|
|
|
|
|
|
|
// 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'),
|
🙇 Blog icon utils and publisher.logo for JSON-LD (#8297)
refs #8221, closes #7688, refs #7558
🙇 Improve meta data publisher logo behaviour
This is a follow-up PR for #8285.
Reasons: The code changes of #8285 caused error messages when falling back to the default `favicon.ico`, as the `image-size` tool doesn't support `ico` files.
This PR takes the logic to decide which logo needs to be listed in our schema into a new fn `blog_logo.js`. There we have now three decisions:
1. If we have a publication **logo**, we'll take that one
2. If we have no publication logo, but an **icon** we'll use this one.
3. If we have none of the above things, we fall back to our default `favicon.ico`
Additional, we're hard coding image dimensions for whenever the logo is an `.ico` file and built and extra decision to not call `image-size` when the dimension are already given.
I will create another follow-up PR, which checks the extension type for the file and offers it as a util.
🛠 Blog icon util
refs #7688
Serve functionality around the blog icon in its own util:
- getIconDimensions -> async function that takes the filepath of on ico file and returns its dimensions
- isIcoImageType -> returns true if file has `.ico` extension
- getIconType -> returns icon-type (`x-icon` or `png`)
- getIconUrl -> returns the absolut or relativ URL for the favicon: `[subdirectory or not]favicon.[ico or png]`
📖 Get .ico sizes for meta data & logo improvement
refs #7558
refs #8221
Use the new `blogIconUtil` in meta data to fetch the dimensions of `.ico` files.
Improvements for `publisher.logo`: We're now returning a hard-coded 'faked' image dimensions value to render an `imageObject` and prevent error our schema (Google structured data). As soon as an image (`.ico` or non-`.ico`) is too large, but - in case of non-`.ico` - a square format, be set the image-dimensions to 60px width and height. This reduces the chances of getting constantly error messages from Googles' webmaster tools.
- add getIconPath util
2017-04-11 19:32:06 +03:00
|
|
|
blogIcon: require('../utils/blog-icon'),
|
2017-12-11 21:14:05 +03:00
|
|
|
url: require('../services/url').utils,
|
2017-12-13 16:05:53 +03:00
|
|
|
localUtils: require('./utils')
|
2017-04-04 19:07:35 +03:00
|
|
|
};
|