Skip to content

Commit

Permalink
Added file exclusions to elastisearch index generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
othercorey committed Feb 22, 2020
1 parent 5131754 commit 355fe9e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.dockerignore
*Dockerfile*
**/.git
/build/
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ ENV DEBIAN_FRONTEND noninteractive
LABEL Description="This image is used to create an environment to contribute to the cakephp/docs"

RUN apt-get update && apt-get install -y \
latexmk \
openjdk-8-jdk \
php \
python3-pip \
texlive-latex-recommended \
texlive-latex-extra \
texlive-fonts-recommended \
texlive-lang-all \
latexmk \
openjdk-8-jdk \
texlive-latex-extra \
texlive-latex-recommended \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
7 changes: 4 additions & 3 deletions deploy.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ ENV DEBIAN_FRONTEND noninteractive
LABEL Description="This image is used to create deployable images for book.cakephp.org"

RUN apt-get update && apt-get install -y \
latexmk \
php \
python3-pip \
texlive-latex-recommended \
texlive-latex-extra \
texlive-fonts-recommended \
texlive-lang-all \
latexmk \
texlive-latex-extra \
texlive-latex-recommended \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
20 changes: 18 additions & 2 deletions scripts/populate_search_index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
define('ES_INDEX', 'documentation');
define('CAKEPHP_VERSION', '4-0');

// file exclusion patterns
const FILE_EXCLUSIONS = [
'/404\.rst$/',
];

/**
* The main function
*
Expand All @@ -32,13 +37,24 @@ function main($argv)
} else {
define('ES_HOST', ES_DEFAULT_HOST);
}

$directory = new RecursiveDirectoryIterator($lang);
$recurser = new RecursiveIteratorIterator($directory);
$matcher = new RegexIterator($recurser, '/\.rst/');

foreach ($matcher as $file) {
updateIndex($lang, $file);
$skip = false;
foreach (FILE_EXCLUSIONS as $exclusion) {
if (preg_match($exclusion, $file) === 1) {
echo "\nSkipping $file\n";
$skip = true;
break;
}
}

if (!$skip) {
updateIndex($lang, $file);
}
}

echo "\nIndex update complete\n";
Expand Down

0 comments on commit 355fe9e

Please sign in to comment.