mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
Merge pull request #613 from openclassify/dia
#1716 Creating Google Sitemap for cats
This commit is contained in:
commit
e6f906bb00
@ -37,7 +37,12 @@
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-6 py-3 pr-0 instructions d-none d-md-block">
|
||||
{{ blocks('register-instructions') }}
|
||||
{% set type = app.request.get('type') %}
|
||||
{% if type %}
|
||||
{{ blocks(type) }}
|
||||
{% else %}
|
||||
{{ blocks('register-instructions') }}
|
||||
{% endif %}
|
||||
|
||||
{{ addBlock('register/instructions')|raw }}
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ class RegisterInstructionSeeder extends Seeder
|
||||
'name' => trans('visiosoft.theme.base::field.list'),
|
||||
'slug' => 'list',
|
||||
'category' => 'other',
|
||||
'content_layout' => '<div class="border {{ block.area.slug == \'register-instructions\' ? \'personal-advantages\' : \'corporate-advantages\' }} py-5 px-5">
|
||||
'content_layout' => '<div class="border {{ block.area.slug == \'store-register-instructions\' ? \'corporate-advantages\' : \'personal-advantages\' }} py-5 px-5">
|
||||
<div class="d-flex align-items-center mb-4">
|
||||
{% if setting_value(\'visiosoft.theme.base::register_page_instruction_logo\') %}
|
||||
<img class="mr-3" src="{{ file(setting_value(\'visiosoft.theme.base::register_page_instruction_logo\')).url }}">
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
{% for category in categories %}
|
||||
<url>
|
||||
<loc>{{ url_route('adv_list_seo', [category.slug]) }}</loc>
|
||||
<lastmod>{{ category.created_at.tz('UTC').toAtomString() }}</lastmod>
|
||||
<changefreq>weekly</changefreq>
|
||||
</url>
|
||||
{% endfor %}
|
||||
</urlset>
|
||||
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
{% for i in 1..pagesCount %}
|
||||
<sitemap>
|
||||
<loc>{{ url('sitemap.xml/categories') }}?page={{ i }}</loc>
|
||||
</sitemap>
|
||||
{% endfor %}
|
||||
</sitemapindex>
|
||||
@ -58,6 +58,10 @@ class CatsModuleServiceProvider extends AddonServiceProvider
|
||||
'admin/cats/create' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@create',
|
||||
'admin/cats/edit/{id}' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@edit',
|
||||
'admin/cats/category/delete/{id}' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@delete',
|
||||
|
||||
// Sitemap
|
||||
'sitemap.xml' => 'Visiosoft\CatsModule\Http\Controller\SitemapController@index',
|
||||
'sitemap.xml/categories' => 'Visiosoft\CatsModule\Http\Controller\SitemapController@categories',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
<?php namespace Visiosoft\CatsModule\Http\Controller;
|
||||
|
||||
use Anomaly\Streams\Platform\Http\Controller\PublicController;
|
||||
use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
|
||||
|
||||
class SitemapController extends PublicController
|
||||
{
|
||||
|
||||
private $categoryRepository;
|
||||
|
||||
public function __construct(CategoryRepositoryInterface $categoryRepository)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->categoryRepository = $categoryRepository;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$categoriesCount = $this->categoryRepository->count();
|
||||
$pagesCount = ceil($categoriesCount / 5000);
|
||||
|
||||
return response()->view('visiosoft.module.cats::sitemap.index', [
|
||||
'pagesCount' => $pagesCount,
|
||||
])->header('Content-Type', 'text/xml');
|
||||
}
|
||||
|
||||
public function categories()
|
||||
{
|
||||
$page = request()->page ?: 1;
|
||||
$skip = $page - 1;
|
||||
|
||||
$categories = $this->categoryRepository->newQuery()->skip(5000 * $skip)->take(5000)->get();
|
||||
|
||||
return response()->view('visiosoft.module.cats::sitemap.categories', [
|
||||
'categories' => $categories,
|
||||
])->header('Content-Type', 'text/xml');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user