gist/README.md

180 lines
4.1 KiB
Markdown
Raw Normal View History

2015-05-06 10:58:55 +02:00
GIST
====
GIST is an open-source application to share code.
2015-05-10 02:32:24 +02:00
https://www.deblan.io/post/517/gist-est-dans-la-place
2015-05-06 10:58:55 +02:00
2015-05-12 11:13:30 +02:00
![Gist](https://upload.deblan.org/u/2015-05/554e2c12.png "Gist")
2015-05-06 10:58:55 +02:00
Requirements
------------
* PHP >= 5.4
* GIT
2015-05-09 17:42:53 +02:00
* MySQL, PostgreSQL or SQLite
2015-05-06 11:04:38 +02:00
* Composer (php)
* Bower (node)
2015-05-06 10:58:55 +02:00
Installation
------------
2015-05-06 11:10:26 +02:00
$ git clone https://gitlab.deblan.org/deblan/gist
$ cd gist
2015-05-06 10:58:55 +02:00
$ make
2015-05-09 17:42:53 +02:00
$ mv propel-dist.yaml propel.yaml
2015-05-25 02:39:39 +02:00
$ # EDIT propel.yaml (dsn)
2015-05-09 17:42:53 +02:00
$ make propel
2015-05-10 02:32:24 +02:00
Screencast: https://asciinema.org/a/19814
2015-05-09 17:42:53 +02:00
### Git
Git can maybe be downloaded from your system's repositories.
2015-05-06 10:58:55 +02:00
2015-05-06 23:05:51 +02:00
$ git config --global user.email "you@example.com"
$ git config --global user.name "Your Name"
2015-05-09 17:42:53 +02:00
### Composer
2015-05-06 10:58:55 +02:00
Composer can maybe be downloaded from your system's repositories.
Else, follow the next instructions:
2015-05-09 17:42:53 +02:00
#### Download
2015-05-06 10:58:55 +02:00
# With cURL
curl -sS https://getcomposer.org/installer | php
# With Wget
wget -O - -q https://getcomposer.org/installer | php
You can now use it with `php composer.phar [arguments]`.
2015-05-09 17:42:53 +02:00
#### Executable
2015-05-06 10:58:55 +02:00
mv composer.phar composer
chmod +x composer
Use it with `./composer [arguments]`.
2015-05-09 17:42:53 +02:00
#### Install
2015-05-06 10:58:55 +02:00
Assuming `~/bin` exists ans is in `$PATH`.
mv composer ~/bin
2015-05-09 17:42:53 +02:00
#### Dependencies Installation (from `composer.lock`)
2015-05-06 10:58:55 +02:00
composer install
2015-05-09 17:42:53 +02:00
#### Dependencies Update (will change `composer.lock`)
2015-05-06 10:58:55 +02:00
composer update
2015-05-09 17:42:53 +02:00
### Bower
2015-05-06 10:58:55 +02:00
2015-05-09 17:42:53 +02:00
#### Install
2015-05-06 10:58:55 +02:00
npm install -g bower
2015-05-10 01:59:30 +02:00
#### Dependencies Installation (from `bower.json`)
2015-05-06 10:58:55 +02:00
bower install
2015-05-10 02:00:04 +02:00
#### Dependencies Update
2015-05-06 10:58:55 +02:00
2015-05-10 01:59:30 +02:00
bower install
2015-05-06 10:58:55 +02:00
Makefile
--------
A Makefile is provided to automate some tasks.
2015-05-09 17:42:53 +02:00
* `make` will install application's dependencies via Composer and Bower,
2015-05-06 10:58:55 +02:00
* `make optimize` will run Composer's autoloader dump script with classmap
2015-05-09 17:42:53 +02:00
* `make update` will update the application
* `make propel` will generate propel's files
2015-09-17 11:41:32 +02:00
* `make run` will run development server on http://127.0.0.1:8080/
2015-07-19 18:39:46 +02:00
API
---
### Create a new gist
**POST** /{locale}/api/create
Params:
* ```form[title]```: String (required, can be empty)
* ```form[type]```: String (required)
Values: html, css, javascript, php, sql, xml, yaml, perl, c, asp, python, bash, actionscript3, text
* ```form[content]```: String (required)
2015-07-19 18:40:49 +02:00
#### Responses:
2015-07-19 18:39:46 +02:00
2015-09-17 11:45:19 +02:00
* Code ```200```: A json which contains gist's information. Example:
2015-07-19 18:39:46 +02:00
```javascript
2015-07-19 18:42:22 +02:00
{
2015-09-17 11:41:32 +02:00
"url": "https:\/\/gist.deblan.org\/en\/view\/55abcfa7771e0\/f4afbf72967dd95e3461490dcaa310d728d6a97d",
2015-07-19 18:42:22 +02:00
"gist": {
2015-09-17 11:48:52 +02:00
"Id": 66,
2015-07-19 18:42:22 +02:00
"Title": "test prod",
"Cipher": false,
"Type": "javascript",
"File": "55abcfa7771e0",
"CreatedAt": "2015-07-19T16:26:15Z",
"UpdatedAt": "2015-07-19T16:26:15Z"
}
}
2015-07-19 18:39:46 +02:00
```
* Code ```405```: Method Not Allowed
* Code ```400```: Bad Request
2015-07-19 18:45:01 +02:00
Console
-------
Gist provides a CLI for using API:
```
$ ./app/console --help create
Usage:
create [options] [--] <input> [<type>]
Arguments:
input Input
type Type [default: "text"]
Options:
-t, --title=TITLE Title of the gist
-u, --show-url Display only the gist url
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
2015-07-19 18:48:52 +02:00
Provides a client to create a gist using the API.
2015-07-19 18:45:01 +02:00
Arguments:
input
Identify the source of the content: path of the file (eg: /path/to/file) or standard input (-)
type
2015-09-17 11:46:51 +02:00
Defines the type of code: html, css, javascript, php, sql, xml, yaml, perl, c, asp, python, bash, actionscript3, text
2015-07-19 18:45:01 +02:00
Default value: text
Options:
--title, -t
Defines a title
--show-url, -u
Display only the url of the gist
```
2015-07-19 18:48:52 +02:00
#### Personal instance
2015-10-06 18:28:50 +02:00
If you install Gist on your server, you have to modify the ```base_uri``` of the API.
2015-07-19 18:48:52 +02:00
Edit ```app/bootstrap.php.d/60-api.php``` and modify ```https://gist.deblan.org/```.