<commit_before>/**
 * ArticleController
 *
 * @module		:: Controller
 * @description	:: Contains logic for handling requests.
 */

var obscura = require('Obscura');

module.exports = {

  /* e.g.
  sayHello: function (req, res) {
    res.send('hello world!');
  }
  */
  
  /**
   * /article/create
   */ 
  create: function (req,res) {

    // This will render the view: 
    // /var/www/html/cyclopedia-sails/views/Article/create.ejs
    res.view();

  },


  /**
   * /article/view
   */ 
  view: function (req,res) {

    // This will render the view: 
    // /var/www/html/cyclopedia-sails/views/Article/view.ejs
    var viewContent = function(content) {
	return content;
    }
    var filters = []
    if (req.session.user) {
      //getting the user's filter prefs - even if a guest user set prefs on the index page, they will be stored here.
      filters = req.session.user.preferences.filters;
    }
    var article = {};
    Article.find().where({id:  req.param("article")}).exec(function(err, articles) {
      article = articles;
    });
    
    var content = obscura.filterContent(filters, article, "html", viewContent);
    sails.log.warn(content);
    res.view({content: content, title: Article.find(req.param("article")).title});
  }

};<commit_msg>becoming less terrible at sails<commit_after>/**
 * ArticleController
 *
 * @module		:: Controller
 * @description	:: Contains logic for handling requests.
 */

var obscura = require('Obscura');

module.exports = {

  /* e.g.
  sayHello: function (req, res) {
    res.send('hello world!');
  }
  */
  
  /**
   * /article/create
   */ 
  create: function (req,res) {

    // This will render the view: 
    // /var/www/html/cyclopedia-sails/views/Article/create.ejs
    res.view();

  },


  /**
   * /article/view
   */ 
  view: function (req,res) {

    // This will render the view: 
    // /var/www/html/cyclopedia-sails/views/Article/view.ejs
    
    var filters = []
    
    if (req.session.user) {
      //getting the user's filter prefs - even if a guest user set prefs on the index page, they will be stored here.
      filters = req.session.user.preferences.filters;
    }

    var article = {};
    
    Article.find().where({id:  req.param("article")}).exec(function(err, articles) {
      article = articles;
    });
    
    var content = '';
    obscura.filterContent(filters, article[0].body, "html",function(err, val) {
	sails.log.warn(val);
        content = val;
      }
    );


    res.view({content: content, title: article[0].title});
  }

};
{'fraction_non_alphanumeric': 0.1574585635359116, 'fraction_numerical': 0.0007892659826361484, 'mean_word_length': 2.496551724137931, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '1992015', 'n_tokens_mistral': 861, 'n_tokens_neox': 821, 'n_words': 185}