Update (front post): Fix parsing issue
This commit is contained in:
@@ -26,6 +26,7 @@ protected function schedule(Schedule $schedule): void
|
|||||||
AISerpGenArticleJob::dispatch()->onQueue('default')->onConnection('default');
|
AISerpGenArticleJob::dispatch()->onQueue('default')->onConnection('default');
|
||||||
})->everyMinute()->when(function () use ($mins_between_posts, $launched_date) {
|
})->everyMinute()->when(function () use ($mins_between_posts, $launched_date) {
|
||||||
$minutes_since_launch = now()->diffInMinutes($launched_date);
|
$minutes_since_launch = now()->diffInMinutes($launched_date);
|
||||||
|
|
||||||
return $minutes_since_launch % $mins_between_posts === 0;
|
return $minutes_since_launch % $mins_between_posts === 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -189,21 +189,26 @@ private function injectTableOfContents($html)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the Table of Contents
|
// Create the Table of Contents
|
||||||
$toc = '<div class="p-3 rounded-3 bg-light mb-3"><ol>';
|
$domDocument = $crawler->getNode(0)->ownerDocument;
|
||||||
$h2Elements->each(function (Crawler $node, $i) use (&$toc) {
|
$tocDiv = $domDocument->createElement('div');
|
||||||
$content = $node->text();
|
$tocDiv->setAttribute('class', 'p-3 rounded-3 bg-light mb-3');
|
||||||
$id = 'link-'.$i; // Creating a simple id based on the index
|
$ol = $domDocument->createElement('ol');
|
||||||
$node->getNode(0)->setAttribute('id', $id); // Set the id to the h2 tag
|
$tocDiv->appendChild($ol);
|
||||||
$toc .= "<li class=\"py-1\"><a class=\"text-decoration-none hover-text-decoration-underline\" href='#{$id}'>{$content}</a></li>";
|
|
||||||
|
$h2Elements->each(function (Crawler $node, $i) use ($ol) {
|
||||||
|
$content = htmlspecialchars($node->text(), ENT_XML1 | ENT_COMPAT, 'UTF-8');
|
||||||
|
$id = 'link-'.$i;
|
||||||
|
$node->getNode(0)->setAttribute('id', $id);
|
||||||
|
$li = $ol->appendChild(new \DOMElement('li'));
|
||||||
|
$li->setAttribute('class', 'py-1');
|
||||||
|
$a = $li->appendChild(new \DOMElement('a', $content));
|
||||||
|
$a->setAttribute('class', 'text-decoration-none hover-text-decoration-underline');
|
||||||
|
$a->setAttribute('href', '#'.$id);
|
||||||
});
|
});
|
||||||
$toc .= '</ol></div>';
|
|
||||||
|
|
||||||
// Insert TOC after h1
|
// Insert TOC after h1
|
||||||
$domDocument = $crawler->getNode(0)->ownerDocument;
|
|
||||||
$fragment = $domDocument->createDocumentFragment();
|
|
||||||
$fragment->appendXML($toc);
|
|
||||||
$h1Node = $crawler->filter('h1')->getNode(0);
|
$h1Node = $crawler->filter('h1')->getNode(0);
|
||||||
$h1Node->parentNode->insertBefore($fragment, $h1Node->nextSibling);
|
$h1Node->parentNode->insertBefore($tocDiv, $h1Node->nextSibling);
|
||||||
|
|
||||||
// Get the updated HTML
|
// Get the updated HTML
|
||||||
$updatedHtml = $crawler->filter('body')->html();
|
$updatedHtml = $crawler->filter('body')->html();
|
||||||
|
|||||||
@@ -4,22 +4,20 @@
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
use LaravelFreelancerNL\LaravelIndexNow\Facades\IndexNow;
|
use LaravelFreelancerNL\LaravelIndexNow\Facades\IndexNow;
|
||||||
use LaravelGoogleIndexing;
|
use LaravelGoogleIndexing;
|
||||||
|
|
||||||
class TestController extends Controller
|
class TestController extends Controller
|
||||||
{
|
{
|
||||||
public function indexing(Request $request)
|
public function indexing(Request $request)
|
||||||
{
|
|
||||||
$url = $request->input('url');
|
|
||||||
|
|
||||||
if (is_null($url))
|
|
||||||
{
|
{
|
||||||
abort(404);
|
$url = $request->input('url');
|
||||||
}
|
|
||||||
|
|
||||||
IndexNow::submit($url);
|
if (is_null($url)) {
|
||||||
LaravelGoogleIndexing::create()->update($url);
|
abort(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IndexNow::submit($url);
|
||||||
|
LaravelGoogleIndexing::create()->update($url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,10 @@ public static function handle($post)
|
|||||||
{
|
{
|
||||||
$keyword = $post->main_keyword;
|
$keyword = $post->main_keyword;
|
||||||
|
|
||||||
if (is_array($post->keywords))
|
if (is_array($post->keywords)) {
|
||||||
{
|
if (count($post->keywords) > 0) {
|
||||||
if (count($post->keywords) > 0)
|
$keyword .= ' '.implode(' ', $post->keywords);
|
||||||
{
|
}
|
||||||
$keyword .= " " . implode(" ", $post->keywords);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = $post->short_title;
|
$title = $post->short_title;
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
|
||||||
class GetNewsSerpTask
|
class GetNewsSerpTask
|
||||||
{
|
{
|
||||||
public static function handle(Category $category, $country_iso)
|
public static function handle(Category $category, $country_iso)
|
||||||
@@ -76,6 +75,7 @@ public static function handle(Category $category, $country_iso)
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Log::error(json_encode($serp_obj));
|
Log::error(json_encode($serp_obj));
|
||||||
inspector()->reportException($e);
|
inspector()->reportException($e);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
use App\Models\NewsSerpResult;
|
use App\Models\NewsSerpResult;
|
||||||
use App\Models\SerpUrl;
|
use App\Models\SerpUrl;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
class ParseNewsSerpDomainsTask
|
class ParseNewsSerpDomainsTask
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
use App\Models\Post;
|
use App\Models\Post;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
use LaravelFreelancerNL\LaravelIndexNow\Facades\IndexNow;
|
use LaravelFreelancerNL\LaravelIndexNow\Facades\IndexNow;
|
||||||
use LaravelGoogleIndexing;
|
use LaravelGoogleIndexing;
|
||||||
|
|
||||||
|
|||||||
@@ -29,17 +29,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Route::get('/now-minute', function (Request $request) {
|
Route::get('/now-minute', function (Request $request) {
|
||||||
dd(now()->minute);
|
dd(now()->minute);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Route::get('/indexing', [App\Http\Controllers\Tests\TestController::class, 'indexing']);
|
Route::get('/indexing', [App\Http\Controllers\Tests\TestController::class, 'indexing']);
|
||||||
|
|
||||||
Route::get('/serp-ai-gen', function (Request $request) {
|
Route::get('/serp-ai-gen', function (Request $request) {
|
||||||
AISerpGenArticleJob::dispatch()->onQueue('default')->onConnection('default');
|
AISerpGenArticleJob::dispatch()->onQueue('default')->onConnection('default');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Route::get('/exponential', function (Request $request) {
|
Route::get('/exponential', function (Request $request) {
|
||||||
$post_counts = get_exponential_posts_gen_by_day($request->input('day', 1));
|
$post_counts = get_exponential_posts_gen_by_day($request->input('day', 1));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user