Commit 3e0445b1 authored by mickadoo's avatar mickadoo

68: Refactoring

parent 89ffcb5a
......@@ -186,13 +186,13 @@ class Publisher {
$version = $this->getVersion($book, $language, $versionDescriptor);
$branch = $version->branch;
$bookRepo = $language->repo;
$tmpPrefix = $book->slug . '_' . $language->code . '_' . time();
$langCode = $language->code;
$tmpPrefix = $book->slug . '_' . $langCode . '_' . time();
$repoRoot = $this->paths->getRepoPathRoot();
$this->showVersionInfo($book, $language, $version);
$repoRoot = $this->paths->getRepoPathRoot();
$masterRepoDir = sprintf('%s/%s/%s', $repoRoot, $book->slug, $language->code);
$masterRepoDir = sprintf('%s/%s/%s', $repoRoot, $book->slug, $langCode);
$this->setupLocalRepo($masterRepoDir, $bookRepo);
$repoPrefix = 'repo_' . $tmpPrefix;
$tmpRepoDir = $this->makeTmpRepo($repoPrefix, $masterRepoDir);
......@@ -206,10 +206,11 @@ class Publisher {
$this->build($book, $language, $version, $tmpRepoDir, $tmpPublishDir);
$path = "{$book->slug}/{$language->code}/{$branch}";
$path = "{$book->slug}/{$langCode}/{$branch}";
$webRoot = $this->paths->getPublishPathRoot() . "/{$path}";
$this->fs->mkdir($webRoot);
$this->fs->removeDir($webRoot);
$this->fs->copyDir($tmpPublishDir, $webRoot);
$format = "<a href='/%s'>Book published successfully</a>.";
......@@ -219,9 +220,7 @@ class Publisher {
$this->setupSymlinks($book, $language, $version, $webRoot);
$this->setupRedirects($tmpRepoDir, $webRoot);
$this->fs->removeDir($tmpRepoDir);
$this->fs->removeDir($tmpPublishDir);
// todo remove yaml file generated by publishing
$this->cleanup($tmpRepoDir, $tmpPublishDir, $publishPrefix);
}
/**
......@@ -427,4 +426,16 @@ class Publisher {
return $tmpRepoDir;
}
/**
* @param $tmpRepoDir
* @param $tmpPublishDir
* @param $publishPrefix
*/
private function cleanup($tmpRepoDir, $tmpPublishDir, $publishPrefix) {
$this->fs->removeDir($tmpRepoDir);
$this->fs->removeDir($tmpPublishDir);
$mkdocsSiteFile = $publishPrefix . '-mkdocs.yml';
$this->fs->remove($mkdocsSiteFile);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment