From 175ea25d7b7738657a7ea9d1345564a581876547 Mon Sep 17 00:00:00 2001
From: ro
Date: Tue, 23 Jan 2024 12:04:52 -0600
Subject: [PATCH] Updated search and listing links, added new icons
Search methodolgy has been tweaked and the correspending result links
have been updated, as well as links in the Listing page to display both
silence and suspend counts and the overall heat rating.
Also plugged in new silence and suspend icons provideb by
https://rage.love/@puf. Big thanks for that, man.
---
app/Http/Controllers/FrontIndexController.php | 75 +++++++++++++------
public/assets/css/front/listing.css | 2 +
.../assets/images/global/status-silence.svg | 4 +-
.../assets/images/global/status-suspend.svg | 4 +-
resources/views/front/about.blade.php | 1 +
resources/views/front/index.blade.php | 26 +++++--
resources/views/front/listing.blade.php | 22 ++++--
7 files changed, 92 insertions(+), 42 deletions(-)
diff --git a/app/Http/Controllers/FrontIndexController.php b/app/Http/Controllers/FrontIndexController.php
index 58555dc..43723b4 100644
--- a/app/Http/Controllers/FrontIndexController.php
+++ b/app/Http/Controllers/FrontIndexController.php
@@ -11,24 +11,24 @@ class FrontIndexController extends Controller
{
private $limit = 15;
- public function start()
+ private function getRecent()
{
- $sources = Source::where("active", true)->get();
$locations = Location::where("active", true)->orderByDesc('updated_at')->get();
$list = [];
foreach ($locations as $location) {
- if (($location->block_count + $location->silence_count) > 2) {
+ if (($location->block_count + $location->silence_count) >= 2) {
array_push($list, $location);
}
}
+ return $list;
+ }
- $recentList = Location::where("active", true)
- ->where('block_count', '>', 2)
- ->limit(10)->orderByDesc('updated_at')->get();
-
+ public function start()
+ {
+ $list = $this->getRecent();
return view('front.index', [
'count' => count($list),
- 'sources' => count($sources),
+ 'sources' => count(Source::where("active", true)->get()),
'recent' => $list,
'title' => "The Bad Space"
]);
@@ -36,6 +36,7 @@ class FrontIndexController extends Controller
public function indexSearch(Request $request)
{
+ // this grabs the search results from the db
$terms = $request->index_search;
$rawSearch = $terms;
$terms = str_replace(",", "", $terms);
@@ -48,18 +49,17 @@ class FrontIndexController extends Controller
}
}
- $locations = Location::where("active", true)->get();
- $count = count($locations);
- $recent = Location::where("active", true)
- ->where('block_count', '>', 2)
- ->where('silence_count', '>', 2)
- ->limit(10)->orderByDesc('updated_at')->get();
+ //this gets recent updates to display under search results
+ $list = $this->getRecent();
return view('front.index', [
- 'count' => $count,
- 'recent' => $recent,
- 'title' => "The Bad Space",
- 'results' => $results
+ 'count' => count($list),
+ 'sources' => count(Source::where("active", true)->get()),
+ 'recent' => $list,
+ 'results' => $results,
+ 'recent' => $list,
+ 'terms' => $terms,
+ 'title' => "Search Results",
]);
}
@@ -92,12 +92,40 @@ class FrontIndexController extends Controller
public function listings(int $pageNum = 1)
{
- $range = $pageNum * $this->limit - $this->limit;
- $active = Location::where("active", true)->where('block_count', '>', 2)->get();
- $locations = Location::where("active", true)->where('block_count', '>', 2)
- ->limit($this->limit)->offset($range)->orderByDesc('id')->get();
+ $locations = Location::where("active", true)->get();
+ $active = [];
+ foreach ($locations as $location) {
+ if (($location->block_count + $location->silence_count) >= 2) {
+ array_push($active, $location);
+ }
+ }
+
+ $pages = [];
+
+ if (count($active) != 0) {
+ if (count($active) < $this->limit) {
+ $this->limit = count($active) - 1;
+ }
+ $range = $pageNum * $this->limit - $this->limit;
+
+ if ($range != 0) {
+ $range = $range + 1;
+ }
+ for ($i = 0; $i <= $this->limit; ++$i) {
+ if (isset($active[$i + $range])) {
+ array_push($pages, $active[$i + $range]);
+ } else {
+ // chill out
+ }
+ }
+ }
+
$pageCount = ceil(count($active) / $this->limit);
+ if ($range != 0) {
+ $range = $range + 1;
+ }
+
$next = $pageNum + 1;
if ($next > $pageCount) {
$next = 1;
@@ -111,11 +139,12 @@ class FrontIndexController extends Controller
return view('front.listing', [
'title' => "Listings",
+ 'sources' => count(Source::where("active", true)->get()),
"totalPages" => $pageCount,
"prev" => $prev,
"next" => $next,
'pageNum' => $pageNum,
- 'locations' => $locations
+ 'locations' => $pages
]);
}
}
diff --git a/public/assets/css/front/listing.css b/public/assets/css/front/listing.css
index 9c19ae3..7f7e96b 100644
--- a/public/assets/css/front/listing.css
+++ b/public/assets/css/front/listing.css
@@ -42,6 +42,7 @@ a.list-link {
width: 80%;
height: 45px;
padding-bottom: 20px;
+ cursor: pointer;
}
a.list-link > .item-rating {
@@ -58,6 +59,7 @@ a.list-link > .item-name {
color: var(--black);
font-weight: 400;
padding: 9px 5px;
+ cursor: pointer;
}
a.list-link > .item-silence {
diff --git a/public/assets/images/global/status-silence.svg b/public/assets/images/global/status-silence.svg
index 38eccda..aa05225 100644
--- a/public/assets/images/global/status-silence.svg
+++ b/public/assets/images/global/status-silence.svg
@@ -1,6 +1,6 @@
diff --git a/public/assets/images/global/status-suspend.svg b/public/assets/images/global/status-suspend.svg
index b0e0d08..58e4833 100644
--- a/public/assets/images/global/status-suspend.svg
+++ b/public/assets/images/global/status-suspend.svg
@@ -1,6 +1,6 @@
diff --git a/resources/views/front/about.blade.php b/resources/views/front/about.blade.php
index 0ccde1d..6dcd9e4 100644
--- a/resources/views/front/about.blade.php
+++ b/resources/views/front/about.blade.php
@@ -20,6 +20,7 @@
Technical support provided by
Ro. The repo can be found here.
+
Custom silence and suspend icons graciously provided by puf.
How does it work?
The Bad Space is a collaboration of instances committed to actively moderating against racism, sexism, heterosexism, transphobia, ableism, casteism, or religion.