Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var useCDN = true;
var cdnPath = '//cdn.framework7.io';
// var processVuePugFiles = require('./src/react-doc-generation/vue-pug-file-processing').processVuePugFiles;
// var processReactHtmlFiles = require('./src/react-doc-generation/react-html-file-processing').processReactHtmlFiles;
var pkg = require('./package.json');
// Get src file url
function getSrcFileUrl(file) {
const srcFileUrl = `${pkg.repository.url}/edit/master/src/pug/${file.path.split('/src/pug/')[1]}`;
return {
srcFileUrl: srcFileUrl,
};
}
// Pug Filter
pug.filters['code'] = function (text) {
return text
.replace( //g, '>' )
}
// Pug YAML Data
function getYamlData(ymlPath) {
var doc = yaml.safeLoad(fs.readFileSync(`./src/pug/${ymlPath}`, 'utf8'));
return doc;
}
/* ==================================================================
Check CDN
================================================================== */
function checkIsLocal(local) {
if (local) local = local.toString().replace('-', '');
if (local === 'local') {
const PORT = Number(process.argv[2]) || 4000
const app = express()
const server = http.createServer(app)
const remark = new Remarkable({
html: true,
highlight: function (code, lang) {
const h = lang
? highlight.highlight(lang, code)
: highlight.highlightAuto(code)
return '<div class="hljs">' + h.value + '</div>'
}
})
pug.filters.markdown = (md, options) => {
return remark.render(md)
}
// Trust "X-Forwarded-For" and "X-Forwarded-Proto" nginx headers
app.enable('trust proxy')
// Disable "powered by express" header
app.set('x-powered-by', false)
// Use pug for templates
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'pug')
app.engine('pug', pug.renderFile)
// Pretty print JSON
app.set('json spaces', 2)
unlimited()
var app = express()
var server = http.createServer(app)
var remark = new Remarkable({
html: true,
highlight: function (code, lang) {
var h = lang
? highlight.highlight(lang, code)
: highlight.highlightAuto(code)
return '<div class="hljs">' + h.value + '</div>'
}
})
pug.filters.markdown = (md, options) => {
return remark.render(md)
}
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'pug')
app.set('x-powered-by', false)
app.engine('pug', pug.renderFile)
// Pretty print JSON
app.set('json spaces', 2)
// Trust the X-Forwarded-* headers from http-proxy
app.enable('trust proxy')
// Use GZIP
app.use(compress())
var session = require('express-session')
var stylus = require('stylus')
var supportsColor = require('supports-color')
var url = require('url')
var useragent = require('useragent')
var auth = require('./lib/auth')
var config = require('./config')
var model = require('./model')
var pro = require('./lib/pro')
var routes = require('./routes')
var run = require('./run')
var secret = require('./secret')
var util = require('./util')
pug.filters.style = function (str) {
var ret
stylus(str, { compress: config.isProd })
.use(nib())
.render(function (err, css) { // sync
if (err) throw err
ret = css
})
return '<style>' + ret + '</style>'
}
function Site (opts, done) {
var self = this
if (!(self instanceof Site)) return new Site(opts, done)
self.port = opts.port || 4000
const pkg = require('../package.json');
const iconsManifest = require('./manifest-icons.json');
const getSrcFileUrl = require('./utils/get-src-file-url');
const getYamlData = require('./utils/get-yaml-data');
const inlineSvg = require('./utils/inline-svg');
const cssVars = require('./utils/css-vars');
const codeFilter = require('./utils/code-filter');
const codeInlineFilter = require('./utils/code-inline-filter');
const createIndex = require('./utils/create-index');
const createMobilePreviewLinks = require('./utils/create-mobile-preview-links');
const createInlineCodeTags = require('./utils/create-inline-code-tags');
const createCodeFilter = require('./utils/create-code-filter');
if (!pug.filter && !pug.filters.code) {
pug.filters = {
code: codeFilter,
code_inline: codeInlineFilter,
};
}
function buildPages(cb, { src = ['**/*.pug', '!**/_*.pug', '!_*.pug'], dest = './public' } = {}) {
const cdn = process.argv.slice(3) ? process.argv.slice(3).toString().replace('-', '') !== 'local' : true;
const time = Date.now();
const name = src[0] === '**/*.pug' ? 'all' : src.join(', ');
console.log(`Starting pug: ${name}`);
gulp.src(src, { cwd: 'src/pug' })
.pipe(gulpData((file) => { return { srcFileUrl: getSrcFileUrl(file) }; }))
.pipe(through2.obj((file, _, cbInternal) => {
const gulp = require('gulp');
const gulpPug = require('gulp-pug');
const connect = require('gulp-connect');
const pug = require('pug');
const codeFilter = require('./utils/code-filter');
const codeInlineFilter = require('./utils/code-inline-filter');
if (!pug.filter && !pug.filters.code) {
pug.filters = {
code: codeFilter,
code_inline: codeInlineFilter,
};
}
function buildPages(cb, { src = ['**/index.pug'], dest = './public/' } = {}) {
const cdn = process.argv.slice(3) ? process.argv.slice(3).toString().replace('-', '') !== 'local' : true;
const time = Date.now();
const name = src[0] === '**/*.pug' ? 'all' : src.join(', ');
console.log(`Starting pug: ${name}`);
gulp.src(src, { cwd: 'src/pug' })
.pipe(gulpPug({
pug,
var pug = require('pug'),
templatePath = require('./template-path'),
templateWrapper = require('./template-wrapper');
pug.filters.style = function (str) { return '<style>' + str.replace(/\s/g, "") + '</style>'; };
var renderTemplate = function(path, templateOptions) {
var template = pug.renderFile(templatePath(path), templateOptions);
return templateWrapper(template);
};
module.exports = renderTemplate;
'use strict';
const Config = require('getconfig');
const Hapi = require('hapi');
const Pug = require('pug');
const Markdown = require('./lib/markdown');
const Path = require('path');
const isProd = process.env.NODE_ENV === 'production';
if (Config.server.cache && isProd) {
Config.server.cache.engine = require(Config.server.cache.engine);
}
const server = Hapi.server(Config.server);
Pug.filters.markdown = Markdown.parseSync;
const start = async function () {
server.ext({
type: 'onPreResponse',
method: function (request, h) {
if (!request.response.isBoom) {
return h.continue;
}
return h.view('error', request.response).code(request.response.output.statusCode);
} });
server.method(require('./lib/npm').methods);
server.method(require('./lib/github').methods);
server.method(require('./lib/markdown').methods);
server.method(require('./lib/changelog').methods);