diff --git a/composer.json b/composer.json index 87a0120..7e5d35a 100644 --- a/composer.json +++ b/composer.json @@ -7,23 +7,23 @@ "firebase/php-jwt": "~3.0", "league/route": "~1.2", "league/plates": "~3.1", - "j4mie/idiorm": "1.5.*" + "j4mie/idiorm": "1.5.*", + "p3k/caterpillar": "0.1.*" }, "require-dev": { "phpunit/phpunit": "*" }, "autoload": { + "psr-4": { + "Telegraph\\": "lib/Telegraph/" + }, "files": [ "lib/helpers.php", - "lib/HTTP.php", "controllers/Controller.php", "controllers/Auth.php", "controllers/API.php" ] }, "autoload-dev": { - "files": [ - "lib/HTTPTest.php" - ] } } diff --git a/composer.lock b/composer.lock index 7a32b66..0651435 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "2ba7de03b37a6d84edc940e53b969dd8", - "content-hash": "a54d5a9f88a410c0295e0530b51e3abc", + "hash": "b33b0001cd49507ca593b5ac7a1c7f62", + "content-hash": "d16bb0e3e3c4ada5c5eb9cb1eb603d15", "packages": [ { "name": "barnabywalters/mf-cleaner", @@ -539,6 +539,93 @@ ], "time": "2015-12-20 19:50:12" }, + { + "name": "p3k/caterpillar", + "version": "0.1.1", + "source": { + "type": "git", + "url": "https://github.com/aaronpk/Caterpillar.git", + "reference": "61f94612f25d6b5dbfda5c792147bd5f6fa62fcb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aaronpk/Caterpillar/zipball/61f94612f25d6b5dbfda5c792147bd5f6fa62fcb", + "reference": "61f94612f25d6b5dbfda5c792147bd5f6fa62fcb", + "shasum": "" + }, + "require": { + "pda/pheanstalk": "3.*", + "php": ">5.4.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Caterpillar": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache 2.0" + ], + "authors": [ + { + "name": "Aaron Parecki", + "homepage": "http://aaronparecki.com/" + } + ], + "description": "Caterpillar is a background queue manager", + "time": "2015-12-21 22:52:21" + }, + { + "name": "pda/pheanstalk", + "version": "v3.1.0", + "source": { + "type": "git", + "url": "https://github.com/pda/pheanstalk.git", + "reference": "430e77c551479aad0c6ada0450ee844cf656a18b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pda/pheanstalk/zipball/430e77c551479aad0c6ada0450ee844cf656a18b", + "reference": "430e77c551479aad0c6ada0450ee844cf656a18b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Pheanstalk\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paul Annesley", + "email": "paul@annesley.cc", + "homepage": "http://paul.annesley.cc/", + "role": "Developer" + } + ], + "description": "PHP client for beanstalkd queue", + "homepage": "https://github.com/pda/pheanstalk", + "keywords": [ + "beanstalkd" + ], + "time": "2015-08-07 21:42:41" + }, { "name": "symfony/http-foundation", "version": "v2.8.0", diff --git a/controllers/API.php b/controllers/API.php index edd0845..a9489b7 100644 --- a/controllers/API.php +++ b/controllers/API.php @@ -125,7 +125,7 @@ class API { $w->callback = $callback; $w->save(); - + q()->queue('Telegraph\Webmention', 'send', [$w->id]); $statusURL = Config::$base . 'webmention/' . $w->token; diff --git a/lib/HTTP.php b/lib/Telegraph/HTTP.php similarity index 100% rename from lib/HTTP.php rename to lib/Telegraph/HTTP.php diff --git a/lib/HTTPTest.php b/lib/Telegraph/HTTPTest.php similarity index 92% rename from lib/HTTPTest.php rename to lib/Telegraph/HTTPTest.php index 0ef5eaa..06af003 100644 --- a/lib/HTTPTest.php +++ b/lib/Telegraph/HTTPTest.php @@ -20,9 +20,9 @@ class HTTPTest { } private static function _read_file($url) { - $filename = dirname(__FILE__).'/../tests/data/'.preg_replace('/https?:\/\//', '', $url); + $filename = dirname(__FILE__).'/../../tests/data/'.preg_replace('/https?:\/\//', '', $url); if(!file_exists($filename)) { - $filename = dirname(__FILE__).'/../tests/data/404.response.txt'; + $filename = dirname(__FILE__).'/../../tests/data/404.response.txt'; } $response = file_get_contents($filename); diff --git a/lib/Telegraph/Webmention.php b/lib/Telegraph/Webmention.php new file mode 100644 index 0000000..d96d157 --- /dev/null +++ b/lib/Telegraph/Webmention.php @@ -0,0 +1,17 @@ +where('id', $id)->find_one(); + if(!$w) { + echo 'Webmention '.$id.' was not found'."\n"; + return; + } + + + } + +} diff --git a/lib/helpers.php b/lib/helpers.php index f65f606..b22e412 100644 --- a/lib/helpers.php +++ b/lib/helpers.php @@ -15,3 +15,12 @@ function view($template, $data=[]) { global $templates; return $templates->render($template, $data); } + +function q() { + static $caterpillar = false; + if(!$caterpillar) { + $logdir = __DIR__.'/../scripts/logs/'; + $caterpillar = new Caterpillar('telegraph', '127.0.0.1', 11300, $logdir); + } + return $caterpillar; +} diff --git a/scripts/telegraph.php b/scripts/telegraph.php new file mode 100644 index 0000000..3eb153c --- /dev/null +++ b/scripts/telegraph.php @@ -0,0 +1,5 @@ +run_workers(2);