Add (ai tool submission)
This commit is contained in:
@@ -19,12 +19,11 @@ class Kernel extends ConsoleKernel
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->call(function () {
|
||||
$url_to_crawl = UrlToCrawl::where('is_crawling', false)->inRandomOrder()->first();
|
||||
$url_to_crawl = UrlToCrawl::where('is_crawling', false)->inRandomOrder()->first();
|
||||
|
||||
if (!is_null($url_to_crawl))
|
||||
{
|
||||
GetUrlBodyJob::dispatch($url_to_crawl->id)->onQueue('default')->onConnection('default');
|
||||
}
|
||||
if (! is_null($url_to_crawl)) {
|
||||
GetUrlBodyJob::dispatch($url_to_crawl->id)->onQueue('default')->onConnection('default');
|
||||
}
|
||||
|
||||
})->everyTenMinutes()->name('parse-url-every-10m');
|
||||
}
|
||||
|
||||
@@ -10,9 +10,10 @@ class Cached
|
||||
public static function tools_count()
|
||||
{
|
||||
$seconds_to_remember = 599;
|
||||
|
||||
// Retrieve the count from the cache or count and store it if not present
|
||||
return Cache::remember('tools_count_' . $seconds_to_remember, $seconds_to_remember, function () {
|
||||
return AiTool::where('status','live')->count();
|
||||
return Cache::remember('tools_count_'.$seconds_to_remember, $seconds_to_remember, function () {
|
||||
return AiTool::where('status', 'live')->count();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,3 +4,4 @@
|
||||
require 'geo_helper.php';
|
||||
require 'proxy_helper.php';
|
||||
require 'route_helper.php';
|
||||
require 'platform_helper.php';
|
||||
|
||||
21
app/Helpers/Global/platform_helper.php
Normal file
21
app/Helpers/Global/platform_helper.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
if (! function_exists('get_notification_channel')) {
|
||||
|
||||
function get_notification_channel()
|
||||
{
|
||||
return 'telegram';
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_notification_user_ids')) {
|
||||
|
||||
function get_notification_user_ids()
|
||||
{
|
||||
return [
|
||||
|
||||
'629991336', // me
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,8 @@
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
if (! function_exists('count_words')) {
|
||||
function count_words($string) {
|
||||
function count_words($string)
|
||||
{
|
||||
// Remove punctuation and line breaks
|
||||
$cleanString = preg_replace('/[\p{P}\s]/u', ' ', $string);
|
||||
|
||||
@@ -16,7 +17,6 @@ function count_words($string) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! function_exists('dmy')) {
|
||||
function dmy(Carbon $carbon)
|
||||
{
|
||||
|
||||
@@ -71,7 +71,7 @@ public function discover(Request $request, $category_slug = null)
|
||||
$ai_tools = AiTool::when(! is_null($category), function ($query) use ($category) {
|
||||
$query->where('category_id', $category->id);
|
||||
})
|
||||
->where('status','live')
|
||||
->where('status', 'live')
|
||||
->whereNotNull('screenshot_img')
|
||||
->orderBy('updated_at', 'DESC')->paginate(6);
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ public function index(Request $request)
|
||||
{
|
||||
$tools_count_rounded = round_to_nearest_base(Cached::tools_count());
|
||||
|
||||
$latest_ai_tools = AiTool::where('status','live')->whereNotNull('screenshot_img')->take(12)->orderBy('created_at', 'DESC')->get();
|
||||
$latest_ai_tools = AiTool::where('status', 'live')->whereNotNull('screenshot_img')->take(12)->orderBy('created_at', 'DESC')->get();
|
||||
|
||||
return view('front.home', compact('latest_ai_tools','tools_count_rounded'));
|
||||
return view('front.home', compact('latest_ai_tools', 'tools_count_rounded'));
|
||||
}
|
||||
|
||||
public function terms(Request $request)
|
||||
|
||||
97
app/Http/Controllers/Front/FrontSubmitToolController.php
Normal file
97
app/Http/Controllers/Front/FrontSubmitToolController.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Front;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\SubmitTool;
|
||||
use App\Models\UrlToCrawl;
|
||||
use App\Notifications\AiToolSubmitted;
|
||||
use Illuminate\Http\Request;
|
||||
use Notification;
|
||||
|
||||
class FrontSubmitToolController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$submitted_tool_count = SubmitTool::whereIn('status', ['initial', 'queued_for_crawl', 'crawled'])->count();
|
||||
|
||||
$max_submissions = 2000;
|
||||
|
||||
$submissions_left = $max_submissions - $submitted_tool_count;
|
||||
|
||||
return view('front.submit_tool_free', compact('submitted_tool_count', 'submissions_left', 'max_submissions'));
|
||||
}
|
||||
|
||||
public function post(Request $request)
|
||||
{
|
||||
$submitted_tool_count = SubmitTool::whereIn('status', ['initial', 'queued_for_crawl', 'crawled'])->count();
|
||||
|
||||
$max_submissions = 2000;
|
||||
|
||||
$submissions_left = $max_submissions - $submitted_tool_count;
|
||||
|
||||
$submited_url = rtrim(trim($request->input('submitted_url')), '/\\');
|
||||
|
||||
if ($submissions_left <= 0) {
|
||||
return redirect()->back()->withInput()->with('error', (object) ['timeout' => 5000, 'message' => 'Unfortunately, all submission slots have been filled. Please check try again later to see if there are any slots released from rejected submissions.']);
|
||||
}
|
||||
|
||||
if (filter_var($submited_url, FILTER_VALIDATE_URL) === false) {
|
||||
return redirect()->back()->withInput()->with('error', (object) ['timeout' => 5000, 'message' => 'Submitted URL is in invalid URL format. Please check your inputs and try again.']);
|
||||
}
|
||||
|
||||
$submit_tool = SubmitTool::where('submitted_url', $submited_url)->first();
|
||||
|
||||
if (! is_null($submit_tool)) {
|
||||
return redirect()->back()->withInput()->with('error', (object) ['timeout' => 5000, 'message' => 'You have submitted this URL before. Submission ignored.']);
|
||||
}
|
||||
|
||||
$ignore_url_keywords = ['play.google.com', 'apps.apple.com', 'https://chromewebstore.google.com'];
|
||||
|
||||
$is_store_url = false;
|
||||
|
||||
foreach ($ignore_url_keywords as $keyword) {
|
||||
if (str_contains($submited_url, $keyword)) {
|
||||
$is_store_url = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$url_to_crawl = null;
|
||||
|
||||
if ($is_store_url) {
|
||||
$url_to_crawl = UrlToCrawl::where('url', $submited_url)->first();
|
||||
} else {
|
||||
$domain = get_domain_from_url($submited_url);
|
||||
$url_to_crawl = UrlToCrawl::where('domain', $domain)->first();
|
||||
}
|
||||
|
||||
if (! is_null($url_to_crawl)) {
|
||||
return redirect()->back()->withInput()->with('success', (object) ['timeout' => 5000, 'message' => 'Our AI crawler has already identified & pre-approved your submission. It has been scheduled for live submission and should appear in our pages soon.']);
|
||||
}
|
||||
|
||||
$submit_tool = new SubmitTool;
|
||||
$submit_tool->submitted_url = $request->input('submitted_url');
|
||||
$submit_tool->email = $request->input('email');
|
||||
$submit_tool->social = $request->input('social');
|
||||
$submit_tool->social_type = $request->input('social_type');
|
||||
$submit_tool->source_type = $request->input('source_type');
|
||||
$submit_tool->source = $request->input('source');
|
||||
$submit_tool->comments = $request->input('comments');
|
||||
|
||||
if ($submit_tool->save()) {
|
||||
$submitted_tool_count = SubmitTool::whereIn('status', ['initial', 'queued_for_crawl', 'crawled'])->count();
|
||||
|
||||
$telegram_ids = get_notification_user_ids();
|
||||
|
||||
foreach ($telegram_ids as $telegram_id) {
|
||||
Notification::route(get_notification_channel(), $telegram_id)->notify(new AiToolSubmitted($submit_tool));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->with('success', (object) ['timeout' => 5000, 'message' => 'AI tool submittted successfully! You are #'.$submitted_tool_count.' in submission list.']);
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->with('error', (object) ['timeout' => 5000, 'message' => 'Something went wrong. Please try again later.']);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ class FrontToolController extends Controller
|
||||
{
|
||||
public function show(Request $request, $ai_tool_slug)
|
||||
{
|
||||
$ai_tool = AiTool::where('slug', $ai_tool_slug)->where('status','live')->first();
|
||||
$ai_tool = AiTool::where('slug', $ai_tool_slug)->where('status', 'live')->first();
|
||||
|
||||
if (is_null($ai_tool)) {
|
||||
return abort(404);
|
||||
@@ -74,8 +74,8 @@ public function show(Request $request, $ai_tool_slug)
|
||||
|
||||
$faq_context = Context::create(FAQPage::class, $faqData);
|
||||
|
||||
SEOTools::setTitle($ai_tool->tool_name . ": ". $ai_tool->tagline, false);
|
||||
SEOTools::setDescription(implode(" ",str_extract_sentences($ai_tool->summary, 2)));
|
||||
SEOTools::setTitle($ai_tool->tool_name.': '.$ai_tool->tagline, false);
|
||||
SEOTools::setDescription(implode(' ', str_extract_sentences($ai_tool->summary, 2)));
|
||||
SEOTools::metatags();
|
||||
SEOTools::twitter()->addImage($ai_tool->screenshot_img);
|
||||
SEOTools::opengraph()->addImage($ai_tool->screenshot_img);
|
||||
|
||||
@@ -73,9 +73,8 @@ public static function handle($url_to_crawl_id, $ai_tool_id)
|
||||
}
|
||||
|
||||
if ($ai_tool->isDirty()) {
|
||||
if($ai_tool->save())
|
||||
{
|
||||
PublishIndexPostJob::dispatch($ai_tool->id)->onQueue('default')->onConnection('default');
|
||||
if ($ai_tool->save()) {
|
||||
PublishIndexPostJob::dispatch($ai_tool->id)->onQueue('default')->onConnection('default');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ public static function handle(int $url_to_crawl_id)
|
||||
$url_to_crawl->save();
|
||||
$url_to_crawl->refresh();
|
||||
|
||||
|
||||
// try {
|
||||
$user_agent = config('platform.proxy.user_agent');
|
||||
|
||||
@@ -71,10 +70,8 @@ public static function handle(int $url_to_crawl_id)
|
||||
// //throw $e;
|
||||
// }
|
||||
|
||||
|
||||
$markdown_output = self::getMarkdownFromHtml($raw_html);
|
||||
|
||||
|
||||
if (! is_empty($markdown_output)) {
|
||||
$url_to_crawl->output_type = 'markdown';
|
||||
$url_to_crawl->output = $markdown_output;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
use App\Helpers\FirstParty\OpenAI\OpenAI;
|
||||
use App\Jobs\GetAIToolScreenshotJob;
|
||||
use App\Jobs\GetUrlBodyJob;
|
||||
use App\Jobs\ParseUrlBodyJob;
|
||||
use App\Jobs\StoreSearchEmbeddingJob;
|
||||
use App\Models\AiTool;
|
||||
use App\Models\AiToolKeyword;
|
||||
@@ -32,15 +31,15 @@ public static function handle(int $url_to_crawl_id)
|
||||
|
||||
if (is_empty($url_to_crawl->output)) {
|
||||
GetUrlBodyJob::dispatch($url_to_crawl->id)->onQueue('default')->onConnection('default');
|
||||
return ;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (count_words($url_to_crawl->output) < 120)
|
||||
{
|
||||
$url_to_crawl->status = 'blocked';
|
||||
$url_to_crawl->save();
|
||||
if (count_words($url_to_crawl->output) < 120) {
|
||||
$url_to_crawl->status = 'blocked';
|
||||
$url_to_crawl->save();
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
$url_meta_response = null;
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
namespace App\Jobs\Tasks;
|
||||
|
||||
use App\Models\AiTool;
|
||||
use App\Notifications\PostWasPublished;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use LaravelFreelancerNL\LaravelIndexNow\Facades\IndexNow;
|
||||
use LaravelGoogleIndexing;
|
||||
|
||||
@@ -19,27 +17,23 @@ public static function handle(int $ai_tool_id)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$ai_tool->is_ai_tool)
|
||||
{
|
||||
return ;
|
||||
if (! $ai_tool->is_ai_tool) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((app()->environment() == 'production') && (config('platform.general.indexing'))) {
|
||||
$ai_tool_url = route('front.aitool.show', ['ai_tool_slug' => $ai_tool->slug]);
|
||||
|
||||
try {
|
||||
IndexNow::submit($ai_tool_url);
|
||||
} catch (Exception) {
|
||||
}
|
||||
|
||||
if ((app()->environment() == 'production') && (config('platform.general.indexing'))) {
|
||||
$ai_tool_url = route('front.aitool.show', ['ai_tool_slug' => $ai_tool->slug]);
|
||||
try {
|
||||
LaravelGoogleIndexing::create()->update($ai_tool_url);
|
||||
} catch (Exception) {
|
||||
}
|
||||
|
||||
try {
|
||||
IndexNow::submit($ai_tool_url);
|
||||
} catch (Exception) {
|
||||
}
|
||||
|
||||
try {
|
||||
LaravelGoogleIndexing::create()->update($ai_tool_url);
|
||||
} catch (Exception) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
45
app/Models/SubmitTool.php
Normal file
45
app/Models/SubmitTool.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class SubmitTool
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $submit_type
|
||||
* @property string $submitted_url
|
||||
* @property string $email
|
||||
* @property string|null $social
|
||||
* @property string|null $social_type
|
||||
* @property string|null $source
|
||||
* @property string|null $source_type
|
||||
* @property string|null $comments
|
||||
* @property string $status
|
||||
* @property string $queue_priority
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*/
|
||||
class SubmitTool extends Model
|
||||
{
|
||||
protected $table = 'submit_tools';
|
||||
|
||||
protected $fillable = [
|
||||
'submit_type',
|
||||
'submitted_url',
|
||||
'email',
|
||||
'social',
|
||||
'social_type',
|
||||
'source',
|
||||
'source_type',
|
||||
'comments',
|
||||
'status',
|
||||
'queue_priority',
|
||||
];
|
||||
}
|
||||
39
app/Notifications/AiToolSubmitted.php
Normal file
39
app/Notifications/AiToolSubmitted.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\SubmitTool;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use NotificationChannels\Telegram\TelegramMessage;
|
||||
|
||||
class AiToolSubmitted extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
protected $submit_tool;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct(SubmitTool $submit_tool)
|
||||
{
|
||||
$this->submit_tool = $submit_tool;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['telegram'];
|
||||
}
|
||||
|
||||
public function toTelegram($notifiable)
|
||||
{
|
||||
return TelegramMessage::create()
|
||||
->content("*AI Tool Submitted*:\nURL: ".$this->submit_tool->submitted_url."\nBy: ".$this->submit_tool->social.' in '.$this->submit_tool->social_type."\nEmail: ".$this->submit_tool->email."\nFound us from: ".$this->submit_tool->source.' from '.$this->submit_tool->source_type."\n\nComments: ".$this->submit_tool->comments);
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@
|
||||
namespace App\View\Composers;
|
||||
|
||||
use App\Helpers\FirstParty\Cached\Cached;
|
||||
use App\Models\AiTool;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class StatsComposer
|
||||
|
||||
Reference in New Issue
Block a user