Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Documentation
Docs Publisher
Commits
288a1454
Commit
288a1454
authored
Mar 10, 2017
by
Sean Madsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Book categorization to close
#30
parent
16e2d7fc
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
47 additions
and
11 deletions
+47
-11
books/dev.yml
books/dev.yml
+1
-0
books/user.yml
books/user.yml
+1
-0
src/AppBundle/Controller/ReadController.php
src/AppBundle/Controller/ReadController.php
+7
-2
src/AppBundle/Model/Book.php
src/AppBundle/Model/Book.php
+8
-0
src/AppBundle/Model/Library.php
src/AppBundle/Model/Library.php
+17
-0
src/AppBundle/Resources/views/Read/book_list.html.twig
src/AppBundle/Resources/views/Read/book_list.html.twig
+2
-2
src/AppBundle/Resources/views/Read/home.html.twig
src/AppBundle/Resources/views/Read/home.html.twig
+11
-7
No files found.
books/dev.yml
View file @
288a1454
name
:
Developer guide
weight
:
10
description
:
For CiviCRM developers
category
:
Core
langs
:
en
:
repo
:
'
https://github.com/civicrm/civicrm-dev-docs'
...
...
books/user.yml
View file @
288a1454
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'
...
...
src/AppBundle/Controller/ReadController.php
View file @
288a1454
...
...
@@ -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'
),
)
);
}
...
...
src/AppBundle/Model/Book.php
View file @
288a1454
...
...
@@ -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
);
}
/**
...
...
src/AppBundle/Model/Library.php
View file @
288a1454
...
...
@@ -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.
*
...
...
src/AppBundle/Resources/views/Read/book_list.html.twig
View file @
288a1454
<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
%}
...
...
src/AppBundle/Resources/views/Read/home.html.twig
View file @
288a1454
...
...
@@ -21,8 +21,12 @@
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'
%}
{%
include
'AppBundle:Read:book_list.html.twig'
with
{
books
:
core_books
}
%}
<h2>
Extensions Books
</h2>
{%
include
'AppBundle:Read:book_list.html.twig'
with
{
books
:
extensions_books
}
%}
{%
endblock
%}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment