<commit_before>/*
 * rss.js: Methods for generating an rss feed.
 *
 * (C) 2011, Nodejitsu Inc.
 *
 */

var smith    = require('../blacksmith'),
    Rss     = require('rss'),
    fs2      = require('../fs2');

var rss = exports;

rss.weld = function (dom, feed) {
  var $ = smith.window.$;

  // Welding, in this case, is a misnomer. In this case, we use the generated
  // content to populate the rss feed.
  Object.keys(smith.content.content).forEach(function (k) {
    var content = smith.content.content[k];

    dom.innerHTML = content.content;

    feed.item({
      title: content.metadata && content.metadata.title || "",
      description: $("#content", content.content).html(),
      author: content.metadata && content.metadata.author || "",
      date: content.metadata && content.metadata.date || new Date()
    });
  });

  return dom;
  
};

rss.generate = function (output, data) {
  // Write rss.xml to disk.
  var xml = data.xml();

  var newPath = __dirname + '/../../public/rss.xml';

  smith.log.info("Writing " + newPath);<commit_msg>[fix] rss now generates in the correct folder.<commit_after>/*
 * rss.js: Methods for generating an rss feed.
 *
 * (C) 2011, Nodejitsu Inc.
 *
 */

var smith = require('../blacksmith'),
    Rss = require('rss'),
    path = require('path'),
    fs2 = require('../fs2');

var rss = exports;

rss.weld = function (dom, feed) {
  var $ = smith.window.$;

  // Welding, in this case, is a misnomer. In this case, we use the generated
  // content to populate the rss feed.
  Object.keys(smith.content.content).forEach(function (k) {
    var content = smith.content.content[k];

    dom.innerHTML = content.content;

    feed.item({
      title: content.metadata && content.metadata.title || "",
      description: $("#content", content.content).html(),
      author: content.metadata && content.metadata.author || "",
      date: content.metadata && content.metadata.date || new Date()
    });
  });

  return dom;
  
};

rss.generate = function (output, data) {
  // Write rss.xml to disk.
  var xml = data.xml();

  var newPath =  path.resolve("./public/feed.xml");

  smith.log.info("Writing " + newPath);
{'fraction_non_alphanumeric': 0.1685185185185185, 'fraction_numerical': 0.005555555555555556, 'mean_word_length': 2.8658318425760285, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '6051765', 'n_tokens_mistral': 713, 'n_tokens_neox': 681, 'n_words': 185}