preview 1

This commit is contained in:
Hesabix 2025-01-10 21:59:38 +00:00
parent 62ccfceb46
commit 9d84aeb307
12 changed files with 174 additions and 31 deletions

View file

@ -0,0 +1,4 @@
# config/routes/easyadmin.yaml
easyadmin:
resource: .
type: easyadmin.routes

BIN
public/img/versions.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

View file

@ -2,19 +2,22 @@
namespace App\Controller\Admin;
use App\Entity\Post;
use App\Entity\Tree;
use App\Entity\User;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\Locale;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use EasyCorp\Bundle\EasyAdminBundle\Dto\LocaleDto;
class DashboardController extends AbstractDashboardController
{
#[Route('/admin', name: 'admin')]
public function index(): Response
#[Route('/admin/{_locale}', name: 'admin')]
public function index($_locale = 'fa'): Response
{
return parent::index();
//return parent::index();
// Option 1. You can make your dashboard redirect to some common page of your backend
//
@ -30,43 +33,28 @@ class DashboardController extends AbstractDashboardController
// Option 3. You can render some custom template to display a proper dashboard with widgets, etc.
// (tip: it's easier if your template extends from @EasyAdmin/page/content.html.twig)
//
// return $this->render('some/path/my-dashboard.html.twig');
return $this->render('admin/dashboard.html.twig');
}
public function configureDashboard(): Dashboard
{
return Dashboard::new()
// the name visible to end users
->setTitle('ACME Corp.')
// you can include HTML contents too (e.g. to link to an image)
->setTitle('<img src="..."> ACME <span class="text-small">Corp.</span>')
->setTitle('پیشخوان')
// by default EasyAdmin displays a black square as its default favicon;
// use this method to display a custom favicon: the given path is passed
// "as is" to the Twig asset() function:
// <link rel="shortcut icon" href="{{ asset('...') }}">
->setFaviconPath('favicon.svg')
->setFaviconPath('favicon/favicon.ico')
// the domain used by default is 'messages'
->setTranslationDomain('my-custom-domain')
// there's no need to define the "text direction" explicitly because
// its default value is inferred dynamically from the user locale
->setTextDirection('ltr')
->setTranslationDomain('admin')
// set this option if you prefer the page content to span the entire
// browser width, instead of the default design which sets a max width
->renderContentMaximized()
// set this option if you prefer the sidebar (which contains the main menu)
// to be displayed as a narrow column instead of the default expanded design
->renderSidebarMinimized()
// by default, users can select between a "light" and "dark" mode for the
// backend interface. Call this method if you prefer to disable the "dark"
// mode for any reason (e.g. if your interface customizations are not ready for it)
->disableDarkMode()
// by default, the UI color scheme is 'auto', which means that the backend
// will use the same mode (light/dark) as the operating system and will
// change in sync when the OS mode changes.
@ -79,12 +67,25 @@ class DashboardController extends AbstractDashboardController
// by default, all backend URLs are generated as absolute URLs. If you
// need to generate relative URLs instead, call this method
->generateRelativeUrls()
->setLocales(['en','fa'])
// to further customize the locale option, pass an instance of
// EasyCorp\Bundle\EasyAdminBundle\Config\Locale
;
}
public function configureMenuItems(): iterable
{
yield MenuItem::linkToDashboard('Dashboard', 'fa fa-home');
// yield MenuItem::linkToCrud('The Label', 'fas fa-list', EntityClass::class);
return [
MenuItem::linkToDashboard('پیشخوان', 'fa fa-home'),
MenuItem::section('پست بلاگ'),
MenuItem::linkToCrud('دسته بندی', 'fa fa-tags', Tree::class),
MenuItem::linkToCrud('محتوا', 'fa fa-file-text', Post::class),
MenuItem::section('کاربران'),
MenuItem::linkToCrud('کاربران', 'fa fa-user', User::class),
];
}
}

View file

@ -3,8 +3,10 @@
namespace App\Controller\Admin;
use App\Entity\Post;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
@ -15,14 +17,22 @@ class PostCrudController extends AbstractCrudController
return Post::class;
}
/*
public function configureFields(string $pageName): iterable
{
return [
IdField::new('id'),
TextField::new('title'),
TextEditorField::new('description'),
TextField::new('title', 'عنوان'),
TextareaField::new('intro', 'خلاصه مطلب'),
TextEditorField::new('body', 'متن'),
];
}
*/
public function configureCrud(Crud $crud): Crud
{
return $crud
// the labels used to refer to this entity in titles, buttons, etc.
->setEntityLabelInSingular('محتوا')
->setEntityLabelInPlural('محتواها')
;
}
}

View file

@ -0,0 +1,28 @@
<?php
namespace App\Controller\Admin;
use App\Entity\Tree;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
class TreeCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Tree::class;
}
/*
public function configureFields(string $pageName): iterable
{
return [
IdField::new('id'),
TextField::new('title'),
TextEditorField::new('description'),
];
}
*/
}

View file

@ -0,0 +1,28 @@
<?php
namespace App\Controller\Admin;
use App\Entity\User;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
class UserCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return User::class;
}
/*
public function configureFields(string $pageName): iterable
{
return [
IdField::new('id'),
TextField::new('title'),
TextEditorField::new('description'),
];
}
*/
}

View file

@ -93,4 +93,13 @@ class PageController extends AbstractController
'trees' => $tress,
]);
}
#[Route('/changes', name: 'app_changes')]
public function app_changes(EntityManagerInterface $entityManagerInterface): Response
{
$posts = $entityManagerInterface->getRepository(Post::class)->findAllByCat('changelog');
return $this->render('post/versions.html.twig', [
'items' => $posts,
]);
}
}

View file

@ -58,4 +58,16 @@ class PostRepository extends ServiceEntityRepository
->getResult()
;
}
public function findAllBycat($cat = 'blog'): array
{
return $this->createQueryBuilder('p')
->innerJoin('p.cat', 'c')
->where('c.code = :cat')
->setParameter('cat', $cat)
->orderBy('p.dateSubmit', 'DESC')
->getQuery()
->getResult()
;
}
}

View file

@ -0,0 +1 @@
{% extends '@EasyAdmin/layout.html.twig' %}

View file

@ -78,6 +78,9 @@
<li class="nav-item">
<a href="{{path('app_api_docs',{'url':'home'})}}" class="nav-link px-2">مستندات API</a>
</li>
<li class="nav-item">
<a href="{{path('app_changes')}}" class="nav-link px-2">تغییرات</a>
</li>
<li class="nav-item">
<a href="https://github.com/morrning" target="_blank" class="nav-link px-2">مخازن کد</a>
</li>

View file

@ -2,12 +2,21 @@
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<!-- created with Free Online Sitemap Generator www.xml-sitemaps.com -->
<url>
<loc>{{ absolute_url(path('app_home')) }}</loc>
<lastmod>2025-01-09T06:58:03+00:00</lastmod>
<priority>1.00</priority>
</url>
<url>
<loc>{{ absolute_url(path('app_changes')) }}</loc>
<lastmod>2025-01-09T06:58:03+00:00</lastmod>
<priority>1.00</priority>
</url>
<url>
<loc>{{ absolute_url(path('app_blog_home')) }}</loc>
<lastmod>2025-01-09T06:58:03+00:00</lastmod>
<priority>1.00</priority>
</url>
{% for post in posts %}
{% if post.cat.code == 'plain' %}
<url>
@ -21,6 +30,18 @@
<lastmod>{{ twigFunctions.getctime(post.dateSubmit) }}</lastmod>
<priority>1.00</priority>
</url>
{% elseif post.cat.code == 'guide' %}
<url>
<loc>{{ absolute_url(path('app_guide',{'url':post.url})) }}</loc>
<lastmod>{{ twigFunctions.getctime(post.dateSubmit) }}</lastmod>
<priority>1.00</priority>
</url>
{% elseif post.cat.code == 'api' %}
<url>
<loc>{{ absolute_url(path('app_api_docs',{'url':post.url})) }}</loc>
<lastmod>{{ twigFunctions.getctime(post.dateSubmit) }}</lastmod>
<priority>1.00</priority>
</url>
{% endif %}
{% endfor %}
</urlset>

View file

@ -0,0 +1,26 @@
{% extends 'base.html.twig' %}
{% block keywords %}item.keywords
{% endblock %}
{% block title %}
تاریخچه تغییرات حسابیکس
{% endblock %}
{% block des %}
تاریخچه تغییرات حسابیکس
{% endblock %}
{% block body %}
<div class="container p-3">
<div class="row">
<div class="col-12 mb-2">
<img src="{{ asset('/img/versions.webp')}}" class="img-fluid rounded-3 shadow" style="max-height:23rem;" />
</div>
{% for item in items %}
<div class="col-12 mb-2">
<h1 class="text-primary fs-3">{{ item.title }}</h1>
<p class="">{{ item.body | raw }}</p>
</div>
{% endfor %}
</div>
</div>
{% endblock %}