forkad från deblan/gist
Merge branch 'dev-master'
This commit is contained in:
incheckning
2f1d57d36b
|
@ -7,6 +7,7 @@
|
|||
/src/Gist/Model/Map/
|
||||
/web/components/
|
||||
/app/propel/
|
||||
/app/config/config.yml
|
||||
/app/config/propel/
|
||||
/data/
|
||||
/trans/
|
||||
|
|
|
@ -8,6 +8,7 @@ deployment:
|
|||
- "*.svn"
|
||||
- "*.git"
|
||||
- "*.swp"
|
||||
- "app/config/config.yml"
|
||||
- "app/config/propel/"
|
||||
- "app/propel/"
|
||||
- "data/git"
|
136
README.md
136
README.md
|
@ -8,21 +8,14 @@ Table of Contents
|
|||
* [Bower](#bower)
|
||||
* [Installation](#installation)
|
||||
* [Upgrade](#upgrade)
|
||||
* [Configuration](#configuration)
|
||||
* [Makefile](#makefile)
|
||||
* [API](#api)
|
||||
* [Create a new gist](#create-a-new-gist)
|
||||
* [Update an existing Gist](#update-an-existing-gist)
|
||||
* [Console](#console)
|
||||
* [Create and update gists](#create-and-update-gists)
|
||||
* [Create user](#create-user)
|
||||
* [Show stats](#show-stats)
|
||||
* [Configuration](#configuration)
|
||||
* [API](#api-1)
|
||||
* [Authentication](#authentication)
|
||||
* [Debug](#debug)
|
||||
* [Deployment](#deployment)
|
||||
* [Contributors](#contributors)
|
||||
|
||||
|
||||
GIST
|
||||
====
|
||||
|
||||
|
@ -33,6 +26,7 @@ https://www.deblan.io/post/517/gist-est-dans-la-place
|
|||
|
||||
![Gist](https://upload.deblan.org/u/2016-06/57655dec.png "Gist")
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
|
@ -80,7 +74,7 @@ Installation
|
|||
$ git clone https://gitnet.fr/deblan/gist
|
||||
$ cd gist
|
||||
$ make
|
||||
$ mv propel-dist.yaml propel.yaml
|
||||
$ cp propel-dist.yaml propel.yaml
|
||||
|
||||
Edit `propel.yaml`. **Use spaces instead of tabulations**.
|
||||
|
||||
|
@ -118,7 +112,11 @@ Edit `propel.yaml`. **Use spaces instead of tabulations**.
|
|||
|
||||
Then `$ make propel`.
|
||||
|
||||
Edit `app/bootstrap.php.d/70-security.php` and modify the value of `$app['token']` with a strong secret phrase.
|
||||
**Versions >= 1.4.4 only**: `$ cp app/config/config.yml.dist app/config/config.yml`
|
||||
|
||||
See the [configuration section](#configuration) for more information about configuration.
|
||||
|
||||
---
|
||||
|
||||
The web server must have permission to write into `data`.
|
||||
|
||||
|
@ -129,6 +127,8 @@ Your webserver must be configured to serve `web/` as document root. If you use n
|
|||
$ sudo a2enmod rewrite
|
||||
$ sudo service apache2 restart
|
||||
|
||||
`app_dev.php` is the development router. Access is granted for an IP range defined in the same file.
|
||||
|
||||
Upgrade
|
||||
-------
|
||||
|
||||
|
@ -139,6 +139,40 @@ If your version is less than v1.4.2, run: `test -d app && git add app && git com
|
|||
|
||||
If you upgrade to v1.4.1, run: `app/console migrate:to:v1.4.1`.
|
||||
|
||||
If you upgrade to v1.4.4 or more, the configuration is moved to a `app/config/config.yml`: `$ cp app/config/config.yml.dist app/config/config.yml` and see the [configuration section](#configuration) for more information.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
### Version < 1.4.4
|
||||
|
||||
Edit `app/bootstrap.php.d/70-security.php`.
|
||||
|
||||
* `$app['token']`: the securty token (a strong passphrase).
|
||||
* `$app['enable_registration']`: defines if the registration is allowed (`true` or `false`)
|
||||
* `$app['enable_login']`: defines if the login is allowed (`true` or `false`)
|
||||
* `$app['login_required_to_edit_gist']`: defines if the user must be logged to create or clone a Gist (`true` or `false`)
|
||||
* `$app['login_required_to_view_gist']`: defines if the user must be logged to view a Gist (`true` or `false`)
|
||||
* `$app['login_required_to_view_gist']`: defines if the user must be logged to view an embeded Gist (`true` or `false`)
|
||||
|
||||
If you install Gist on your server, you have to modify the `base_uri` of the API.
|
||||
Edit `app/bootstrap.php.d/60-api.php` and replace `https://gist.deblan.org/`.
|
||||
|
||||
### Version >= 1.4.4
|
||||
|
||||
Edit `app/config/config.yml`.
|
||||
|
||||
* `security.token`: the securty token (a strong passphrase)
|
||||
* `security.enable_registration`: defines if the registration is allowed (`true` or `false`)
|
||||
* `security.enable_login`: defines if the login is allowed (`true` or `false`)
|
||||
* `security.login_required_to_edit_gist`: defines if the user must be logged to create or clone a Gist (`true` or `false`)
|
||||
* `security.login_required_to_view_gist`: defines if the user must be logged to view a Gist (`true` or `false`)
|
||||
* `security.login_required_to_view_gist`: defines if the user must be logged to view an embeded Gist (`true` or `false`)
|
||||
* `api.base_uri`: The url of your instance.
|
||||
* `data.path`: the path where the files are saved.
|
||||
* `git.path`: The path of `git`.
|
||||
* `theme.name`: the name of the theme (`dark` or `light`)
|
||||
|
||||
Makefile
|
||||
--------
|
||||
|
||||
|
@ -165,8 +199,11 @@ Params:
|
|||
|
||||
**Responses:**
|
||||
|
||||
* Code `405`: Method Not Allowed
|
||||
* Code `400`: Bad Request
|
||||
* Code `200`: A json which contains gist's information. Example:
|
||||
```javascript
|
||||
|
||||
```javascript
|
||||
{
|
||||
"url": "https:\/\/gist.deblan.org\/en\/view\/55abcfa7771e0\/f4afbf72967dd95e3461490dcaa310d728d6a97d",
|
||||
"gist": {
|
||||
|
@ -179,11 +216,9 @@ Params:
|
|||
"UpdatedAt": "2015-07-19T16:26:15Z"
|
||||
}
|
||||
}
|
||||
```
|
||||
* Code `405`: Method Not Allowed
|
||||
* Code `400`: Bad Request
|
||||
```
|
||||
|
||||
### Update an existing Gist
|
||||
### Update an existing gist
|
||||
|
||||
**POST** /{locale}/api/update/{id}
|
||||
Params:
|
||||
|
@ -193,8 +228,11 @@ Params:
|
|||
|
||||
**Responses:**
|
||||
|
||||
* Code `405`: Method Not Allowed
|
||||
* Code `400`: Bad Request
|
||||
* Code `200`: A json which contains gist's information. Example:
|
||||
```javascript
|
||||
|
||||
```javascript
|
||||
{
|
||||
"url": "https:\/\/gist.deblan.org\/en\/view\/55abcfa7771e0\/abcgi72967dd95e3461490dcaa310d728d6adef",
|
||||
"gist": {
|
||||
|
@ -207,67 +245,15 @@ Params:
|
|||
"UpdatedAt": "2015-07-19T16:30:15Z"
|
||||
}
|
||||
}
|
||||
```
|
||||
* Code `405`: Method Not Allowed
|
||||
* Code `400`: Bad Request
|
||||
```
|
||||
|
||||
Console
|
||||
-------
|
||||
|
||||
### Create and update gists
|
||||
|
||||
```
|
||||
$ app/console --help create
|
||||
$ app/console --help update
|
||||
```
|
||||
|
||||
### Create user
|
||||
|
||||
```
|
||||
$ app/console --help user:create
|
||||
```
|
||||
|
||||
### Show stats
|
||||
|
||||
```
|
||||
$ app/console --help stats
|
||||
```
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
### API
|
||||
|
||||
**Personal instance**
|
||||
|
||||
If you install Gist on your server, you have to modify the `base_uri` of the API.
|
||||
Edit `app/bootstrap.php.d/60-api.php` and replace `https://gist.deblan.org/`.
|
||||
|
||||
### Authentication
|
||||
|
||||
**Disabling login**
|
||||
|
||||
Edit `app/bootstrap.php.d/70-security.php` and modify the value of `$app['enable_login']` with `false`.
|
||||
|
||||
**Disabling registration**
|
||||
|
||||
Edit `app/bootstrap.php.d/70-security.php` and modify the value of `$app['enable_registration']` with `false`.
|
||||
|
||||
**Login required to edit a gist**
|
||||
|
||||
Edit `app/bootstrap.php.d/70-security.php` and modify the value of `$app['login_required_to_edit_gist']` with `true`.
|
||||
|
||||
**Login required to view a gist**
|
||||
|
||||
Edit `app/bootstrap.php.d/70-security.php` and modify the value of `$app['login_required_to_view_gist']` with `true`.
|
||||
|
||||
**Login required to view an embeded gist**
|
||||
|
||||
Edit `app/bootstrap.php.d/70-security.php` and modify the value of `$app['login_required_to_view_embeded_gist']` with `true`.
|
||||
|
||||
### Debug
|
||||
|
||||
`app_dev.php` is the development router. Access is granted for an IP range defined in the same file.
|
||||
* **Create a gist**: `$ app/console --help create`
|
||||
* **Update a gist**: `$ app/console --help update`
|
||||
* **Create user**: `app/console --help user:create`
|
||||
* **Show stats**: `$ app/console --help stats`
|
||||
|
||||
Deployment
|
||||
----------
|
||||
|
@ -284,7 +270,7 @@ Gist uses [Magallanes](http://magephp.com/) to manage deployment.
|
|||
|
||||
$ composer require andres-montanez/magallanes
|
||||
|
||||
There is an example of the configuration of an environment in `.mage/config/environment/prod.yml-dist`.
|
||||
There is an example of the configuration of an environment in `.mage/config/environment/prod.yml.dist`.
|
||||
|
||||
# global installation
|
||||
$ mage deploy to:prod
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
<?php
|
||||
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
$app['config.locator.path'] = $app['root_path'].'/app/config/';
|
||||
|
||||
$app['config.locator'] = function ($app) {
|
||||
return new FileLocator($app['config.locator.path']);
|
||||
};
|
||||
|
||||
$app['settings'] = $app->share(function ($app) {
|
||||
return Yaml::parse($app['config.locator']->locate('config.yml'));
|
||||
});
|
||||
|
|
|
@ -3,10 +3,16 @@
|
|||
use GitWrapper\GitWrapper;
|
||||
use Gist\Service\Gist;
|
||||
|
||||
$app['gist_path'] = $app['root_path'].'/data/git';
|
||||
$dataPath = $app['settings']['data']['path'];
|
||||
|
||||
if ($dataPath[0] !== '/') {
|
||||
$app['gist_path'] = $app['root_path'].$dataPath;
|
||||
} else {
|
||||
$app['gist_path'] = $dataPath;
|
||||
}
|
||||
|
||||
$app['git_wrapper'] = $app->share(function ($app) {
|
||||
return new GitWrapper('/usr/bin/git');
|
||||
return new GitWrapper($app['settings']['git']['path']);
|
||||
});
|
||||
|
||||
$app['git_working_copy'] = $app->share(function ($app) {
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
use Gist\Api\Client;
|
||||
|
||||
$app['api_client'] = $app->share(function ($app) {
|
||||
return new Client(['base_uri' => 'https://gist.deblan.org/']);
|
||||
return new Client(['base_uri' => $app['settings']['api']['base_uri']]);
|
||||
});
|
||||
|
|
|
@ -9,13 +9,9 @@ use Gist\Security\AuthenticationListener;
|
|||
use Gist\Security\LogoutSuccessHandler;
|
||||
use Silex\Provider\SessionServiceProvider;
|
||||
|
||||
$app['enable_registration'] = true;
|
||||
$app['enable_login'] = true;
|
||||
$app['login_required_to_edit_gist'] = false;
|
||||
$app['login_required_to_view_gist'] = false;
|
||||
$app['login_required_to_view_embeded_gist'] = false;
|
||||
$securitySettings = $app['settings']['security'];
|
||||
|
||||
$app['token'] = 'ThisTokenIsNotSoSecretChangeIt';
|
||||
$app['token'] = $securitySettings['token'];
|
||||
|
||||
$app['salt_generator'] = $app->share(function ($app) {
|
||||
return new SaltGenerator();
|
||||
|
@ -77,10 +73,10 @@ $firewall = [
|
|||
],
|
||||
];
|
||||
|
||||
if ($app['login_required_to_edit_gist'] || $app['login_required_to_view_gist'] || $app['login_required_to_view_embeded_gist']) {
|
||||
if ($securitySettings['login_required_to_edit_gist'] || $securitySettings['login_required_to_view_gist'] || $securitySettings['login_required_to_view_embeded_gist']) {
|
||||
$exceptedUriPattern = ['login', 'register'];
|
||||
|
||||
if ($app['login_required_to_view_gist'] === true) {
|
||||
if ($securitySettings['login_required_to_view_gist'] === true) {
|
||||
$firewall['security.access_rules'][] = ['^/[a-z]{2}/view.*$', 'ROLE_USER'];
|
||||
$firewall['security.access_rules'][] = ['^/[a-z]{2}/revs.*$', 'ROLE_USER'];
|
||||
} else {
|
||||
|
@ -88,13 +84,13 @@ if ($app['login_required_to_edit_gist'] || $app['login_required_to_view_gist'] |
|
|||
$exceptedUriPattern[] = 'revs';
|
||||
}
|
||||
|
||||
if ($app['login_required_to_view_embeded_gist'] === true) {
|
||||
if ($securitySettings['login_required_to_view_embeded_gist'] === true) {
|
||||
$firewall['security.access_rules'][] = ['^/[a-z]{2}/embed.*$', 'ROLE_USER'];
|
||||
} else {
|
||||
$exceptedUriPattern[] = 'embed';
|
||||
}
|
||||
|
||||
if ($app['login_required_to_edit_gist'] === true) {
|
||||
if ($securitySettings['login_required_to_edit_gist'] === true) {
|
||||
$firewall['security.access_rules'][] = ['^/[a-z]{2}/(?!('.implode('|', $exceptedUriPattern).')).*$', 'ROLE_USER'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
security:
|
||||
token: ThisTokenIsNotSoSecretChangeIt
|
||||
enable_registration: true
|
||||
enable_login: true
|
||||
login_required_to_edit_gist: true
|
||||
login_required_to_view_gist: true
|
||||
login_required_to_view_embeded_gist: true
|
||||
api:
|
||||
base_url: 'https://gist.deblan.org/'
|
||||
data:
|
||||
path: data/git
|
||||
git:
|
||||
path: /usr/bin/git
|
||||
theme:
|
||||
name: dark
|
|
@ -26,7 +26,7 @@ class LoginController extends Controller
|
|||
{
|
||||
$app = $this->getApp();
|
||||
|
||||
if (false === $app['enable_registration']) {
|
||||
if (false === $app['settings']['enable_registration']) {
|
||||
return new Response('', 403);
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ class LoginController extends Controller
|
|||
{
|
||||
$app = $this->getApp();
|
||||
|
||||
if (false === $app['enable_login']) {
|
||||
if (false === $app['settings']['enable_login']) {
|
||||
return new Response('', 403);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
{% set theme_settings = app.settings.theme %}
|
||||
{% set security_dettings = app.settings.security %}
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
{% block css %}
|
||||
<link rel="stylesheet" href="{{ web_path }}components/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="{{ web_path }}components/flag-icon-css/css/flag-icon.min.css" />
|
||||
<link rel="stylesheet" href="{{ web_path }}app/css/bootstrap/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="{{ web_path }}app/css/app.css" />
|
||||
|
||||
{% if theme_settings.name == 'dark' %}
|
||||
<link rel="stylesheet" href="{{ web_path }}app/css/bootstrap/bootstrap.min.css" />
|
||||
{% else %}
|
||||
<link rel="stylesheet" href="{{ web_path }}components/bootstrap/dist/css/bootstrap-theme.min.css" />
|
||||
{% endif %}
|
||||
|
||||
<link rel="stylesheet" href="{{ web_path }}app/css/themes/{{ theme_settings.name }}.css" />
|
||||
{% endblock %}
|
||||
|
||||
{% block metas %}
|
||||
|
@ -17,7 +25,7 @@
|
|||
</head>
|
||||
<body>
|
||||
{% block nav %}
|
||||
<nav class="navbar navbar-inverse">
|
||||
<nav class="navbar navbar-{{ theme_settings.name == 'dark' ? 'inverse' : 'default' }}">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-menu">
|
||||
|
@ -48,14 +56,14 @@
|
|||
{{ 'app.menu.my.logout.title'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
{% elseif app.enable_login %}
|
||||
{% elseif security_dettings.enable_login %}
|
||||
<li>
|
||||
<a href="{{ path('login') }}">
|
||||
{{ 'app.menu.my.login.title'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{% if app.enable_registration %}
|
||||
{% if security_dettings.enable_registration %}
|
||||
<li>
|
||||
<a href="{{ path('register') }}">
|
||||
{{ 'app.menu.my.register.title'|trans }}
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
.navbar {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
#form_content {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
#languages {
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
#languages .btn-group:first-child {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
pre {
|
||||
background: #222;
|
||||
border: #222;
|
||||
color: #ddd;
|
||||
white-space: pre-wrap;
|
||||
white-space: -moz-pre-wrap;
|
||||
white-space: -pre-wrap;
|
||||
white-space: -o-pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
pre ol {
|
||||
padding-left: 50px !important;
|
||||
}
|
||||
|
||||
pre li:hover {
|
||||
background: #444;
|
||||
}
|
||||
|
||||
.panel-heading .actions {
|
||||
margin-top: -5px;
|
||||
}
|
||||
|
||||
div.diff {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.de1 {
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
.li1 {
|
||||
background: #333;
|
||||
}
|
||||
|
||||
.re8 {
|
||||
color: #52F700;
|
||||
}
|
||||
|
||||
.kw3 {
|
||||
color: #C6C765;
|
||||
}
|
||||
|
||||
#viewer .syntaxhighlighter td {
|
||||
vertical-align: top !important;
|
||||
}
|
||||
|
||||
#options {
|
||||
margin-bottom: 17px;
|
||||
}
|
||||
|
||||
.btn-delete {
|
||||
background: #DE3336;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-error:active, .btn-error:hover, .btn-error:focus {
|
||||
color: #000;
|
||||
}
|
Laddar…
Referens i nytt ärende