Compare commits

4 Commits

Author SHA1 Message Date
x
0ddb0dae53 adding actual useful feature 2024-06-10 00:27:00 +02:00
7040a9851d QoL fix for videotitle height, thanks to duke 2024-05-14 00:23:32 +02:00
a525c12794 blah 2024-03-18 17:56:29 +01:00
c5a1a42923 ... 2024-03-17 16:30:27 +01:00
15 changed files with 380 additions and 55 deletions

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Http\Controllers;
use App\Models\Tag;
use App\Models\Video;
use Illuminate\Http\Request;
class TagController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\View\View
*/
public function index()
{
return view('tags', ['tags' => 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.
}

View File

@@ -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.');
}

View File

@@ -0,0 +1,118 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\Tag;
class DebugController extends Controller
{
public function getRandomVideoForCategory(Category $category)
{
$randomVideo = \App\Models\Video::getRandom($category);
// Now you can return or use $randomVideo as needed
}
public function getRandomVideoForTag(Tag $tag)
{
$randomVideo = \App\Models\Video::getRandom($tag);
// Now you can return or use $randomVideo as needed
}
public function getSingleRandomVideoForCategory(Category $category)
{
$singleRandomVideo = \App\Models\Video::getSingleRandom($category);
// Now you can return or use $singleRandomVideo as needed
}
public function getSingleRandomVideoForTag(Tag $tag)
{
$singleRandomVideo = \App\Models\Video::getSingleRandom($tag);
// Now you can return or use $singleRandomVideo as needed
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* 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)
{
//
}
}

View File

@@ -0,0 +1,125 @@
<?php
namespace App\Http\Controllers;
use App\Models\Category;
use App\Models\Video;
use App\Models\Banner;
use Illuminate\Http\Request;
use Illuminate\Database\Eloquent\Relations\HasMany;
use App\Http\Requests;
use Cviebrock\EloquentTaggable\Services\TagService;
class TagviewController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index($tag)
{
$tag = $video = Video::with('tags')->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 showVideo($shortname, $id = null)
{
// return $shortname;
if (is_null($id)) {
$video = Video::getRandom($shortname, true);
if ($video instanceof HasMany) {
$video = $video->first();
}
else {
return redirect()->back()->with('error', 'tag is empty.');
}
return redirect('/t/' . $shortname . '/' . $video->id);
} else {
// Don't filter on specific video.
// TODO: Add warning page
$video = Video::withAnyTags($shortname)->find($id);
}
if (is_null($video)) {
return redirect()->back()->with('error', 'tag is empty.');
}
$sfw = $video->tags->contains(function($key, $tag) {
return $tag->normalized === 'sfw';
});
return view('video', [
'video' => $video,
'related' => $shortname,
'isTag' => true,
'sfw' => $sfw,
'banner' => Banner::getRandom($video->isSfw())]);
}
/**
* 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)
{
//
}
}

View File

@@ -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@showVideo')->where('tag', '[a-z][a-z0-9]+');
Route::get('t/{tag}/{id}', 'TagviewController@showVideo')->where(['tag' => '[a-z][a-z0-9]+', 'id' => '[0-9]+']);
});

View File

@@ -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
{

View File

@@ -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);
}
@@ -67,31 +71,43 @@ class Video extends Model
return $this->belongsToMany(User::class, 'favorites', 'video_id', 'user_id');
}
public static function getFirstId($related = null) {
public static function getFirstId($related = null, $isTag = false) {
if ($related) {
return $related->videos()->filtered()->orderBy('id', 'ASC')->first()->id;
if (!$isTag) {
return $related->videos()->filtered()->orderBy('id', 'ASC')->first()->id;
}
return Video::withAnyTags($related)->filtered()->orderBy('id', 'ASC')->first()->id;
}
return static::filtered()->orderBy('id', 'ASC')->first()->id;
}
public static function getLastId($related = null) {
public static function getLastId($related = null, $isTag = false) {
if ($related) {
return $related->videos()->filtered()->orderBy('id', 'DESC')->first()->id;
if (!$isTag) {
return $related->videos()->filtered()->orderBy('id', 'DESC')->first()->id;
}
return Video::withAnyTags($related)->filtered()->orderBy('id', 'DESC')->first()->id;
}
return static::select('id')->filtered()->orderBy('id', 'DESC')->first()->id;
}
public function getNext($related = null) {
public function getNext($related = null, $isTag = false) {
if ($related) {
return $related->videos()->filtered()->where('id', '>', $this->id)->orderBy('id', 'ASC')->first();
if (!$isTag) {
return $related->videos()->filtered()->where('id', '>', $this->id)->orderBy('id', 'ASC')->first();
}
return Video::withAnyTags($related)->filtered()->where('id', '>', $this->id)->orderBy('id', 'ASC')->first();
} else {
return static::filtered()->where('id', '>', $this->id)->orderBy('id', 'ASC')->first();
}
}
public function getPrev($related = null) {
public function getPrev($related = null, $isTag = false) {
if ($related) {
return $related->videos()->filtered()->where('id', '<', $this->id)->orderBy('id', 'DESC')->first();
if (!$isTag) {
return $related->videos()->filtered()->where('id', '<', $this->id)->orderBy('id', 'DESC')->first();
}
return Video::withAnyTags($related)->filtered()->where('id', '<', $this->id)->orderBy('id', 'DESC')->first();
} else {
return static::filtered()->where('id', '<', $this->id)->orderBy('id', 'DESC')->first();
}
@@ -220,14 +236,24 @@ public function blurryThumb() {
}
}
public static function getRandom($related = null) {
public static function getRandom($related = null, $tag = false) {
if ($related) {
$id = $related->videos()->filtered()->countScoped()->count() - 1;
if (!$tag) {
$id = $related->videos()->filtered()->countScoped()->count() - 1;
if ($id < 0) {
return redirect()->back()->with('error', 'no videos found');
}
$id = mt_rand(0, $id);
return $related->videos()->filtered()->skip($id);
}
// jetzt sind wir im tag
$id = Video::withAnyTags($related)->filtered()->countScoped()->count()-1;
if ($id < 0) {
return redirect()->back()->with('error', 'no videos found');
}
$id = mt_rand(0, $id);
return $related->videos()->filtered()->skip($id);
$id = mt_rand(0,$id);
return Video::withAnyTags($related)->filtered()->skip($id);
}
$id = static::filtered()->countScoped()->count() - 1;
if ($id < 0) {
@@ -237,13 +263,25 @@ 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);
}
}

View File

@@ -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) {

View File

@@ -20,9 +20,8 @@
}
</style>
<h5>Oh shit! Something went wrong!</h5>
<h5>If you can see this message something with the software went wrong.</h5>
<div id="sf-resetcontent" class="sf-reset box">
<h6>Please don't send this fucking text to an admin, we have other problems.</h6>
<?php
$iv = openssl_random_pseudo_bytes(16);
?>

View File

@@ -2,8 +2,6 @@
<html>
<head>
<title>Please Stand By we are just fucking this up</title>
<link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">
<style>
html, body {
height: 100%;

View File

@@ -4,8 +4,7 @@
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="theme-color" content="#161618">
<meta name="viewport"
content="width=device-width,initial-scale=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta charset="UTF-8">
<meta name="_token" content="{{csrf_token()}}">
<meta name="keywords" content="Random WebMs, WebMs, Internet Videos">

View File

@@ -19,6 +19,7 @@
<p>Also make sure to check out his uploads <a href="https://w0bm.com/main?q=marderchen">https://w0bm.com/main?q=marderchen</a> and enjoy it.</p>
<p><i>- w0bm staff</i></p>
<p style="float: right;">21.6.2023</p>
</div>
@endsection

View File

@@ -0,0 +1,5 @@
<div style="position: relative;">
<?php
echo $category;
?>
</div>

View File

@@ -0,0 +1,8 @@
<a href="/t/{{$tag}}">rand</a>
<br>
leon du huan
<br>
<video controls src="/b/{{ $video[0]['file'] }}"></video>
<br>

View File

@@ -1,3 +1,6 @@
<div style="background:black;color:green;">
{{$video}}
</div>
@extends('layout')
@section('content')
@@ -6,7 +9,7 @@
<div class="vertical-align">
<div class="wrapper">
<div class="videotitle-div">
<h5 style="height: 22px;">
<h5 style="min-height: 22px;">
@if($video->videotitle)
{{$video->videotitle}}
@else
@@ -38,20 +41,20 @@
?>
<div class="text-center" style="position: unset;">
@if($related)
@if(($prev = $video->getPrev($related)) === null)
@if(($prev = $video->getPrev($related,$isTag)) === null)
<a class="first" href="#" style="visibility: hidden;">← first</a>
<a id="prev" href="#" style="visibility: hidden;">← prev</a> |
@else
<a class="first" href="{{url($related->baseurl(), $video->getFirstId($related))}}">← first</a>
<a id="prev" href="{{url($related->baseurl(), [$prev->id])}}">← prev</a> |
<a class="first" href="{{url($isTag ? '/t/' . $related : $related->baseurl(), $video->getFirstId($related,$isTag))}}">← first</a>
<a id="prev" href="{{url($isTag ? '/t/' . $related : $related->baseurl(), [$prev->id])}}">← prev</a> |
@endif
<a href="{{url($related->baseurl())}}">{!!$related->displayName()!!}</a>
@if(($next = $video->getNext($related)) === null)
<a href="{{url($isTag ? '/t/' . $related : $related->baseurl())}}">{!!$isTag ? $related:$related->displayName()!!}</a>
@if(($next = $video->getNext($related,$isTag)) === null)
| <a id="next" href="#" style="visibility: hidden;">next →</a>
<a class="last" href="#" style="visibility: hidden;">last →</a>
@else
| <a id="next" href="{{url($related->baseurl(), [$next->id])}}">next →</a>
<a class="last" href="{{url($related->baseurl(), $video->getLastId($related))}}">last →</a>
| <a id="next" href="{{url($isTag ? '/t/' . $related : $related->baseurl(), [$next->id])}}">next →</a>
<a class="last" href="{{url($isTag ? '/t/' . $related : $related->baseurl(), $video->getLastId($related,$isTag))}}">last →</a>
@endif
@else
@if(($prev = $video->getPrev()) === null)
@@ -135,6 +138,7 @@
</aside>
@else
{{{-- Wenn man nicht eingeloggt ist könnte man folgendes sehen, bzw machen --}}}
<div class="centered">
<div class="modal-content col-md-5">
<div class="modal-header">