<commit_before>/**
 * Copyright (c) 2013-2015 Memba Sarl. All rights reserved.
 * Sources at https://github.com/Memba
 */

/* jshint node: true */

'use strict';

var assert = require('assert');
var async = require('async');
var qs = require('qs');
var ApplicationError = require('../lib/error');
var convert = require('../lib/convert');
var logger = require('../lib/logger');
var markdown = require('../lib/markdown');
var url = require('../lib/url');
var utils = require('../lib/utils');
var indexModel = require('../models/indexModel');
var menuModel = require('../models/menuModel');

module.exports = {

    /**
     * Returns the user page
     * @param req
     * @param res
     * @param next
     */
    getHtmlPage: function (req, res, next) {

        var config = res.locals.config;
        var format = res.locals.format;
        // var url = res.locals.url;

        // Create a trace that we can track in the browser
        req.trace = utils.uuid();

        // Log the request
        logger.info({
            message: 'requesting a blog post',
            module: 'routes/blogRoute',
            method: 'getHtmlPage',
            request: req
        });

        assert.equal(language, res.getLocale(), format('i18n locale is not `{0}`', language));

        async.parallel(
            [
                // get menu
                function (callback) {
                    menuModel.getMenu(language, callback);
                },
                // get blog post
                function (callback) {
                    /* jscs: disable requireCamelCaseOrUpperCaseIdentifiers */
                    var site_url = req.protocol + '://' + req.get('host') + url.parse(req.originalUrl).pathname;
                    indexModel.findBySiteUrl(site_url, req.query, callback);
                    /* jscs: enable requireCamelCaseOrUpperCaseIdentifiers */
                },
                // Get grouped categories<commit_msg>Throttled webhook access<commit_after>/**
 * Copyright (c) 2013-2015 Memba Sarl. All rights reserved.
 * Sources at https://github.com/Memba
 */

/* jshint node: true */

'use strict';

var assert = require('assert');
var async = require('async');
var qs = require('qs');
var ApplicationError = require('../lib/error');
var convert = require('../lib/convert');
var logger = require('../lib/logger');
var markdown = require('../lib/markdown');
var url = require('../lib/url');
var utils = require('../lib/utils');
var indexModel = require('../models/indexModel');
var menuModel = require('../models/menuModel');

module.exports = {

    /**
     * Returns the user page
     * @param req
     * @param res
     * @param next
     */
    getHtmlPage: function (req, res, next) {

        var config = res.locals.config;
        var format = res.locals.format;
        // var url = res.locals.url;

        // Create a trace that we can track in the browser
        req.trace = utils.uuid();

        // Log the request
        logger.info({
            message: 'requesting a blog post',
            module: 'routes/blogRoute',
            method: 'getHtmlPage',
            request: req
        });

        var language = req.params.language;
        assert.equal(language, res.getLocale(), format('i18n locale is not `{0}`', language));

        async.parallel(
            [
                // get menu
                function (callback) {
                    menuModel.getMenu(language, callback);
                },
                // get blog post
                function (callback) {
                    /* jscs: disable requireCamelCaseOrUpperCaseIdentifiers */
                    var site_url = req.protocol + '://' + req.get('host') + url.parse(req.originalUrl).pathname;
                    indexModel.findBySiteUrl(site_url, req.query, callback);
                    /* jscs: enable requireCamelCaseOrUpperCaseIdentifiers */
                },
                // Get grouped categories
{'fraction_non_alphanumeric': 0.1384732437230535, 'fraction_numerical': 0.005579507988840984, 'mean_word_length': 1.9021339220014717, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4482313', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1057, 'n_words': 282}