@ -0,0 +1 @@ | |||
CONSUMER_KEY= |
@ -1,2 +1,37 @@ | |||
# Super Hog | |||
<p align="center"> | |||
<img title="Laravel Zero" height="100" src="https://raw.githubusercontent.com/laravel-zero/docs/master/images/logo/laravel-zero-readme.png" /> | |||
</p> | |||
<p align="center"> | |||
<a href="https://github.com/laravel-zero/framework/actions"><img src="https://img.shields.io/github/workflow/status/laravel-zero/framework/Continuous%20Integration.svg" alt="Build Status"></img></a> | |||
<a href="https://scrutinizer-ci.com/g/laravel-zero/framework"><img src="https://img.shields.io/scrutinizer/g/laravel-zero/framework.svg" alt="Quality Score"></img></a> | |||
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://poser.pugx.org/laravel-zero/framework/d/total.svg" alt="Total Downloads"></a> | |||
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://poser.pugx.org/laravel-zero/framework/v/stable.svg" alt="Latest Stable Version"></a> | |||
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://poser.pugx.org/laravel-zero/framework/license.svg" alt="License"></a> | |||
</p> | |||
<h4> <center>This is a <bold>community project</bold> and not an official Laravel one </center></h4> | |||
Laravel Zero was created by, and is maintained by [Nuno Maduro](https://github.com/nunomaduro), and is a micro-framework that provides an elegant starting point for your console application. It is an **unofficial** and customized version of Laravel optimized for building command-line applications. | |||
- Built on top of the [Laravel](https://laravel.com) components. | |||
- Optional installation of Laravel [Eloquent](https://laravel-zero.com/docs/database/), Laravel [Logging](https://laravel-zero.com/docs/logging/) and many others. | |||
- Supports interactive [menus](https://laravel-zero.com/docs/build-interactive-menus/) and [desktop notifications](https://laravel-zero.com/docs/send-desktop-notifications/) on Linux, Windows & MacOS. | |||
- Ships with a [Scheduler](https://laravel-zero.com/docs/task-scheduling/) and a [Standalone Compiler](https://laravel-zero.com/docs/build-a-standalone-application/). | |||
- Integration with [Collision](https://github.com/nunomaduro/collision) - Beautiful error reporting | |||
------ | |||
## Documentation | |||
For full documentation, visit [laravel-zero.com](https://laravel-zero.com/). | |||
## Support the development | |||
**Do you like this project? Support it by donating** | |||
- PayPal: [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L) | |||
- Patreon: [Donate](https://www.patreon.com/nunomaduro) | |||
## License | |||
Laravel Zero is an open-source software licensed under the [MIT license](https://github.com/laravel-zero/laravel-zero/blob/stable/LICENSE.md). |
@ -0,0 +1,67 @@ | |||
<?php | |||
namespace App\Commands; | |||
use Illuminate\Console\Scheduling\Schedule; | |||
use LaravelZero\Framework\Commands\Command; | |||
use Illuminate\Support\Facades\Http; | |||
use SimpleXMLElement; | |||
class CrawlerRunCommand extends Command | |||
{ | |||
/** | |||
* The signature of the command. | |||
* | |||
* @var string | |||
*/ | |||
protected $signature = 'crawler:run'; | |||
/** | |||
* The description of the command. | |||
* | |||
* @var string | |||
*/ | |||
protected $description = 'Command description'; | |||
/** | |||
* Execute the console command. | |||
* | |||
* @return mixed | |||
*/ | |||
public function handle() | |||
{ | |||
$sources = [ | |||
'https://steadyhq.com/rss/krautreporter?auth=f7da00aa-fd3f-4411-a16f-138a1ce88dcc', | |||
'https://steadyhq.com/rss/insertmoin?auth=d37bffc9-9a84-4eed-95f6-3b6cb77c2406' | |||
]; | |||
$handler = new RssHandler(); | |||
$response = $handler->get($url); | |||
// if it is a 200 | |||
if ($response->ok()) { | |||
$handler->run($response, $actions); | |||
// if there is an error on the source | |||
} else if ($response->serverError()) { | |||
} | |||
} | |||
private function get($url, $handler) | |||
{ | |||
} | |||
/** | |||
* Define the command's schedule. | |||
* | |||
* @param \Illuminate\Console\Scheduling\Schedule $schedule | |||
* @return void | |||
* | |||
*/ | |||
public function schedule(Schedule $schedule): void | |||
{ | |||
$schedule->command(static::class)->everyMinute(); | |||
} | |||
} |
@ -0,0 +1,37 @@ | |||
<?php | |||
namespace App\Commands; | |||
use Illuminate\Console\Scheduling\Schedule; | |||
use LaravelZero\Framework\Commands\Command; | |||
class SettingsMenuCommand extends Command | |||
{ | |||
/** | |||
* The signature of the command. | |||
* | |||
* @var string | |||
*/ | |||
protected $signature = 'settings:menu'; | |||
/** | |||
* The description of the command. | |||
* | |||
* @var string | |||
*/ | |||
protected $description = 'Command description'; | |||
/** | |||
* Execute the console command. | |||
* | |||
* @return mixed | |||
*/ | |||
public function handle() | |||
{ | |||
$option = $this->menu('Settings', [ | |||
'Freshly baked muffins', | |||
'Freshly baked croissants', | |||
'Turnovers, crumb cake, cinnamon buns, scones', | |||
])->open(); | |||
} | |||
} |
@ -0,0 +1,13 @@ | |||
<?php | |||
use App\Action; | |||
/** | |||
* | |||
* | |||
*/ | |||
interface ActionInterface | |||
{ | |||
public function config(); | |||
public function run(); | |||
} |
@ -0,0 +1,11 @@ | |||
<?php | |||
/** | |||
* | |||
* | |||
* | |||
*/ | |||
class FileMoveActionHandler extends ActionHandler { | |||
} |
@ -0,0 +1,28 @@ | |||
<?php | |||
namespace App\ResponseHandler; | |||
/** | |||
* | |||
* | |||
* | |||
*/ | |||
class RssResponseHandler extends ResponseHandler implements ResponseHandlerInterface | |||
{ | |||
protected $response; | |||
protected $source; | |||
protected $actions; | |||
protected $beforeActions; | |||
protected $afterActions; | |||
/** | |||
* | |||
* @param [type] $actions | |||
* | |||
*/ | |||
public function __construct($source) | |||
{ | |||
$this->source = $source; | |||
} | |||
} |
@ -0,0 +1,14 @@ | |||
<?php | |||
namespace App\ResponseHandler; | |||
/** | |||
* | |||
* | |||
* | |||
*/ | |||
interface RssResponseInterface | |||
{ | |||
public function get(); | |||
public function handle(); | |||
} |
@ -0,0 +1,46 @@ | |||
<?php | |||
namespace App\ResponseHandler; | |||
/** | |||
* Handle Response of a Rss Feed, | |||
* response will parsed to SimpleXMLElement | |||
* each item in a channel will be run through actions | |||
* | |||
* | |||
*/ | |||
class Rss extends ResponseHandler | |||
{ | |||
/** | |||
* getting data from | |||
* | |||
* | |||
* @return object | |||
* | |||
*/ | |||
public function get() | |||
{ | |||
$this->response = Http::withHeaders([ | |||
"Content-Type" => "text/xml;charset=utf-8" | |||
])->get($this->source->url); | |||
return $this->response; | |||
} | |||
/** | |||
* handle response | |||
* | |||
* | |||
* | |||
*/ | |||
public function handle() | |||
{ | |||
$xml = new SimpleXMLElement($this->response->body()); | |||
foreach($xml->channel->item as $item) { | |||
foreach($this->actions as $action) { | |||
$action->handle($item); | |||
} | |||
} | |||
} | |||
} |
@ -0,0 +1,13 @@ | |||
<?php | |||
/** | |||
* | |||
* | |||
* | |||
* | |||
*/ | |||
class Source | |||
{ | |||
} |
@ -0,0 +1,147 @@ | |||
<?php | |||
use Illuminate\Support\Str; | |||
return [ | |||
/* | |||
|-------------------------------------------------------------------------- | |||
| Default Database Connection Name | |||
|-------------------------------------------------------------------------- | |||
| | |||
| Here you may specify which of the database connections below you wish | |||
| to use as your default connection for all database work. Of course | |||
| you may use many connections at once using the Database library. | |||
| | |||
*/ | |||
'default' => env('DB_CONNECTION', 'sqlite'), | |||
/* | |||
|-------------------------------------------------------------------------- | |||
| Database Connections | |||
|-------------------------------------------------------------------------- | |||
| | |||
| Here are each of the database connections setup for your application. | |||
| Of course, examples of configuring each database platform that is | |||
| supported by Laravel is shown below to make development simple. | |||
| | |||
| | |||
| All database work in Laravel is done through the PHP PDO facilities | |||
| so make sure you have the driver for your particular database of | |||
| choice installed on your machine before you begin development. | |||
| | |||
*/ | |||
'connections' => [ | |||
'sqlite' => [ | |||
'driver' => 'sqlite', | |||
'url' => env('DATABASE_URL'), | |||
'database' => env('DB_DATABASE', database_path('database.sqlite')), | |||
'prefix' => '', | |||
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), | |||
], | |||
'mysql' => [ | |||
'driver' => 'mysql', | |||
'url' => env('DATABASE_URL'), | |||
'host' => env('DB_HOST', '127.0.0.1'), | |||
'port' => env('DB_PORT', '3306'), | |||
'database' => env('DB_DATABASE', 'forge'), | |||
'username' => env('DB_USERNAME', 'forge'), | |||
'password' => env('DB_PASSWORD', ''), | |||
'unix_socket' => env('DB_SOCKET', ''), | |||
'charset' => 'utf8mb4', | |||
'collation' => 'utf8mb4_unicode_ci', | |||
'prefix' => '', | |||
'prefix_indexes' => true, | |||
'strict' => true, | |||
'engine' => null, | |||
'options' => extension_loaded('pdo_mysql') ? array_filter([ | |||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), | |||
]) : [], | |||
], | |||
'pgsql' => [ | |||
'driver' => 'pgsql', | |||
'url' => env('DATABASE_URL'), | |||
'host' => env('DB_HOST', '127.0.0.1'), | |||
'port' => env('DB_PORT', '5432'), | |||
'database' => env('DB_DATABASE', 'forge'), | |||
'username' => env('DB_USERNAME', 'forge'), | |||
'password' => env('DB_PASSWORD', ''), | |||
'charset' => 'utf8', | |||
'prefix' => '', | |||
'prefix_indexes' => true, | |||
'schema' => 'public', | |||
'sslmode' => 'prefer', | |||
], | |||
'sqlsrv' => [ | |||
'driver' => 'sqlsrv', | |||
'url' => env('DATABASE_URL'), | |||
'host' => env('DB_HOST', 'localhost'), | |||
'port' => env('DB_PORT', '1433'), | |||
'database' => env('DB_DATABASE', 'forge'), | |||
'username' => env('DB_USERNAME', 'forge'), | |||
'password' => env('DB_PASSWORD', ''), | |||
'charset' => 'utf8', | |||
'prefix' => '', | |||
'prefix_indexes' => true, | |||
], | |||
], | |||
/* | |||
|-------------------------------------------------------------------------- | |||
| Migration Repository Table | |||
|-------------------------------------------------------------------------- | |||
| | |||
| This table keeps track of all the migrations that have already run for | |||
| your application. Using this information, we can determine which of | |||
| the migrations on disk haven't actually been run in the database. | |||
| | |||
*/ | |||
'migrations' => 'migrations', | |||
/* | |||
|-------------------------------------------------------------------------- | |||
| Redis Databases | |||
|-------------------------------------------------------------------------- | |||
| | |||
| Redis is an open source, fast, and advanced key-value store that also | |||
| provides a richer body of commands than a typical key-value system | |||
| such as APC or Memcached. Laravel makes it easy to dig right in. | |||
| | |||
*/ | |||
'redis' => [ | |||
'client' => env('REDIS_CLIENT', 'phpredis'), | |||
'options' => [ | |||
'cluster' => env('REDIS_CLUSTER', 'redis'), | |||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), | |||
], | |||
'default' => [ | |||
'url' => env('REDIS_URL'), | |||
'host' => env('REDIS_HOST', '127.0.0.1'), | |||
'password' => env('REDIS_PASSWORD', null), | |||
'port' => env('REDIS_PORT', '6379'), | |||
'database' => env('REDIS_DB', '0'), | |||
], | |||
'cache' => [ | |||
'url' => env('REDIS_URL'), | |||
'host' => env('REDIS_HOST', '127.0.0.1'), | |||
'password' => env('REDIS_PASSWORD', null), | |||
'port' => env('REDIS_PORT', '6379'), | |||
'database' => env('REDIS_CACHE_DB', '1'), | |||
], | |||
], | |||
]; |
@ -0,0 +1,100 @@ | |||
<?php | |||
use Monolog\Handler\NullHandler; | |||
use Monolog\Handler\StreamHandler; | |||
use Monolog\Handler\SyslogUdpHandler; | |||
return [ | |||
/* | |||
|-------------------------------------------------------------------------- | |||
| Default Log Channel | |||
|-------------------------------------------------------------------------- | |||
| | |||
| This option defines the default log channel that gets used when writing | |||
| messages to the logs. The name specified in this option should match | |||
| one of the channels defined in the "channels" configuration array. | |||
| | |||
*/ | |||
'default' => env('LOG_CHANNEL', 'stack'), | |||
/* | |||
|-------------------------------------------------------------------------- | |||
| Log Channels | |||
|-------------------------------------------------------------------------- | |||
| | |||
| Here you may configure the log channels for your application. Out of | |||
| the box, Laravel uses the Monolog PHP logging library. This gives | |||
| you a variety of powerful log handlers / formatters to utilize. | |||
| | |||
| Available Drivers: "single", "daily", "slack", "syslog", | |||
| "errorlog", "monolog", | |||
| "custom", "stack" | |||
| | |||
*/ | |||
'channels' => [ | |||
'stack' => [ | |||
'driver' => 'stack', | |||
'channels' => ['stderr'], | |||
'ignore_exceptions' => false, | |||
], | |||
'single' => [ | |||
'driver' => 'single', | |||
'path' => storage_path('logs/laravel.log'), | |||
'level' => 'debug', | |||
], | |||
'daily' => [ | |||
'driver' => 'daily', | |||
'path' => storage_path('logs/laravel.log'), | |||
'level' => 'debug', | |||
'days' => 14, | |||
], | |||
'slack' => [ | |||
'driver' => 'slack', | |||
'url' => env('LOG_SLACK_WEBHOOK_URL'), | |||
'username' => 'Laravel Log', | |||
'emoji' => ':boom:', | |||
'level' => 'critical', | |||
], | |||
'papertrail' => [ | |||
'driver' => 'monolog', | |||
'level' => 'debug', | |||
'handler' => SyslogUdpHandler::class, | |||
'handler_with' => [ | |||
'host' => env('PAPERTRAIL_URL'), | |||
'port' => env('PAPERTRAIL_PORT'), | |||
], | |||
], | |||
'stderr' => [ | |||
'driver' => 'monolog', | |||
'handler' => StreamHandler::class, | |||
'formatter' => env('LOG_STDERR_FORMATTER'), | |||
'with' => [ | |||
'stream' => 'php://stderr', | |||
], | |||
], | |||
'syslog' => [ | |||
'driver' => 'syslog', | |||
'level' => 'debug', | |||
], | |||
'errorlog' => [ | |||
'driver' => 'errorlog', | |||
'level' => 'debug', | |||
], | |||
'null' => [ | |||
'driver' => 'monolog', | |||
'handler' => NullHandler::class, | |||
], | |||
], | |||
]; |
@ -1,37 +0,0 @@ | |||
<p align="center"> | |||
<img title="Laravel Zero" height="100" src="https://raw.githubusercontent.com/laravel-zero/docs/master/images/logo/laravel-zero-readme.png" /> | |||
</p> | |||
<p align="center"> | |||
<a href="https://github.com/laravel-zero/framework/actions"><img src="https://img.shields.io/github/workflow/status/laravel-zero/framework/Continuous%20Integration.svg" alt="Build Status"></img></a> | |||
<a href="https://scrutinizer-ci.com/g/laravel-zero/framework"><img src="https://img.shields.io/scrutinizer/g/laravel-zero/framework.svg" alt="Quality Score"></img></a> | |||
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://poser.pugx.org/laravel-zero/framework/d/total.svg" alt="Total Downloads"></a> | |||
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://poser.pugx.org/laravel-zero/framework/v/stable.svg" alt="Latest Stable Version"></a> | |||
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://poser.pugx.org/laravel-zero/framework/license.svg" alt="License"></a> | |||
</p> | |||
<h4> <center>This is a <bold>community project</bold> and not an official Laravel one </center></h4> | |||
Laravel Zero was created by, and is maintained by [Nuno Maduro](https://github.com/nunomaduro), and is a micro-framework that provides an elegant starting point for your console application. It is an **unofficial** and customized version of Laravel optimized for building command-line applications. | |||
- Built on top of the [Laravel](https://laravel.com) components. | |||
- Optional installation of Laravel [Eloquent](https://laravel-zero.com/docs/database/), Laravel [Logging](https://laravel-zero.com/docs/logging/) and many others. | |||
- Supports interactive [menus](https://laravel-zero.com/docs/build-interactive-menus/) and [desktop notifications](https://laravel-zero.com/docs/send-desktop-notifications/) on Linux, Windows & MacOS. | |||
- Ships with a [Scheduler](https://laravel-zero.com/docs/task-scheduling/) and a [Standalone Compiler](https://laravel-zero.com/docs/build-a-standalone-application/). | |||
- Integration with [Collision](https://github.com/nunomaduro/collision) - Beautiful error reporting | |||
------ | |||
## Documentation | |||
For full documentation, visit [laravel-zero.com](https://laravel-zero.com/). | |||
## Support the development | |||
**Do you like this project? Support it by donating** | |||
- PayPal: [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L) | |||
- Patreon: [Donate](https://www.patreon.com/nunomaduro) | |||
## License | |||
Laravel Zero is an open-source software licensed under the [MIT license](https://github.com/laravel-zero/laravel-zero/blob/stable/LICENSE.md). |
@ -1,44 +0,0 @@ | |||
<?php | |||
namespace App\Commands; | |||
use Illuminate\Console\Scheduling\Schedule; | |||
use LaravelZero\Framework\Commands\Command; | |||
class InspiringCommand extends Command | |||
{ | |||
/** | |||
* The signature of the command. | |||
* | |||
* @var string | |||
*/ | |||
protected $signature = 'inspiring {name=Artisan}'; | |||
/** | |||
* The description of the command. | |||
* | |||
* @var string | |||
*/ | |||
protected $description = 'Display an inspiring quote'; | |||
/** | |||
* Execute the console command. | |||
* | |||
* @return mixed | |||
*/ | |||
public function handle() | |||
{ | |||
$this->info('Simplicity is the ultimate sophistication.'); | |||
} | |||
/** | |||
* Define the command's schedule. | |||
* | |||
* @param \Illuminate\Console\Scheduling\Schedule $schedule | |||
* @return void | |||
*/ | |||
public function schedule(Schedule $schedule) | |||
{ | |||
// $schedule->command(static::class)->everyMinute(); | |||
} | |||
} |
@ -0,0 +1,37 @@ | |||
<?php | |||
use Illuminate\Database\Migrations\Migration; | |||
use Illuminate\Database\Schema\Blueprint; | |||
use Illuminate\Support\Facades\Schema; | |||
class CreateSourcesTable extends Migration | |||
{ | |||
/** | |||
* Run the migrations. | |||
* | |||
* @return void | |||
*/ | |||
public function up() | |||
{ | |||
Schema::create('sources', function (Blueprint $table) { | |||
$table->id(); | |||
$table->string('name'); | |||
$table->string('url'); | |||
$table->string('response_handler_class'); | |||
$table->dateTime('last_run_at'); | |||
$table->timestamps(); | |||
}); | |||
} | |||
/** | |||
* Reverse the migrations. | |||
* | |||
* @return void | |||
*/ | |||
public function down() | |||
{ | |||
Schema::dropIfExists('sources'); | |||
} | |||
} |
@ -0,0 +1,45 @@ | |||
<?php | |||
use Illuminate\Database\Migrations\Migration; | |||
use Illuminate\Database\Schema\Blueprint; | |||
use Illuminate\Support\Facades\Schema; | |||
class CreateActionsTable extends Migration | |||
{ | |||
/** | |||
* Run the migrations. | |||
* | |||
* @return void | |||
*/ | |||
public function up() | |||
{ | |||
Schema::create('actions', function (Blueprint $table) { | |||
$table->id(); | |||
$table->string('action_handler_class'); | |||
$table->enum('type', [ | |||
'before', 'after' | |||
])->nullable(); | |||
$table->integer('priority'); | |||
// sources | |||
$table->uuid('source_id') | |||
->nullable(); | |||
$table->foreign('source_id') | |||
->references('id') | |||
->on('sources'); | |||
$table->timestamps(); | |||
}); | |||
} | |||
/** | |||
* Reverse the migrations. | |||
* | |||
* @return void | |||
*/ | |||
public function down() | |||
{ | |||
Schema::dropIfExists('actions'); | |||
} | |||
} |
@ -0,0 +1,41 @@ | |||
<?php | |||
use Illuminate\Database\Migrations\Migration; | |||
use Illuminate\Database\Schema\Blueprint; | |||
use Illuminate\Support\Facades\Schema; | |||
class CreateLogsTable extends Migration | |||
{ | |||
/** | |||
* Run the migrations. | |||
* | |||
* @return void | |||
*/ | |||
public function up() | |||
{ | |||
Schema::create('logs', function (Blueprint $table) { | |||
$table->uuid(); | |||
$tabke->json('message'); | |||
$table->enum('state', [ | |||
'critical', 'solved', 'error' | |||
]); | |||
// sources | |||
$table->uuid('source_id')->nullable(); | |||
$table->foreign('source_id')->references('id')->on('sources'); | |||
$table->timestamps(); | |||
}); | |||
} | |||
/** | |||
* Reverse the migrations. | |||
* | |||
* @return void | |||
*/ | |||
public function down() | |||
{ | |||
Schema::dropIfExists('logs'); | |||
} | |||
} |
@ -0,0 +1,16 @@ | |||
<?php | |||
use Illuminate\Database\Seeder; | |||
class DatabaseSeeder extends Seeder | |||
{ | |||
/** | |||
* Seed the application's database. | |||
* | |||
* @return void | |||
*/ | |||
public function run() | |||
{ | |||
// $this->call(UsersTableSeeder::class); | |||
} | |||
} |