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/storage
/public/reference
/public/assets/images/references
/storage/*.key
/vendor
.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)
{
$member = Auth::user();

View file

@ -79,16 +79,12 @@ class FrontIndexController extends Controller
($member->role == 1 || $member->role == 2) ? $edit = true : $edit = false;
}
$links = explode(',', $location->archive_links);
$comments = explode('+', $location->description);
return view('front.location', [
'title' => str_replace(".", " ", $name),
'location' => $location,
'comments' => $comments,
'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,33 +57,23 @@ 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) {
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]);
$path = $file->store('reference');
array_push($images, ["path" => $path]);
}
}
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" . $request->hasfile("references")];
return ['status' => true, 'message' => "Location Editited -IMG- " . $request->hasfile("references")];
} else {
return ['status' => false, 'message' => "Location Not Editited"];
}

View file

@ -9,16 +9,10 @@ use GuzzleHttp\Exception\ConnectException;
class SourceRepository
{
protected $source;
protected $missing;
protected $updated;
protected $sources;
public function __construct(Source $source)
{
$this->source = $source;
$this->missing = [];
$this->updated = [];
$this->sources = $source::where("active", true)->get();
}
public function getActive()
@ -26,64 +20,30 @@ class SourceRepository
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
$count = count($this->sources);
if ($count == 0) {
return [
'checked' => $this->updated,
'notchecked' => $this->missing,
'count' => $count,
'updated' => 'false',
];
} else {
//check index
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 {
//if empty run the same index again
array_push($this->missing, ['source' => $source->url]);
$result = $this->updateSourceData($index);
}
} else {
//continue
}
return [
'checked' => $this->updated,
'notchecked' => $this->missing,
'count' => $count,
'updated' => 'true',
];
}
}
private function getMastoBlocklist($source)
{
foreach ($sources as $source) {
$result = [];
if ($source['type'] == 'mastodon') {
if ($source['token'] == null) {
try {
$result = \Mastodon::domain('https://' . $source['url'])
->get('/instance/domain_blocks');
array_push($checked, ['source' => $source->url]);
} catch (ConnectException $e) {
//TODO: Logo Errors
array_push($missing, ['source' => $source->url]);
}
} else {
try {
$result = \Mastodon::domain('https://' . $source['url'])
->token($source['token'])
->get('/instance/domain_blocks');
array_push($checked, ['source' => $source->url]);
} catch (ConnectException $e) {
//TODO: Logo Errors
}
}
} elseif ($source['type'] == 'custom' && $source['format'] == 'csv') {
@ -100,6 +60,11 @@ class SourceRepository
array_push($missing, ['source' => $source->url]);
}
}
return $result;
$source->list_data = json_encode($result);
$source->last_updated = Carbon::now();
$source->save();
}
return ['checked' => $checked, 'notchecked' => $missing];
}
}

View file

@ -23,11 +23,8 @@ class UpdateService
public function data()
{
$response = $this->source->updateSourceData();
if ($response['updated'] == 'true') {
return count($response['checked']) . ' SOURCES UPDATED';
} else {
return 'NO SOURCES PRESENT';
}
return count($response['checked']) . ' SOURCES UPDATED - ' .
count($response['notchecked']) . ' SOURCES NOT CHECKED';
}
public function list()
@ -37,14 +34,13 @@ class UpdateService
$unified = [];
$sources = $this->source->getActive();
$locations = $this->location->getActiveLocations();
foreach ($sources as $source) {
//$listData = json_decode();
foreach (json_decode($source->list_data) as $item) {
$index = array_search($item->domain, array_column($unified, 'url'));
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") {
++$unified[$index]['block_count'];
array_push($unified[$index]['block_vote'], $source->url);
@ -52,9 +48,6 @@ class UpdateService
++$unified[$index]['silence_count'];
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 {
$silence = 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) {
$location = $this->location->getLocation($item['url']);
if ($location) {
@ -99,12 +86,6 @@ class UpdateService
$location->silence_count = $item['silence_count'];
$location->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'];

View file

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

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,6 +6,8 @@
<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

@ -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>
<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">
<title>
@yield('title')

View file

@ -38,8 +38,27 @@
@endisset
<section class="index-meta">
<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">
<label>Active Locations Tracked</label>
<label>Locations Tracked</label>
<label>{{$count}}</label>
<label>Total Sources</label>
<label>{{$sources}}</label>

View file

@ -7,16 +7,12 @@
<section>
<article>
<h2>Description</h2>
@foreach($comments as $comment)
@if($comment != " " && $comment != '')
{{trim($comment)}}<br /><br />
@endif
@endforeach
{{$location->description}}<br />
<h2>References</h2>
<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
@ -25,9 +21,6 @@
$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,7 +40,6 @@ 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']);