Commit a9151c29 authored by Michael McAndrew's avatar Michael McAndrew

only display books on the home page if master has been defined

parent 7d90d585
......@@ -4,3 +4,4 @@ langs:
en:
repo: 'https://github.com/civicrm/civicrm-dev-docs'
latest: master
#stable: master
......@@ -45,7 +45,13 @@ class ReadController extends Controller
$yaml = new Parser();
foreach ($finder->in($this->get('kernel')->getRootDir().'/config/books')->name("*.yml") as $file) {
$books[basename($file, '.yml')] = $yaml->parse(file_get_contents("$file"));
$book = $yaml->parse(file_get_contents("$file"));
foreach($book['langs'] as $lang){
if(isset($lang['stable'])){
$books[basename($file, '.yml')] = $book;
break;
}
}
}
return $this->render('AppBundle:Read:home.html.twig', array('books'=>$books, 'locales' => $locales['Names']));
}
......
......@@ -15,11 +15,15 @@
{% for lang, language in book.langs %}
<li>
{{ attribute(locales, lang) }}:
<strong><a href="/{{url}}/{{ lang }}/stable">Current edition</a></strong>. Other editions:
<strong>
<a href="/{{url}}/{{ lang }}/stable">Current edition</a>
</strong>. Other editions:
</strong>
{% for version in language.history %}
<a href="/{{url}}/{{ lang }}/{{ version }}">{{ version }}</a>,
{% endfor %}
{% if language.history is defined %}
{% for version in language.history %}
<a href="/{{url}}/{{ lang }}/{{ version }}">{{ version }}</a>,
{% endfor %}
{% endif %}
<a href="/{{url}}/{{ lang }}/latest">latest</a>.</li>
{% endfor %}
</ul>
......
......@@ -136,23 +136,24 @@ class Publisher{
}
//@TODO script to check and update symlinks so that latest and stable point to the right places
$symlinks['latest'] = $bookConfig['langs'][$lang]['latest'];
$symlinks['stable'] = $bookConfig['langs'][$lang]['stable'];
$symlinks = array('latest', 'stable');
$langDir = realpath("$publishDir/..");
foreach($symlinks as $destination => $source){
$this->fs->remove("$langDir/$destination");
if ($this->fs->exists("$langDir/$source")) {
$this->fs->symlink("$langDir/$source", "$langDir/$destination");
} else {
$this->addMessage('CRITICAL', "'$source' is defined as the $destination version of this documentation but is not yet published. <a href='{$this->baseUrl}/admin/publish/{$book}/{$lang}/{$source}'>Publish now</a>");
foreach($symlinks as $symlink){
if(isset($bookConfig['langs'][$lang][$symlink])){
$source = $bookConfig['langs'][$lang][$symlink];
if ($this->fs->exists("$langDir/$source")) {
if ($this->fs->exists("$langDir/$symlink")) {
$this->fs->remove("$langDir/$symlink");
$this->fs->symlink("$langDir/$source", "$langDir/$symlink");
}
} else {
$this->addMessage('CRITICAL', "'$source' is defined as the '{$symlink}' version of this documentation but is not yet published. <a href='{$this->baseUrl}/admin/publish/{$book}/{$lang}/{$source}'>Publish now</a>");
}
}else{
$this->addMessage('WARNING', "'{$symlink}' is not defined in this documentation's config file.");
}
// if ($this->fs->exists("$langDir/$destination")) {
// echo $this->fs->remove("$langDir/$destination");exit;
// }
// }
}
}
......
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