A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
move directory controller functions around but ajax not gone yet
aminnausinb88202ee4672
diff --git a/app/Http/Controllers/Api/V1/AuthController.php b/app/Http/Controllers/Api/V1/AuthController.phpindex 13ddecca..19ee47a2 100644--- a/app/Http/Controllers/Api/V1/AuthController.php+++ b/app/Http/Controllers/Api/V1/AuthController.php@@ -51,7 +51,7 @@ class AuthController extends Controllerif (! $request->expectsJson()) {$request->session()->regenerate();- return redirect()->route('testing');+ return redirect()->route('home');}}diff --git a/app/Http/Controllers/Api/V1/FolderController.php b/app/Http/Controllers/Api/V1/FolderController.phpnew file mode 100644index 00000000..981bbae6--- /dev/null+++ b/app/Http/Controllers/Api/V1/FolderController.php@@ -0,0 +1,35 @@+<?php++namespace App\Http\Controllers\Api\V1;++use App\Http\Controllers\Controller;+use App\Http\Requests\FolderCollectionRequest;+use App\Http\Resources\FolderResource;+use App\Models\Folder;+use App\Traits\HttpResponses;+use Illuminate\Http\Request;++class FolderController extends Controller+{+ use HttpResponses;++ /**+ * Display a listing of the resource.+ */+ public function getFrom(FolderCollectionRequest $request)+ {+ $request->validated($request->all());++ try {+ return $this->success(+ Folder::where('category_id', $request->category_id)->first()+ //FolderResource::collection(+ // Folder::withCount(['videos'])->having('category_id', '=', $request->category_id)->get()+ //Folder::where('category_id', $request->category_id)->withCount(['videos'])->get()+ //)+ );+ } catch (\Throwable $th) {+ return $this->error(null, 'Unable to get folders. Error: ' . $th->getMessage(), 500);+ }+ }+}diff --git a/app/Http/Controllers/Api/V1/VideoController.php b/app/Http/Controllers/Api/V1/VideoController.phpnew file mode 100644index 00000000..76d3259a--- /dev/null+++ b/app/Http/Controllers/Api/V1/VideoController.php@@ -0,0 +1,46 @@+<?php++namespace App\Http\Controllers\Api\V1;++use App\Http\Controllers\Controller;+use App\Http\Requests\FolderCollectionRequest;+use App\Http\Requests\VideoCollectionRequest;+use App\Http\Resources\VideoResource;+use App\Models\Folder;+use App\Models\Video;+use App\Traits\HttpResponses;+use Illuminate\Http\Request;++class VideoController extends Controller+{+ use HttpResponses;++ /**+ * Display a listing of the resource.+ */+ public function update(FolderCollectionRequest $request)+ {+ try {+ return $this->success(+ VideoResource::collection(+ Video::where('folder_id', $request->folder_id)->get()+ ),$request->folder_id+ );+ } catch (\Throwable $th) {+ return $this->error(null, 'Unable to get videos. Error: ' . $th->getMessage(), 500);+ }+ }++ // /**+ // * Display the specified resource.+ // *+ // * @param int $video_id+ // * @return \Illuminate\Http\Response+ // */+ // public function getOne(Video $video)+ // {+ // return RecordResource::collection(+ // Record::where('user_id', Auth::user()->id)->where('video_id', $video->id)->get()+ // );+ // }+}diff --git a/app/Http/Controllers/DirectoryController.php b/app/Http/Controllers/DirectoryController.phpindex 11e4ecd9..0653a0f1 100644--- a/app/Http/Controllers/DirectoryController.php+++ b/app/Http/Controllers/DirectoryController.php@@ -2,6 +2,8 @@namespace App\Http\Controllers;+use App\Http\Requests\VideoCollectionRequest;+use App\Jobs\IndexFiles;use App\Models\Category;use App\Models\Folder;use App\Models\Video;@@ -18,12 +20,6 @@ class DirectoryController extends Controllerreturn view('home', $data);}- public function showDirectoryTest($dir,$folder_name = null) {- $data['dir'] = $dir;- $data['folder_name'] = $folder_name;- return view('testing', $data);- }-public function getDirectory(Request $request){try {$default = 'tv';@@ -56,7 +52,7 @@ class DirectoryController extends Controller}}- public function getFolderContents(Request $request){+ public function getFolderContents(VideoCollectionRequest $request){try {$folder_id = isset($request->folder_id) ? $request->folder_id : throw new ErrorException("No folder id or invalid folder name provided. Cannot generate videos.");@@ -68,401 +64,51 @@ class DirectoryController extends Controller}}- public function generateDirectory(Request $request) {- $dir = $request->dir;- $mediaRoot = '/media/';- $publicRoot = '/storage';- $default = 'tv';- $path = isset($dir) ? $mediaRoot . $dir : $mediaRoot . $default ;-- if(!Storage::exists('public/' . $path)){- $error = 'Invalid Directory: "' . $path . '"';-- return json_encode(array("success"=>false, "result"=>"", "error"=>$error), JSON_UNESCAPED_SLASHES);- }--- $allDirectories = Storage::directories('public' . $path);-- $folders = array();- $currentFolder = array("name"=>"", "files"=>array());--- foreach ($allDirectories as $directory) {- if (basename($directory) != '.thumbs') {- $currentFolder['name'] = basename($directory);- $files = File::allFiles(storage_path('app') . '/' . $directory);-- foreach($files as $file){- if ($file->getExtension() == 'mp4' || $file->getExtension() == 'mkv' ) {- $fileData = array('name'=> $publicRoot . $path . '/' . basename($directory) . '/' . basename($file), 'title'=>basename($file), 'date' => filectime($file), 'formattedDate' => date("Y-m-d g:i A", filectime($file)));- $rawFile = array('name'=> $publicRoot . $path . '/' . basename($directory) . '/' . basename($file), 'title'=>basename($file), 'date' => filectime($file), 'formattedDate' => date("Y-m-d g:i A", filectime($file)));- array_push($currentFolder['files'], $fileData);- }- }- }- array_push($folders, $currentFolder);- $currentFolder['files'] = array();- }-- return json_encode(array("success"=>true, "result"=>$folders, "error"=>""), JSON_UNESCAPED_SLASHES);- }-- public function generateData() {- $path = "public\media\\";-- if(!Storage::exists($path)){- $error = 'Invalid Directory: "media"';-- dd(json_encode(array("success"=>false, "result"=>"", "error"=>$error), JSON_UNESCAPED_SLASHES));- }-- $realPath = Storage::path($path);-- $directories = $this->generateCategories($realPath);- $subDirectories = $this->generateFolders($path, $directories["data"]["categoryStructure"]);- $files = $this->generateVideos($path, $subDirectories["data"]["folderStructure"], $directories["data"]["categoryStructure"]);-- if(isset($files["updatedFolderStructure"])) $subDirectories["data"]["folderStructure"] = $files["updatedFolderStructure"];-- $categories = $directories["categoryChanges"];- $folders = $subDirectories["folderChanges"];- $videos = $files["videoChanges"];-- #region- // $shows = array();- // $show = array("id"=>null,"name"=>"", "path"=>"", "category_id"=>"");- // $videos = array();- // $video = array("id"=>null,"name"=>"","path"=>"","category_id"=>"","show_id"=>null,"file_id"=>null,"episode_id"=>null);-- // //Raw file data connected to video (when folder is not a show)- // $rawFiles = array();- // $rawFile = array("name"=> "", "path"=>"", "date" => "", "formattedDate" => null);-- // //Episodic data connected to video (when folder is a show)- // $episodes = array();- // $episode = array("id"=>null, "episode_no"=>null, "season_no"=>null, "episode_synopsis"=>"lorem ipsum");- #endregion-- $dbOut = "";- $categoryTransactions = array();- $folderTransactions = array();- $videoTransactions = array();-- foreach ($categories as $categoryChange){ // for each in stored, remove from new (delete)- $changeID = $categoryChange['id'];- $changeName = $categoryChange["name"];- $changeMediaContent = $categoryChange["media_content"] ?? 'False';- $changeAction = $categoryChange["action"];-- if($changeAction === "INSERT"){- $dbOut .= "INSERT INTO [Categories] VALUES ($changeID, $changeName, $changeMediaContent );\n"; // insert-- $transaction = $categoryChange;- unset($transaction["action"]);- array_push($categoryTransactions, $transaction);- // Category::create(- // ["name"=>$changeName, "media_content" => $changeMediaContent]- // );- }- else{- $dbOut .= "DELETE FROM [Categories] WHERE [Categories].[ID] = $changeID;\n";- Category::where('id', $changeID)->delete();- }- }-- foreach ($folders as $folderChange){ // for each in stored, remove from new (delete)- $changeID = $folderChange['id'];- $changeName = $folderChange["name"];- $changePath = $folderChange["path"];- $changeCategoryID = $folderChange["category_id"];- $changeAction = $folderChange["action"];-- if($changeAction === "INSERT"){- $dbOut .= "INSERT INTO [Folders] VALUES ({$changeID}, {$changeName}, {$changePath}, {$changeCategoryID} );\n"; // insert-- $transaction = $folderChange;- unset($transaction["action"]);- array_push($folderTransactions, $transaction);-- //Folder::create(["name"=>$changeName, "path"=>$changePath,"category_id"=>$changeCategoryID]);- }- else{- $dbOut .= "DELETE FROM [Folders] WHERE [Folder].[ID] = {$changeID};";- Folder::where('id', $changeID)->delete();- }- }-- foreach ($videos as $videoChange){ // for each in stored, remove from new (delete)- $changeID = $videoChange['id'];- $changeName = $videoChange["name"];- $changePath = $videoChange["path"];- $changeFolderID = $videoChange["folder_id"];- $changeDate = $videoChange["date"];- $changeAction = $videoChange["action"];-- if($changeAction === "INSERT"){- $dbOut .= "INSERT INTO [Videos] VALUES ({$changeID}, {$changeName}, {$changePath}, {$changeFolderID}, {$changeDate} );\n"; // insert-- // $video = new Video();- // $video->name = "anime";- // $video->path = $changePath;- // $video->folder_id = $changeCategoryID;- // $video->date = $changeDate;-- // $video->save();-- $transaction = $videoChange;- unset($transaction["action"]);- array_push($videoTransactions, $transaction);-- //Video::create( ["name"=>$changeName, "path"=>$changePath,"folder_id"=>$changeCategoryID, "date"=>$changeDate] );- }- else{- $dbOut .= "DELETE FROM [Videos] WHERE [Categories].[ID] = {$changeID};\n";- Video::where('id', $changeID)->delete();- }- }-- Storage::disk('public')->put('categories.json', json_encode($directories["data"], JSON_UNESCAPED_SLASHES));- Storage::disk('public')->put('folders.json', json_encode($subDirectories["data"], JSON_UNESCAPED_SLASHES));- Storage::disk('public')->put('videos.json', json_encode($files["data"], JSON_UNESCAPED_SLASHES));-- Category::insert($categoryTransactions);- Folder::insert($folderTransactions);- Video::insert($videoTransactions);-- $data = array("categories"=>$categories,"folders"=>$folders,"videos"=>$videos);-- Storage::disk('public')->put('dataCache.json', json_encode($data, JSON_UNESCAPED_SLASHES));- dump($directories, $subDirectories, $files, $data, $dbOut);- }-- private function generateCategories($path){- $data = Storage::json('public\categories.json') ?? array("next_ID"=>1, "categoryStructure" => array()); //array("anime"=>1,"tv"=>2,"yogscast"=>3); // read from json- $scanned = array_map("htmlspecialchars", scandir($path)); // read folder structure-- $currentID = $data["next_ID"];- $stored = $data["categoryStructure"];- $changes = array(); // send to db- $current = array(); // save into json-- // foreach ($stored as $savedID){ // O(n) where n = number of already known categories- // $currentID = max($currentID, $savedID + 1); // gets max currently used id- // }-- /*- If scanned is in stored, add to current, remove from stored- If scanned not in stored, add to current, add to new (insert), id++-- after:-- for each in stored, remove from new (delete)-- send new to database-- save current to json- */- foreach ($scanned as $local){ // O(n) where n = number of already known categories- if(is_dir($local)) continue; //? . and .. are dirs-- $name = basename($local);-- if(isset($stored[$name])){ // If scanned is in stored, add to current, remove from stored- $current[$name] = $stored[$name]; // add to current- unset($stored[$name]); // remove from stored- }- else{ // If scanned not in stored, add to current, add to new (insert), id++- $generated = array("id"=>$currentID,"name"=>$name,"media_content"=>'False', "action"=>"INSERT");- $current[$name] = $currentID; // add to current- array_push($changes, $generated); // add to new (insert)- $currentID++;- }- }-- foreach ($stored as $remainingID){- $generated = array("id"=>$remainingID,"name"=>null,"media_content"=>null, "action"=>"DELETE"); // delete by id- array_push($changes, $generated); // add to new (delete)+ public function indexFiles(Request $request){+ try {+ IndexFiles::dispatch();+ } catch (\Throwable $th) {+ dump('Error cannot index files');}-- $data["next_ID"] = $currentID;- $data["categoryStructure"] = $current;-- return array("categoryChanges"=> $changes, "data" => $data);}-- private function generateFolders($path, $categoryStructure){- $data = Storage::json('public\folders.json') ?? array("next_ID"=>1,"folderStructure"=>array()); //array("anime/frieren"=>array("id"=>0,"name"=>"frieren"),"starwars/andor"=>array("id"=1,"name"="andor")); // read from json- $scannedCategories = array_keys($categoryStructure);- $cost = 0;+ // public function generateDirectory(Request $request) {+ // $dir = $request->dir;+ // $mediaRoot = '/media/';+ // $publicRoot = '/storage';+ // $default = 'tv';+ // $path = isset($dir) ? $mediaRoot . $dir : $mediaRoot . $default ;++ // if(!Storage::exists('public/' . $path)){+ // $error = 'Invalid Directory: "' . $path . '"';- $currentID = $data["next_ID"];- $stored = $data["folderStructure"];- $changes = array(); // send to db- $current = array(); // save into json into json-- // foreach ($stored as $savedFolder){ // O(n) where n = number of already known categories- // $currentID = max($currentID, $savedFolder["id"] + 1); // gets max currently used id- // $cost ++;- // }-- /*- Double Foreach loop-- o(M*N) where M = number of categories and N = number of files in each category- really becomes O(n) where n = number of files since N is not constant-- for each folder in each category- key = category/folder- if isset in stored- // old folder already seen-- add to current -> key, id, basename(folder)- remove from stored- continue- else- // new folder not seen before-- add to current -> key, id, basename(folder) ?- add to changes (insert)- id += 1;- */- foreach ($scannedCategories as $category) { // O(n) where n = number of folders * 2 (for scan)- $cost++;-- $folders = Storage::directories("$path\\$category"); // Immediate folders (dont scan sub folders)-- foreach ($folders as $folder){- $cost++;-- $name = basename($folder);- $key = "$category\\$name";+ // return json_encode(array("success"=>false, "result"=>"", "error"=>$error), JSON_UNESCAPED_SLASHES);+ // }- if($name === ".thumbs") continue;- if(isset($stored[$key])){- $current[$key] = $stored[$key]; // add to current- unset($stored[$key]); // remove from stored- }- else{- $generated = array("id"=>$currentID,"name"=>$name,"path"=>$key, "category_id"=>$categoryStructure[$category], "action"=>"INSERT");- $current[$key] = array("id"=>$currentID, "last_scan"=>-1); // add to current- array_push($changes, $generated); // add to new (insert)- $currentID++;- }- }- }--- foreach ($stored as $remainingID){- $generated = array("id"=>$remainingID,"name"=>null,"path"=>null, "category_id"=>null, "action"=>"DELETE"); // delete by id- array_push($changes, $generated); // add to new (delete)- $cost++;- }--- // if($current !== $storedCopy) {- // //Storage::disk('public')->put('folders.json', json_encode($current, JSON_UNESCAPED_SLASHES));- // }-- $data["next_ID"] = $currentID;- $data["folderStructure"] = $current;- return array("folderChanges"=> $changes, "data" => $data, "cost"=>$cost);- }-- private function generateVideos($path, $folderStructure){- $data = Storage::json('public\videos.json') ?? array("next_ID"=>1,"videoStructure"=>array()); //array("anime/frieren/S1E01.mp4"=>array("id"=>0,"name"=>"S1E01"),"starwars/andor/S1E01.mkv"=>array("id"=1,"name"="S1E01.mkv")); // read from json- $scannedFolders = array_keys($folderStructure);- $cost = 0;-- $currentID = $data["next_ID"];- $stored = $data["videoStructure"];- $changes = array(); // send to db- $current = array(); // save into json into json-- $foldersCopy = $folderStructure;- $unModefiedFolders = array();- $rawPath = Storage::path('');-- // foreach ($stored as $savedVideo){ // O(n) where n = number of already known categories- // $currentID = max($currentID, $savedVideo + 1); // gets max currently used id- // $cost ++;- // }+ // $allDirectories = Storage::directories('public' . $path);- /*- Double Foreach loop+ // $folders = array();+ // $currentFolder = array("name"=>"", "files"=>array());- o(M*N) where M = number of categories and N = number of files in each category- really becomes O(n) where n = number of files since N is not constant-- for each video in each category- folder = parent directory of video- key = category/folder/video- if isset in stored- // old video already seen- add to current -> key, id, basename(folder)- remove from stored- continue- else- // new folder not seen before+ // foreach ($allDirectories as $directory) {+ // if (basename($directory) != '.thumbs') {+ // $currentFolder['name'] = basename($directory);+ // $files = File::allFiles(storage_path('app') . '/' . $directory);- add to current -> key, id, basename(folder) ?- add to changes (insert)- id += 1;--- */- foreach ($scannedFolders as $folder) { // O(n) where n = number of folders * 2 (for scan)- $cost++;- $folderAccessTime = filemtime("{$rawPath}public\media\\$folder\\");-- if($folderAccessTime <= $folderStructure[$folder]["last_scan"]){- $unModefiedFolders[$folder] = 1;- continue;- }-- $files = Storage::files("$path$folder"); // Immediate folders (dont scan sub folders)- $foldersCopy[$folder]['last_scan'] = $folderAccessTime;-- foreach ($files as $file){- $cost++;- $ext = pathinfo($file, PATHINFO_EXTENSION);- if ($ext !== 'mp4' && $ext !== 'mkv' ) continue;-- $name = basename($file);- $cleanName = basename($file,".$ext");- $key = "$folder\\$name";- $rawFile = "$rawPath$file";-- if(isset($stored[$key])){- $current[$key] = $stored[$key]; // add to current- unset($stored[$key]); // remove from stored- }- else{- $generated = array("id"=>$currentID,"name"=>$cleanName,"path"=>"storage\\". basename($path) . "\\$key", "folder_id"=>$folderStructure[$folder]["id"], "date" => date("Y-m-d g:i A", filemtime($rawFile)), "action"=>"INSERT");- $current[$key] = $currentID; // add to current- array_push($changes, $generated); // add to new (insert)- $currentID++;- }- }- }-- foreach ($stored as $video => $remainingID){- if(isset($unModefiedFolders[dirname($video)])){- $current[$video] = $stored[$video];- continue;- }- $generated = array("id"=>$remainingID,"name"=>null,"path"=>null, "folder_id"=>null, "date" => null, "action"=>"DELETE"); // delete by id- array_push($changes, $generated); // add to new (delete)- $cost++;- }-- if($foldersCopy === $folderStructure) $foldersCopy = null;-- $data["next_ID"] = $currentID;- $data["videoStructure"] = $current;- return array("videoChanges"=> $changes, "data" => $data, "cost"=>$cost, "updatedFolderStructure"=>$foldersCopy);- }+ // foreach($files as $file){+ // if ($file->getExtension() == 'mp4' || $file->getExtension() == 'mkv' ) {+ // $fileData = array('name'=> $publicRoot . $path . '/' . basename($directory) . '/' . basename($file), 'title'=>basename($file), 'date' => filectime($file), 'formattedDate' => date("Y-m-d g:i A", filectime($file)));+ // $rawFile = array('name'=> $publicRoot . $path . '/' . basename($directory) . '/' . basename($file), 'title'=>basename($file), 'date' => filectime($file), 'formattedDate' => date("Y-m-d g:i A", filectime($file)));+ // array_push($currentFolder['files'], $fileData);+ // }+ // }+ // }+ // array_push($folders, $currentFolder);+ // $currentFolder['files'] = array();+ // }++ // return json_encode(array("success"=>true, "result"=>$folders, "error"=>""), JSON_UNESCAPED_SLASHES);+ // }}\ No newline at end of filediff --git a/app/Http/Controllers/VideoController.php b/app/Http/Controllers/VideoController.phpdeleted file mode 100644index b760852b..00000000--- a/app/Http/Controllers/VideoController.php+++ /dev/null@@ -1,10 +0,0 @@-<?php--namespace App\Http\Controllers;--use Illuminate\Http\Request;--class VideoController extends Controller-{- //-}diff --git a/app/Http/Requests/FolderCollectionRequest.php b/app/Http/Requests/FolderCollectionRequest.phpnew file mode 100644index 00000000..b1e075eb--- /dev/null+++ b/app/Http/Requests/FolderCollectionRequest.php@@ -0,0 +1,29 @@+<?php++namespace App\Http\Requests;++use Illuminate\Foundation\Http\FormRequest;++class FolderCollectionRequest extends FormRequest+{+ /**+ * Determine if the user is authorized to make this request.+ */+ public function authorize(): bool+ {+ return false;+ }++ /**+ * Get the validation rules that apply to the request.+ *+ * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>+ */+ public function rules(): array+ {+ return [+ 'category_id' => ['required'],+ 'dir' => []+ ];+ }+}diff --git a/app/Http/Requests/VideoCollectionRequest.php b/app/Http/Requests/VideoCollectionRequest.phpnew file mode 100644index 00000000..51c91c75--- /dev/null+++ b/app/Http/Requests/VideoCollectionRequest.php@@ -0,0 +1,28 @@+<?php++namespace App\Http\Requests;++use Illuminate\Foundation\Http\FormRequest;++class VideoCollectionRequest extends FormRequest+{+ /**+ * Determine if the user is authorized to make this request.+ */+ public function authorize(): bool+ {+ return false;+ }++ /**+ * Get the validation rules that apply to the request.+ *+ * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>+ */+ public function rules(): array+ {+ return [+ 'folder_id' => ['required']+ ];+ }+}diff --git a/app/Http/Resources/FolderResource.php b/app/Http/Resources/FolderResource.phpnew file mode 100644index 00000000..3f6ae123--- /dev/null+++ b/app/Http/Resources/FolderResource.php@@ -0,0 +1,30 @@+<?php++namespace App\Http\Resources;++use App\Models\Video;+use Illuminate\Http\Request;+use Illuminate\Http\Resources\Json\JsonResource;++class FolderResource extends JsonResource+{+ /**+ * Transform the resource into an array.+ *+ * @return array<string, mixed>+ */+ public function toArray(Request $request): array+ {+ return [+ 'id' => (string)$this->id,+ 'attributes' => [+ 'name' => $this->name,+ 'path' => $this->path,+ 'file_count' => $this->videos_count+ ],+ 'relationships' => [+ 'category_id' => (string)$this->category->id,+ ]+ ];+ }+}diff --git a/app/Http/Resources/RecordResource.php b/app/Http/Resources/RecordResource.phpindex 9a63b335..b369aa3d 100644--- a/app/Http/Resources/RecordResource.php+++ b/app/Http/Resources/RecordResource.php@@ -2,7 +2,6 @@namespace App\Http\Resources;-use App\Models\Folder;use Illuminate\Http\Request;use Illuminate\Http\Resources\Json\JsonResource;diff --git a/app/Http/Resources/VideoResource.php b/app/Http/Resources/VideoResource.phpnew file mode 100644index 00000000..c7915e28--- /dev/null+++ b/app/Http/Resources/VideoResource.php@@ -0,0 +1,29 @@+<?php++namespace App\Http\Resources;++use Illuminate\Http\Request;+use Illuminate\Http\Resources\Json\JsonResource;++class VideoResource extends JsonResource+{+ /**+ * Transform the resource into an array.+ *+ * @return array<string, mixed>+ */+ public function toArray(Request $request): array+ {+ return [+ 'id' => (string)$this->id,+ 'attributes' => [+ 'name' => $this->name,+ 'path' => $this->path,+ 'date' => $this->date+ ],+ 'relationships' => [+ 'folder_id' => (string)$this->folder->id+ ]+ ];+ }+}diff --git a/app/Jobs/IndexFiles.php b/app/Jobs/IndexFiles.phpnew file mode 100644index 00000000..b00bc8ef--- /dev/null+++ b/app/Jobs/IndexFiles.php@@ -0,0 +1,379 @@+<?php++namespace App\Jobs;++use Illuminate\Bus\Queueable;+use Illuminate\Contracts\Queue\ShouldQueue;+use Illuminate\Contracts\Queue\ShouldBeUnique;+use Illuminate\Foundation\Bus\Dispatchable;+use Illuminate\Queue\InteractsWithQueue;+use Illuminate\Queue\SerializesModels;+use Illuminate\Support\Facades\Storage;+use Illuminate\Support\Facades\File;+use App\Models\Category;+use App\Models\Folder;+use App\Models\Video;++class IndexFiles implements ShouldQueue, ShouldBeUnique+{+ use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;++ /**+ * Create a new job instance.+ */+ public function __construct()+ {+ //+ }++ /**+ * Execute the job.+ */+ public function handle(): void+ {+ $this->generateData();+ }++ public function generateData() {+ $path = "public\media\\";++ if(!Storage::exists($path)){+ $error = 'Invalid Directory: "media"';++ dd(json_encode(array("success"=>false, "result"=>"", "error"=>$error), JSON_UNESCAPED_SLASHES));+ }++ $realPath = Storage::path($path);++ $directories = $this->generateCategories($realPath);+ $subDirectories = $this->generateFolders($path, $directories["data"]["categoryStructure"]);+ $files = $this->generateVideos($path, $subDirectories["data"]["folderStructure"], $directories["data"]["categoryStructure"]);++ if(isset($files["updatedFolderStructure"])) $subDirectories["data"]["folderStructure"] = $files["updatedFolderStructure"];++ $categories = $directories["categoryChanges"];+ $folders = $subDirectories["folderChanges"];+ $videos = $files["videoChanges"];++ #region+ // $shows = array();+ // $show = array("id"=>null,"name"=>"", "path"=>"", "category_id"=>"");++ // $videos = array();+ // $video = array("id"=>null,"name"=>"","path"=>"","category_id"=>"","show_id"=>null,"file_id"=>null,"episode_id"=>null);++ // //Raw file data connected to video (when folder is not a show)+ // $rawFiles = array();+ // $rawFile = array("name"=> "", "path"=>"", "date" => "", "formattedDate" => null);++ // //Episodic data connected to video (when folder is a show)+ // $episodes = array();+ // $episode = array("id"=>null, "episode_no"=>null, "season_no"=>null, "episode_synopsis"=>"lorem ipsum");+ #endregion++ $dbOut = "";+ $categoryTransactions = array();+ $folderTransactions = array();+ $videoTransactions = array();++ foreach ($categories as $categoryChange){ // for each in stored, remove from new (delete)+ $changeID = $categoryChange['id'];+ $changeName = $categoryChange["name"];+ $changeMediaContent = $categoryChange["media_content"] ?? 'False';+ $changeAction = $categoryChange["action"];++ if($changeAction === "INSERT"){+ $dbOut .= "INSERT INTO [Categories] VALUES ($changeID, $changeName, $changeMediaContent );\n"; // insert++ $transaction = $categoryChange;+ unset($transaction["action"]);+ array_push($categoryTransactions, $transaction);+ }+ else{+ $dbOut .= "DELETE FROM [Categories] WHERE [Categories].[ID] = $changeID;\n";+ Category::where('id', $changeID)->delete();+ }+ }++ foreach ($folders as $folderChange){ // for each in stored, remove from new (delete)+ $changeID = $folderChange['id'];+ $changeName = $folderChange["name"];+ $changePath = $folderChange["path"];+ $changeCategoryID = $folderChange["category_id"];+ $changeAction = $folderChange["action"];++ if($changeAction === "INSERT"){+ $dbOut .= "INSERT INTO [Folders] VALUES ({$changeID}, {$changeName}, {$changePath}, {$changeCategoryID} );\n"; // insert++ $transaction = $folderChange;+ unset($transaction["action"]);+ array_push($folderTransactions, $transaction);+ }+ else{+ $dbOut .= "DELETE FROM [Folders] WHERE [Folder].[ID] = {$changeID};";+ Folder::where('id', $changeID)->delete();+ }+ }++ foreach ($videos as $videoChange){ // for each in stored, remove from new (delete)+ $changeID = $videoChange['id'];+ $changeName = $videoChange["name"];+ $changePath = $videoChange["path"];+ $changeFolderID = $videoChange["folder_id"];+ $changeDate = $videoChange["date"];+ $changeAction = $videoChange["action"];++ if($changeAction === "INSERT"){+ $dbOut .= "INSERT INTO [Videos] VALUES ({$changeID}, {$changeName}, {$changePath}, {$changeFolderID}, {$changeDate} );\n"; // insert++ $transaction = $videoChange;+ unset($transaction["action"]);+ array_push($videoTransactions, $transaction);+ }+ else{+ $dbOut .= "DELETE FROM [Videos] WHERE [Categories].[ID] = {$changeID};\n";+ Video::where('id', $changeID)->delete();+ }+ }++ Storage::disk('public')->put('categories.json', json_encode($directories["data"], JSON_UNESCAPED_SLASHES));+ Storage::disk('public')->put('folders.json', json_encode($subDirectories["data"], JSON_UNESCAPED_SLASHES));+ Storage::disk('public')->put('videos.json', json_encode($files["data"], JSON_UNESCAPED_SLASHES));++ Category::insert($categoryTransactions);+ Folder::insert($folderTransactions);+ Video::insert($videoTransactions);++ $data = array("categories"=>$categories,"folders"=>$folders,"videos"=>$videos);++ Storage::disk('public')->put('dataCache.json', json_encode($data, JSON_UNESCAPED_SLASHES));+ dump($directories, $subDirectories, $files, $data, $dbOut);+ }++ private function generateCategories($path){+ $data = Storage::json('public\categories.json') ?? array("next_ID"=>1, "categoryStructure" => array()); //array("anime"=>1,"tv"=>2,"yogscast"=>3); // read from json+ $scanned = array_map("htmlspecialchars", scandir($path)); // read folder structure++ $currentID = $data["next_ID"];+ $stored = $data["categoryStructure"];+ $changes = array(); // send to db+ $current = array(); // save into json++ // foreach ($stored as $savedID){ // O(n) where n = number of already known categories+ // $currentID = max($currentID, $savedID + 1); // gets max currently used id+ // }++ /*+ If scanned is in stored, add to current, remove from stored+ If scanned not in stored, add to current, add to new (insert), id++++ after:++ for each in stored, remove from new (delete)++ send new to database++ save current to json+ */+ foreach ($scanned as $local){ // O(n) where n = number of already known categories+ if(is_dir($local)) continue; //? . and .. are dirs++ $name = basename($local);++ if(isset($stored[$name])){ // If scanned is in stored, add to current, remove from stored+ $current[$name] = $stored[$name]; // add to current+ unset($stored[$name]); // remove from stored+ }+ else{ // If scanned not in stored, add to current, add to new (insert), id+++ $generated = array("id"=>$currentID,"name"=>$name,"media_content"=>'False', "action"=>"INSERT");+ $current[$name] = $currentID; // add to current+ array_push($changes, $generated); // add to new (insert)+ $currentID++;+ }+ }++ foreach ($stored as $remainingID){+ $generated = array("id"=>$remainingID,"name"=>null,"media_content"=>null, "action"=>"DELETE"); // delete by id+ array_push($changes, $generated); // add to new (delete)+ }++ $data["next_ID"] = $currentID;+ $data["categoryStructure"] = $current;++ return array("categoryChanges"=> $changes, "data" => $data);+ }++ private function generateFolders($path, $categoryStructure){+ $data = Storage::json('public\folders.json') ?? array("next_ID"=>1,"folderStructure"=>array()); //array("anime/frieren"=>array("id"=>0,"name"=>"frieren"),"starwars/andor"=>array("id"=1,"name"="andor")); // read from json+ $scannedCategories = array_keys($categoryStructure);+ $cost = 0;++ $currentID = $data["next_ID"];+ $stored = $data["folderStructure"];+ $changes = array(); // send to db+ $current = array(); // save into json into json++ // foreach ($stored as $savedFolder){ // O(n) where n = number of already known categories+ // $currentID = max($currentID, $savedFolder["id"] + 1); // gets max currently used id+ // $cost ++;+ // }++ /*+ Double Foreach loop++ o(M*N) where M = number of categories and N = number of files in each category+ really becomes O(n) where n = number of files since N is not constant++ for each folder in each category+ key = category/folder+ if isset in stored+ // old folder already seen++ add to current -> key, id, basename(folder)+ remove from stored+ continue+ else+ // new folder not seen before++ add to current -> key, id, basename(folder) ?+ add to changes (insert)+ id += 1;+ */+ foreach ($scannedCategories as $category) { // O(n) where n = number of folders * 2 (for scan)+ $cost++;++ $folders = Storage::directories("$path\\$category"); // Immediate folders (dont scan sub folders)++ foreach ($folders as $folder){+ $cost++;++ $name = basename($folder);+ $key = "$category\\$name";++ if($name === ".thumbs") continue;++ if(isset($stored[$key])){+ $current[$key] = $stored[$key]; // add to current+ unset($stored[$key]); // remove from stored+ }+ else{+ $generated = array("id"=>$currentID,"name"=>$name,"path"=>$key, "category_id"=>$categoryStructure[$category], "action"=>"INSERT");+ $current[$key] = array("id"=>$currentID, "last_scan"=>-1); // add to current+ array_push($changes, $generated); // add to new (insert)+ $currentID++;+ }+ }+ }+++ foreach ($stored as $remainingID){+ $generated = array("id"=>$remainingID,"name"=>null,"path"=>null, "category_id"=>null, "action"=>"DELETE"); // delete by id+ array_push($changes, $generated); // add to new (delete)+ $cost++;+ }+++ // if($current !== $storedCopy) {+ // //Storage::disk('public')->put('folders.json', json_encode($current, JSON_UNESCAPED_SLASHES));+ // }++ $data["next_ID"] = $currentID;+ $data["folderStructure"] = $current;+ return array("folderChanges"=> $changes, "data" => $data, "cost"=>$cost);+ }++ private function generateVideos($path, $folderStructure){+ $data = Storage::json('public\videos.json') ?? array("next_ID"=>1,"videoStructure"=>array()); //array("anime/frieren/S1E01.mp4"=>array("id"=>0,"name"=>"S1E01"),"starwars/andor/S1E01.mkv"=>array("id"=1,"name"="S1E01.mkv")); // read from json+ $scannedFolders = array_keys($folderStructure);+ $cost = 0;++ $currentID = $data["next_ID"];+ $stored = $data["videoStructure"];+ $changes = array(); // send to db+ $current = array(); // save into json into json++ $foldersCopy = $folderStructure;+ $unModefiedFolders = array();+ $rawPath = Storage::path('');++ // foreach ($stored as $savedVideo){ // O(n) where n = number of already known categories+ // $currentID = max($currentID, $savedVideo + 1); // gets max currently used id+ // $cost ++;+ // }++ /*+ Double Foreach loop++ o(M*N) where M = number of categories and N = number of files in each category+ really becomes O(n) where n = number of files since N is not constant++ for each video in each category+ folder = parent directory of video+ key = category/folder/video+ if isset in stored+ // old video already seen++ add to current -> key, id, basename(folder)+ remove from stored+ continue+ else+ // new folder not seen before++ add to current -> key, id, basename(folder) ?+ add to changes (insert)+ id += 1;+++ */+ foreach ($scannedFolders as $folder) { // O(n) where n = number of folders * 2 (for scan)+ $cost++;+ $folderAccessTime = filemtime("{$rawPath}public\media\\$folder\\");++ if($folderAccessTime <= $folderStructure[$folder]["last_scan"]){+ $unModefiedFolders[$folder] = 1;+ continue;+ }++ $files = Storage::files("$path$folder"); // Immediate folders (dont scan sub folders)+ $foldersCopy[$folder]['last_scan'] = $folderAccessTime;++ foreach ($files as $file){+ $cost++;+ $ext = pathinfo($file, PATHINFO_EXTENSION);+ if ($ext !== 'mp4' && $ext !== 'mkv' ) continue;++ $name = basename($file);+ $cleanName = basename($file,".$ext");+ $key = "$folder\\$name";+ $rawFile = "$rawPath$file";++ if(isset($stored[$key])){+ $current[$key] = $stored[$key]; // add to current+ unset($stored[$key]); // remove from stored+ }+ else{+ $generated = array("id"=>$currentID,"name"=>$cleanName,"path"=>"storage\\". basename($path) . "\\$key", "folder_id"=>$folderStructure[$folder]["id"], "date" => date("Y-m-d g:i A", filemtime($rawFile)), "action"=>"INSERT");+ $current[$key] = $currentID; // add to current+ array_push($changes, $generated); // add to new (insert)+ $currentID++;+ }+ }+ }++ foreach ($stored as $video => $remainingID){+ if(isset($unModefiedFolders[dirname($video)])){+ $current[$video] = $stored[$video];+ continue;+ }+ $generated = array("id"=>$remainingID,"name"=>null,"path"=>null, "folder_id"=>null, "date" => null, "action"=>"DELETE"); // delete by id+ array_push($changes, $generated); // add to new (delete)+ $cost++;+ }++ if($foldersCopy === $folderStructure) $foldersCopy = null;++ $data["next_ID"] = $currentID;+ $data["videoStructure"] = $current;+ return array("videoChanges"=> $changes, "data" => $data, "cost"=>$cost, "updatedFolderStructure"=>$foldersCopy);+ }+}diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.phpindex 444fafb7..87cb53ab 100644--- a/database/migrations/2014_10_12_000000_create_users_table.php+++ b/database/migrations/2014_10_12_000000_create_users_table.php@@ -13,7 +13,7 @@ return new class extends Migration{Schema::create('users', function (Blueprint $table) {$table->id();- $table->string('name');+ $table->string('name')->unique();$table->string('email')->unique();$table->timestamp('email_verified_at')->nullable();$table->string('password');diff --git a/public/js/auth.js b/public/js/auth.jsindex f4c46a72..e29667e0 100644--- a/public/js/auth.js+++ b/public/js/auth.js@@ -26,7 +26,7 @@ function login(){if(json.success){localStorage.setItem('auth-token', json.data.token)toastr['info'](localStorage.getItem('auth-token'));- window.location.href = '/testing';+ window.location.href = '/';}}).catch((error) => {console.log(error);@@ -48,7 +48,7 @@ function logout(){).then(json => {console.log(json);localStorage.clear('auth-token');- if(json.success == true) window.location.href = "/testing";+ if(json.success == true) window.location.href = "/";}).catch((error) => {console.log(error);});diff --git a/public/js/main-old.js b/public/js/main-old.jsnew file mode 100644index 00000000..eb73cca8--- /dev/null+++ b/public/js/main-old.js@@ -0,0 +1,88 @@+async function loadVideos(){+ const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');+ const dir = stateVideoDirectory ?? 'anime';++ fetch('/ajax/generateDir', {+ method: 'post',+ headers: {+ 'Accept': 'application/json',+ 'Content-Type': 'application/json',+ 'X-CSRF-TOKEN': csrfToken+ },+ body: JSON.stringify({+ dir:dir+ })+ }).then((response) =>+ response.json()+ ).then((json) => {+ console.log(json);+ if(json.success == false){+ toastr["error"](`The directory '${dir}' does not exist.`, "Invalid Category");+ return;+ }+ parseVideos(json.result);+ }).catch((error) => {+ console.log(error);+ });+}++function parseVideos(data){+ // const dataContainer = document.getElementById('dataContainer');+ const darkModeSettings = getDarkModeSettings();++ var folderTemplate = function(folderName, folderCount, fileElements) {+ return `+ <div class="col-sm-12">+ <div class="folder-header row mb-4">+ <h4 class="col-sm-8 col-lg-10 ps-0 text-center text-sm-start"> ${folderName} </h4>+ <button class="col-sm-4 col-lg-2 btn ${darkModeSettings.btnClass} folder-toggle" id="dataTable-${folderCount}-collapse-toggle" type="button" data-bs-toggle="collapse" data-bs-target="#dataTable-${folderCount}-collapse">+ <i class="bi bi-list"></i>+ Show Folder+ </button>+ </div>+ <div class="collapse show" id="dataTable-${folderCount}-collapse" data-state="0">+ <table class="vid-table hover stripe" id="dataTable-${folderCount}" data-folder="${folderName}">+ <thead>+ <tr>+ <th>Title</th>+ <!-- <th>Length</th> -->+ <th>Date</th>+ </tr>+ </thead>+ <tbody>+ ${fileElements}+ </tbody>+ </table>+ </div>+ </div>+ <hr>+ `+ }+ var videoTemplate = function(fileArray){+ let fileName = fileArray['name'].substring(1);+ let title = fileArray['title'];+ let date = fileArray['date'];+ let formattedDate = fileArray['formattedDate'];+ return `+ <tr>+ <td class="vid-row" data-col="col-title" value="${fileName}">${title}</td>+ <!-- <td class="vid-row" data-col="col-length" value="0">Unimplemented</td> -->+ <td class="vid-row" data-col="col-date" value="${date}">${formattedDate}</td>+ </tr>+ `+ }++ // console.log(data.length);++ for (let folderCount = 0; folderCount < data.length; folderCount++) {+ const folderName = data[folderCount]['name'];+ const files = data[folderCount]['files'];++ let fileElements = files.map(videoTemplate);+ let folderElement = folderTemplate(folderName, folderCount, fileElements.toString().replaceAll(',',''));+ $('#dataContainer').append(folderElement);+ }++ initVideos();+}+diff --git a/public/js/main.js b/public/js/main.jsindex 6d54c535..236af66b 100644--- a/public/js/main.js+++ b/public/js/main.js@@ -1,17 +1,43 @@var token = ''-var folderData = [];+/*+ Video Retrieval Structure :++ Requires :+ - directory+ - folder name++ Path :+ -> DOMContentLoaded+ -> loadCategoryFolders() - get folders in directory and then+ -> parseFolders() - create ui components for each folder from last request+ -> loadVideosAndParse() - parses the given folder name to a folder from last request and creates a datatable to correspond to it+ - gets videos that have given folder's id and creates ui components (table rows) and then+ -> initVideos() - initialises ui functionality for each video row++ Video History Structure :+++*/+document.addEventListener("DOMContentLoaded", function(event) {try {- document.getElementById('dark-mode-toggle').addEventListener('click', () => { toggleDarkMode(); });- if(folderName === null | folderName === undefined) { loadVideos(); }- else { loadVideosTest(); }- toggleDarkMode();+ if(stateFolderName === null | stateFolderName === undefined) { loadVideos(); }+ else { loadCategoryFolders(); }++ if(document.getElementById('dark-mode-toggle')){+ document.getElementById('dark-mode-toggle').addEventListener('click', () => { toggleDarkMode(); });+ toggleDarkMode();+ }} catch (error) {- toastr['error']('Dark mode not supported!');+ toastr['error']('Unable to load data.');+ console.log(error);+ return;}+ //#region UI Navigation+$("#user_header").on('click', function(){document.querySelector("#user_dropdown").classList.toggle("hidden");});@@ -25,38 +51,27 @@ document.addEventListener("DOMContentLoaded", function(event) {});window.addEventListener('click', function(e){- // close dropdown when clicked outsidetry {let dropdown = this.document.querySelector("#user_dropdown")if (!this.document.querySelector("#user_options").contains(e.target)){dropdown.classList.add("hidden");}} catch (error) {-+ console.log(error);}});- try {- if(localStorage.getItem('auth-token').length > 0){- //document.querySelector("#user-menu-auth").classList.remove("hidden");- //document.querySelector("#user-menu-unauth").classList.add("hidden");- toastr['success']('Logged in!')- }- else{- //document.querySelector("#user-menu-auth").classList.add("hidden");- //document.querySelector("#user-menu-unauth").classList.remove("hidden");- toastr['error']('Logged out!')- }- } catch (error) {-- }+ //#endregion});function reload(newFolder){- folderName = newFolder;- parseVideosTest(folderData);+ stateFolderName = newFolder;+ window.history.pushState({dir: stateVideoDirectory, folder: stateFolderName},`${stateVideoDirectory} - ${stateFolderName}`, `/${stateVideoDirectory}/${stateFolderName}`);+ loadVideosAndParse(folderData);}+//#region UI Navigation+function showLogin(){//logIn();window.location.href = "/login";@@ -107,6 +122,8 @@ function cycleSideBar(state){}}+//#endregion+async function loadHistory(){const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');fetch(`/api/records`, {@@ -147,7 +164,7 @@ async function addToHistory(id){).then((json) => {console.log(json);if(json.success == true) {- toastr['success']('Added to history!');+ // toastr['success']('Added to history!');loadHistory();};}).catch((error) => {@@ -187,37 +204,9 @@ function parseHistory(data, count = 10, destination = '#list-content-history') {}}-async function loadVideos(){- const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');- const dir = videoDirectory ?? 'anime';-- fetch('/ajax/generateDir', {- method: 'post',- headers: {- 'Accept': 'application/json',- 'Content-Type': 'application/json',- 'X-CSRF-TOKEN': csrfToken- },- body: JSON.stringify({- dir:dir- })- }).then((response) =>- response.json()- ).then((json) => {- console.log(json);- if(json.success == false){- toastr["error"](`The directory '${dir}' does not exist.`, "Invalid Category");- return;- }- parseVideos(json.result);- }).catch((error) => {- console.log(error);- });-}--async function loadVideosTest(){+async function loadCategoryFolders(){const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');- const dir = videoDirectory ?? 'anime';+ const dir = stateVideoDirectory ?? 'anime';fetch(`/ajax/getFolders`, {method: 'post',@@ -240,72 +229,12 @@ async function loadVideosTest(){folderData = json.result;parseFolders(folderData);- parseVideosTest(folderData);+ loadVideosAndParse(folderData);}).catch((error) => {console.log(error);});}-function parseVideos(data){- // const dataContainer = document.getElementById('dataContainer');- const darkModeSettings = getDarkModeSettings();-- var folderTemplate = function(folderName, folderCount, fileElements) {- return `- <div class="col-sm-12">- <div class="folder-header row mb-4">- <h4 class="col-sm-8 col-lg-10 ps-0 text-center text-sm-start"> ${folderName} </h4>- <button class="col-sm-4 col-lg-2 btn ${darkModeSettings.btnClass} folder-toggle" id="dataTable-${folderCount}-collapse-toggle" type="button" data-bs-toggle="collapse" data-bs-target="#dataTable-${folderCount}-collapse">- <i class="bi bi-list"></i>- Show Folder- </button>- </div>- <div class="collapse show" id="dataTable-${folderCount}-collapse" data-state="0">- <table class="vid-table hover stripe" id="dataTable-${folderCount}" data-folder="${folderName}">- <thead>- <tr>- <th>Title</th>- <!-- <th>Length</th> -->- <th>Date</th>- </tr>- </thead>- <tbody>- ${fileElements}- </tbody>- </table>- </div>- </div>- <hr>- `- }- var videoTemplate = function(fileArray){- let fileName = fileArray['name'].substring(1);- let title = fileArray['title'];- let date = fileArray['date'];- let formattedDate = fileArray['formattedDate'];- return `- <tr>- <td class="vid-row" data-col="col-title" value="${fileName}">${title}</td>- <!-- <td class="vid-row" data-col="col-length" value="0">Unimplemented</td> -->- <td class="vid-row" data-col="col-date" value="${date}">${formattedDate}</td>- </tr>- `- }-- // console.log(data.length);-- for (let folderCount = 0; folderCount < data.length; folderCount++) {- const folderName = data[folderCount]['name'];- const files = data[folderCount]['files'];-- let fileElements = files.map(videoTemplate);- let folderElement = folderTemplate(folderName, folderCount, fileElements.toString().replaceAll(',',''));- $('#dataContainer').append(folderElement);- }-- initVideos();-}-async function parseFolders(data){var folderTemplate = function(folderName, folderCount) {@@ -337,11 +266,11 @@ async function parseFolders(data){}}-async function parseVideosTest(data){+async function loadVideosAndParse(data){const darkModeSettings = getDarkModeSettings();const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');- var folderTemplate = function(setfolderName, folderCount, fileElements) {+ var folderTemplate = function(folderName, folderCount, fileElements) {old = `<button class="col-sm-4 col-lg-2 btn ${darkModeSettings.btnClass} folder-toggle" id="dataTable-${folderCount}-collapse-toggle" type="button" data-bs-toggle="collapse" data-bs-target="#dataTable-${folderCount}-collapse">@@ -352,10 +281,10 @@ async function parseVideosTest(data){return `<div class="col-sm-12"><div class="folder-header row mb-4">- <h4 class="col-sm-8 col-lg-10 ps-0 text-center text-sm-start"> ${setfolderName} </h4>+ <h4 class="col-sm-8 col-lg-10 ps-0 text-center text-sm-start"> ${folderName} </h4></div><div class="" id="dataTable-${folderCount}-collapse" data-state="1">- <table class="vid-table hover stripe" id="dataTable-${folderCount}" data-folder="${setfolderName}">+ <table class="vid-table hover stripe" id="dataTable-${folderCount}" data-folder="${folderName}"><thead><tr><th>Title</th>@@ -386,11 +315,11 @@ async function parseVideosTest(data){`}- let selectedFolderName = folderName;+ let selectedFolderName = stateFolderName;let folder_id = -1;- if(folderName === null | folderName === undefined) {- toastr["error"](`An invalid folder name [${folderName}] was provided in the URL.`, "Invalid Folder");+ if(selectedFolderName === null | selectedFolderName === undefined) {+ toastr["error"](`An invalid folder name [${selectedFolderName}] was provided in the URL.`, "Invalid Folder");return;}diff --git a/resources/views/home.blade.php b/resources/views/home.blade.phpindex 319305f0..fe9460f5 100644--- a/resources/views/home.blade.php+++ b/resources/views/home.blade.php@@ -1,34 +1,193 @@<x-app-layout>- <script src="{{ URL::asset('js/auth.js') }}"></script>- <main class="container">- <div class="row">- <div class="col-sm-12">- <div class="neu-card light-mode">- <div class="col-sm-12">- <div style="display: flex; flex-direction: row-reverse;">- <div style="width:auto; display: flex; align-items: center;" class="ms-3">- <div class="toggle-switch">- <label class="switch-label">- <input type="checkbox" class="checkbox" id="dark-mode-toggle">- <span class="slider"></span>- </label>+ <script src="{{ URL::asset('js/main.js') }}"></script>+ <script>+ var stateVideoDirectory = <?php echo json_encode($dir ?? 'anime') ?>;+ var stateFolderName = <?php echo json_encode($folder_name ?? 'ODDTAXI') ?>;+ </script>+ <div class=" hidden p-6 max-w-sm mx-auto bg-white rounded-xl shadow-lg flex items-center space-x-4">+ <div class="shrink-0">+ <img class="h-12 w-12" src="storage/avatars/12345.jpg" alt="ChitChat Logo">+ </div>+ <div>+ <div class="text-xl font-medium text-black">ChitChat</div>+ <p class="text-slate-500">You have a new message!</p>+ </div>+ </div>+ <button type="button" class="hidden flex justify-center items-center select-none bg-red-500 border-2 text-white text-xl font-bold p-2 m-2 rounded-full shadow h-20 w-20 focus:outline-none focus:shadow-outline">+ <svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x">+ <line x1="18" y1="6" x2="6" y2="18"></line>+ <line x1="6" y1="6" x2="18" y2="18"></line>+ </svg>+ </button>++ <main class="mx-[4%] flex flex-row-reverse flex-wrap-reverse lg:flex-nowrap">+ <section id="list-card" class="invisible dark:bg-neutral-900 shadow-xl m-[1%] p-[1%] pb-[2%] rounded-[15px] light-mode w-full lg:w-[18%] space-y-2">+ <div class="flex p-1 text-ri">+ <h1 id="sidebar-title" class="text-2xl w-full">Folders</h1>+ </div>++ <hr class="mt-2 mb-3">+ <section id="list-content-folders" class="hidden flex space-y-2 flex-wrap">+ <div class="hidden flex flex-wrap rounded-xl dark:bg-neutral-800 bg-slate-100 dark:text-white shadow p-[3%] w-full divide-y divide-gray-300 group flex-grow">+ <section class="flex flex-row-reverse justify-between items-baseline w-full">+ <h2 class="text-lg text-right text-neutral-500 text-nowrap">24 Episodes</h2>+ <h2 class="text-xl text-left">Frieren</h2>+ </section>+ <aside class="flex justify-between items-center w-full pt-1">+ <h3 class="text-lg text-left text-neutral-500">Drama</h2>+ <span class="hidden group-hover:flex space-x-1">+ <button class="hover:bg-orange-500 hover:stroke-none border-orange-500 border-2 rounded shadow px-2">Watch</button>+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">+ <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 13.5 12 21m0 0-7.5-7.5M12 21V3" />+ </svg>+ </span>+ </aside>+ </div>+ </section>+ <section id="list-content-history" class="hidden flex space-y-2 flex-wrap">+ <div class="hidden flex flex-wrap rounded-xl dark:bg-neutral-800 dark:hover:bg-neutral-700 hover:bg-slate-200 bg-slate-100 dark:text-white shadow p-[3%] w-full divide-y divide-gray-300 group flex-grow">+ <section class="flex justify-between items-baseline w-full">+ <h2 class="text-xl text-left">S1E24</h2>+ </section>+ <aside class="flex justify-between items-center w-full pt-1">+ <h3 class="text-lg text-left text-neutral-500">Frieren</h2>+ <h3 class="text-lg text-right text-neutral-500 text-nowrap">3 days ago</h3>+ <span class="hidden flex space-x-1">+ <button class="hover:bg-orange-500 hover:stroke-none border-orange-500 border-2 rounded shadow px-2">Watch</button>+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">+ <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 13.5 12 21m0 0-7.5-7.5M12 21V3" />+ </svg>+ </span>+ </aside>+ </div>+ </section>+ </section>+ <section id="content-card" class=" dark:bg-neutral-900 shadow-xl m-[1%] p-[2%] pt-[1%] rounded-[15px] light-mode w-full lg:w-[70%]">+ <nav id="navbar">+ <div class="flex flex-row-reverse p-1 ">+ <span class="flex max-w-sm mx-auto items-center space-x-2 shrink-0">+ <section id="user_options" class="dropdown group inline-block relative" aria-expanded="true" aria-haspopup="true" data-dropdown-toggle="user_dropdown">+ <div class="hidden absolute top-12 origin-top-right left-7 w-56 z-10 divide-y divide-gray-200 rounded-md shadow-lg ring-1 bg-white ring-black ring-opacity-5 focus:outline-none" id="user_dropdown" aria-orientation="vertical" aria-labelledby="user_options">+ @auth++ <div class="divide-y divide-gray-300" role="menu" id="user-menu-auth">+ <section class="px-4 py-3">+ <p class="text-sm leading-5 text-orange-500">Logged in as</p>+ <p class="text-sm font-medium leading-5 text-gray-900 truncate">{{ Auth::user()->email }}</p>+ </section>+ <section class="py-1">+ <button class="text-gray-700 flex justify-between w-full px-4 py-2 text-sm leading-5 text-left" role="menuitem">Account settings</button>+ <button class="text-gray-700 flex justify-between w-full px-4 py-2 text-sm leading-5 text-left" role="menuitem">Collections</button>+ <button class="text-gray-700 flex justify-between w-full px-4 py-2 text-sm leading-5 text-left" role="menuitem">Dashboard</button>+ <button class="text-gray-700 flex justify-between w-full px-4 py-2 text-sm leading-5 text-left" role="menuitem">Full History</button>+ <span role="menuitem" tabindex="-1" class="flex justify-between w-full px-4 py-2 text-sm leading-5 text-left text-gray-700 cursor-not-allowed opacity-50" aria-disabled="true">New feature (soon)</span>+ </section>+ <section class="py-1">+ <button class="text-gray-700 flex justify-between w-full px-4 py-2 text-sm leading-5 text-left" onclick="logout();" role="menuitem">Log out</button>+ </section>+ </div>+ @else+ <div role="menu" id="user-menu-unauth" class="text-gray-700">+ <section class="">+ <button class="rounded-t-md hover:bg-neutral-100 flex justify-between w-full px-4 py-2 text-sm leading-5 text-left" onclick="showLogin();" role="menuitem">Log in</button>+ <button class="rounded-b-md hover:bg-neutral-100 flex justify-between w-full px-4 py-2 text-sm leading-5 text-left" onclick="showSignup();" role="menuitem">Sign up</button>+ </section></div>+ @endauth+ </div>+ <button id="user_header" class="flex space-x-2 text-2xl text-slate-900 dark:text-white hover:text-orange-600 dark:hover:text-orange-600 items-center justify-center">+ @auth+ <span id="user_name">{{ Auth::user()->name }}</span>+ <img src="storage/avatars/12345.jpg" class="h-7 w-7 rounded-full sm:mx-0 sm:shrink-0 ring-2 ring-orange-600/60 shadow-lg">++ @else+ <span id="user_name_unauth" class="w-[10vw] text-right">Guest</span>+ <img src="storage/avatars/12345.jpg" class="h-7 w-7 rounded-full sm:mx-0 sm:shrink-0 ring-2 ring-orange-600/60 shadow-lg">+ @endauth++ </button>+ </section>+++ <section id="navbar-video" class="flex items-center space-x-2">+ <button id="btn-nav-folders" class="flex justify-center items-center shrink-0 h-8 w-8 rounded-lg shadow-lg bg-red-300 hover:bg-red-200 bg-gray-300 hover:bg-slate-200">+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" height="24" width="24" class="stroke-slate-900">+ <path stroke-linecap="round" stroke-linejoin="round" d="M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 0 0-1.883 2.542l.857 6a2.25 2.25 0 0 0 2.227 1.932H19.05a2.25 2.25 0 0 0 2.227-1.932l.857-6a2.25 2.25 0 0 0-1.883-2.542m-16.5 0V6A2.25 2.25 0 0 1 6 3.75h3.879a1.5 1.5 0 0 1 1.06.44l2.122 2.12a1.5 1.5 0 0 0 1.06.44H18A2.25 2.25 0 0 1 20.25 9v.776" />+ </svg>+ </button>+ @auth+ <button id="btn-nav-history" class="flex justify-center items-center shrink-0 h-8 w-8 rounded-lg shadow-lg bg-purple-300 hover:bg-purple-200">+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" height="24" width="24" class="fill-slate-900">+ <path d="M0 0h24v24H0z" fill="none" />+ <path fill-rule="evenodd" d="M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z" />+ </svg>+ </button>+ <button id="btn-nav-settings" class=" hidden flex justify-center items-center shrink-0 h-8 w-8 rounded-lg shadow-lg bg-red-300 hover:bg-red-200">+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" height="24" width="24" class="fill-slate-900">+ <path fill-rule="evenodd" d="M3 6.75A.75.75 0 0 1 3.75 6h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 6.75ZM3 12a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 12Zm0 5.25a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75Z" clip-rule="evenodd" />+ </svg>+ </button>+ @endauth+ </section>++ <div class="toggle-switch shrink-0">+ <label class="switch-label">+ <input type="checkbox" class="checkbox invisible" id="dark-mode-toggle">+ <span class="slider"></span>+ </label>+ </div>+ </span>+ <h1 id="mp4-title-folder" class="text-2xl w-full"></h1>+ </div>+ <hr class="mt-2 mb-3">+ </nav>+ <section id="content-video">+ <div id="video-container">+ <video id="vid-source" width="100%" src="" type="video/mp4" controls class="focus:outline-none">+ </video>++ <hr class="mt-4 mb-3">++ <div class="p-6 my-4 w-full mx-auto dark:bg-neutral-800 bg-white rounded-xl shadow-lg flex justify-between space-x-4">+ <div class="flex items-center space-x-4">+ <div class="shrink-0">+ <img class="h-12 w-12" src="storage/avatars/12345.jpg" alt="ChitChat Logo"></div>- <div style="display: flex; justify-content: space-between; width: 100%;">- <h3 id="mp4-title"></h3>- <h3 id="mp4-title-folder"></h3>+ <div>+ <div id="mp4-title" class="text-xl font-medium">ChitChat</div>+ <p class="dark:text-slate-400 text-slate-500">This episode is about a walrus going for a juice box run at 3am</p></div></div>- <hr class="mt-2">- <video id="vid-source" width="100%" src="" type="video/mp4" controls>- </video>+ <div id="mp4-controls" class="my-auto container flex w-auto" role="group">+ <button type="button" class="bg-gray-800 text-white rounded-l-md border-r border-gray-100 py-2 hover:bg-red-700 hover:text-white px-3 shadow-xl">+ <div class="flex flex-row align-middle">+ <svg class="w-5 mr-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">+ <path fill-rule="evenodd" d="M7.707 14.707a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l2.293 2.293a1 1 0 010 1.414z" clip-rule="evenodd"></path>+ </svg>+ <p class="ml-2">Prev</p>+ </div>+ </button>+ <button type="button" class="bg-gray-800 text-white rounded-r-md py-2 border-l border-gray-200 hover:bg-red-700 hover:text-white px-3 shadow-xl">+ <div class="flex flex-row align-middle">+ <span class="mr-2">Next</span>+ <svg class="w-5 ml-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">+ <path fill-rule="evenodd" d="M12.293 5.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-2.293-2.293a1 1 0 010-1.414z" clip-rule="evenodd"></path>+ </svg>+ </div>+ </button>+ </div></div>+ </div>- <hr id='preData'>+ <hr id='preData' class="my-4">- <div id='dataContainer'></div>- </div>- </div>- </div>+ <div id='dataContainer'></div>+ </section>++ <section id="content-history">++ </section>+ </section>+ <section id="left-card" class="w-full lg:w-[15%]"></section></main></x-app-layout>\ No newline at end of filediff --git a/resources/views/home.blade.php.old b/resources/views/home.blade.php.oldnew file mode 100644index 00000000..319305f0--- /dev/null+++ b/resources/views/home.blade.php.old@@ -0,0 +1,34 @@+<x-app-layout>+ <script src="{{ URL::asset('js/auth.js') }}"></script>+ <main class="container">+ <div class="row">+ <div class="col-sm-12">+ <div class="neu-card light-mode">+ <div class="col-sm-12">+ <div style="display: flex; flex-direction: row-reverse;">+ <div style="width:auto; display: flex; align-items: center;" class="ms-3">+ <div class="toggle-switch">+ <label class="switch-label">+ <input type="checkbox" class="checkbox" id="dark-mode-toggle">+ <span class="slider"></span>+ </label>+ </div>+ </div>+ <div style="display: flex; justify-content: space-between; width: 100%;">+ <h3 id="mp4-title"></h3>+ <h3 id="mp4-title-folder"></h3>+ </div>+ </div>+ <hr class="mt-2">+ <video id="vid-source" width="100%" src="" type="video/mp4" controls>+ </video>+ </div>++ <hr id='preData'>++ <div id='dataContainer'></div>+ </div>+ </div>+ </div>+ </main>+</x-app-layout>\ No newline at end of filediff --git a/resources/views/testing.blade.php b/resources/views/testing.blade.phpdeleted file mode 100644index 37eee545..00000000--- a/resources/views/testing.blade.php+++ /dev/null@@ -1,193 +0,0 @@-<x-app-layout>- <script src="{{ URL::asset('js/main.js') }}"></script>- <script>- var videoDirectory = <?php echo json_encode($dir ?? 'anime') ?>;- var folderName = <?php echo json_encode($folder_name ?? 'ODDTAXI') ?>;- </script>- <div class=" hidden p-6 max-w-sm mx-auto bg-white rounded-xl shadow-lg flex items-center space-x-4">- <div class="shrink-0">- <img class="h-12 w-12" src="storage/avatars/12345.jpg" alt="ChitChat Logo">- </div>- <div>- <div class="text-xl font-medium text-black">ChitChat</div>- <p class="text-slate-500">You have a new message!</p>- </div>- </div>- <button type="button" class="hidden flex justify-center items-center select-none bg-red-500 border-2 text-white text-xl font-bold p-2 m-2 rounded-full shadow h-20 w-20 focus:outline-none focus:shadow-outline">- <svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x">- <line x1="18" y1="6" x2="6" y2="18"></line>- <line x1="6" y1="6" x2="18" y2="18"></line>- </svg>- </button>-- <main class="mx-[4%] flex flex-row-reverse flex-wrap-reverse lg:flex-nowrap">- <section id="list-card" class="invisible dark:bg-neutral-900 shadow-xl m-[1%] p-[1%] pb-[2%] rounded-[15px] light-mode w-full lg:w-[18%] space-y-2">- <div class="flex p-1 text-ri">- <h1 id="sidebar-title" class="text-2xl w-full">Folders</h1>- </div>-- <hr class="mt-2 mb-3">- <section id="list-content-folders" class="hidden flex space-y-2 flex-wrap">- <div class="hidden flex flex-wrap rounded-xl dark:bg-neutral-800 bg-slate-100 dark:text-white shadow p-[3%] w-full divide-y divide-gray-300 group flex-grow">- <section class="flex flex-row-reverse justify-between items-baseline w-full">- <h2 class="text-lg text-right text-neutral-500 text-nowrap">24 Episodes</h2>- <h2 class="text-xl text-left">Frieren</h2>- </section>- <aside class="flex justify-between items-center w-full pt-1">- <h3 class="text-lg text-left text-neutral-500">Drama</h2>- <span class="hidden group-hover:flex space-x-1">- <button class="hover:bg-orange-500 hover:stroke-none border-orange-500 border-2 rounded shadow px-2">Watch</button>- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">- <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 13.5 12 21m0 0-7.5-7.5M12 21V3" />- </svg>- </span>- </aside>- </div>- </section>- <section id="list-content-history" class="hidden flex space-y-2 flex-wrap">- <div class="hidden flex flex-wrap rounded-xl dark:bg-neutral-800 dark:hover:bg-neutral-700 hover:bg-slate-200 bg-slate-100 dark:text-white shadow p-[3%] w-full divide-y divide-gray-300 group flex-grow">- <section class="flex justify-between items-baseline w-full">- <h2 class="text-xl text-left">S1E24</h2>- </section>- <aside class="flex justify-between items-center w-full pt-1">- <h3 class="text-lg text-left text-neutral-500">Frieren</h2>- <h3 class="text-lg text-right text-neutral-500 text-nowrap">3 days ago</h3>- <span class="hidden flex space-x-1">- <button class="hover:bg-orange-500 hover:stroke-none border-orange-500 border-2 rounded shadow px-2">Watch</button>- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">- <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 13.5 12 21m0 0-7.5-7.5M12 21V3" />- </svg>- </span>- </aside>- </div>- </section>- </section>- <section id="content-card" class=" dark:bg-neutral-900 shadow-xl m-[1%] p-[2%] pt-[1%] rounded-[15px] light-mode w-full lg:w-[70%]">- <nav id="navbar">- <div class="flex flex-row-reverse p-1 ">- <span class="flex max-w-sm mx-auto items-center space-x-2 shrink-0">- <section id="user_options" class="dropdown group inline-block relative" aria-expanded="true" aria-haspopup="true" data-dropdown-toggle="user_dropdown">- <div class="hidden absolute top-12 origin-top-right left-7 w-56 z-10 divide-y divide-gray-200 rounded-md shadow-lg ring-1 bg-white ring-black ring-opacity-5 focus:outline-none" id="user_dropdown" aria-orientation="vertical" aria-labelledby="user_options">- @auth-- <div class="divide-y divide-gray-300" role="menu" id="user-menu-auth">- <section class="px-4 py-3">- <p class="text-sm leading-5 text-orange-500">Logged in as</p>- <p class="text-sm font-medium leading-5 text-gray-900 truncate">{{ Auth::user()->email }}</p>- </section>- <section class="py-1">- <button class="text-gray-700 flex justify-between w-full px-4 py-2 text-sm leading-5 text-left" role="menuitem">Account settings</button>- <button class="text-gray-700 flex justify-between w-full px-4 py-2 text-sm leading-5 text-left" role="menuitem">Collections</button>- <button class="text-gray-700 flex justify-between w-full px-4 py-2 text-sm leading-5 text-left" role="menuitem">Dashboard</button>- <button class="text-gray-700 flex justify-between w-full px-4 py-2 text-sm leading-5 text-left" role="menuitem">Full History</button>- <span role="menuitem" tabindex="-1" class="flex justify-between w-full px-4 py-2 text-sm leading-5 text-left text-gray-700 cursor-not-allowed opacity-50" aria-disabled="true">New feature (soon)</span>- </section>- <section class="py-1">- <button class="text-gray-700 flex justify-between w-full px-4 py-2 text-sm leading-5 text-left" onclick="logout();" role="menuitem">Log out</button>- </section>- </div>- @else- <div role="menu" id="user-menu-unauth" class="text-gray-700">- <section class="">- <button class="rounded-t-md hover:bg-neutral-100 flex justify-between w-full px-4 py-2 text-sm leading-5 text-left" onclick="showLogin();" role="menuitem">Log in</button>- <button class="rounded-b-md hover:bg-neutral-100 flex justify-between w-full px-4 py-2 text-sm leading-5 text-left" onclick="showSignup();" role="menuitem">Sign up</button>- </section>- </div>- @endauth- </div>- <button id="user_header" class="flex space-x-2 text-2xl text-slate-900 dark:text-white hover:text-orange-600 dark:hover:text-orange-600 items-center justify-center">- @auth- <span id="user_name">{{ Auth::user()->name }}</span>- <img src="storage/avatars/12345.jpg" class="h-7 w-7 rounded-full sm:mx-0 sm:shrink-0 ring-2 ring-orange-600/60 shadow-lg">-- @else- <span id="user_name_unauth" class="w-[10vw] text-right">Guest</span>- <img src="storage/avatars/12345.jpg" class="h-7 w-7 rounded-full sm:mx-0 sm:shrink-0 ring-2 ring-orange-600/60 shadow-lg">- @endauth-- </button>- </section>--- <section id="navbar-video" class="flex items-center space-x-2">- <button id="btn-nav-folders" class="flex justify-center items-center shrink-0 h-8 w-8 rounded-lg shadow-lg bg-red-300 hover:bg-red-200 bg-gray-300 hover:bg-slate-200">- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" height="24" width="24" class="stroke-slate-900">- <path stroke-linecap="round" stroke-linejoin="round" d="M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 0 0-1.883 2.542l.857 6a2.25 2.25 0 0 0 2.227 1.932H19.05a2.25 2.25 0 0 0 2.227-1.932l.857-6a2.25 2.25 0 0 0-1.883-2.542m-16.5 0V6A2.25 2.25 0 0 1 6 3.75h3.879a1.5 1.5 0 0 1 1.06.44l2.122 2.12a1.5 1.5 0 0 0 1.06.44H18A2.25 2.25 0 0 1 20.25 9v.776" />- </svg>- </button>- @auth- <button id="btn-nav-history" class="flex justify-center items-center shrink-0 h-8 w-8 rounded-lg shadow-lg bg-purple-300 hover:bg-purple-200">- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" height="24" width="24" class="fill-slate-900">- <path d="M0 0h24v24H0z" fill="none" />- <path fill-rule="evenodd" d="M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z" />- </svg>- </button>- <button id="btn-nav-settings" class=" hidden flex justify-center items-center shrink-0 h-8 w-8 rounded-lg shadow-lg bg-red-300 hover:bg-red-200">- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" height="24" width="24" class="fill-slate-900">- <path fill-rule="evenodd" d="M3 6.75A.75.75 0 0 1 3.75 6h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 6.75ZM3 12a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 12Zm0 5.25a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75Z" clip-rule="evenodd" />- </svg>- </button>- @endauth- </section>-- <div class="toggle-switch shrink-0">- <label class="switch-label">- <input type="checkbox" class="checkbox invisible" id="dark-mode-toggle">- <span class="slider"></span>- </label>- </div>- </span>- <h1 id="mp4-title-folder" class="text-2xl w-full"></h1>- </div>- <hr class="mt-2 mb-3">- </nav>- <section id="content-video">- <div id="video-container">- <video id="vid-source" width="100%" src="" type="video/mp4" controls class="focus:outline-none">- </video>-- <hr class="mt-4 mb-3">-- <div class="p-6 my-4 w-full mx-auto dark:bg-neutral-800 bg-white rounded-xl shadow-lg flex justify-between space-x-4">- <div class="flex items-center space-x-4">- <div class="shrink-0">- <img class="h-12 w-12" src="storage/avatars/12345.jpg" alt="ChitChat Logo">- </div>- <div>- <div id="mp4-title" class="text-xl font-medium">ChitChat</div>- <p class="dark:text-slate-400 text-slate-500">This episode is about a walrus going for a juice box run at 3am</p>- </div>- </div>- <div id="mp4-controls" class="my-auto container flex w-auto" role="group">- <button type="button" class="bg-gray-800 text-white rounded-l-md border-r border-gray-100 py-2 hover:bg-red-700 hover:text-white px-3 shadow-xl">- <div class="flex flex-row align-middle">- <svg class="w-5 mr-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">- <path fill-rule="evenodd" d="M7.707 14.707a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l2.293 2.293a1 1 0 010 1.414z" clip-rule="evenodd"></path>- </svg>- <p class="ml-2">Prev</p>- </div>- </button>- <button type="button" class="bg-gray-800 text-white rounded-r-md py-2 border-l border-gray-200 hover:bg-red-700 hover:text-white px-3 shadow-xl">- <div class="flex flex-row align-middle">- <span class="mr-2">Next</span>- <svg class="w-5 ml-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">- <path fill-rule="evenodd" d="M12.293 5.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-2.293-2.293a1 1 0 010-1.414z" clip-rule="evenodd"></path>- </svg>- </div>- </button>- </div>- </div>- </div>-- <hr id='preData' class="my-4">-- <div id='dataContainer'></div>- </section>-- <section id="content-history">-- </section>- </section>- <section id="left-card" class="w-full lg:w-[15%]"></section>- </main>-</x-app-layout>\ No newline at end of filediff --git a/routes/api.php b/routes/api.phpindex 1adfb481..4aeb926c 100644--- a/routes/api.php+++ b/routes/api.php@@ -1,6 +1,8 @@<?phpuse App\Http\Controllers\Api\V1\AuthController;+use App\Http\Controllers\Api\V1\FolderController;+use App\Http\Controllers\Api\V1\VideoController;use App\Http\Controllers\ProfileController;use App\Http\Controllers\RecordController;use Illuminate\Http\Request;@@ -14,6 +16,8 @@ Route::middleware('auth:sanctum')->get('/user', function (Request $request) {Route::post('/login', [AuthController::class, 'login']);Route::post('/register', [AuthController::class, 'register']);+Route::post('/videos', [VideoController::class, 'getFrom']);+Route::post('/folders', [FolderController::class, 'getFrom']);// protecteddiff --git a/routes/web.php b/routes/web.phpindex d52b18cc..8d94a64b 100644--- a/routes/web.php+++ b/routes/web.php@@ -15,24 +15,10 @@ use App\Http\Controllers\DirectoryController;|*/-Route::get('/welcome', function () {- return view('welcome');-});--Route::get('/testing', function () {- return view('testing', ['dir' => 'anime', 'folder_name' => 'ODDTAXI']);-})->name('testing');;--Route::get('/', function () {- return view('testing', ['dir' => 'anime', 'folder_name' => null]);-});--// Route::get('/account', function () {-// return view('account', ['dir' => 'none', 'folder_name' => null]);-// });---+// public+Route::get('/', function () { return view('home', ['dir' => 'anime', 'folder_name' => null]); })->name('home');+Route::get('/testing', function () { return redirect()->route('home'); })->name('testing');+Route::get('/welcome', function () { return view('welcome'); });Route::get('login', [AuthController::class, 'create'])->name('login');Route::post('login', [AuthController::class, 'login'])->name('login');@@ -43,6 +29,8 @@ Route::post('register', [AuthController::class, 'register'])->name('register');Route::get('/{dir}', [DirectoryController::class, 'showDirectory']);Route::get('/{dir}/{folder_name}', [DirectoryController::class, 'showDirectory']);+// private+Route::middleware('auth')->group(function () {Route::post('/logout', [AuthController::class, 'destroy'])->name('logout');@@ -51,24 +39,12 @@ Route::middleware('auth')->group(function () {Route::get('/test/folders/{dir}', [DirectoryController::class, 'getDirectoryContents']);Route::get('/test/videos/{folder_name}/{category_id}', [DirectoryController::class, 'getFolderContents']);- Route::get('/{dir}', [DirectoryController::class, 'showDirectoryTest']);- Route::get('/{dir}/{folder_name}', [DirectoryController::class, 'showDirectoryTest']);-- // Route::get('/{dir}', function ($dir) {- // return view('testing', ['dir' => $dir]);- // });- // Route::get('/{dir}/{folder_name}', function ($dir,$folder_name) {- // return view('testing', ['dir' => $dir, 'folder_name' => $folder_name]);- // });+ Route::get('/{dir}', [DirectoryController::class, 'showDirectory']);+ Route::get('/{dir}/{folder_name}', [DirectoryController::class, 'showDirectory']);});----+// oldRoute::post('/ajax/generateDir', [DirectoryController::class, 'generateDirectory']);-Route::post('/ajax/getFolders', [DirectoryController::class, 'getDirectoryContents']);Route::post('/ajax/getVideos', [DirectoryController::class, 'getFolderContents']);--+Route::get('/jobs/indexFiles', [DirectoryController::class, 'indexFiles']);\ No newline at end of file