Skip to content

Commit

Permalink
remove search stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
rmurphey committed Jan 5, 2016
1 parent ea2734f commit c7a328a
Showing 1 changed file with 2 additions and 43 deletions.
45 changes: 2 additions & 43 deletions bin/blog.js
Expand Up @@ -9,7 +9,6 @@ var path = require('path');
var moment = require('moment');
var Promise = require('promise'); // jshint ignore:line
var readline = require('readline');
var elasticsearch = require('elasticsearch');
var fs = require('then-fs');
var exec = require('child_process').exec;
var rl = readline.createInterface({
Expand Down Expand Up @@ -111,12 +110,7 @@ function publish(title) {
return fs.writeFile(draftData, JSON.stringify(drafts, '', 2));
});
}).then(function () {
return fs.readFile(source, 'utf8').then(addToSearch.bind(null, {
slug: slug,
title: post.title,
tags: post.tags,
date: post.date,
}));
return fs.readFile(source, 'utf8');
}).then(function () {
return new Promise(function (resolve, reject) {
exec('git mv ' + source + ' ' + target, function (error, stdout, stderr) {
Expand Down Expand Up @@ -173,41 +167,6 @@ function prompt() {
});
}

function addToSearch(json, doc) {
return new Promise(function (resolve, reject) {
if (!process.env.BONSAI_URL) {
console.log('Need to manually insert search data');
resolve();
}

var client = new elasticsearch.Client({
host: process.env.BONSAI_URL,
log: 'trace',
});

client.create({
index: 'blog-posts',
type: 'blog',
id: json.slug,
body: {
title: json.title,
tags: json.tags,
published: true,
date: json.date,
body: doc.replace(/<(?:.|\n)*?>/gm, ''), // strip html
counter: 1,
},
}, function (error, response) {
client.close();
if (error) {
return reject(error);
}

resolve();
});
});
}

var actions = {
draft: draft,
publish: publish,
Expand Down Expand Up @@ -235,4 +194,4 @@ function blog() {
});
}

module.exports = blog;
module.exports = blog;

0 comments on commit c7a328a

Please sign in to comment.