Commit 7c327747 authored by seanmadsen's avatar seanmadsen

Merge branch 'master' into 'master'

Docker support and more

See merge request !67
parents 725bfd5d aa0cd4c3
/.idea/
/app/config/parameters.yml
/build/
/phpunit.xml
/var/*
!/var/cache
/var/cache/*
!var/cache/.gitkeep
!/var/logs
/var/logs/*
var/*
!var/logs/.gitkeep
!/var/sessions
/var/sessions/*
!var/sessions/.gitkeep
!var/repos/.gitkeep
!var/SymfonyRequirements.php
/vendor/
/web/*
!/web/.htaccess
!/web/app.php
!/web/app_dev.php
!/web/robots.txt
!/web/static
vendor/
web/*
!web/dev/.gitkeep
!web/.htaccess
!web/app.php
!web/app_dev.php
!web/robots.txt
!web/static
## Description
_A brief non-tech description of what you're trying to achieve_
## Before
_The status quo_
## After
_Your fantastical improvements_
- [ ] Tests pass
FROM richarvey/nginx-php-fpm
RUN apk update \
&& apk add \
git \
curl \
unzip \
vim \
python \
python-dev \
py-pip
RUN pip install mkdocs mkdocs-material pygments pymdown-extensions
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN rm /etc/nginx/sites-enabled/*
ADD app/config/civicrm-docs.conf /etc/nginx/sites-enabled
......@@ -73,11 +73,40 @@ https://docs.civicrm.org/admin/publish/{book}/{lang}/{branch}
## Installing a local copy of the docs infrastructure
### Docker
The repo includes a dockerfile which you can use to create a container which has everything needed to run the application.
To build the container and install composer dependencies just run (from the project directory):
```bash
docker build -t civicrm-docs .
docker run -v $PWD:/var/www civicrm-docs composer install --working-dir=/var/www
```
And then to run it:
```bash
docker run -v $PWD:/var/www -p 8080:8080 civicrm-docs
```
You might want to change the first 8080 in the port argument if you've already got something listening on that port.
The `nginx` user in the container will need to be able to write to these directories.
```bash
sudo chmod -R a+rwx var/cache var/logs/ web/dev/ var/repos/
```
You should be able to see the app at http://localhost:8080.
### On your host machine
**Note**: the following steps are only useful and necessary for people looking after CiviCRM's documentation *infrastructure*. You don't need to do this if you just want to [contribute to documentation content](https://docs.civicrm.org/dev/en/master/documentation/).
1. Ensure that that you have [pip](https://packaging.python.org/en/latest/install_requirements_linux/#installing-pip-setuptools-wheel-with-linux-package-managers) (for python) and [composer](https://getcomposer.org/) (for php) installed..
2. Install MkDocs (`$ sudo pip install mkdocs`). ***Note:*** *Ensure that MkDocs is installed as root so that it can be accessed from the src/publish.php script (typically invoked as https://docs.civicrm.org/publish.php)*
2. [Install MkDocs](https://docs.civicrm.org/dev/en/master/documentation/#mkdocs). Ensure that MkDocs is installed as root so that it can be accessed from the src/publish.php script (typically invoked as https://docs.civicrm.org/publish.php)*
3. clone this repository to somewhere like /var/www/civicrm-docs and run `composer install`
......
server {
server_name docs;
root /var/www/civicrm-docs/web;
server_name localhost;
listen *:8080;
root /var/www/web;
# For a development configuration, change "app" to "app_dev" everywhere
# below. Then you'll see the Symfony web debug toolbar when viewing pages.
......@@ -10,22 +11,22 @@ server {
# - Book slug can't be "admin"
# - Must begin with three distinct path pieces, separated by forward slashes
location ~ ^/(?!_)(?!admin/)[^/]+/[^/]+/[^/]+ {
# - Use a trailing slash for the $uri to treat paths like directories
# - Then, try to find directories that match our request.
# - If we can't find anything, we send the request to the app and let
# it deal with the rest.
try_files $uri/ $uri /app.php$is_args$args;
# - Use a trailing slash for the $uri to treat paths like directories
# - Then, try to find directories that match our request.
# - If we can't find anything, we send the request to the app and let
# it deal with the rest.
try_files $uri/ $uri /app_dev.php$is_args$args;
}
# requests for Symfony app functionality
location / {
# - Don't use a trailing slash for $uri here. This line is straight from
# the Symfony recommended nginx settings
try_files $uri /app.php$is_args$args;
# the Symfony recommended nginx settings
try_files $uri /app_dev.php$is_args$args;
}
location ~ ^/app\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
location ~ ^/app_dev\.php(/|$) {
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# When you are using symlinks to link the document root to the
......@@ -46,7 +47,7 @@ server {
# return 404 for all other php files not matching the front controller
# this prevents access to other php files you don't want to be accessible.
location ~ \.php$ {
return 404;
return 404;
}
#error_log /var/log/nginx/civicrm-docs-error.log;
......
{
"name": "michael/civicrm.docs",
"license": "proprietary",
"name": "civicrm/civicrm-docs",
"license": "MIT",
"type": "project",
"autoload": {
"psr-4": {
......@@ -17,9 +17,10 @@
}
},
"require": {
"php": ">=5.5.9",
"php": "^5.6|^7.0",
"symfony/symfony": "3.0.*",
"doctrine/orm": "^2.5",
"twig/twig": "^1.33",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"symfony/swiftmailer-bundle": "^2.3",
......@@ -30,7 +31,8 @@
},
"require-dev": {
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.0"
"symfony/phpunit-bridge": "^3.0",
"phpunit/phpunit": "^5.7"
},
"scripts": {
"post-install-cmd": [
......@@ -50,11 +52,6 @@
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
"config": {
"platform": {
"php": "5.5.9"
}
},
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
......
This diff is collapsed.
......@@ -13,9 +13,10 @@ class StringTools {
* @return string The cleaned string, safe for use in URLs
*/
public static function urlSafe($s) {
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', strtolower(trim($s)));
$clean = iconv('UTF-8', 'ASCII', strtolower(trim($s)));
$clean = preg_replace('#[^.a-zA-Z0-9/_|+ -]#', '', $clean);
$clean = preg_replace('#[/_|+ -]+#', '-', $clean);
return $clean;
}
......
<?php
namespace Tests\AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class DefaultControllerTest extends WebTestCase
{
public function testIndex()
{
$client = static::createClient();
$crawler = $client->request('GET', '/');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertContains('Welcome to Symfony', $crawler->filter('#container h1')->text());
}
}
<?php
namespace AppBundle\Tests\Utils;
use AppBundle\Utils\StringTools;
class StringToolsTest extends \PHPUnit_Framework_TestCase
{
/**
* @param string $string
* The string to make safe for usage in URLs
* @param string $expected
* The expected result
* @dataProvider urlProvider
*/
public function testUrlSafe($string, $expected) {
$this->assertEquals($expected, StringTools::urlSafe($string));
}
/**
* @return array
*/
public function urlProvider() {
return [
[
'PAGE-1',
'page-1',
],
[
'this is a path',
'this-is-a-path',
],
[
'***path 1',
'path-1',
],
[
'another_path',
'another-path',
],
];
}
}
File mode changed from 100644 to 100755
......@@ -12,7 +12,7 @@ use Symfony\Component\Debug\Debug;
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server')
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1', '172.17.0.1']) || php_sapi_name() === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
......
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