Commit bc33e12c authored by Sean Madsen's avatar Sean Madsen Committed by GitHub

Merge pull request #47 from seanmadsen/categories

Book categories
parents d2c0f5d1 bf027037
name: Developer guide
weight: 10
description: For CiviCRM developers
category: Core
langs:
en:
repo: 'https://github.com/civicrm/civicrm-dev-docs'
......
name: User guide
weight: -100
description: Aimed at day to day users of CiviCRM.
category: Core
langs:
en:
repo: 'https://github.com/civicrm/civicrm-user-guide'
......
......@@ -11,9 +11,14 @@ class ReadController extends Controller {
* @Route("/")
*/
public function HomeAction() {
/** @var \AppBundle\Model\Library $library */
$library = $this->get('library');
return $this->render(
'AppBundle:Read:home.html.twig',
array('library' => $this->get('library'))
'AppBundle:Read:home.html.twig', array(
'core_books' => $library->getBooksByCategory('Core'),
'extensions_books' => $library->getBooksByCategory('Extensions'),
)
);
}
......
......@@ -33,6 +33,12 @@ class Book {
*/
public $weight;
/**
*
* @var string (e.g. "Core", "Extensions") Should be in sentence case
*/
public $category;
/**
* Creates a book based on a yaml conf file
*
......@@ -49,6 +55,8 @@ class Book {
foreach ($yaml['langs'] as $code => $languageData) {
$this->languages[] = new Language($code, $languageData);
}
$category = isset($yaml['category']) ? $yaml['category'] : "Extensions";
$this->category = ucwords($category);
}
/**
......
......@@ -99,6 +99,23 @@ class Library {
return $chosen;
}
/**
* Gives an array of book objects which match a given category
*
* @param string $category
*
* @return array of Book objects
*/
public function getBooksByCategory($category) {
$books = array();
foreach ($this->books as $book) {
if ($book->category == $category) {
$books[] = $book;
}
}
return $books;
}
/**
* See which books/languages are using a given repository.
*
......
<ul class="books">
{% for book in library.books %}
{% for book in books %}
<li class="book">
<span class="name">
{% if book.isMultiLanguage or book.languages|first.isMultiVersion %}
......@@ -15,7 +15,7 @@
{% if book.isMultiLanguage %}
{% include 'AppBundle:Read:language_list.html.twig' %}
{% elseif book.languages|first.isMultiVersion %}
{% include 'AppBundle:Read:version_list.html.twig'
{% include 'AppBundle:Read:version_list.html.twig'
with {language: book.languages|first} %}
{% endif %}
</li>
......
......@@ -3,26 +3,30 @@
{% block title %}CiviCRM Documentation{% endblock %}
{% block body %}
<a href="https://civicrm.org">CiviCRM home</a>
<h1>CiviCRM Documentation</h1>
<p>CiviCRM offers community contributed documentation in the form of digital
<em>books</em>, listed below. We encourage everyone to
<em>books</em>, listed below. We encourage everyone to
<a href="https://docs.civicrm.org/dev/en/latest/documentation/">
help contribute to documentation</a>.</p>
<p><em>Note: some documentation has not yet been moved into book format and
can still be found on our
<p><em>Note: some documentation has not yet been moved into book format and
can still be found on our
<a href="https://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Documentation">wiki</a>
while it awaits migration. In particular, information about
while it awaits migration. In particular, information about
<a href="https://wiki.civicrm.org/confluence/display/CRMDOC/Installation+and+Upgrades">
installation and upgrades</a>
is still on the wiki.</em></p>
<h2>Books</h2>
<h2>Core Books</h2>
{% include 'AppBundle:Read:book_list.html.twig' with {books: core_books} %}
<h2>Extensions Books</h2>
{% include 'AppBundle:Read:book_list.html.twig' %}
{% include 'AppBundle:Read:book_list.html.twig' with {books: extensions_books} %}
{% endblock %}
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