Commit 99390f84 authored by Sean Madsen's avatar Sean Madsen

Merge branch 'editions' into 'master'

redirect to default language; details of editions on a new editions page.

See merge request documentation/docs-publisher!80
parents cbbf3243 809ec99c
......@@ -26,10 +26,30 @@ class ReadController extends Controller {
* Displays a page for one book which shows the various languages and
* versions available for the book
*
* @route("/{slug}/", requirements={"slug": "(?!_)(?!admin/)[^/]+"},
* name="book_home")
* @route("/{slug}/", name="book", requirements={"slug": "(?!_)(?!admin/)[^/]+"})
*/
public function BookAction($slug) {
/** @var \AppBundle\Model\Library */
$library = $this->get('library');
/** @var \AppBundle\Model\Book */
$book = $library->getBookBySlug($slug);
if (!$book) {
throw $this->createNotFoundException(
"We can't find a '$slug' book");
}
$language = $book->getDefaultLanguage();
$version = $language->getDefaultVersion();
return $this->redirect("/{$slug}/{$language->code}/{$version->path}");
}
/**
* Displays a page for one book which shows the various languages and
* versions available for the book
*
* @route("/{slug}/editions", requirements={"slug": "(?!_)(?!admin/)[^/]+"},
* name="book_editions")
*/
public function EditionsAction($slug) {
/** @var \AppBundle\Model\Library */
$library = $this->get('library');
$book = $library->getBookBySlug($slug);
......@@ -45,7 +65,11 @@ class ReadController extends Controller {
* @route("/{slug}/{code}/", requirements={"slug": "(?!_)(?!admin/)[^/]+"})
*/
public function LanguageAction($slug, $code) {
return $this->redirectToRoute('book_home', array('slug' => $slug));
/** @var \AppBundle\Model\Library */
$path = "{$slug}/{$code}";
$library = $this->get('library');
$id = $library->getObjectsByIdentifier($path);
$version = $id['language']->getDefaultVersion()->path;
return $this->redirect("/{$path}/{$version}");
}
}
......@@ -22,7 +22,7 @@
{{ config.site_name }}
<span class="edition">({{ config.extra.edition }})</span>
</a>
<a href="{{ config.extra.book_home }}" class="other-editions">
<a href="{{ config.extra.book_home }}/editions" class="other-editions">
(Other editions)
</a>
</div>
......
......@@ -18,7 +18,7 @@
{% if countOtherEditions > 0 %}
<span class="or">&ndash;&nbsp;or&nbsp;&ndash;</span>
<span class="other-editions">
<a href="/{{ book.slug }}">(See all {{ book.countEditions }} editions)</a>
<a href="/{{ book.slug }}/editions">(See all {{ book.countEditions }} editions)</a>
</span>
{% endif %}
</div>
......
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