diff --git a/app/Helpers/Global/helpers.php b/app/Helpers/Global/helpers.php index 69b7471..15aee83 100644 --- a/app/Helpers/Global/helpers.php +++ b/app/Helpers/Global/helpers.php @@ -4,3 +4,4 @@ require 'geo_helper.php'; require 'platform_helper.php'; require 'proxy_helper.php'; +require 'route_helper.php'; \ No newline at end of file diff --git a/app/Helpers/Global/route_helper.php b/app/Helpers/Global/route_helper.php new file mode 100644 index 0000000..d95002f --- /dev/null +++ b/app/Helpers/Global/route_helper.php @@ -0,0 +1,13 @@ + strtolower(urlencode($query)), + ]); + } +} diff --git a/app/Http/Controllers/Front/FrontListController.php b/app/Http/Controllers/Front/FrontListController.php index 813da85..ffeae92 100644 --- a/app/Http/Controllers/Front/FrontListController.php +++ b/app/Http/Controllers/Front/FrontListController.php @@ -17,14 +17,14 @@ public function search(Request $request) return redirect()->back(); } - return redirect()->to(route('front.search.results',['query' => $request->input('query')])); + return redirect()->to(get_route_search_result($request->input('query'))); } public function searchResults(Request $request, $query) { $page_type = 'search'; - $query = strtolower($query); + $query = urldecode($query); $breadcrumbs = collect([ ['name' => 'Home', 'url' => route('front.home')], diff --git a/app/Jobs/Tasks/CrawlRssPostTask.php b/app/Jobs/Tasks/CrawlRssPostTask.php index c32159b..a43c1d9 100644 --- a/app/Jobs/Tasks/CrawlRssPostTask.php +++ b/app/Jobs/Tasks/CrawlRssPostTask.php @@ -4,6 +4,7 @@ use App\Jobs\ParseRssPostMetadataJob; use App\Models\RssPost; +use App\Models\ServiceCostUsage; use Exception; use Illuminate\Support\Facades\Http; use League\HTMLToMarkdown\HtmlConverter; @@ -34,7 +35,16 @@ public static function handle(int $rss_post_id) if ($response->successful()) { $raw_html = $response->body(); - $costs['unblocker'] = calculate_smartproxy_cost(round(strlen($raw_html) / 1024, 2), 'rotating_global'); + $cost = calculate_smartproxy_cost(round(strlen($raw_html) / 1024, 2), 'rotating_global'); + + $service_cost_usage = new ServiceCostUsage; + $service_cost_usage->cost = $cost; + $service_cost_usage->name = 'smartproxy-CrawlRssPostTask'; + $service_cost_usage->reference_1 = 'rss_post'; + $service_cost_usage->reference_2 = strval($rss_post_id); + $service_cost_usage->output = null; + $service_cost_usage->save(); + } else { $raw_html = null; $response->throw(); diff --git a/app/Models/RssPost.php b/app/Models/RssPost.php index 55d8a03..08f8cc4 100644 --- a/app/Models/RssPost.php +++ b/app/Models/RssPost.php @@ -8,6 +8,9 @@ use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; +use Spatie\Feed\Feedable; +use Spatie\Feed\FeedItem; + /** * Class RssPost @@ -33,7 +36,7 @@ * @property Carbon|null $updated_at * @property Category|null $category */ -class RssPost extends Model +class RssPost extends Model implements Feedable { protected $table = 'rss_posts'; @@ -68,4 +71,31 @@ public function category() { return $this->belongsTo(Category::class); } + + public function getAllKeywordsAttribute() + { + if (!is_empty($this->keyword_list)) + { + return array_unique(explode(",",$this->keyword_list)); + } + return []; + + } + + public function toFeedItem(): FeedItem + { + return FeedItem::create([ + 'id' => $this->id, + 'title' => $this->title, + 'summary' => $this->bites, + 'updated' => $this->published_at, + // 'link' => route('front.post', ['slug' => $this->slug, 'category_slug' => $this->category->slug]), + 'authorName' => 'FutureWalker', + ]); + } + + public static function getFeedItems() + { + return self::with('category')->where('status', 'published')->latest('published_at')->take(60)->get(); + } } diff --git a/resources/views/front/partials/news_bites.blade.php b/resources/views/front/partials/news_bites.blade.php index 6ca9516..e65a794 100644 --- a/resources/views/front/partials/news_bites.blade.php +++ b/resources/views/front/partials/news_bites.blade.php @@ -57,6 +57,7 @@ class="d-inline text-secondary small">{{ min_read($post->bites) }}
+
The Bite:
{{ $post->bites }}
@if (in_array($post->impact_level, ['medium','high'])) @@ -69,7 +70,7 @@ class="d-inline text-secondary small">{{ min_read($post->bites) }} @endif @if ($post->entities)
- More about: @foreach( $post->keywords as $keyword) {{ $keyword }} @endforeach + More about: @foreach( $post->all_keywords as $keyword) {{ $keyword }} @endforeach
@endif