<commit_before>// DecentCMS (c) 2014 <NAME>, under MIT. See LICENSE.txt for licensing details.
'use strict';

var async = require('async');

function NavigationHandler(scope) {
  this.scope = scope;
}
NavigationHandler.feature = 'navigation';
NavigationHandler.service = 'shape-handler';
NavigationHandler.scope = 'request';

NavigationHandler.prototype.handle = function handleNavigation(context, done) {
  var layout = context.shape;
  if (!layout.meta || layout.meta.type !== 'layout') return done();
  var scope = this.scope;
  var navigationContext = {
    menu: 'default',
    items: []
  };
  this.scope.callService('navigation-provider', 'addRootItems', navigationContext, function() {
    var shapeHelper = scope.require('shape');
    shapeHelper.place(layout, 'navigation', {
      meta: {type: 'menu'},
      name: navigationContext.menu,
      items: navigationContext.items
    }, 'after');
    done();
  });
};

module.exports = NavigationHandler;<commit_msg>Include site and current url in navigation shape data.<commit_after>// DecentCMS (c) 2014 <NAME>, under MIT. See LICENSE.txt for licensing details.
'use strict';

var async = require('async');

function NavigationHandler(scope) {
  this.scope = scope;
}
NavigationHandler.feature = 'navigation';
NavigationHandler.service = 'shape-handler';
NavigationHandler.scope = 'request';

NavigationHandler.prototype.handle = function handleNavigation(context, done) {
  var layout = context.shape;
  if (!layout.meta || layout.meta.type !== 'layout') return done();
  var scope = this.scope;
  var navigationContext = {
    menu: 'default',
    items: []
  };
  this.scope.callService('navigation-provider', 'addRootItems', navigationContext, function() {
    var site = scope.require('shell');
    var current = scope.url;
    var shapeHelper = scope.require('shape');
    shapeHelper.place(layout, 'navigation', {
      meta: {type: 'menu'},
      site: site,
      name: navigationContext.menu,
      items: navigationContext.items,
      current: current
    }, 'after');
    done();
  });
};

module.exports = NavigationHandler;
{'fraction_non_alphanumeric': 0.14258464473056748, 'fraction_numerical': 0.003814973772055317, 'mean_word_length': 4.245, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '3830019', 'n_tokens_mistral': 597, 'n_tokens_neox': 579, 'n_words': 153}