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.
This commit is contained in:
ro 2024-09-13 15:12:43 -06:00
parent 43e0004ac5
commit 0eeab6355e
10 changed files with 50 additions and 18 deletions

1
.gitignore vendored
View file

@ -4,6 +4,7 @@
/public/hot
/public/storage
/public/reference
/public/assets/images/references
/storage/*.key
/vendor
.env

View file

@ -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();

View file

@ -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
]);

View file

@ -57,23 +57,33 @@ class LocationRepository
public function editLocation($request)
{
$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]);
}
}
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"];
}

View file

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

View file

@ -24,7 +24,7 @@
<h3>Images</h3>
@if($images != null)
@foreach($images as $image)
<a href="/{{$image->path}}" class="location-image" style="background: url(/{{$image->path}}) no-repeat center center / cover #fc6399" />
<a href="{{$image->path}}" class="location-image" style="background: url({{$image->path}}) no-repeat center center / cover #fc6399" />
</a>
@endforeach
@endif

View file

@ -6,8 +6,6 @@
<section>
<article>
<h2>Member Listing </h2>
<a href="/den/admin/update">UPDATE LOCATIONS</a><br />
<a href="/den/admin/compile">COMPILE LOCATIONS</a>
</article>
</section>
@endsection

View file

@ -0,0 +1,12 @@
@extends('frame')
@section('title', 'Den | Your Profile')
@section('main-content')
<section>
<article>
<h2>Edit Profile Deets </h2>
Hi. This is where you change stuff.
</article>
</section>
@endsection

View file

@ -12,7 +12,7 @@
<h3>Images</h3>
@if($images != null)
@foreach($images as $image)
<a href="/{{$image->path}}" class="location-image" style="background: url(/{{$image->path}}) no-repeat center center / cover #fc6399" />
<a href="{{$image->path}}" class="location-image" style="background: url({{$image->path}}) no-repeat center center / cover #fc6399" />
</a>
@endforeach
@endif
@ -21,6 +21,9 @@
$rating = floor(($action / $sources_count)*100);
@endphp
<h3>Links</h3>
@foreach($links as $link)
<a href="{{$link}}">{{$link}}</a><br />
@endforeach
<div class="location-rating">
<div>
<img class="rating-icon" src="/assets/images/global/heat.svg" title="heat-rating" />

View file

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