Skip to content

Commit

Permalink
Merge branch 'release/v0.14.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed May 23, 2016
2 parents 3a4670e + 302b164 commit 770bedc
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 132 deletions.
6 changes: 3 additions & 3 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@
# built documents.
#
# The short X.Y version.
version = '0.13.0'
version = '0.14.0'
# The full version, including alpha/beta/rc tags.
release = 'alpha 0.13.0'
release = 'alpha 0.14.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -316,7 +316,7 @@
epub_title = u'Roadiz'
epub_author = u'Ambroise Maupate, Maxime Constantinian, Julien Blanchet, Thomas Aufresne'
epub_publisher = u'REZO ZERO'
epub_copyright = u'2015, Ambroise Maupate & Julien Blanchet'
epub_copyright = u'2016, Ambroise Maupate & Julien Blanchet'

# The basename for the epub file. It defaults to the project name.
#epub_basename = u'Roadiz'
Expand Down
19 changes: 9 additions & 10 deletions developer/first-steps/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,27 @@ CMS Structure
Requirements
------------

Roadiz is a web application running with PHP. It requires an HTTP server for static assets and SSH with out/ingoing allowed connections.

.. note::
If you are using a *shared hosting plan*, make sure that your server’s SSH connection allows external connections. You can verify with a simple ``ping google.com``.
If you get request timeouts, your hosting provider might be blocking your SSH connectivity.
You should consider using at least a VPS-like hosting.
If you really need to setup Roadiz on a simple shared-hosting plan, we encourage you to install it on your own computer and send it with SFTP/FTP (it might take a long time) or *rsync* it.

Roadiz is a web application running with PHP. It requires an HTTP server for static assets and **SSH access** with out/ingoing allowed connections.
Here is a short summary of mandatory elements before installing Roadiz:

* Nginx or Apache, with a dedicated virtual host as described below.
* PHP 5.4.3+
* PHP 5.4.3+, PHP 5.6 or 7+ recommended
* ``php5-gd`` extension
* ``php5-intl`` extension
* ``php5-curl`` extension
* PHP cache (APC/XCache) + Var cache (strongly recommended)
* PHP cache (APC/OPCache) + Var cache (strongly recommended)
* MariaDB/MySQL/PostgreSQL or SQLite database (do not forget to install ``php5-xxxsql`` extension according to your database driver flavor)
* Zip/Unzip
* cUrl
* Composer
* Git

.. note::
If you are using a *shared hosting plan*, make sure that your server’s SSH connection allows external connections. You can verify with a simple ``ping google.com``.
If you get request timeouts, your hosting provider might be blocking your SSH connectivity.
You should consider using at least a VPS-like hosting.
If you really need to setup Roadiz on a simple shared-hosting plan, we encourage you to install it on your own computer and send it with SFTP/FTP (it might take a long time) or *rsync* it.

For Nginx users
^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion developer/first-steps/moving.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Now you can perform a schema update without losing your nodes data:
bin/roadiz orm:schema-tool:update --dump-sql;
bin/roadiz orm:schema-tool:update --force;
bin/roadiz cache:clear --env=prod
bin/roadiz cache:clear -e prod
.. note::
If you are using an OPcode cache like XCache or APC, you’ll need to purge cache manually
Expand Down
4 changes: 2 additions & 2 deletions developer/first-steps/upgrading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Upgrading
**Always do a database backup before upgrading.** You can use the *mysqldump* or *pg_dump* tools
to quickly export your database as a file.

* With a MySQL server: ``mysqldump -u [user] -p[user_password] [database_name] > dumpfilename.sql``
* With a MySQL server: ``mysqldump -u[user] -p[user_password] [database_name] > dumpfilename.sql``
* With a PostgreSQL server: ``pg_dump -U [user] [database_name] -f dumpfilename.sql``

Download latest version using *Git*
Expand Down Expand Up @@ -43,7 +43,7 @@ Then, if migration summary is OK (no data loss), perform the following changes:
.. code-block:: bash
bin/roadiz orm:schema-tool:update --force;
bin/roadiz cache:clear --env=prod
bin/roadiz cache:clear -e prod
.. note::
If you are using an OPcode cache like XCache or APC, you’ll need to purge cache manually
Expand Down
2 changes: 1 addition & 1 deletion developer/first-steps/vagrant.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ When you use default `vagrant up` command, it’s the same as using:
# Default vagrant up provisioners
vagrant up --no-provision
vagrant provision --provision-with roadiz,phpmyadmin,mailcatcher,solr,devtools
vagrant provision --provision-with=roadiz,phpmyadmin,mailcatcher,solr,devtools
.. note::
Pay attention that *mailcatcher* and *solr* provision scripts may take several
Expand Down
5 changes: 1 addition & 4 deletions developer/forms/contact_forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ Then in your contact page Twig template
{% if session.messages|length %}
{% for type, msgs in session.messages %}
{% for msg in msgs %}
<div data-uk-alert class="uk-alert
uk-alert-{% if type == "confirm" %}success
{% elseif type == "warning" %}warning{% else %}danger{% endif %}">
<a href="" class="uk-alert-close uk-close"></a>
<div class="alert alert-{% if type == "confirm" %}success{% elseif type == "warning" %}warning{% else %}danger{% endif %}">
<p>{{ msg }}</p>
</div>
{% endfor %}
Expand Down
62 changes: 60 additions & 2 deletions developer/services/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,74 @@ in your themes.
* Firewall: ``$this->getService('firewall')``
* …


Entity APIs
-----------

All these services are Doctrine repository wrappers meant to ease querying
entities inside your themes and according to ``AuthorizationChecker``.
entities inside your themes and according to ``AuthorizationChecker``. This will
implicitely check if nodes or node-sources are published when you request them
without bothering to insert the right criteria in your *findBy* calls.

Each of these implements ``AbstractApi`` methods ``getBy`` and ``getOneBy``

* `nodeApi <http://api.roadiz.io/RZ/Roadiz/CMS/Utils/NodeApi.html>`_
* `nodeTypeApi <http://api.roadiz.io/RZ/Roadiz/CMS/Utils/NodeTypeApi.html>`_
* `nodeSourceApi <http://api.roadiz.io/RZ/Roadiz/CMS/Utils/NodeSourceApi.html>`_
* `tagApi <http://api.roadiz.io/RZ/Roadiz/CMS/Utils/TagApi.html>`_

Using Solr API
--------------

Solr is a really powerful tool to search over your node database with
a clever plain-text search engine and the ability to highlight your criteria
in the search results. Before going further, make sure that a Solr server is available
and that it is well configured in your ``config.yml``. You can use the
``bin/roadiz solr:check`` command to verify and then ``bin/roadiz solr:reindex`` command
to force synchronizing your node database with Solr index.

You can use the ``solr.search.nodeSource`` service and its two methods to
get node-sources from a search query.

Simple search results
^^^^^^^^^^^^^^^^^^^^^

``$this->getService('solr.search.nodeSource')->search()`` method will return an array of ``NodesSources``

.. code-block:: php
$criteria = [];
$results = $this->getService('solr.search.nodeSource')
->search(
$request->get('q'), # Use ?q query parameter to search with
$criteria, # a simple criteria array to filter search results
10, # result count
true # Search in tags too
);
foreach ($results as $nodeSource) {
# NodesSources object
echo $nodeSource->getTitle();
}
Search results with hightlighting
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

``$this->getService('solr.search.nodeSource')->searchWithHighlight()`` method will return an array of array with a simple structure: ``nodeSource`` for the NodesSources object and ``highlighting`` for the *html* data with highlighted text wrapped in ``span.solr-highlight`` html tag.

.. code-block:: php
$criteria = [];
$results = $this->getService('solr.search.nodeSource')
->searchWithHighlight(
$request->get('q'), # Use ?q query parameter to search with
$criteria, # a simple criteria array to filter search results
10, # result count
true # Search in tags too
);
foreach ($results as $result) {
# NodesSources object
$nodeSource = $result['nodeSource'];
# String object (HTML)
$hightlight = $result['highlighting'];
}
125 changes: 23 additions & 102 deletions developer/themes/theme_firewall.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ to be sure that ``^/`` request matcher has **the lowest priority**.
parent::setupDependencyInjection($container);
}
Configuring a firewall map entry
--------------------------------
Configuring a firewall map entry with FirewallEntry class
---------------------------------------------------------

Before copy and pasting the following lines, think about it a little time…
A firewall map entry defines severals mandatory routes:
Expand All @@ -63,125 +63,46 @@ add the matching *use* statement in your file header.

.. code-block:: php
use RZ\Roadiz\Core\Authentification\AuthenticationFailureHandler;
use RZ\Roadiz\Core\Authentification\AuthenticationSuccessHandler;
use Symfony\Component\HttpFoundation\RequestMatcher;
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver;
use Symfony\Component\Security\Http\EntryPoint\FormAuthenticationEntryPoint;
use Symfony\Component\Security\Http\Firewall\ExceptionListener;
use Symfony\Component\Security\Http\Firewall\LogoutListener;
use Symfony\Component\Security\Http\Firewall\UsernamePasswordFormAuthenticationListener;
use Symfony\Component\Security\Http\Logout\DefaultLogoutSuccessHandler;
use Symfony\Component\Security\Http\Logout\SessionLogoutHandler;
use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategy;
use RZ\Roadiz\Utils\Security\FirewallEntry;
/**
* {@inheritdoc}
*/
public static function setupDependencyInjection(Container $container)
{
$firewallBasePattern = '^/press';
$firewallBasePath = '/press';
$firewallLogin = '/signin';
$firewallLogout = '/press/logout';
$firewallLoginCheck = '/press/login_check';
$firewallBaseRole = 'ROLE_ACCESS_PRESS';
/*
* Define firewall map base path
*/
$requestMatcher = new RequestMatcher($firewallBasePattern);
/*
* Enforce required ROLE for this area
*/
$container['accessMap']->add($requestMatcher, [$firewallBaseRole]);
/*
* Logout listener
*/
$logoutListener = new LogoutListener(
$container['securityTokenStorage'],
$container['httpUtils'],
new DefaultLogoutSuccessHandler(
$container['httpUtils'],
$firewallLogin
),
[
'logout_path' => $firewallLogout,
]
);
$logoutListener->addHandler(new SessionLogoutHandler());
$logoutListener->addHandler($container['cookieClearingLogoutHandler']);
$listeners = [
// manages the SecurityContext persistence through a session
$container['contextListener'],
// logout users
$logoutListener,
$container['rememberMeListener'],
// authentication via a simple form composed of a username and a password
new UsernamePasswordFormAuthenticationListener(
$container['securityTokenStorage'],
$container['authentificationManager'],
new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE),
$container['httpUtils'],
Kernel::SECURITY_DOMAIN,
new AuthenticationSuccessHandler(
$container['httpUtils'],
$container['em'],
$container['tokenBasedRememberMeServices'],
[
'always_use_default_target_path' => false,
'default_target_path' => $firewallBasePath,
'login_path' => $firewallLogin,
'target_path_parameter' => '_target_path',
'use_referer' => true,
]
),
new AuthenticationFailureHandler(
$container['httpKernel'],
$container['httpUtils'],
[
'failure_path' => $firewallLogin,
'failure_forward' => false,
'login_path' => $firewallLogin,
'failure_path_parameter' => '_failure_path',
],
$container['logger']
),
[
'check_path' => $firewallLoginCheck,
],
$container['logger'],
$container['dispatcher'],
null
),
$container['securityAccessListener'],
$container["switchUser"],
];
$formEntryPoint = new FormAuthenticationEntryPoint(
$container['httpKernel'],
$container['httpUtils'],
$firewallEntry = new FirewallEntry(
$container,
$firewallBasePattern,
$firewallBasePath,
$firewallLogin,
true
);
$exceptionListener = new ExceptionListener(
$container['securityTokenStorage'],
new AuthenticationTrustResolver('', ''),
$container['httpUtils'],
Kernel::SECURITY_DOMAIN,
$formEntryPoint,
null,
null,
$container['logger']
$firewallLogout,
$firewallLoginCheck,
$firewallBaseRole
// You can add a special AuthenticationSuccessHandler
// if you need to do some stuff for your theme at visitor login
//'Themes\YourTheme\Authentification\AuthenticationSuccessHandler'
);
// Allow anonymous authentification
$firewallEntry->withAnonymousAuthenticationListener();
// Allow switch user feature
$firewallEntry->withSwitchUserListener();
/*
* Finally add this long long configuration to the Roadiz
* Finally add this entry to the Roadiz
* firewall map.
*/
$container['firewallMap']->add($requestMatcher, $listeners, $exceptionListener);
$container['firewallMap']->add(
$firewallEntry->getRequestMatcher(),
$firewallEntry->getListeners(),
$firewallEntry->getExceptionListener()
);
/*
* Always setup general setupDependencyInjection AFTER
Expand Down
14 changes: 7 additions & 7 deletions developer/themes/using_twig.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ theme class. Create it if it does not exist yet.
{
parent::setupDependencyInjection($container);
// We extend twig setup
$container->extend('twig.environment', function ($twig, $c) {
// We extend twig filters
$container->extend('twig.filters', function ($filters, $c) {
// The first filter will extract red value
$red = new \Twig_SimpleFilter('red', function ($hex) {
Expand All @@ -288,7 +288,7 @@ theme class. Create it if it does not exist yet.
return 0;
}
});
$twig->addFilter($red);
$filters->add($red);
// The second filter will extract green value
$green = new \Twig_SimpleFilter('green', function ($hex) {
Expand All @@ -298,7 +298,7 @@ theme class. Create it if it does not exist yet.
return 0;
}
});
$twig->addFilter($green);
$filters->add($green);
// The third filter will extract blue value
$blue = new \Twig_SimpleFilter('blue', function ($hex) {
Expand All @@ -308,10 +308,10 @@ theme class. Create it if it does not exist yet.
return 0;
}
});
$twig->addFilter($blue);
$filters->add($blue);
// Then we return our extended twig environment
return $twig;
// Then we return our extended filters collection
return $filters;
});
}
Expand Down

0 comments on commit 770bedc

Please sign in to comment.