Host images locally
We don’t need the complexity of S3. Sepcifically the complexity of managing my own AWS account, flysystem made the Laravel side easy. A command is added to copy the the S3 files over to local storage.
This commit is contained in:
parent
d80e8164c8
commit
d7da42b626
47 changed files with 295 additions and 214 deletions
|
@ -58,10 +58,10 @@ class Article extends Model
|
|||
{
|
||||
return Attribute::get(
|
||||
get: function () {
|
||||
$environment = new Environment();
|
||||
$environment->addExtension(new CommonMarkCoreExtension());
|
||||
$environment->addRenderer(FencedCode::class, new FencedCodeRenderer());
|
||||
$environment->addRenderer(IndentedCode::class, new IndentedCodeRenderer());
|
||||
$environment = new Environment;
|
||||
$environment->addExtension(new CommonMarkCoreExtension);
|
||||
$environment->addRenderer(FencedCode::class, new FencedCodeRenderer);
|
||||
$environment->addRenderer(IndentedCode::class, new IndentedCodeRenderer);
|
||||
$markdownConverter = new MarkdownConverter($environment);
|
||||
|
||||
return $markdownConverter->convert($this->main)->getContent();
|
||||
|
|
|
@ -33,7 +33,7 @@ class Media extends Model
|
|||
return $attributes['path'];
|
||||
}
|
||||
|
||||
return config('filesystems.disks.s3.url') . '/' . $attributes['path'];
|
||||
return config('app.url') . '/storage/' . $attributes['path'];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class Media extends Model
|
|||
$basename = $this->getBasename($path);
|
||||
$extension = $this->getExtension($path);
|
||||
|
||||
return config('filesystems.disks.s3.url') . '/' . $basename . '-' . $size . '.' . $extension;
|
||||
return config('app.url') . '/storage/' . $basename . '-' . $size . '.' . $extension;
|
||||
}
|
||||
|
||||
private function getBasename(string $path): string
|
||||
|
|
|
@ -271,7 +271,7 @@ class Note extends Model
|
|||
]);
|
||||
|
||||
if ($oEmbed->httpstatus >= 400) {
|
||||
throw new Exception();
|
||||
throw new Exception;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return null;
|
||||
|
@ -388,18 +388,18 @@ class Note extends Model
|
|||
'mentions_handle' => [
|
||||
'prefix' => '@',
|
||||
'pattern' => '([\w@.])+(\b)',
|
||||
'generator' => new MentionGenerator(),
|
||||
'generator' => new MentionGenerator,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$environment = new Environment($config);
|
||||
$environment->addExtension(new CommonMarkCoreExtension());
|
||||
$environment->addExtension(new AutolinkExtension());
|
||||
$environment->addExtension(new MentionExtension());
|
||||
$environment->addRenderer(Mention::class, new MentionRenderer());
|
||||
$environment->addRenderer(FencedCode::class, new FencedCodeRenderer());
|
||||
$environment->addRenderer(IndentedCode::class, new IndentedCodeRenderer());
|
||||
$environment->addExtension(new CommonMarkCoreExtension);
|
||||
$environment->addExtension(new AutolinkExtension);
|
||||
$environment->addExtension(new MentionExtension);
|
||||
$environment->addRenderer(Mention::class, new MentionRenderer);
|
||||
$environment->addRenderer(FencedCode::class, new FencedCodeRenderer);
|
||||
$environment->addRenderer(IndentedCode::class, new IndentedCodeRenderer);
|
||||
$markdownConverter = new MarkdownConverter($environment);
|
||||
|
||||
return $markdownConverter->convert($note)->getContent();
|
||||
|
|
|
@ -42,7 +42,7 @@ class WebMention extends Model
|
|||
return null;
|
||||
}
|
||||
|
||||
$authorship = new Authorship();
|
||||
$authorship = new Authorship;
|
||||
$hCard = $authorship->findAuthor(json_decode($attributes['mf2'], true));
|
||||
|
||||
if ($hCard === false) {
|
||||
|
@ -140,7 +140,7 @@ class WebMention extends Model
|
|||
return $profile_image;
|
||||
}
|
||||
|
||||
$filesystem = new Filesystem();
|
||||
$filesystem = new Filesystem;
|
||||
if ($filesystem->exists(public_path() . '/assets/profile-images/' . $host . '/image')) {
|
||||
return '/assets/profile-images/' . $host . '/image';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue