Changes
This commit is contained in:
+10
-3
@@ -14,7 +14,8 @@ RUN apt-get update && apt-get install -y \
|
|||||||
libzip-dev \
|
libzip-dev \
|
||||||
zip \
|
zip \
|
||||||
unzip \
|
unzip \
|
||||||
git && \
|
git \
|
||||||
|
cron && \
|
||||||
docker-php-ext-configure gd --with-webp --with-jpeg && \
|
docker-php-ext-configure gd --with-webp --with-jpeg && \
|
||||||
docker-php-ext-install gd && \
|
docker-php-ext-install gd && \
|
||||||
docker-php-ext-install pdo_mysql && \
|
docker-php-ext-install pdo_mysql && \
|
||||||
@@ -30,7 +31,6 @@ RUN docker-php-ext-install intl
|
|||||||
|
|
||||||
RUN apt-get update && apt-get install -y default-mysql-client
|
RUN apt-get update && apt-get install -y default-mysql-client
|
||||||
|
|
||||||
|
|
||||||
# Копирование конфигурационного файла PHP
|
# Копирование конфигурационного файла PHP
|
||||||
COPY ./_docker/app/php.ini /usr/local/etc/php/conf.d/php.ini
|
COPY ./_docker/app/php.ini /usr/local/etc/php/conf.d/php.ini
|
||||||
|
|
||||||
@@ -38,7 +38,6 @@ COPY ./_docker/app/php.ini /usr/local/etc/php/conf.d/php.ini
|
|||||||
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
|
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
|
||||||
RUN apt-get install -y nodejs npm
|
RUN apt-get install -y nodejs npm
|
||||||
|
|
||||||
|
|
||||||
EXPOSE 6001
|
EXPOSE 6001
|
||||||
EXPOSE 5173
|
EXPOSE 5173
|
||||||
|
|
||||||
@@ -47,5 +46,13 @@ RUN curl -sS https://getcomposer.org/installer | php -- \
|
|||||||
--filename=composer \
|
--filename=composer \
|
||||||
--install-dir=/usr/local/bin
|
--install-dir=/usr/local/bin
|
||||||
|
|
||||||
|
# Настройка Cron
|
||||||
|
COPY ./_docker/app/crontab /etc/cron.d/laravel-cron
|
||||||
|
RUN chmod 0644 /etc/cron.d/laravel-cron # Устанавливаем правильные права
|
||||||
|
RUN crontab /etc/cron.d/laravel-cron # Добавляем задачи в crontab
|
||||||
|
RUN touch /var/log/cron.log # Создаем файл для логов Cron
|
||||||
|
|
||||||
WORKDIR /var/www
|
WORKDIR /var/www
|
||||||
|
|
||||||
|
# Запуск Cron и PHP-FPM
|
||||||
|
CMD ["sh", "-c", "cron && php-fpm"]
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
* * * * * root php /var/www/artisan schedule:run >> /var/log/cron.log 2>&1
|
||||||
@@ -43,18 +43,18 @@ class GenerateSitemap extends Command
|
|||||||
{
|
{
|
||||||
$sitemap = Sitemap::create();
|
$sitemap = Sitemap::create();
|
||||||
|
|
||||||
|
// Генерация карты сайта для всех моделей
|
||||||
$this->generatePages($sitemap);
|
$this->generatePages($sitemap);
|
||||||
$this->generatePosts($sitemap);
|
$this->generatePosts($sitemap);
|
||||||
$this->generateEvents($sitemap);
|
$this->generateDivisions($sitemap);
|
||||||
$this->generateFaculties($sitemap);
|
$this->generateEducationPrograms($sitemap); // Добавляем генерацию для EducationProgram
|
||||||
$this->generateDepartments($sitemap);
|
$this->generateEvents($sitemap); // Добавляем генерацию для Event
|
||||||
$this->generateDivisisons($sitemap);
|
$this->generateAdditionalEducations($sitemap); // Добавляем генерацию для AdditionalEducation
|
||||||
$this->generateEducationalPrograms($sitemap);
|
$this->generateFaculties($sitemap); // Добавляем генерацию для Faculty
|
||||||
$this->generateAdditionalPrograms($sitemap);
|
$this->generateDepartments($sitemap); // Добавляем генерацию для Department
|
||||||
$this->generateAcademicJournals($sitemap);
|
$this->generateUsers($sitemap); // Добавляем генерацию для User
|
||||||
$this->generateVirtualExhibitions($sitemap);
|
|
||||||
$this->generateLibraryNews($sitemap);
|
|
||||||
|
|
||||||
|
// Сохраняем карту сайта в файл
|
||||||
$sitemap->writeToFile(public_path('sitemap.xml'));
|
$sitemap->writeToFile(public_path('sitemap.xml'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,27 +67,14 @@ class GenerateSitemap extends Command
|
|||||||
|
|
||||||
$this->addUrlsToSitemap($sitemap, $pages, function($page) {
|
$this->addUrlsToSitemap($sitemap, $pages, function($page) {
|
||||||
return [
|
return [
|
||||||
'path' => "/{$page->path}",
|
'route' => 'page.view',
|
||||||
|
'params' => ['path' => $page->path],
|
||||||
'lastModificationDate' => $page->updated_at,
|
'lastModificationDate' => $page->updated_at,
|
||||||
'priority' => 0.5,
|
'priority' => 0.5,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function generateEvents(Sitemap $sitemap)
|
|
||||||
{
|
|
||||||
$events = Event::query()
|
|
||||||
->get();
|
|
||||||
|
|
||||||
$this->addUrlsToSitemap($sitemap, $events, function($event) {
|
|
||||||
return [
|
|
||||||
'path' => route('client.event.show', $event->slug, false),
|
|
||||||
'lastModificationDate' => $event->updated_at,
|
|
||||||
'priority' => 0.5,
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function generatePosts(Sitemap $sitemap)
|
protected function generatePosts(Sitemap $sitemap)
|
||||||
{
|
{
|
||||||
$posts = Post::query()
|
$posts = Post::query()
|
||||||
@@ -96,39 +83,75 @@ class GenerateSitemap extends Command
|
|||||||
|
|
||||||
$this->addUrlsToSitemap($sitemap, $posts, function($post) {
|
$this->addUrlsToSitemap($sitemap, $posts, function($post) {
|
||||||
return [
|
return [
|
||||||
'path' => route('client.post.show', $post->slug, false),
|
'route' => 'client.post.show',
|
||||||
|
'params' => ['slug' => $post->slug],
|
||||||
'lastModificationDate' => $post->updated_at,
|
'lastModificationDate' => $post->updated_at,
|
||||||
'priority' => 0.5,
|
'priority' => 0.5,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function generateEducationalPrograms(Sitemap $sitemap)
|
protected function generateDivisions(Sitemap $sitemap)
|
||||||
{
|
{
|
||||||
$posts = EducationalProgram::query()
|
$divisions = Division::query()
|
||||||
->where('status', EducationalProgramStatus::PUBLISHED)
|
->where('is_active', true)
|
||||||
->whereHas('admission_plans')
|
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$this->addUrlsToSitemap($sitemap, $posts, function($program) {
|
$this->addUrlsToSitemap($sitemap, $divisions, function($division) {
|
||||||
return [
|
return [
|
||||||
'path' => route('client.program.show', $program->slug, false),
|
'route' => 'client.division.show',
|
||||||
|
'params' => ['slug' => $division->slug],
|
||||||
|
'lastModificationDate' => $division->updated_at,
|
||||||
|
'priority' => 0.5,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function generateEducationPrograms(Sitemap $sitemap)
|
||||||
|
{
|
||||||
|
$programs = EducationalProgram::query()
|
||||||
|
->where('status', EducationalProgramStatus::PUBLISHED) // Пример условия для активных программ
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$this->addUrlsToSitemap($sitemap, $programs, function($program) {
|
||||||
|
return [
|
||||||
|
'route' => 'client.program.show',
|
||||||
|
'params' => ['slug' => $program->slug],
|
||||||
'lastModificationDate' => $program->updated_at,
|
'lastModificationDate' => $program->updated_at,
|
||||||
'priority' => 0.5,
|
'priority' => 0.5,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function generateAdditionalPrograms(Sitemap $sitemap)
|
protected function generateEvents(Sitemap $sitemap)
|
||||||
{
|
{
|
||||||
$posts = AdditionalEducation::query()
|
$now = now()->toDateString(); // Текущая дата
|
||||||
->where('is_active', true)
|
|
||||||
|
$events = Event::query()
|
||||||
|
->where('event_date_end', '>=', $now) // Только актуальные события
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$this->addUrlsToSitemap($sitemap, $posts, function($program) {
|
$this->addUrlsToSitemap($sitemap, $events, function($event) {
|
||||||
return [
|
return [
|
||||||
'path' => route('client.additionalProgram.show', $program->slug, false),
|
'route' => 'client.event.show',
|
||||||
'lastModificationDate' => $program->updated_at,
|
'params' => ['slug' => $event->slug],
|
||||||
|
'lastModificationDate' => $event->updated_at,
|
||||||
|
'priority' => 0.5,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function generateAdditionalEducations(Sitemap $sitemap)
|
||||||
|
{
|
||||||
|
$educations = AdditionalEducation::query()
|
||||||
|
->where('is_active', true) // Пример условия для активных программ
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$this->addUrlsToSitemap($sitemap, $educations, function($education) {
|
||||||
|
return [
|
||||||
|
'route' => 'client.additionalEducation.show',
|
||||||
|
'params' => ['slug' => $education->slug],
|
||||||
|
'lastModificationDate' => $education->updated_at,
|
||||||
'priority' => 0.5,
|
'priority' => 0.5,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
@@ -136,13 +159,14 @@ class GenerateSitemap extends Command
|
|||||||
|
|
||||||
protected function generateFaculties(Sitemap $sitemap)
|
protected function generateFaculties(Sitemap $sitemap)
|
||||||
{
|
{
|
||||||
$posts = Faculty::query()
|
$faculties = Faculty::query()
|
||||||
->where('is_active', true)
|
->where('is_active', true) // Пример условия для активных факультетов
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$this->addUrlsToSitemap($sitemap, $posts, function($faculty) {
|
$this->addUrlsToSitemap($sitemap, $faculties, function($faculty) {
|
||||||
return [
|
return [
|
||||||
'path' => route('client.faculty.show', $faculty->slug, false),
|
'route' => 'client.faculty.show',
|
||||||
|
'params' => ['slug' => $faculty->slug],
|
||||||
'lastModificationDate' => $faculty->updated_at,
|
'lastModificationDate' => $faculty->updated_at,
|
||||||
'priority' => 0.5,
|
'priority' => 0.5,
|
||||||
];
|
];
|
||||||
@@ -151,107 +175,44 @@ class GenerateSitemap extends Command
|
|||||||
|
|
||||||
protected function generateDepartments(Sitemap $sitemap)
|
protected function generateDepartments(Sitemap $sitemap)
|
||||||
{
|
{
|
||||||
$posts = Department::query()
|
$departments = Department::query()
|
||||||
->with('faculty')
|
->where('is_active', true) // Пример условия для активных кафедр
|
||||||
->where('is_active', true)
|
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$this->addUrlsToSitemap($sitemap, $posts, function($department) {
|
$this->addUrlsToSitemap($sitemap, $departments, function($department) {
|
||||||
return [
|
return [
|
||||||
'path' => route('client.department.show', [
|
'route' => 'client.department.show',
|
||||||
'facultySlug' => $department->faculty->slug,
|
'params' => ['facultySlug' => $department->faculty->slug, 'departmentSlug' => $department->slug],
|
||||||
'departmentSlug' => $department->slug,
|
|
||||||
], false),
|
|
||||||
'lastModificationDate' => $department->updated_at,
|
'lastModificationDate' => $department->updated_at,
|
||||||
'priority' => 0.5,
|
'priority' => 0.5,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function generateDivisisons(Sitemap $sitemap)
|
protected function generateUsers(Sitemap $sitemap)
|
||||||
{
|
{
|
||||||
$posts = Division::query()
|
$users = User::query()
|
||||||
->where('is_active', true)
|
->whereHas('userDetail', function ($q) {
|
||||||
|
$q->where('is_only_worker', false);
|
||||||
|
})
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$this->addUrlsToSitemap($sitemap, $posts, function($division) {
|
$this->addUrlsToSitemap($sitemap, $users, function($user) {
|
||||||
return [
|
return [
|
||||||
'path' => route('client.division.show', $division->slug, false),
|
'route' => 'client.person.show',
|
||||||
'lastModificationDate' => $division->updated_at,
|
'params' => ['slug' => $user->slug],
|
||||||
|
'lastModificationDate' => $user->updated_at,
|
||||||
'priority' => 0.5,
|
'priority' => 0.5,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function generateAcademicJournals(Sitemap $sitemap)
|
|
||||||
{
|
|
||||||
$posts = AcademicJournal::query()
|
|
||||||
->where('is_active', true)
|
|
||||||
->get();
|
|
||||||
|
|
||||||
$this->addUrlsToSitemap($sitemap, $posts, function($journal) {
|
|
||||||
return [
|
|
||||||
'path' => route('client.academicJournal.show', $journal->slug, false),
|
|
||||||
'lastModificationDate' => $journal->updated_at,
|
|
||||||
'priority' => 0.5,
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function generateLibraryNews(Sitemap $sitemap)
|
|
||||||
{
|
|
||||||
$posts = LibraryNews::query()
|
|
||||||
->where('is_active', true)
|
|
||||||
->get();
|
|
||||||
|
|
||||||
$this->addUrlsToSitemap($sitemap, $posts, function($journal) {
|
|
||||||
return [
|
|
||||||
'path' => route('client.library.news.show', $journal->slug, false),
|
|
||||||
'lastModificationDate' => $journal->updated_at,
|
|
||||||
'priority' => 0.5,
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function generateVirtualExhibitions(Sitemap $sitemap)
|
|
||||||
{
|
|
||||||
$posts = VirtualExhibition::query()
|
|
||||||
->where('is_active', true)
|
|
||||||
->get();
|
|
||||||
|
|
||||||
$this->addUrlsToSitemap($sitemap, $posts, function($exhibition) {
|
|
||||||
return [
|
|
||||||
'path' => route('client.library.exhibition.show', $exhibition->slug, false),
|
|
||||||
'lastModificationDate' => $exhibition->updated_at,
|
|
||||||
'priority' => 0.5,
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function generatePersons(Sitemap $sitemap)
|
|
||||||
{
|
|
||||||
$posts = User::query()
|
|
||||||
->whereHas('userDetail')
|
|
||||||
->with('userDetail')
|
|
||||||
->get();
|
|
||||||
|
|
||||||
$this->addUrlsToSitemap($sitemap, $posts, function($user) {
|
|
||||||
return [
|
|
||||||
'path' => route('client.person.show', $user->slug, false),
|
|
||||||
'lastModificationDate' => $user->userDetail->updated_at,
|
|
||||||
'priority' => 0.5,
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected function addUrlsToSitemap(Sitemap $sitemap, $items, callable $callback)
|
protected function addUrlsToSitemap(Sitemap $sitemap, $items, callable $callback)
|
||||||
{
|
{
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
$urlData = $callback($item);
|
$urlData = $callback($item);
|
||||||
$sitemap->add(Url::create($urlData['path'])
|
$url = route($urlData['route'], $urlData['params']);
|
||||||
|
$sitemap->add(Url::create($url)
|
||||||
->setLastModificationDate($urlData['lastModificationDate'])
|
->setLastModificationDate($urlData['lastModificationDate'])
|
||||||
->setPriority($urlData['priority']));
|
->setPriority($urlData['priority']));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class Kernel extends ConsoleKernel
|
|||||||
*/
|
*/
|
||||||
protected function schedule(Schedule $schedule): void
|
protected function schedule(Schedule $schedule): void
|
||||||
{
|
{
|
||||||
// $schedule->command('inspire')->hourly();
|
$schedule->command('sitemap:generate')->dailyAt('03:00');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- '5173'
|
- '5173'
|
||||||
command: >
|
command: >
|
||||||
sh -c "php artisan inertia:start-ssr & php-fpm"
|
sh -c "cron && php artisan inertia:start-ssr & php-fpm"
|
||||||
|
|
||||||
php-queue:
|
php-queue:
|
||||||
restart: always
|
restart: always
|
||||||
|
|||||||
Reference in New Issue
Block a user