fix: added og headers, lots of cleanup.
This commit is contained in:
@@ -12,6 +12,7 @@ use Illuminate\Validation\Rules\File;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Intervention\Image\Facades\Image;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
@@ -28,11 +29,13 @@ class ArtworkController extends Controller
|
||||
{
|
||||
$user = auth()->user();
|
||||
$artworks = Artwork::whereNotNull('approved_by')
|
||||
->join('episodes', 'artworks.episode_id', '=', 'episodes.id')
|
||||
->select('artworks.*', DB::raw('episodes.episode_number episode_number'))
|
||||
->with('artist')
|
||||
->with('podcast')
|
||||
->with('episode')
|
||||
->orderBy('episode_id', 'desc')
|
||||
->orderBy('created_at', 'desc')
|
||||
->orderBy('episode_number', 'desc')
|
||||
->orderBy('artworks.created_at', 'desc')
|
||||
->paginate($perPage = 52, $columns = ['*'], $pageName = 'artworks');
|
||||
$podcasts = Cache::remember('publishedPodcasts', 30, function() {
|
||||
return Podcast::where('published', true)->get();
|
||||
@@ -107,6 +110,8 @@ class ArtworkController extends Controller
|
||||
'podcast_id' => $podcast->id,
|
||||
'episode_id' => $episode->id,
|
||||
'filename' => $filename,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
])->create();
|
||||
$img = Image::make($rawFile)->resize(3000, null, function($constraint){
|
||||
$constraint->aspectRatio();
|
||||
@@ -138,6 +143,12 @@ class ArtworkController extends Controller
|
||||
->with('episode')
|
||||
->with('artist')
|
||||
->first();
|
||||
if (is_null($artwork->approved_by) && $user && $user->id != $artwork->id) {
|
||||
return redirect('artworks');
|
||||
}
|
||||
if (is_null($artwork->approved_by) && !$user) {
|
||||
return redirect('artworks');
|
||||
}
|
||||
return view('artworks.artwork', [
|
||||
'artwork' => $artwork,
|
||||
'user' => $user,
|
||||
@@ -194,4 +205,26 @@ class ArtworkController extends Controller
|
||||
dd($request->path());
|
||||
//$artwork = Artwork::where('legacy_filename', '/assets/artwork/')
|
||||
}
|
||||
|
||||
public function downloadArchiveList(Request $request, $type = 'sd')
|
||||
{
|
||||
$artworks = Artwork::whereNotNull('approved_by')
|
||||
->orderBy('created_at', 'desc')
|
||||
->pluck('filename');
|
||||
$output = '';
|
||||
if ($type == 'sd') {
|
||||
foreach($artworks as $artwork) {
|
||||
$output .= '"https://static.noagendaartgenerator.com/thumbnails/' . $artwork . '"' . "\r\n";
|
||||
}
|
||||
} else {
|
||||
foreach($artworks as $artwork) {
|
||||
$output .= '"https://static.noagendaartgenerator.com/artworks/' . $artwork . '"' . "\r\n";
|
||||
}
|
||||
}
|
||||
return response($output, 200)
|
||||
->header('Content-type', 'text/plain')
|
||||
->header('Content-Length', strlen($output))
|
||||
->header('Content-Disposition', 'attachment; filename="naartgen-archivelist-' . $type . '.txt"');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user