From 0eeab6355e453fb4609198c1025345e1f70856ab Mon Sep 17 00:00:00 2001 From: ro Date: Fri, 13 Sep 2024 15:12:43 -0600 Subject: [PATCH] updated image uploading, edited html templates changed the the way files are uploaded to go into their own directory called 'references' organized by location, identified by uuid. the 'references' directory was added to git ignore to those images are not saved in the repo, since every install will have their own set of images also updated reference links to be shown on the front end if they have been added to a location unnecessary links where moved from the admin member template since they have been incorporated into the appropriate area. a template for editing member account information has also been added. --- .gitignore | 1 + app/Http/Controllers/DenController.php | 10 ++++++++ app/Http/Controllers/FrontIndexController.php | 2 ++ app/Repositories/LocationRepository.php | 24 +++++++++++++------ app/Repositories/SourceRepository.php | 9 ++----- resources/views/back/location.blade.php | 2 +- resources/views/back/member.blade.php | 2 -- resources/views/back/profile.blade.php | 12 ++++++++++ resources/views/front/location.blade.php | 5 +++- routes/web.php | 1 + 10 files changed, 50 insertions(+), 18 deletions(-) create mode 100644 resources/views/back/profile.blade.php diff --git a/.gitignore b/.gitignore index cc4914a..4bbe4c0 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /public/hot /public/storage /public/reference +/public/assets/images/references /storage/*.key /vendor .env diff --git a/app/Http/Controllers/DenController.php b/app/Http/Controllers/DenController.php index 9f2d8fd..a15b3e9 100644 --- a/app/Http/Controllers/DenController.php +++ b/app/Http/Controllers/DenController.php @@ -34,6 +34,16 @@ class DenController extends Controller ]); } + public function profile(Request $request) + { + $member = Auth::user(); + return view('back.profile', [ + 'handle' => $member->handle, + 'title' => "Your Profile", + 'role' => $member->role + ]); + } + public function member(Request $request) { $member = Auth::user(); diff --git a/app/Http/Controllers/FrontIndexController.php b/app/Http/Controllers/FrontIndexController.php index e6e1e83..375b948 100644 --- a/app/Http/Controllers/FrontIndexController.php +++ b/app/Http/Controllers/FrontIndexController.php @@ -79,12 +79,14 @@ class FrontIndexController extends Controller ($member->role == 1 || $member->role == 2) ? $edit = true : $edit = false; } + $links = explode(',', $location->archive_links); return view('front.location', [ 'title' => str_replace(".", " ", $name), 'location' => $location, 'actions' => $location->block_count + $location->silence_count, 'sources_count' => count($sources), 'images' => json_decode($location->images), + 'links' => $links, 'updated' => $location->updated_at->format('Y M d'), 'edit' => $edit ]); diff --git a/app/Repositories/LocationRepository.php b/app/Repositories/LocationRepository.php index 28425be..47227d9 100644 --- a/app/Repositories/LocationRepository.php +++ b/app/Repositories/LocationRepository.php @@ -56,24 +56,34 @@ class LocationRepository public function editLocation($request) { - $location = $this->getLocation($request->id); - $images = []; + $location = $this->getLocation($request->id); + $publicPath = '../public/'; + $refPath = 'assets/images/references/' . $location->uuid; + $images = []; if ($request->hasfile("references")) { foreach ($request->references as $file) { - $path = $file->store('reference'); - array_push($images, ["path" => $path]); + if (!is_dir($publicPath . $refPath)) { + mkdir($publicPath . $refPath, 0755, true); + } + $filename = urlencode($file->getClientOriginalName()); + $file->move($publicPath . $refPath, $filename); + //$path = $file->store('reference'); + array_push($images, ["path" => '/' . $refPath . '/' . $filename]); } } - $request->merge(['images' => json_encode($images)]); + if (!empty($images)) { + $request->merge(['images' => json_encode($images)]); + $location->images = json_encode($images); + } + $location->name = $request->name; $location->description = $request->description; $location->archive_links = $request->archive_links; - $location->images = json_encode($images); $result = []; if ($location->save()) { - return ['status' => true, 'message' => "Location Editited -IMG- " . $request->hasfile("references")]; + return ['status' => true, 'message' => "Location Editited" . $request->hasfile("references")]; } else { return ['status' => false, 'message' => "Location Not Editited"]; } diff --git a/app/Repositories/SourceRepository.php b/app/Repositories/SourceRepository.php index 29deab7..25409ca 100644 --- a/app/Repositories/SourceRepository.php +++ b/app/Repositories/SourceRepository.php @@ -28,7 +28,6 @@ class SourceRepository public function updateSourceData($index = 0) { - //$sources = $this->getActive(); //checks all the sources to refresh data $count = count($this->sources); if ($count == 0) { @@ -75,20 +74,16 @@ class SourceRepository try { $result = \Mastodon::domain('https://' . $source['url']) ->get('/instance/domain_blocks'); - //array_push($checked, ['source' => $source->url]); } catch (ConnectException $e) { - //dd($source); - //array_push($missing, ['source' => $source->url]); + //TODO: Logo Errors } } else { try { $result = \Mastodon::domain('https://' . $source['url']) ->token($source['token']) ->get('/instance/domain_blocks'); - //array_push($checked, ['source' => $source->url]); } catch (ConnectException $e) { - //array_push($missing, ['source' => $source->url]); - //dd($source); + //TODO: Logo Errors } } } elseif ($source['type'] == 'custom' && $source['format'] == 'csv') { diff --git a/resources/views/back/location.blade.php b/resources/views/back/location.blade.php index 9de2829..86b4d46 100644 --- a/resources/views/back/location.blade.php +++ b/resources/views/back/location.blade.php @@ -24,7 +24,7 @@

Images

@if($images != null) @foreach($images as $image) - + @endforeach @endif diff --git a/resources/views/back/member.blade.php b/resources/views/back/member.blade.php index 62b033c..3140d9b 100644 --- a/resources/views/back/member.blade.php +++ b/resources/views/back/member.blade.php @@ -6,8 +6,6 @@
@endsection \ No newline at end of file diff --git a/resources/views/back/profile.blade.php b/resources/views/back/profile.blade.php new file mode 100644 index 0000000..41fc901 --- /dev/null +++ b/resources/views/back/profile.blade.php @@ -0,0 +1,12 @@ +@extends('frame') + +@section('title', 'Den | Your Profile') + + @section('main-content') +
+
+

Edit Profile Deets

+ Hi. This is where you change stuff. +
+
+ @endsection \ No newline at end of file diff --git a/resources/views/front/location.blade.php b/resources/views/front/location.blade.php index 0c99bd4..cd48e8b 100644 --- a/resources/views/front/location.blade.php +++ b/resources/views/front/location.blade.php @@ -12,7 +12,7 @@

Images

@if($images != null) @foreach($images as $image) - + @endforeach @endif @@ -21,6 +21,9 @@ $rating = floor(($action / $sources_count)*100); @endphp

Links

+ @foreach($links as $link) + {{$link}}
+ @endforeach
diff --git a/routes/web.php b/routes/web.php index 407e2ae..b4607f5 100644 --- a/routes/web.php +++ b/routes/web.php @@ -40,6 +40,7 @@ Route::get("/logout", [AuthController::class, 'leave']); //back Route::group(['prefix' => 'den', 'middleware' => 'member.check'], function () { Route::get("/", [DenController::class, 'start']); + Route::get("/you", [DenController::class, 'profile']); Route::get("/member", [DenController::class, 'member']); Route::get("/listings/{pageNum}", [DenController::class, 'location']); Route::get("/location/edit/{uuid}", [DenController::class, 'locationEdit']);