Compare commits

..

No commits in common. "develop" and "develop" have entirely different histories.

14 changed files with 79 additions and 156 deletions

1
.gitignore vendored
View file

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

View file

@ -34,16 +34,6 @@ 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) public function member(Request $request)
{ {
$member = Auth::user(); $member = Auth::user();

View file

@ -79,16 +79,12 @@ class FrontIndexController extends Controller
($member->role == 1 || $member->role == 2) ? $edit = true : $edit = false; ($member->role == 1 || $member->role == 2) ? $edit = true : $edit = false;
} }
$links = explode(',', $location->archive_links);
$comments = explode('+', $location->description);
return view('front.location', [ return view('front.location', [
'title' => str_replace(".", " ", $name), 'title' => str_replace(".", " ", $name),
'location' => $location, 'location' => $location,
'comments' => $comments,
'actions' => $location->block_count + $location->silence_count, 'actions' => $location->block_count + $location->silence_count,
'sources_count' => count($sources), 'sources_count' => count($sources),
'images' => json_decode($location->images), 'images' => json_decode($location->images),
'links' => $links,
'updated' => $location->updated_at->format('Y M d'), 'updated' => $location->updated_at->format('Y M d'),
'edit' => $edit 'edit' => $edit
]); ]);

View file

@ -56,34 +56,24 @@ class LocationRepository
public function editLocation($request) public function editLocation($request)
{ {
$location = $this->getLocation($request->id); $location = $this->getLocation($request->id);
$publicPath = '../public/'; $images = [];
$refPath = 'assets/images/references/' . $location->uuid;
$images = [];
if ($request->hasfile("references")) { if ($request->hasfile("references")) {
foreach ($request->references as $file) { foreach ($request->references as $file) {
if (!is_dir($publicPath . $refPath)) { $path = $file->store('reference');
mkdir($publicPath . $refPath, 0755, true); array_push($images, ["path" => $path]);
}
$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)]);
$request->merge(['images' => json_encode($images)]);
$location->images = json_encode($images);
}
$location->name = $request->name; $location->name = $request->name;
$location->description = $request->description; $location->description = $request->description;
$location->archive_links = $request->archive_links; $location->archive_links = $request->archive_links;
$location->images = json_encode($images);
$result = []; $result = [];
if ($location->save()) { if ($location->save()) {
return ['status' => true, 'message' => "Location Editited" . $request->hasfile("references")]; return ['status' => true, 'message' => "Location Editited -IMG- " . $request->hasfile("references")];
} else { } else {
return ['status' => false, 'message' => "Location Not Editited"]; return ['status' => false, 'message' => "Location Not Editited"];
} }

View file

@ -9,16 +9,10 @@ use GuzzleHttp\Exception\ConnectException;
class SourceRepository class SourceRepository
{ {
protected $source; protected $source;
protected $missing;
protected $updated;
protected $sources;
public function __construct(Source $source) public function __construct(Source $source)
{ {
$this->source = $source; $this->source = $source;
$this->missing = [];
$this->updated = [];
$this->sources = $source::where("active", true)->get();
} }
public function getActive() public function getActive()
@ -26,80 +20,51 @@ class SourceRepository
return $this->source::where("active", true)->get(); return $this->source::where("active", true)->get();
} }
public function updateSourceData($index = 0) public function updateSourceData()
{ {
$sources = $this->getActive();
$missing = [];
$checked = [];
//checks all the sources to refresh data //checks all the sources to refresh data
$count = count($this->sources); foreach ($sources as $source) {
if ($count == 0) { $result = [];
return [ if ($source['type'] == 'mastodon') {
'checked' => $this->updated, if ($source['token'] == null) {
'notchecked' => $this->missing, try {
'count' => $count, $result = \Mastodon::domain('https://' . $source['url'])
'updated' => 'false', ->get('/instance/domain_blocks');
]; array_push($checked, ['source' => $source->url]);
} else { } catch (ConnectException $e) {
//check index array_push($missing, ['source' => $source->url]);
if ($index <= $count - 1) { }
$source = $this->sources[$index];
$result = $this->getMastoBlocklist($source);
if (count($result) > 0) {
$source->list_data = json_encode($result);
$source->last_updated = Carbon::now();
$source->save();
array_push($this->updated, ['source' => $source->url]);
$index++;
$result = $this->updateSourceData($index);
} else { } else {
//if empty run the same index again try {
array_push($this->missing, ['source' => $source->url]); $result = \Mastodon::domain('https://' . $source['url'])
$result = $this->updateSourceData($index); ->token($source['token'])
->get('/instance/domain_blocks');
array_push($checked, ['source' => $source->url]);
} catch (ConnectException $e) {
}
}
} elseif ($source['type'] == 'custom' && $source['format'] == 'csv') {
try {
$denylist = array_map('str_getcsv', file('https://' . $source['url']));
foreach ($denylist as $item) {
array_push($result, [
'domain' => $item[0],
'severity' => $item[1],
'comment' => $item[2]]);
}
array_push($checked, ['source' => $source->url]);
} catch (Exception $e) {
array_push($missing, ['source' => $source->url]);
} }
} else {
//continue
} }
return [
'checked' => $this->updated,
'notchecked' => $this->missing,
'count' => $count,
'updated' => 'true',
];
}
}
private function getMastoBlocklist($source) $source->list_data = json_encode($result);
{ $source->last_updated = Carbon::now();
$result = []; $source->save();
if ($source['type'] == 'mastodon') {
if ($source['token'] == null) {
try {
$result = \Mastodon::domain('https://' . $source['url'])
->get('/instance/domain_blocks');
} catch (ConnectException $e) {
//TODO: Logo Errors
}
} else {
try {
$result = \Mastodon::domain('https://' . $source['url'])
->token($source['token'])
->get('/instance/domain_blocks');
} catch (ConnectException $e) {
//TODO: Logo Errors
}
}
} elseif ($source['type'] == 'custom' && $source['format'] == 'csv') {
try {
$denylist = array_map('str_getcsv', file('https://' . $source['url']));
foreach ($denylist as $item) {
array_push($result, [
'domain' => $item[0],
'severity' => $item[1],
'comment' => $item[2]]);
}
array_push($checked, ['source' => $source->url]);
} catch (Exception $e) {
array_push($missing, ['source' => $source->url]);
}
} }
return $result; return ['checked' => $checked, 'notchecked' => $missing];
} }
} }

View file

@ -23,11 +23,8 @@ class UpdateService
public function data() public function data()
{ {
$response = $this->source->updateSourceData(); $response = $this->source->updateSourceData();
if ($response['updated'] == 'true') { return count($response['checked']) . ' SOURCES UPDATED - ' .
return count($response['checked']) . ' SOURCES UPDATED'; count($response['notchecked']) . ' SOURCES NOT CHECKED';
} else {
return 'NO SOURCES PRESENT';
}
} }
public function list() public function list()
@ -36,15 +33,14 @@ class UpdateService
$fresh = 0; $fresh = 0;
$unified = []; $unified = [];
$sources = $this->source->getActive(); $sources = $this->source->getActive();
$locations = $this->location->getActiveLocations();
foreach ($sources as $source) { foreach ($sources as $source) {
//$listData = json_decode(); //$listData = json_decode();
foreach (json_decode($source->list_data) as $item) { foreach (json_decode($source->list_data) as $item) {
$index = array_search($item->domain, array_column($unified, 'url')); $index = array_search($item->domain, array_column($unified, 'url'));
if ($index) { if ($index) {
//if there is a match, update the count and comment //if there is a match, update the count
if ($item->severity == "suspend" || $item->severity == "defederate") { if ($item->severity == "suspend" || $item->severity == "defederate") {
++$unified[$index]['block_count']; ++$unified[$index]['block_count'];
array_push($unified[$index]['block_vote'], $source->url); array_push($unified[$index]['block_vote'], $source->url);
@ -52,9 +48,6 @@ class UpdateService
++$unified[$index]['silence_count']; ++$unified[$index]['silence_count'];
array_push($unified[$index]['silence_vote'], $source->url); array_push($unified[$index]['silence_vote'], $source->url);
} }
if (!is_null($item->comment) && $item->comment != ' ' && $item->comment != '') {
$unified[$index]['comment'] = $item->comment . '+' . $unified[$index]['comment'];
}
} else { } else {
$silence = 0; $silence = 0;
$suspend = 0; $suspend = 0;
@ -81,12 +74,6 @@ class UpdateService
} }
} }
//clear out all previous descriptions
foreach ($locations as $loc) {
$loc->description = ' ';
$loc->save();
}
foreach ($unified as $item) { foreach ($unified as $item) {
$location = $this->location->getLocation($item['url']); $location = $this->location->getLocation($item['url']);
if ($location) { if ($location) {
@ -99,12 +86,6 @@ class UpdateService
$location->silence_count = $item['silence_count']; $location->silence_count = $item['silence_count'];
$location->silence_vote = []; $location->silence_vote = [];
$location->silence_vote = $item['silence_vote']; $location->silence_vote = $item['silence_vote'];
//clear descriptions
if (!is_null($item['comment']) || !$item['comment'] != " ") {
$location->description = $item['comment'];
} else {
$location->description = 'description pending';
}
$location->actions_count = $item['block_count'] + $item['silence_count']; $location->actions_count = $item['block_count'] + $item['silence_count'];

View file

@ -199,8 +199,9 @@ footer {
padding: 10px; padding: 10px;
gap: 10px; gap: 10px;
height: auto; height: auto;
width: auto; width: 80%;
margin: 20px auto; margin: 20px auto;
max-width: 1000px;
position: relative; position: relative;
} }

View file

@ -24,7 +24,7 @@
<h3>Images</h3> <h3>Images</h3>
@if($images != null) @if($images != null)
@foreach($images as $image) @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> </a>
@endforeach @endforeach
@endif @endif

View file

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

View file

@ -1,12 +0,0 @@
@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

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="theme-color" content="#c3639e" /> <meta name="theme-color" content="#d66365" />
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title> <title>
@yield('title') @yield('title')

View file

@ -38,8 +38,27 @@
@endisset @endisset
<section class="index-meta"> <section class="index-meta">
<article> <article>
<h2>Recent Updates</h2>
@foreach($recent as $item)
<a class="list-link" role="listitem" href="/location/{{$item->uuid}}">
@php
$rating = floor(($item->actions_count / $sources)*100);
@endphp
<span class="item-rating">{{$rating}}%</span>
<label class="item-name">{{$item->name}}</label>
<div class="item-silence">
<img class="item-icon" src="/assets/images/global/status-silence.svg" title="silenced" />
{{$item->silence_count}}
</div>
<div class="item-block">
<img class="item-icon" src="/assets/images/global/status-suspend.svg" title="suspended" />
{{$item->block_count}}
</div>
</a>
@endforeach
<h2>Info</h2>
<div class="index-meta"> <div class="index-meta">
<label>Active Locations Tracked</label> <label>Locations Tracked</label>
<label>{{$count}}</label> <label>{{$count}}</label>
<label>Total Sources</label> <label>Total Sources</label>
<label>{{$sources}}</label> <label>{{$sources}}</label>

View file

@ -7,16 +7,12 @@
<section> <section>
<article> <article>
<h2>Description</h2> <h2>Description</h2>
@foreach($comments as $comment) {{$location->description}}<br />
@if($comment != " " && $comment != '')
{{trim($comment)}}<br /><br />
@endif
@endforeach
<h2>References</h2> <h2>References</h2>
<h3>Images</h3> <h3>Images</h3>
@if($images != null) @if($images != null)
@foreach($images as $image) @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> </a>
@endforeach @endforeach
@endif @endif
@ -25,9 +21,6 @@
$rating = floor(($action / $sources_count)*100); $rating = floor(($action / $sources_count)*100);
@endphp @endphp
<h3>Links</h3> <h3>Links</h3>
@foreach($links as $link)
<a href="{{$link}}">{{$link}}</a><br />
@endforeach
<div class="location-rating"> <div class="location-rating">
<div> <div>
<img class="rating-icon" src="/assets/images/global/heat.svg" title="heat-rating" /> <img class="rating-icon" src="/assets/images/global/heat.svg" title="heat-rating" />

View file

@ -40,7 +40,6 @@ Route::get("/logout", [AuthController::class, 'leave']);
//back //back
Route::group(['prefix' => 'den', 'middleware' => 'member.check'], function () { Route::group(['prefix' => 'den', 'middleware' => 'member.check'], function () {
Route::get("/", [DenController::class, 'start']); Route::get("/", [DenController::class, 'start']);
Route::get("/you", [DenController::class, 'profile']);
Route::get("/member", [DenController::class, 'member']); Route::get("/member", [DenController::class, 'member']);
Route::get("/listings/{pageNum}", [DenController::class, 'location']); Route::get("/listings/{pageNum}", [DenController::class, 'location']);
Route::get("/location/edit/{uuid}", [DenController::class, 'locationEdit']); Route::get("/location/edit/{uuid}", [DenController::class, 'locationEdit']);