Completed LinkBundleCreator
This commit is contained in:
parent
2100fec73f
commit
c8ccebfebc
|
@ -4,6 +4,7 @@
|
|||
|
||||
use App\Classes\Bundle;
|
||||
use App\Exceptions\BundleAlreadyExists;
|
||||
use App\Services\Browser;
|
||||
use Illuminate\Filesystem\FilesystemAdapter;
|
||||
|
||||
use function Laravel\Prompts\text;
|
||||
|
@ -26,7 +27,6 @@ public function createBundle(): string
|
|||
$hash = md5($url);
|
||||
$date = now();
|
||||
$path = sprintf('%s/%s/%s', static::$section, $date->format('Y/m/d'), $hash);
|
||||
|
||||
$bundle = new Bundle($path, $this->disk);
|
||||
|
||||
if ($bundle->exists()) {
|
||||
|
@ -35,11 +35,26 @@ public function createBundle(): string
|
|||
);
|
||||
}
|
||||
|
||||
$bundle->markdown()->set('');
|
||||
// $bundle->metadata()->set([
|
||||
// 'title' => $title,
|
||||
// 'date' => $date->toIso8601String(),
|
||||
// ]);
|
||||
$browser = new Browser($url);
|
||||
|
||||
$browser->go();
|
||||
|
||||
$screenshot = $browser->getScreenshot();
|
||||
$title = $browser->getTitle();
|
||||
$description = $browser->getDescription();
|
||||
|
||||
$ref = $bundle->attachments('images')->addToHistory('screenshot', [
|
||||
'contents' => $screenshot,
|
||||
'filename' => 'screenshot.jpg',
|
||||
]);
|
||||
|
||||
$bundle->metadata()->set([
|
||||
'title' => $title,
|
||||
'date' => $date->toIso8601String(),
|
||||
'cover' => $ref,
|
||||
]);
|
||||
|
||||
$bundle->markdown()->set('> ' . $description . "\n\n");
|
||||
|
||||
$bundle->save();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user