From 937ac365b4ad8edfc2e9813a6610c132e5f7858c Mon Sep 17 00:00:00 2001 From: Schlaefer Date: Sun, 15 Mar 2015 08:38:29 +0100 Subject: [PATCH 1/7] code formatting --- .../Embedly/View/Helper/EmbedlyHelper.php | 99 ++++++++++--------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/app/Plugin/Embedly/View/Helper/EmbedlyHelper.php b/app/Plugin/Embedly/View/Helper/EmbedlyHelper.php index 520c5d02b..3a4a31683 100644 --- a/app/Plugin/Embedly/View/Helper/EmbedlyHelper.php +++ b/app/Plugin/Embedly/View/Helper/EmbedlyHelper.php @@ -1,64 +1,65 @@ 'Mozilla/5.0 (compatible; cakephp/1.0)', - 'key' => self::$_apiKey, - )); + $api = new Embedly\Embedly( + array( + 'user_agent' => 'Mozilla/5.0 (compatible; cakephp/1.0)', + 'key' => self::$_apiKey, + ) + ); - $request = ['urls' => [$string]]; + $request = ['urls' => [$string]]; - try { - $obj = current($api->oembed($request)); - } catch (Exception $e) { - return 'Embedding failded: ' . $e->getMessage(); - } + try { + $obj = current($api->oembed($request)); + } catch (Exception $e) { + return 'Embedding failded: ' . $e->getMessage(); + } - if ( isset($obj->html) ): - // use the html code from embedly if possible - $out = $obj->html; - elseif ( isset($obj->title) && isset($obj->url) ): - // else just link to target - $title = ''; - $escape = TRUE; - if ( isset($obj->thumbnail_url) ) : - // use thumbnail for link if available - $title .= $this->Html->image($obj->thumbnail_url, array( - 'class' => 'embedly-image' - )); - $title .= $this->Html->tag('br'); - $escape = FALSE; - endif; - $title .= $obj->title; - $out = $this->Html->link( - $title, $obj->url, array( 'escape' => $escape ) - ); - endif; + if (isset($obj->html)): + // use the html code from embedly if possible + $out = $obj->html; + elseif (isset($obj->title) && isset($obj->url)): + // else just link to target + $title = ''; + $escape = true; + if (isset($obj->thumbnail_url)) : + // use thumbnail for link if available + $title .= $this->Html->image( + $obj->thumbnail_url, array( + 'class' => 'embedly-image' + ) + ); + $title .= $this->Html->tag('br'); + $escape = false; + endif; + $title .= $obj->title; + $out = $this->Html->link( + $title, $obj->url, array('escape' => $escape) + ); + endif; - return $out; - } + return $out; + } - } - -?> \ No newline at end of file +} From 0e781b053d06743e9e480855f565380222c58493 Mon Sep 17 00:00:00 2001 From: Schlaefer Date: Sun, 15 Mar 2015 08:41:16 +0100 Subject: [PATCH 2/7] code formatting --- .../Embedly/View/Helper/EmbedlyHelper.php | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/app/Plugin/Embedly/View/Helper/EmbedlyHelper.php b/app/Plugin/Embedly/View/Helper/EmbedlyHelper.php index 3a4a31683..6e4c4ed5b 100644 --- a/app/Plugin/Embedly/View/Helper/EmbedlyHelper.php +++ b/app/Plugin/Embedly/View/Helper/EmbedlyHelper.php @@ -21,43 +21,38 @@ public function embedly($string) { $out = false; - $api = new Embedly\Embedly( - array( - 'user_agent' => 'Mozilla/5.0 (compatible; cakephp/1.0)', - 'key' => self::$_apiKey, - ) - ); - - $request = ['urls' => [$string]]; + $properties = [ + 'user_agent' => 'Mozilla/5.0 (compatible; cakephp/1.0)', + 'key' => self::$_apiKey, + ]; + $api = new Embedly\Embedly($properties); try { + $request = ['urls' => [$string]]; $obj = current($api->oembed($request)); } catch (Exception $e) { return 'Embedding failded: ' . $e->getMessage(); } - if (isset($obj->html)): + if (isset($obj->html)) { // use the html code from embedly if possible $out = $obj->html; - elseif (isset($obj->title) && isset($obj->url)): + } elseif (isset($obj->title) && isset($obj->url)) { // else just link to target $title = ''; $escape = true; - if (isset($obj->thumbnail_url)) : + if (isset($obj->thumbnail_url)) { // use thumbnail for link if available $title .= $this->Html->image( - $obj->thumbnail_url, array( - 'class' => 'embedly-image' - ) + $obj->thumbnail_url, + ['class' => 'embedly-image'] ); $title .= $this->Html->tag('br'); $escape = false; - endif; + } $title .= $obj->title; - $out = $this->Html->link( - $title, $obj->url, array('escape' => $escape) - ); - endif; + $out = $this->Html->link($title, $obj->url, ['escape' => $escape]); + } return $out; } From 76a5b3fa6786da5f6bb1cb297b6daa9123e82ddb Mon Sep 17 00:00:00 2001 From: Schlaefer Date: Sun, 15 Mar 2015 09:11:10 +0100 Subject: [PATCH 3/7] fix #314 don't embed complete html pages --- app/Plugin/Embedly/View/Helper/EmbedlyHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Plugin/Embedly/View/Helper/EmbedlyHelper.php b/app/Plugin/Embedly/View/Helper/EmbedlyHelper.php index 6e4c4ed5b..eeb626eb9 100644 --- a/app/Plugin/Embedly/View/Helper/EmbedlyHelper.php +++ b/app/Plugin/Embedly/View/Helper/EmbedlyHelper.php @@ -34,7 +34,7 @@ public function embedly($string) { return 'Embedding failded: ' . $e->getMessage(); } - if (isset($obj->html)) { + if (isset($obj->html) && $obj->type !== 'link') { // use the html code from embedly if possible $out = $obj->html; } elseif (isset($obj->title) && isset($obj->url)) { From 3a91ca6e464f991822940f7c7d3826d3d3accc67 Mon Sep 17 00:00:00 2001 From: Schlaefer Date: Fri, 20 Mar 2015 09:10:11 +0100 Subject: [PATCH 4/7] remove category to category_id conversion in API post new; fixes #313 --- .../Api/Controller/ApiEntriesController.php | 4 ---- .../Controller/ApiEntriesControllerTest.php | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/Plugin/Api/Controller/ApiEntriesController.php b/app/Plugin/Api/Controller/ApiEntriesController.php index 2105bf6ca..f829e0a59 100644 --- a/app/Plugin/Api/Controller/ApiEntriesController.php +++ b/app/Plugin/Api/Controller/ApiEntriesController.php @@ -59,10 +59,6 @@ public function threadsGet() { */ public function entriesItemPost() { $data['Entry'] = $this->request->data; - if (isset($data['Entry']['category_id'])) { - $data['Entry']['category'] = $data['Entry']['category_id']; - unset($data['Entry']['category_id']); - } if (isset($data['Entry']['parent_id'])) { $data['Entry']['pid'] = $data['Entry']['parent_id']; unset($data['Entry']['parent_id']); diff --git a/app/Plugin/Api/Test/Case/Controller/ApiEntriesControllerTest.php b/app/Plugin/Api/Test/Case/Controller/ApiEntriesControllerTest.php index 12a62f0a4..d206595f3 100644 --- a/app/Plugin/Api/Test/Case/Controller/ApiEntriesControllerTest.php +++ b/app/Plugin/Api/Test/Case/Controller/ApiEntriesControllerTest.php @@ -133,6 +133,25 @@ public function testEntriesItemPostEmptySubject() { ); } + public function testEntriesItemPostSuccess() { + $this->generate('Api.ApiEntries'); + $this->_loginUser(3); + $result = $this->testAction( + $this->_apiRoot . 'entries.json', + [ + 'return' => 'view', + 'method' => 'POST', + 'data' => [ + 'subject' => 'subject', + 'parent_id' => 0, + 'category_id' => 2 + ] + ] + ); + $statusCode = $this->controller->response->statusCode(); + $this->assertEquals(200, $statusCode); + } + public function testEntriesItemPutOnlyAuthenticatedUsers() { $this->generate('ApiEntries', ['methods' => 'entriesItemPut']); $this->testAction($this->_apiRoot . 'entries/1', ['method' => 'PUT']); From 405818f14bbcb55296157219e0da0eb4bd45ad69 Mon Sep 17 00:00:00 2001 From: Schlaefer Date: Fri, 20 Mar 2015 09:12:15 +0100 Subject: [PATCH 5/7] update to CakePHP 2.6.3 and composer update --- app/composer.json | 2 +- app/composer.lock | 91 ++++++++++++++++++++++++++--------------------- 2 files changed, 52 insertions(+), 41 deletions(-) diff --git a/app/composer.json b/app/composer.json index 9d21ec759..935c79bea 100644 --- a/app/composer.json +++ b/app/composer.json @@ -30,7 +30,7 @@ "php": ">=5.4.0", "ext-mcrypt": "*", "markstory/geshi": "0.3.*", - "pear-pear.cakephp.org/CakePHP": "2.6.2", + "pear-pear.cakephp.org/CakePHP": "2.6.3", "kzykhys/ciconia": "~1.0.3", "jbbcode/jbbcode": "~1.3", "aura/di": "~2.1" diff --git a/app/composer.lock b/app/composer.lock index 401a8b925..72be82f3b 100644 --- a/app/composer.lock +++ b/app/composer.lock @@ -4,20 +4,20 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "667a776e3044f0e3db2592754a36b8e4", + "hash": "c3a6e7b373f46833ada5702bc89104d5", "packages": [ { "name": "aura/di", - "version": "2.1.0", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/auraphp/Aura.Di.git", - "reference": "68ffa4f76a2525ce3b7d211c09c71709a882556c" + "reference": "8e167c9faca11a8fde3594e2e6e4a967aaad9bd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/auraphp/Aura.Di/zipball/68ffa4f76a2525ce3b7d211c09c71709a882556c", - "reference": "68ffa4f76a2525ce3b7d211c09c71709a882556c", + "url": "https://api.github.com/repos/auraphp/Aura.Di/zipball/8e167c9faca11a8fde3594e2e6e4a967aaad9bd1", + "reference": "8e167c9faca11a8fde3594e2e6e4a967aaad9bd1", "shasum": "" }, "require": { @@ -56,7 +56,7 @@ "di", "di container" ], - "time": "2014-11-06 18:13:34" + "time": "2015-03-16 00:22:17" }, { "name": "composer/installers", @@ -296,10 +296,10 @@ }, { "name": "pear-pear.cakephp.org/CakePHP", - "version": "2.6.2", + "version": "2.6.3", "dist": { "type": "file", - "url": "http://pear.cakephp.org/get/CakePHP-2.6.2.tgz", + "url": "http://pear.cakephp.org/get/CakePHP-2.6.3.tgz", "reference": null, "shasum": null }, @@ -307,7 +307,7 @@ "php": ">=5.2.8.0" }, "replace": { - "pear-cakephp/cakephp": "== 2.6.2.0" + "pear-cakephp/cakephp": "== 2.6.3.0" }, "type": "pear-library", "autoload": { @@ -471,16 +471,16 @@ }, { "name": "pdepend/pdepend", - "version": "2.0.4", + "version": "2.0.6", "source": { "type": "git", "url": "https://github.com/pdepend/pdepend.git", - "reference": "1b0acf162da4f30237987e61e177a57f78e3d87e" + "reference": "a15ffcbfbcc4570d4a733ca7b76e9cac0a56c3f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pdepend/pdepend/zipball/1b0acf162da4f30237987e61e177a57f78e3d87e", - "reference": "1b0acf162da4f30237987e61e177a57f78e3d87e", + "url": "https://api.github.com/repos/pdepend/pdepend/zipball/a15ffcbfbcc4570d4a733ca7b76e9cac0a56c3f4", + "reference": "a15ffcbfbcc4570d4a733ca7b76e9cac0a56c3f4", "shasum": "" }, "require": { @@ -506,20 +506,20 @@ "BSD-3-Clause" ], "description": "Official version of pdepend to be handled with Composer", - "time": "2014-12-04 12:38:39" + "time": "2015-03-02 08:06:43" }, { "name": "phpmd/phpmd", - "version": "2.2.0", + "version": "2.2.1", "source": { "type": "git", "url": "https://github.com/phpmd/phpmd.git", - "reference": "580e6ca75b472a844389ab8df7a0b412901d0d91" + "reference": "58c4b00f924d301e8c5281f40cfa9a66f3df9eee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpmd/phpmd/zipball/580e6ca75b472a844389ab8df7a0b412901d0d91", - "reference": "580e6ca75b472a844389ab8df7a0b412901d0d91", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/58c4b00f924d301e8c5281f40cfa9a66f3df9eee", + "reference": "58c4b00f924d301e8c5281f40cfa9a66f3df9eee", "shasum": "" }, "require": { @@ -530,7 +530,8 @@ "symfony/filesystem": ">=2.4" }, "require-dev": { - "phpunit/phpunit": "*" + "phpunit/phpunit": "*", + "squizlabs/php_codesniffer": "*" }, "bin": [ "src/bin/phpmd" @@ -567,7 +568,7 @@ "phpmd", "pmd" ], - "time": "2015-01-25 13:46:59" + "time": "2015-03-02 10:26:50" }, { "name": "phpunit/php-code-coverage", @@ -1007,23 +1008,26 @@ }, { "name": "symfony/config", - "version": "v2.6.4", + "version": "v2.6.5", "target-dir": "Symfony/Component/Config", "source": { "type": "git", "url": "https://github.com/symfony/Config.git", - "reference": "a9f781ba1221067d1f07c8cec0bc50f81b8d7408" + "reference": "7a47189c7667ca69bcaafd19ef8a8941db449a2c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/a9f781ba1221067d1f07c8cec0bc50f81b8d7408", - "reference": "a9f781ba1221067d1f07c8cec0bc50f81b8d7408", + "url": "https://api.github.com/repos/symfony/Config/zipball/7a47189c7667ca69bcaafd19ef8a8941db449a2c", + "reference": "7a47189c7667ca69bcaafd19ef8a8941db449a2c", "shasum": "" }, "require": { "php": ">=5.3.3", "symfony/filesystem": "~2.3" }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, "type": "library", "extra": { "branch-alias": { @@ -1051,21 +1055,21 @@ ], "description": "Symfony Config Component", "homepage": "http://symfony.com", - "time": "2015-01-21 20:57:55" + "time": "2015-03-12 10:28:44" }, { "name": "symfony/dependency-injection", - "version": "v2.6.4", + "version": "v2.6.5", "target-dir": "Symfony/Component/DependencyInjection", "source": { "type": "git", "url": "https://github.com/symfony/DependencyInjection.git", - "reference": "42bbb43fab66292a1865dc9616c299904c3d4d14" + "reference": "a49245b2beebe332924561c30772b16e1d32f13a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/42bbb43fab66292a1865dc9616c299904c3d4d14", - "reference": "42bbb43fab66292a1865dc9616c299904c3d4d14", + "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/a49245b2beebe332924561c30772b16e1d32f13a", + "reference": "a49245b2beebe332924561c30772b16e1d32f13a", "shasum": "" }, "require": { @@ -1077,6 +1081,7 @@ "require-dev": { "symfony/config": "~2.2", "symfony/expression-language": "~2.6", + "symfony/phpunit-bridge": "~2.7", "symfony/yaml": "~2.1" }, "suggest": { @@ -1111,26 +1116,29 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "http://symfony.com", - "time": "2015-01-25 04:39:26" + "time": "2015-03-17 12:44:40" }, { "name": "symfony/filesystem", - "version": "v2.6.4", + "version": "v2.6.5", "target-dir": "Symfony/Component/Filesystem", "source": { "type": "git", "url": "https://github.com/symfony/Filesystem.git", - "reference": "a1f566d1f92e142fa1593f4555d6d89e3044a9b7" + "reference": "fdc5f151bc2db066b51870d5bea3773d915ced0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/a1f566d1f92e142fa1593f4555d6d89e3044a9b7", - "reference": "a1f566d1f92e142fa1593f4555d6d89e3044a9b7", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/fdc5f151bc2db066b51870d5bea3773d915ced0b", + "reference": "fdc5f151bc2db066b51870d5bea3773d915ced0b", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, "type": "library", "extra": { "branch-alias": { @@ -1158,26 +1166,29 @@ ], "description": "Symfony Filesystem Component", "homepage": "http://symfony.com", - "time": "2015-01-03 21:13:09" + "time": "2015-03-12 10:28:44" }, { "name": "symfony/yaml", - "version": "v2.6.4", + "version": "v2.6.5", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "60ed7751671113cf1ee7d7778e691642c2e9acd8" + "reference": "0cd8e72071e46e15fc072270ae39ea1b66b10a9d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/60ed7751671113cf1ee7d7778e691642c2e9acd8", - "reference": "60ed7751671113cf1ee7d7778e691642c2e9acd8", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/0cd8e72071e46e15fc072270ae39ea1b66b10a9d", + "reference": "0cd8e72071e46e15fc072270ae39ea1b66b10a9d", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, "type": "library", "extra": { "branch-alias": { @@ -1205,7 +1216,7 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2015-01-25 04:39:26" + "time": "2015-03-12 10:28:44" } ], "aliases": [], From 28376f2b898c5a0bf0b2c885c8afea977c3f1182 Mon Sep 17 00:00:00 2001 From: Schlaefer Date: Fri, 20 Mar 2015 09:18:28 +0100 Subject: [PATCH 6/7] bump version string --- app/Config/version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Config/version.php b/app/Config/version.php index 89730fd52..fccc9dc6c 100644 --- a/app/Config/version.php +++ b/app/Config/version.php @@ -1,4 +1,4 @@ Date: Fri, 20 Mar 2015 09:42:00 +0100 Subject: [PATCH 7/7] use travis composer installation --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d550e3c64..e11ea2a4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ env: - DB=pgsql before_script: - - if [ ! -f composer.phar ]; then curl -s http://getcomposer.org/installer | php; fi; php composer.phar install -d app -o + - composer install -d app -o - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi" - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE DATABASE cakephp_test;' -U postgres; fi" - chmod -R 777 ./app/tmp