From c5a1a4292331f2152b6826b297c8a5303f62cce2 Mon Sep 17 00:00:00 2001 From: schrumpel Date: Sun, 17 Mar 2024 16:30:27 +0100 Subject: [PATCH] ... --- .Trash-1000/files/TagController.php | 43 ++++ app/Http/Controllers/CategoryController.php | 4 +- app/Http/Controllers/DebugController.php | 118 +++++++++ app/Http/Controllers/TagviewController.php | 230 ++++++++++++++++++ app/Http/routes.php | 8 +- app/Models/Rulez.php | 20 -- app/Models/Video.php | 15 ++ public/css/w0bmcustom.css | 13 +- resources/views/layout1/errors/500.blade.php | 3 +- resources/views/layout1/errors/503.blade.php | 2 - resources/views/layout1/layout.blade.php | 3 +- resources/views/layout1/marder.blade.php | 1 + .../views/layout1/partials/devtools.blade.php | 5 + resources/views/layout1/tagviewdev.blade.php | 1 + resources/views/layout1/video.blade.php | 4 + 15 files changed, 435 insertions(+), 35 deletions(-) create mode 100644 .Trash-1000/files/TagController.php create mode 100644 app/Http/Controllers/DebugController.php create mode 100644 app/Http/Controllers/TagviewController.php create mode 100644 resources/views/layout1/partials/devtools.blade.php create mode 100644 resources/views/layout1/tagviewdev.blade.php diff --git a/.Trash-1000/files/TagController.php b/.Trash-1000/files/TagController.php new file mode 100644 index 0000000..65a4d9d --- /dev/null +++ b/.Trash-1000/files/TagController.php @@ -0,0 +1,43 @@ + Tag::all()]); + } + + + + /** + * Display the specified resource. + * + * @param string $normalized + * @param int|null $id + * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View + */ + public function showVideo($tagName) + { + // Retrieve the tag based on the provided tag name + $tag = Tag::where('name', $tagName)->firstOrFail(); + + // Get a random video related to the tag + $randomVideo = \App\Models\Video::getSingleRandom($tag); + + // Pass the tag and the random video to your view + return view('tag.show')->with(compact('tag', 'randomVideo')); + } + + // Define other CRUD operations for tags as needed. +} \ No newline at end of file diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index fef24c2..76a9279 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -42,7 +42,6 @@ class CategoryController extends Controller { // } - /** * Display the specified resource. * @@ -52,10 +51,12 @@ class CategoryController extends Controller */ public function showVideo($shortname, $id = null) { + // return $shortname; $category = Category::whereShortname($shortname)->first(); if (is_null($category)) { return redirect()->back()->with('error', 'Category not found'); } + if (is_null($id)) { $video = Video::getRandom($category); if ($video instanceof HasMany) { @@ -70,6 +71,7 @@ class CategoryController extends Controller // TODO: Add warning page $video = $category->videos()->find($id); } + if (is_null($video)) { return redirect()->back()->with('error', 'Category is empty.'); } diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php new file mode 100644 index 0000000..0a8fdd6 --- /dev/null +++ b/app/Http/Controllers/DebugController.php @@ -0,0 +1,118 @@ +find($tag->id); + return $tag; + // $tag = Video::withAnyTags($tag)->first(); + // return $tag; + // $video = Video::with('tags')->find($tag->id); + // return redirect('t/' . $tag->normalized . '/' . $video->id); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + // + } + + public function tagview($tag, $id = null) + { + + if (is_null($tag)) { + return "penis"; + } + // return $tag; + // $tag = + $video = Video::getRandom($tag); + return $video; + + + //$video = Video::with('tags')->find($tag->id); + if(!$id) { + // id unset + return redirect('t/' . $tag . '/' . $video->id); + } else { + + return view('tagviewdev',[ + 'video' => $video, + 'related' => $video + ]); + } + } + + // public function tagview($tag, $id = null) + // { + // $x = Video::withAllTags($tag)->first(); + + // // return $x; + // // id 1 + // // file "1.webm" + // // videotitle "su" + // // interpret null + // // songtitle null + // // imgsource null + // // category_id 8 + // // user_id 1 + // // created_at "2024-02-22 00:31:49" + // // updated_at "2024-02-22 00:31:49" + // // deleted_at null + // // hash "3cdd7e0aa1a1cf175e06f22da2f485091f3b9f22" + // // tag_id 2 + // // taggable_id 1 + // // taggable_type "App\\Models\\Video" + // // name "misc" + // // normalized "misc" + + // if(!$id) { + // // gibs keine... + // $z = Video::getAllTags(); + // return $z; + // } else { + // $y = $x->id; + // return $y; + // } + // } + + // public function tagview($tag, $id = null) + // { + // // $tag_in = Video::withAnyTags($tag)->first(); + // // return $tag_in; + // $video = Video::getRandom($tag->id); + // if ($video instanceof HasMany) { + // $video = $video->first(); + // } + // // $video = Video::getRandom($tag->id); + + // if (is_null($id)) { + // $video = Video::getRandom($tag); + // } else { + + // } + // } + + // public function helloworld($tag, $id = null) + // { + // if(!$tag) { + // return redirect()->back()->with('error', 'Tag not found'); + // } + + // if (is_null($id)) { + // $tag = Video::withAnyTags($tag)->first(); + // return redirect('t/' . $tag->normalized . '/' . $tag->id); + // } else { + // $tag = Video::withAnyTags($tag)->first(); + // $video = Video::with('tags')->find($tag->id); + + // return view('tagviewdev', [ + // 'id' => $tag->id, + // 'video' => $video, + // 'tag' => $tag->name, + // 'related' => $video->name, + // 'banner' => 'banner' + // ]); + // } + + // if(!$id) { + // // is not null + // // implement redirect to t/$tag/$id + // } else { + // $tag = Video::withAnyTags($tag)->first(); + // // reverse lookup of $video thanks to the api for tag + // $video = Video::with('tags')->find($tag->id); + + // $tags = $video->tags; + + // return view('tagviewdev', [ + // 'video' => $video, + // 'tags' => $tags, + // 'related' => $tag->name + // ]); + // //return redirect('t/' . $tag . '/' . ); + // } + + // $blub = $tag->id; + // return $blub; + + // if (is_null($id)) { + + // $video = Video::getRandom($tag); + // if ($video instanceof HasMany) { + // $video = $video->first(); + // } + // else { + // return redirect()->back()->with('error', '404'); + // } + // return redirect('t/' . $tag . '/' . $video->id); + // } else { + // // Don't filter on specific video. + // // TODO: Add warning page + // // $video = $tag->videos()->find($id); + // } + + // //return $tag; + // return view('tagviewdev', [ + // 'tag' => $tag, + // 'related' => $tag, + // ]); + + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + /** + * Display the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function show($id) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + // + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + // + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + // + } +} diff --git a/app/Http/routes.php b/app/Http/routes.php index 74a558d..1c20339 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -141,7 +141,7 @@ Route::group(["middleware" => "theme"], function() { #Route::get('rulez', 'rulezController@index')->middleware('auth'); Route::get('todo', function() { return view('todo'); })->middleware('auth'); Route::get('contact', function() { return view('contact'); }); - Route::get('change', function() { return view('change'); }); + //Route::get('change', function() { return view('change'); }); #Route::get('terms', function() { return view('tos'); })->middleware('auth'); Route::get('privacy', function() { return view('privacy'); }); Route::get('marderchen', function() { return view('marder'); }); @@ -154,6 +154,7 @@ Route::group(["middleware" => "theme"], function() { //'fav_count' => \App\Models\UserFavorite::count(), 'latest_video' => \App\Models\Video::getLastId(), 'newest_user' => \App\Models\User::orderBy('id', 'DESC')->first()->username, + // this function heavily slows down the page load on /stats in prod. should be addressed some day 'dirsize' => shell_exec("(du -sh " . public_path() . "/b | cut -f1)") ]); })->middleware('auth'); @@ -185,4 +186,9 @@ Route::group(["middleware" => "theme"], function() { ##Category View Route::get('{shortname}', 'CategoryController@showVideo')->where('shortname', '[a-z][a-z0-9]+'); Route::get('{shortname}/{id}', 'CategoryController@showVideo')->where(['shortname' => '[a-z][a-z0-9]+', 'id' => '[0-9]+']); + + ##Tag View anybody? + Route::get('t/{tag}', 'TagviewController@tagview')->where('tag', '[a-z][a-z0-9]+'); + Route::get('t/{tag}/{id}', 'TagviewController@tagview')->where(['tag' => '[a-z][a-z0-9]+', 'id' => '[0-9]+']); + }); diff --git a/app/Models/Rulez.php b/app/Models/Rulez.php index 063a1e1..f0fb358 100644 --- a/app/Models/Rulez.php +++ b/app/Models/Rulez.php @@ -4,26 +4,6 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -/** - * App\Models\Category - * - * @property integer $id - * @property string $name - * @property string $shortname - * @property string $description - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at - * @property string $deleted_at - * @property-read \Illuminate\Database\Eloquent\Collection|Video[] $videos - * @method static \Illuminate\Database\Query\Builder|\App\Models\Category whereId($value) - * @method static \Illuminate\Database\Query\Builder|\App\Models\Category whereName($value) - * @method static \Illuminate\Database\Query\Builder|\App\Models\Category whereShortname($value) - * @method static \Illuminate\Database\Query\Builder|\App\Models\Category whereDescription($value) - * @method static \Illuminate\Database\Query\Builder|\App\Models\Category whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\App\Models\Category whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\App\Models\Category whereDeletedAt($value) - * @property-read \Illuminate\Database\Eloquent\Collection|User[] $users - */ class Rulez extends Model { diff --git a/app/Models/Video.php b/app/Models/Video.php index 5f903e5..ba46f9e 100644 --- a/app/Models/Video.php +++ b/app/Models/Video.php @@ -51,6 +51,10 @@ class Video extends Model use SoftDeletes; use \Cviebrock\EloquentTaggable\Taggable; + public static function getTags() { + return $tag_list; + } + public function user() { return $this->belongsTo(User::class); } @@ -237,13 +241,24 @@ public function blurryThumb() { return static::filtered()->skip($id); } + public static function getSingleRandom($related = null) { + $query = $related ? $related->videos()->filtered() : static::filtered(); + $count = $query->countScoped()->count(); + if ($count < 1) { + return null; // Return null if no videos found + } + return $query->inRandomOrder()->first(); + } + public function isSfw() { return !$this->tags->contains(function ($key, $tag) { return $tag->normalized === 'nsfw'; }); } + public function filesize() { return filesize(getcwd() . "/b/" . $this->file); } } + diff --git a/public/css/w0bmcustom.css b/public/css/w0bmcustom.css index 7e50ed3..dfa2bed 100644 --- a/public/css/w0bmcustom.css +++ b/public/css/w0bmcustom.css @@ -1505,7 +1505,7 @@ div#tag-add { } /* Sidebar Mobile */ - +/* @media (max-width: 767px) { #sidebar { top: 40em; @@ -1563,15 +1563,14 @@ div#tag-add { } @media (max-width: 367px) { #sidebar { - /*top: 24.6em;*/ top: 27em; } -} -@media (max-width: 360px) { +}*/ +/*@media (max-width: 360px) { #sidebar { top: 26.6em; } -} +} */ /* Sidebar Mobile Queries END */ /* TAGS MOBILE FIXED */ @@ -2278,7 +2277,7 @@ input.form-control { } /* Handy fix */ -@media (max-width: 690px) { +/* @media (max-width: 690px) { .text-center { font-size: 19px; display: flex; @@ -2304,7 +2303,7 @@ input.form-control { margin-bottom: 5px; color: #eaedec; } -} +} */ @media (max-width: 690px) { diff --git a/resources/views/layout1/errors/500.blade.php b/resources/views/layout1/errors/500.blade.php index fc5e5cd..7bdce49 100644 --- a/resources/views/layout1/errors/500.blade.php +++ b/resources/views/layout1/errors/500.blade.php @@ -20,9 +20,8 @@ } -
Oh shit! Something went wrong!
+
If you can see this message something with the software went wrong.
-
Please don't send this fucking text to an admin, we have other problems.
diff --git a/resources/views/layout1/errors/503.blade.php b/resources/views/layout1/errors/503.blade.php index 4f63d68..8d1bf8c 100644 --- a/resources/views/layout1/errors/503.blade.php +++ b/resources/views/layout1/errors/503.blade.php @@ -2,8 +2,6 @@ Please Stand By we are just fucking this up - -