How to use ghost-ignition - 10 common examples

To help you get started, we’ve selected a few ghost-ignition examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TryGhost / Ghost / core / server / api / canary / utils / serializers / output / pages.js View on Github external
const debug = require('ghost-ignition').debug('api:canary:utils:serializers:output:pages');
const mapper = require('./utils/mapper');

module.exports = {
    all(models, apiConfig, frame) {
        debug('all');

        // CASE: e.g. destroy returns null
        if (!models) {
            return;
        }

        if (models.meta) {
            frame.response = {
                pages: models.data.map(model => mapper.mapPage(model, frame)),
                meta: models.meta
            };
github chadly / ghost / core / server / lib / image / image-size.js View on Github external
const debug = require('ghost-ignition').debug('utils:image-size');
const sizeOf = require('image-size');
const probeSizeOf = require('probe-image-size');
const url = require('url');
const Promise = require('bluebird');
const _ = require('lodash');
const request = require('../request');
const urlUtils = require('../../lib/url-utils');
const common = require('../common');
const config = require('../../config');
const storage = require('../../adapters/storage');
const storageUtils = require('../../adapters/storage/utils');
const validator = require('../../data/validation').validator;

// these are formats supported by image-size but not probe-image-size
const FETCH_ONLY_FORMATS = [
    'cur', 'icns', 'ico', 'dds'
github TryGhost / Ghost / core / server / api / v2 / utils / serializers / output / mail.js View on Github external
const _ = require('lodash');
const debug = require('ghost-ignition').debug('api:v2:utils:serializers:output:mail');

module.exports = {
    all(response, apiConfig, frame) {
        debug('all');
        const toReturn = _.cloneDeep(frame.data);

        delete toReturn.mail[0].options;
        // Sendmail returns extra details we don't need and that don't convert to JSON
        delete toReturn.mail[0].message.transport;

        toReturn.mail[0].status = {
            message: response.message
        };

        frame.response = toReturn;
    }
github chadly / ghost / core / frontend / helpers / ghost_head.js View on Github external
// # Ghost Head Helper
// Usage: `{{ghost_head}}`
//
// Outputs scripts and other assets at the top of a Ghost theme
var proxy = require('./proxy'),
    _ = require('lodash'),
    debug = require('ghost-ignition').debug('ghost_head'),

    getMetaData = proxy.metaData.get,
    getAssetUrl = proxy.metaData.getAssetUrl,
    escapeExpression = proxy.escapeExpression,
    SafeString = proxy.SafeString,
    logging = proxy.logging,
    settingsCache = proxy.settingsCache,
    config = proxy.config,
    blogIconUtils = proxy.blogIcon,
    labs = proxy.labs;

function writeMetaTag(property, content, type) {
    type = type || property.substring(0, 7) === 'twitter' ? 'name' : 'property';
    return '';
}
github TryGhost / gscan / app / index.js View on Github external
const express = require('express');
const debug = require('ghost-ignition').debug('app');
const hbs = require('express-hbs');
const multer = require('multer');
const server = require('ghost-ignition').server;
const errors = require('ghost-ignition').errors;
const gscan = require('../lib');
const fs = require('fs-extra');
const logRequest = require('./middlewares/log-request');
const uploadValidation = require('./middlewares/upload-validation');
const ghostVer = require('./ghost-version');
const pkgJson = require('../package.json');
const ghostVersions = require('../lib/utils').versions;
const upload = multer({dest: __dirname + '/uploads/'});
const app = express();
const scanHbs = hbs.create();

// Configure express
app.set('x-powered-by', false);
app.set('query parser', false);

app.engine('hbs', scanHbs.express4({
github chadly / ghost / core / server / errors.js View on Github external
var _ = require('lodash'),
    util = require('util'),
    errors = require('ghost-ignition').errors;

function GhostError(options) {
    options = options || {};
    this.value = options.value;

    errors.IgnitionError.call(this, options);
}

// jscs:disable
var ghostErrors = {
    DataExportError: function DataExportError(options) {
        GhostError.call(this, _.merge({
            statusCode: 500,
            errorType: 'DataExportError'
        }, options));
    },
github TryGhost / gscan / app / middlewares / upload-validation.js View on Github external
// NOTE: this middleware was extracted from Ghost core validation for theme uploads
//       might be useful to unify this logic in the future if it's extracted to separate module
const path = require('path');
const errors = require('ghost-ignition').errors;

const checkFileExists = function checkFileExists(fileData) {
    return !!(fileData.mimetype && fileData.path);
};

const checkFileIsValid = function checkFileIsValid(fileData, types, extensions) {
    const type = fileData.mimetype;

    if (types.includes(type) && extensions.includes(fileData.ext)) {
        return true;
    }

    return false;
};

module.exports = function uploadValidation(req, res, next) {
github TryGhost / Ghost / core / server / lib / common / errors.js View on Github external
},
    UpdateCollisionError: function UpdateCollisionError(options) {
        GhostError.call(this, merge({
            statusCode: 409,
            errorType: 'UpdateCollisionError'
        }, options));
    },
    HelperWarning: function HelperWarning(options) {
        GhostError.call(this, merge({
            errorType: 'HelperWarning',
            hideStack: true
        }, options));
    }
};

util.inherits(GhostError, errors.IgnitionError);
each(ghostErrors, function (error) {
    util.inherits(error, GhostError);
});

// we need to inherit all general errors from GhostError, otherwise we have to check instanceof IgnitionError
each(errors, function (error) {
    if (error.name === 'IgnitionError' || typeof error === 'object') {
        return;
    }

    util.inherits(error, GhostError);
});

module.exports = merge(ghostErrors, errors);
module.exports.GhostError = GhostError;
github chadly / ghost / core / server / errors.js View on Github external
},
    DisabledFeatureError: function DisabledFeatureError(options) {
        GhostError.call(this, _.merge({
            statusCode: 409,
            errorType: 'DisabledFeatureError',
        }, options));
    },
    UpdateCollisionError: function UpdateCollisionError(options) {
        GhostError.call(this, _.merge({
            statusCode: 409,
            errorType: 'UpdateCollisionError',
        }, options));
    }
};

util.inherits(GhostError, errors.IgnitionError);
_.each(ghostErrors, function (error) {
    util.inherits(error, GhostError);
});

// we need to inherit all general errors from GhostError, otherwise we have to check instanceof IgnitionError
_.each(errors, function (error) {
    if (error.name === 'IgnitionError' || typeof error === 'object') {
        return;
    }

    util.inherits(error, GhostError);
});

module.exports = _.merge(ghostErrors, errors);
module.exports.GhostError = GhostError;
github gazooka / GhostInAzureWebApp / postinstall.js View on Github external
var config = require('ghost/core/server/config');
var deasync = require('deasync');
var fs = require('fs');
var knexMigrator = require('knex-migrator');
var logging = require('ghost-ignition').logging();
var path = require('path');
var replaceInFile = require('replace-in-file');
var strReplaceAll = require('str-replace-all');
var uglifyJs = require('uglify-es');
var zlib = require('zlib');

// to hold the generated server cache
var serverCacheItems = [];
var serverCacheFilesProcessed = [];

// files being processed
var configProductionJsonPath = path.resolve(__dirname, 'config.production.json');
var knexMigratorPath = path.resolve(__dirname, 'node_modules/ghost');
var serverJsPath = path.resolve(__dirname, 'server.js');
var serverCacheJsPath = path.resolve(__dirname, 'server.cache.js');
var serverCacheJsZippedPath = path.resolve(__dirname, 'server.cache.js.gz');