Skip to content

Commit

Permalink
Fix script. Somehow I broke it.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Feb 29, 2012
1 parent aa73255 commit 94fa42c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions scripts/populate_search_index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Elastic search config
define('ES_URL', 'http://localhost:9200');
define('ES_INDEX', 'documentation');
define('ES_TYPE', 'docs');


function main($argv) {
Expand All @@ -30,19 +29,20 @@ function main($argv) {

function update_index($lang, $file) {
$contents = file_get_contents($file);
list($filename) = explode('.', $file);
$filename = $file->getPathName();
list($filename) = explode('.', $filename);

$path = str_replace($lang . '/', '', $filename) . '.html';
$filename = str_replace('/', '-', $filename);
$filename = trim($filename, '-');
$path = $filename . '.html';
$id = str_replace($lang . '/', '', $filename);
$id = str_replace('/', '-', $id);
$id = trim($id, '-');

$url = implode('/', array(ES_URL, ES_INDEX, ES_TYPE, $filename));
$url = implode('/', array(ES_URL, ES_INDEX, $lang, $id));

$data = array(
'url' => $path,
'title' => $filename,
'contents' => $contents,
'lang' => $lang
'title' => $filename,
'url' => $path,
);

$data = json_encode($data);
Expand All @@ -52,7 +52,7 @@ function update_index($lang, $file) {
fwrite($fh, $data);
rewind($fh);

echo "Sending request for $file\n";
echo "Sending request for $file to $url\n";

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_PUT, true);
Expand Down

0 comments on commit 94fa42c

Please sign in to comment.