Commit 196ba057 authored by Sean Madsen's avatar Sean Madsen

a home page for each book

parent 16e2d7fc
......@@ -4,20 +4,91 @@
<head>
<meta charset="UTF-8">
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
<title>{% block title %}CiviCRM documentation{% endblock %}</title>
<title>
{% if page_title is defined %}
{{ page_title }} -
{% endif %}
CiviCRM documentation
</title>
<link media="all" href="https://civicrm.org/sites/all/themes/civicrm_bootstrap/css/style.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="{{ asset('/static/css/main.css') }}" />
{% block stylesheets %}{% endblock %}
<link media="all" href="https://civicrm.org/sites/all/themes/civicrm_bootstrap/css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="container">
<div class="row-stripe">
<div>
{% block body %}{% endblock %} {% block javascripts %}{% endblock %}
</div>
<header>
<div class="container">
<nav>
<a href="https://civicrm.org">
<img class="logo" width="75" height="77" src="/static/images/logo.svg" alt=""/>
CiviCRM
</a>
<span class="separator">/</span>
<a href="/">Documentation</a>
{% if block('extra_links') is not empty %}
<span class="separator">/</span>
{% endif %}
{% block extra_links %}{% endblock %}
</nav>
</div>
</header>
<div class="page">
<div class="container">
<div class="row-stripe">
<h1>
{% if page_title is defined %}
{{ page_title }}
{% else %}
CiviCRM Documentation
{% endif %}
</h1>
<div class="content">
{% block content %}{% endblock %}
</div>
</div>
</div>
</div>
<div class="footer">
<div class="container">
<div class="row-stripe">
<div>
<p>CiviCRM documentation is maintained by community members, with
facilitation from the
<a href="https://civicrm.org/working-groups/documentation">
Documentation Working Group.</a>
</p>
<p>To get involved, read about <a href="/dev/en/latest/documentation/">
contributing to documentation</a>, or join us in the
<a href="https://chat.civicrm.org/civicrm/channels/documentation">
documentation chat room</a>!
</p>
<p>This site publishes documentation books using a
<a href="https://github.com/civicrm/civicrm-docs">custom system</a>
maintained by the community. To give feedback about this site, please
<a href="https://github.com/civicrm/civicrm-docs/issues">
file an issue</a>.
</p>
</div>
</div>
</div>
</div>
{% block javascripts %}{% endblock %}
</body>
</html>
......@@ -17,4 +17,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")
*/
public function BookAction($slug) {
/** @var \AppBundle\Model\Library */
$library = $this->get('library');
$book = $library->getBookBySlug($slug);
if (!$book) {
throw $this->createNotFoundException(
"We can't find a '$slug' book");
}
return $this->render('AppBundle:Read:book.html.twig', array(
'book' => $book));
}
/**
* @route("/{slug}/{code}/", requirements={"slug": "(?!_)(?!admin/)[^/]+"})
*/
public function LanguageAction($slug, $code) {
return $this->redirectToRoute('book_home', array('slug' => $slug));
}
}
......@@ -76,6 +76,13 @@ class Book {
return $chosen;
}
/**
* @return \AppBundle\Model\Language
*/
public function getDefaultLanguage() {
return current($this->languages);
}
/**
* Check this book for any problems in the way it's defined.
*
......
......@@ -192,6 +192,13 @@ class Language {
return $chosen;
}
/**
* @return \AppBundle\Model\Version
*/
public function getDefaultVersion() {
return current($this->versions);
}
/**
* Retrieves a version object defined for this language, based on a descriptor
* which can be either a branch, or a name, or an alias.
......
{% extends "::base.html.twig" %}
{% set page_title = book.name %}
{% block extra_links %}
<span>{{ book.name }}</span>
{% endblock %}
{% block content %}
<ul>
{% set default_language = book.getDefaultLanguage() %}
{% set default_version = default_language.getDefaultVersion() %}
{% set default_url = book.slug ~ "/" ~ default_language.code ~ "/"
~ default_version.name %}
{% set default_title = default_language.nativeName() ~ " / " ~ default_version.name %}
<li>Default edition: <a href="{{ default_url }}">{{ default_title }}</a></li>
{# <li>Category: {{ book.category }}</li> #} {# uncomment when we have categorization #}
</ul>
<h2>Description</h2>
<p>{{ book.description }}</p>
<h2>All available editions:</h2>
<table class="editions">
<tr>
<th>Language</th>
<th>Version</th>
<th></th>
</tr>
{% for language in book.languages %}
{% for version in language.versions %}
{% set url = "/" ~ book.slug ~ "/" ~ language.code ~ "/" ~ version.name %}
<tr>
<td class="language">
<span class="native-name">{{ language.nativeName }}</span>
{% if language.nativeName != language.englishName %}
<span class="english-name">({{ language.englishName }})</span>
{% endif %}
</td>
<td class="version">
<span class="version-name">{{ version.name }}</span>
<span class="branch">({{ version.branch }} branch)</span></td>
<td class="links">
<a href="{{ url }}" class="read button">Read</a>
{% if version.branch == 'master' %}
{% set repo_url = language.repo %}
{% else %}
{% set repo_url = language.repo ~ "/tree/" ~ version.branch %}
{% endif %}
<a href="{{ repo_url }}" class="repo">
Source&nbsp;code
</a>
</td>
</tr>
{% endfor %}
{% endfor %}
</table>
{% endblock %}
<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 %}
{{ book.name }}
{% else %}
{% set language = book.languages|first %}
{% set url = "/" ~ book.slug ~ "/" ~ language.code ~ "/latest" %}
<a href="{{ url }}">{{ book.name }}</a>
{% endif %}
</span>
<span class="separator">&ndash;</span>
<span class="description">{{ book.description }}</span>
{% if book.isMultiLanguage %}
{% include 'AppBundle:Read:language_list.html.twig' %}
{% elseif book.languages|first.isMultiVersion %}
{% include 'AppBundle:Read:version_list.html.twig'
with {language: book.languages|first} %}
{% endif %}
<div>
{% set language = book.getDefaultLanguage() %}
{% set version = language.getDefaultVersion() %}
{% set url = "/" ~ book.slug ~ "/" ~ language.code ~ "/" ~ version.name %}
<a href="{{ url }}">
<span class="name">
{{ book.name }}
</span>
<span class="edition">
({{ language.nativeName() }} / {{ version.name }})
</span>
<span class="other-editions">
<a href="/{{ book.slug }}">(Other editions)</a>
</span>
</a>
</div>
<div class="description">
{{ book.description }}
</div>
</li>
{% endfor %}
</ul>
{% extends "::base.html.twig" %}
{% block title %}CiviCRM Documentation{% endblock %}
{% block body %}
<a href="https://civicrm.org">CiviCRM home</a>
<h1>CiviCRM Documentation</h1>
{% block content %}
<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>
{% include 'AppBundle:Read:book_list.html.twig' %}
{% include 'AppBundle:Read:book_list.html.twig' with {books: library.books} %}
{% endblock %}
<ul class="languages">
{% for language in book.languages %}
<li class="language {{ language.code }}">
{% spaceless %}
<span class="language-name">
{% if language.isMultiVersion %}
{{- language.descriptiveName -}}
<span class="separator">:</span>
{% else %}
{% set url = "/" ~ book.slug ~ "/" ~ language.code ~ "/latest" %}
<a href="{{ url }}">
{{- language.descriptiveName -}}
</a>
{% endif %}
</span>
{% endspaceless %}
{% if language.isMultiVersion %}
{% include 'AppBundle:Read:version_list.html.twig' %}
{% endif %}
</li>
{% endfor %}
</ul>
{% for version in language.versions %}
<ul class="versions">
<li class="version">
{% set url = "/" ~ book.slug ~ "/" ~ language.code ~ "/" ~ version.name %}
<a href="{{ url }}">{{ version.name }} version</a>
</li>
</ul>
{% endfor %}
\ No newline at end of file
/* Basic elements */
h2 {
font-size: 160% !important;
}
/* Header */
header {
background-color: #3387ac;
padding: 10px 0px;
color: #BBDEED;
box-shadow: 0px 2px 3px rgba(0,0,0,0.2);
}
header .logo {
height: 50px;
}
header nav a {
color: white;
}
header nav .separator {
padding: 5px;
}
header nav a:hover {
color: white;
}
/* Page */
.page {
background-color: white;
min-height: 600px;
}
/* Footer */
body, .footer {
background-color: #363333 !important;
}
.footer {
padding: 0px;
margin: 0px;
color: #DADADA;
font-size: 80%;
}
.footer .container {
margin-top: 25px;
}
.footer a, .footer a:hover, .footer a:active {
color: #85D453;
}
/* Home page */
.book {
......@@ -12,6 +77,47 @@
font-style: italic;
}
/* Editions table */
table {
border-collapse: collapse;
}
td, th {
padding: 5px !important;
}
.english-name, .version .branch {
font-style: italic;
font-size: 80%;
color: #888;
}
.button {
display: inline-block;
padding: 8px 12px;
background: #6FB346;
border-radius: 4px;
font-weight: bold;
color: white;
}
.button:hover {
box-shadow: 2px 2px 3px rgba(0,0,0,0.3);
color: white;
}
.repo {
padding-left: 1em;
font-style: italic;
font-size: 80%;
}
/* Publishing messages */
.message {
......
This diff is collapsed.
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