Commit 038480b2 authored by Sean Madsen's avatar Sean Madsen

home page - better display of editions

parent 9a5d988d
......@@ -66,6 +66,25 @@ class Book {
return count($this->languages) > 1;
}
/**
* @return integer The total number of language/version combinations defined
* for this book
*/
public function countEditions() {
$sum = 0;
foreach ($this->languages as $language) {
$sum = $sum + $language->countVersions();
}
return $sum;
}
/**
* @return bool TRUE if the book has more than one language/version combo
*/
public function isMultiEdition() {
return $this->countEditions() > 1;
}
/**
* Selects one of the languages within the book
*
......@@ -88,7 +107,7 @@ class Book {
* @return \AppBundle\Model\Language
*/
public function getDefaultLanguage() {
return current($this->languages);
return $this->languages[0];
}
/**
......
......@@ -174,6 +174,13 @@ class Language {
return count($this->versions) > 1;
}
/**
* @return integer
*/
public function countVersions() {
return count($this->versions);
}
/**
* Retrieves a version object defined for this language
*
......@@ -196,7 +203,7 @@ class Language {
* @return \AppBundle\Model\Version
*/
public function getDefaultVersion() {
return current($this->versions);
return $this->versions[0];
}
/**
......
<ul class="books">
{% for book in books %}
<li class="book">
{% set editionClass = (book.isMultiEdition) ? 'multi_edition' : 'single_edition' %}
<li class="book {{ editionClass }}">
<div>
{% set language = book.getDefaultLanguage() %}
{% set version = language.getDefaultVersion() %}
{% set language = book.getDefaultLanguage %}
{% set version = language.getDefaultVersion %}
{% set url = "/" ~ book.slug ~ "/" ~ language.code ~ "/" ~ version.name %}
<a href="{{ url }}">
<span class="name">
......@@ -13,13 +14,18 @@
({{ language.nativeName() }} / {{ version.name }})
</span>
</a>
<span class="other-editions">
<a href="/{{ book.slug }}">(Other editions)</a>
</span>
{% set countOtherEditions = book.countEditions - 1 %}
{% 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>
</span>
{% endif %}
</div>
<div class="description">
{{ book.description }}
</div>
</li>
{% endfor %}
</ul>
......@@ -41,7 +41,7 @@ header nav a:hover {
}
/* Footer */
/* Footer */
body, .footer {
background-color: #363333 !important;
......@@ -51,7 +51,7 @@ body, .footer {
padding: 0px;
margin: 0px;
color: #DADADA;
font-size: 80%;
font-size: 80%;
}
.footer .container {
......@@ -65,7 +65,7 @@ body, .footer {
/* Home page */
/* Book list (on Home page) */
.book {
margin-bottom: 0.8em;
......@@ -76,23 +76,13 @@ body, .footer {
font-size: 120%;
}
.book .edition,
.book .other-editions a {
.book.single_edition .edition{
color: #C2CCCF;
}
.book a:hover .edition,
.book .other-editions a:hover {
color: #056186;
}
.book .other-editions {
padding-left: 0.8em;
font-style: italic;
}
.book .description {
.book .or {
color: #C2CCCF;
padding: 0px 1em;
}
......
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