forked from projects/thebadspace
Compare commits
3 commits
Author | SHA1 | Date | |
---|---|---|---|
2932af0d3f | |||
0eeab6355e | |||
43e0004ac5 |
14 changed files with 155 additions and 78 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,6 +4,7 @@
|
||||||
/public/hot
|
/public/hot
|
||||||
/public/storage
|
/public/storage
|
||||||
/public/reference
|
/public/reference
|
||||||
|
/public/assets/images/references
|
||||||
/storage/*.key
|
/storage/*.key
|
||||||
/vendor
|
/vendor
|
||||||
.env
|
.env
|
||||||
|
|
|
@ -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)
|
public function member(Request $request)
|
||||||
{
|
{
|
||||||
$member = Auth::user();
|
$member = Auth::user();
|
||||||
|
|
|
@ -79,12 +79,16 @@ 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
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -57,23 +57,33 @@ class LocationRepository
|
||||||
public function editLocation($request)
|
public function editLocation($request)
|
||||||
{
|
{
|
||||||
$location = $this->getLocation($request->id);
|
$location = $this->getLocation($request->id);
|
||||||
|
$publicPath = '../public/';
|
||||||
|
$refPath = 'assets/images/references/' . $location->uuid;
|
||||||
$images = [];
|
$images = [];
|
||||||
if ($request->hasfile("references")) {
|
if ($request->hasfile("references")) {
|
||||||
foreach ($request->references as $file) {
|
foreach ($request->references as $file) {
|
||||||
$path = $file->store('reference');
|
if (!is_dir($publicPath . $refPath)) {
|
||||||
array_push($images, ["path" => $path]);
|
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)]);
|
$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 -IMG- " . $request->hasfile("references")];
|
return ['status' => true, 'message' => "Location Editited" . $request->hasfile("references")];
|
||||||
} else {
|
} else {
|
||||||
return ['status' => false, 'message' => "Location Not Editited"];
|
return ['status' => false, 'message' => "Location Not Editited"];
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,16 @@ 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()
|
||||||
|
@ -20,30 +26,64 @@ class SourceRepository
|
||||||
return $this->source::where("active", true)->get();
|
return $this->source::where("active", true)->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateSourceData()
|
public function updateSourceData($index = 0)
|
||||||
{
|
{
|
||||||
$sources = $this->getActive();
|
|
||||||
$missing = [];
|
|
||||||
$checked = [];
|
|
||||||
//checks all the sources to refresh data
|
//checks all the sources to refresh data
|
||||||
foreach ($sources as $source) {
|
$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)
|
||||||
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
if ($source['type'] == 'mastodon') {
|
if ($source['type'] == 'mastodon') {
|
||||||
if ($source['token'] == null) {
|
if ($source['token'] == null) {
|
||||||
try {
|
try {
|
||||||
$result = \Mastodon::domain('https://' . $source['url'])
|
$result = \Mastodon::domain('https://' . $source['url'])
|
||||||
->get('/instance/domain_blocks');
|
->get('/instance/domain_blocks');
|
||||||
array_push($checked, ['source' => $source->url]);
|
|
||||||
} catch (ConnectException $e) {
|
} catch (ConnectException $e) {
|
||||||
array_push($missing, ['source' => $source->url]);
|
//TODO: Logo Errors
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
$result = \Mastodon::domain('https://' . $source['url'])
|
$result = \Mastodon::domain('https://' . $source['url'])
|
||||||
->token($source['token'])
|
->token($source['token'])
|
||||||
->get('/instance/domain_blocks');
|
->get('/instance/domain_blocks');
|
||||||
array_push($checked, ['source' => $source->url]);
|
|
||||||
} catch (ConnectException $e) {
|
} catch (ConnectException $e) {
|
||||||
|
//TODO: Logo Errors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($source['type'] == 'custom' && $source['format'] == 'csv') {
|
} elseif ($source['type'] == 'custom' && $source['format'] == 'csv') {
|
||||||
|
@ -60,11 +100,6 @@ class SourceRepository
|
||||||
array_push($missing, ['source' => $source->url]);
|
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];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,11 @@ class UpdateService
|
||||||
public function data()
|
public function data()
|
||||||
{
|
{
|
||||||
$response = $this->source->updateSourceData();
|
$response = $this->source->updateSourceData();
|
||||||
return count($response['checked']) . ' SOURCES UPDATED - ' .
|
if ($response['updated'] == 'true') {
|
||||||
count($response['notchecked']) . ' SOURCES NOT CHECKED';
|
return count($response['checked']) . ' SOURCES UPDATED';
|
||||||
|
} else {
|
||||||
|
return 'NO SOURCES PRESENT';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function list()
|
public function list()
|
||||||
|
@ -34,13 +37,14 @@ class UpdateService
|
||||||
$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
|
//if there is a match, update the count and comment
|
||||||
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);
|
||||||
|
@ -48,6 +52,9 @@ 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;
|
||||||
|
@ -74,6 +81,12 @@ 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) {
|
||||||
|
@ -86,6 +99,12 @@ 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'];
|
||||||
|
|
||||||
|
|
|
@ -199,9 +199,8 @@ footer {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
height: auto;
|
height: auto;
|
||||||
width: 80%;
|
width: auto;
|
||||||
margin: 20px auto;
|
margin: 20px auto;
|
||||||
max-width: 1000px;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
<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
|
12
resources/views/back/profile.blade.php
Normal file
12
resources/views/back/profile.blade.php
Normal 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
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="theme-color" content="#d66365" />
|
<meta name="theme-color" content="#c3639e" />
|
||||||
<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')
|
||||||
|
|
|
@ -38,27 +38,8 @@
|
||||||
@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>Locations Tracked</label>
|
<label>Active Locations Tracked</label>
|
||||||
<label>{{$count}}</label>
|
<label>{{$count}}</label>
|
||||||
<label>Total Sources</label>
|
<label>Total Sources</label>
|
||||||
<label>{{$sources}}</label>
|
<label>{{$sources}}</label>
|
||||||
|
|
|
@ -7,12 +7,16 @@
|
||||||
<section>
|
<section>
|
||||||
<article>
|
<article>
|
||||||
<h2>Description</h2>
|
<h2>Description</h2>
|
||||||
{{$location->description}}<br />
|
@foreach($comments as $comment)
|
||||||
|
@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
|
||||||
|
@ -21,6 +25,9 @@
|
||||||
$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" />
|
||||||
|
|
|
@ -40,6 +40,7 @@ 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']);
|
||||||
|
|
Loading…
Reference in a new issue