From acf48c4a754a0131faef2502da18fd01997615dd Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 8 Aug 2018 09:37:19 +0200 Subject: [PATCH 1/2] Documentation --- README.md | 68 +++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 8a0420b..b854ff3 100644 --- a/README.md +++ b/README.md @@ -40,41 +40,41 @@ Requirements Git can maybe be downloaded from your system's repositories. - $ git config --global user.email "you@example.com" - $ git config --global user.name "Your Name" + $ git config --global user.email "you@example.com" + $ git config --global user.name "Your Name" ### Composer Composer can maybe be downloaded from your system's repositories. Else, follow the next instructions: - # With cURL - $ curl -sS https://getcomposer.org/installer | php + # With cURL + $ curl -sS https://getcomposer.org/installer | php - # With Wget - $ wget -O - -q https://getcomposer.org/installer | php + # With Wget + $ wget -O - -q https://getcomposer.org/installer | php - $ chmod +x composer.phar + $ chmod +x composer.phar - # For a local installation and if the envvar PATH contains "$HOME/bin/" - $ mv composer.phar ~/bin/composer + # For a local installation and if the envvar PATH contains "$HOME/bin/" + $ mv composer.phar ~/bin/composer - # For a global installation - $ sudo mv composer.phar /usr/local/bin/composer + # For a global installation + $ sudo mv composer.phar /usr/local/bin/composer ### Bower - $ sudo apt-get install npm - $ sudo npm install -g bower + $ sudo apt-get install npm + $ sudo npm install -g bower Installation ------------ - $ cd /path/to/www/ - $ git clone https://gitnet.fr/deblan/gist - $ cd gist - $ make - $ cp propel-dist.yaml propel.yaml + $ cd /path/to/www/ + $ git clone https://gitnet.fr/deblan/gist + $ cd gist + $ make + $ cp propel-dist.yaml propel.yaml Edit `propel.yaml`. **Use spaces instead of tabulations**. @@ -120,12 +120,12 @@ See the [configuration section](#configuration) for more information about confi The web server must have permission to write into `data`. - $ sudo chown -R www-data:www-data data + $ sudo chown -R www-data:www-data data Your webserver must be configured to serve `web/` as document root. If you use nginx, all virtual paths must be rooted with `web/index.php` or `web/app_dev.php` ([documentation](https://www.nginx.com/resources/wiki/start/topics/recipes/symfony/)). If you use apache, you must enable the `rewrite` module and restart: - $ sudo a2enmod rewrite - $ sudo service apache2 restart + $ 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. @@ -134,8 +134,8 @@ Upgrade If your version is less than v1.4.2, run: `test -d app && git add app && git commit -m "Configuration"`. - $ make update - $ make propel + $ make update + $ make propel If you upgrade to v1.4.1 or more: `app/console migrate:to:v1.4.1`. @@ -282,7 +282,7 @@ Response example: "file": "55abcfa7771e0", "createdAt": "2015-07-19T16:26:15Z", "updatedAt": "2015-07-19T16:30:15Z" - "url": "https:\/\/gist.deblan.org\/en\/view\/55abcfa7771e0\/abcgi72967dd95e3461490dcaa310d728d6adef", + "url": "https:\/\/gist.deblan.org\/en\/view\/55abcfa7771e0\/abcgi72967dd95e3461490dcaa310d728d6adef", }, { "id": 67, @@ -292,9 +292,9 @@ Response example: "file": "xyzbcfa7771e0", "createdAt": "2015-08-19T16:26:15Z", "updatedAt": "2015-08-19T16:30:15Z" - "url": "https:\/\/gist.deblan.org\/en\/view\/5byzbcfa7771e0\/def72967dd95e346koq0dcaa310d728d6artu", + "url": "https:\/\/gist.deblan.org\/en\/view\/5byzbcfa7771e0\/def72967dd95e346koq0dcaa310d728d6artu", }, - ... + ... ] ``` @@ -386,21 +386,21 @@ Gist uses [Magallanes](http://magephp.com/) to manage deployment. **Global installation** - $ composer global require andres-montanez/magallanes - # if the envvar PATH contains "$HOME/bin/" - $ ln -s ~/.composer/vendor/bin/mage ~/bin/mage + $ composer global require andres-montanez/magallanes + # if the envvar PATH contains "$HOME/bin/" + $ ln -s ~/.composer/vendor/bin/mage ~/bin/mage **Local installation** - $ composer require andres-montanez/magallanes + $ composer require andres-montanez/magallanes There is an example of the configuration of an environment in `.mage/config/environment/prod.yml.dist`. - # global installation - $ mage deploy to:prod + # global installation + $ mage deploy to:prod - # local installation - $ ./vendor/andres-montanez/magallanes/bin/mage deploy to:prod + # local installation + $ ./vendor/andres-montanez/magallanes/bin/mage deploy to:prod Contributors ------------ From 31ffaced481b3d46587e20003ef39978d6a3a027 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 8 Aug 2018 09:38:51 +0200 Subject: [PATCH 2/2] Fix issue with API: the client requested 'list' instead of 'update' for updating gist and the update controller found bad gist --- src/Gist/Api/Client.php | 2 +- src/Gist/Controller/ApiController.php | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Gist/Api/Client.php b/src/Gist/Api/Client.php index 82ed6cd..ca17817 100644 --- a/src/Gist/Api/Client.php +++ b/src/Gist/Api/Client.php @@ -88,7 +88,7 @@ class Client extends BaseClient public function update($gist, $content) { $response = $this->post( - str_replace('{gist}', $gist, $this->mergeApiKey(self::LIST)), + str_replace('{gist}', $gist, $this->mergeApiKey(self::UPDATE)), array( 'form_params' => array( 'form' => array( diff --git a/src/Gist/Controller/ApiController.php b/src/Gist/Controller/ApiController.php index 89e18e1..283a616 100644 --- a/src/Gist/Controller/ApiController.php +++ b/src/Gist/Controller/ApiController.php @@ -158,12 +158,16 @@ class ApiController extends Controller return $this->invalidMethodResponse('POST method is required.'); } - $gist = GistQuery::create() - ->filterByCipher(false) - ->filterById((int) $gist) - ->_or() - ->filterByFile($gist) - ->findOne(); + $query = GistQuery::create() + ->filterByCipher(false); + + if (ctype_digit($gist)) { + $query->filterById((int) $gist); + } else { + $query->filterByFile($gist); + } + + $gist = $query->findOne(); if (!$gist) { return $this->invalidRequestResponse('Invalid Gist');