diff --git a/assets/styles/app.css b/assets/styles/app.css index 66f01ea..bd26e3c 100644 --- a/assets/styles/app.css +++ b/assets/styles/app.css @@ -1,11 +1,21 @@ -body { - font-family: "Yekan Bakh FaNum"; +body { + font-family: "Yekan Bakh FaNum"; font-feature-settings: "kern" on, "liga" on, "dlig" on; -moz-font-feature-settings: "kern" on, "liga" on, "dlig" on; -webkit-font-feature-settings: "kern" on, "liga" on, "dlig" on; -ms-font-feature-settings: "kern" on, "liga" on, "dlig" on; -o-font-feature-settings: "kern" on, "liga" on, "dlig" on; } -a.nav-link:hover{ + +a.nav-link:hover { color: #1743bb; } + +.rul{ + text-decoration: none; +} + +.accordion-button:after { + margin-right: auto; + margin-left: 0; +} diff --git a/assets/styles/global.scss b/assets/styles/global.scss index e43a722..e36d662 100644 --- a/assets/styles/global.scss +++ b/assets/styles/global.scss @@ -2,5 +2,10 @@ // customize some Bootstrap variables $primary: #1743bb; +$link-hover-decoration: none; +$accordion-button-bg: rgb(248, 249, 250); +$accordion-bg: rgb(248, 249, 250); +$accordion-button-active-bg: rgb(248, 249, 250); +$accordion-padding-y: 0.6rem; // the ~ allows you to reference things in node_modules @import "~bootstrap/scss/bootstrap"; \ No newline at end of file diff --git a/public/uploaded/b315c85f-92c3-4d81-bc8c-72b698339f44 (1).webp b/public/uploaded/b315c85f-92c3-4d81-bc8c-72b698339f44 (1).webp new file mode 100644 index 0000000..37071cb Binary files /dev/null and b/public/uploaded/b315c85f-92c3-4d81-bc8c-72b698339f44 (1).webp differ diff --git a/public/uploaded/illustration showing why accounting software is essential for businesses. The image features a modern office setup with a computer scre.webp b/public/uploaded/illustration showing why accounting software is essential for businesses. The image features a modern office setup with a computer scre.webp new file mode 100644 index 0000000..8329fc4 Binary files /dev/null and b/public/uploaded/illustration showing why accounting software is essential for businesses. The image features a modern office setup with a computer scre.webp differ diff --git a/src/Controller/PageController.php b/src/Controller/PageController.php index 1f78137..21b1bd0 100644 --- a/src/Controller/PageController.php +++ b/src/Controller/PageController.php @@ -2,7 +2,9 @@ namespace App\Controller; +use App\Entity\Cat; use App\Entity\Post; +use App\Entity\Tree; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; @@ -22,13 +24,25 @@ class PageController extends AbstractController } #[Route('/blog/{page}', name: 'app_blog_home')] - public function app_blog_home($page = 1, EntityManagerInterface $entityManagerInterface, string $url): Response + public function app_blog_home(EntityManagerInterface $entityManagerInterface, $page = 1): Response { - $item = $entityManagerInterface->getRepository(Post::class)->findByUrlFilterCat($url, 'blog'); - if (!$item) - throw $this->createNotFoundException(); + $perpage = 6; + $posts = $entityManagerInterface->getRepository(Post::class)->findByCat('blog',$perpage,$page); + $cat = $entityManagerInterface->getRepository(Cat::class)->findOneBy(['code'=>'blog']); + $count = $entityManagerInterface->getRepository(Post::class)->count(['cat'=>$cat]); + if(fmod($count,$perpage) == 0){ + $maxpages = $count/$perpage; + } + else{ + $maxpages = ($count/$perpage) + 1; + } + $maxpages = $count / $perpage; return $this->render('post/blog_home.html.twig', [ - 'item' => $item, + 'posts' => $posts, + 'page' => $page, + 'perpage'=> $perpage, + 'count' => $count, + 'maxpages' => $maxpages ]); } @@ -38,8 +52,45 @@ class PageController extends AbstractController $item = $entityManagerInterface->getRepository(Post::class)->findByUrlFilterCat($url, 'blog'); if (!$item) throw $this->createNotFoundException(); - return $this->render('post/page.html.twig', [ + if (!$item->getViews()) + $item->setViews(1); + else + $item->setViews($item->getViews() + 1); + $entityManagerInterface->persist($item); + + return $this->render('post/blog_post.html.twig', [ 'item' => $item, + 'posts' => $entityManagerInterface->getRepository(Post::class)->findByCat('blog',3), + ]); + } + + #[Route('/api_docs/{url}', name: 'app_api_docs')] + public function app_api_docs(EntityManagerInterface $entityManagerInterface, string $url='home'): Response + { + $item = $entityManagerInterface->getRepository(Post::class)->findByUrlFilterCat($url, 'api'); + if (!$item) + throw $this->createNotFoundException(); + + //get list of trees + $tress = $entityManagerInterface->getRepository(Tree::class)->findAllByCat('api'); + return $this->render('post/api_docs.html.twig', [ + 'item' => $item, + 'trees' => $tress, + ]); + } + + #[Route('/guide/{url}', name: 'app_guide')] + public function app_guide(EntityManagerInterface $entityManagerInterface, string $url='home'): Response + { + $item = $entityManagerInterface->getRepository(Post::class)->findByUrlFilterCat($url, 'guide'); + if (!$item) + throw $this->createNotFoundException(); + + //get list of trees + $tress = $entityManagerInterface->getRepository(Tree::class)->findAllByCat('guide'); + return $this->render('post/guide.html.twig', [ + 'item' => $item, + 'trees' => $tress, ]); } } diff --git a/src/Entity/Post.php b/src/Entity/Post.php index dc6c1ef..872c81b 100644 --- a/src/Entity/Post.php +++ b/src/Entity/Post.php @@ -71,6 +71,9 @@ class Post #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $intro = null; + #[ORM\Column(length: 255, nullable: true)] + private ?string $views = null; + public function __construct() { $this->tree = new ArrayCollection(); @@ -291,4 +294,16 @@ class Post return $this; } + + public function getViews(): ?string + { + return $this->views; + } + + public function setViews(?string $views): static + { + $this->views = $views; + + return $this; + } } diff --git a/src/Repository/PostRepository.php b/src/Repository/PostRepository.php index 489238b..8552650 100644 --- a/src/Repository/PostRepository.php +++ b/src/Repository/PostRepository.php @@ -33,7 +33,7 @@ class PostRepository extends ServiceEntityRepository // ; // } - public function findByUrlFilterCat($value,$cat='plain'): ?Post + public function findByUrlFilterCat($value, $cat = 'plain'): ?Post { return $this->createQueryBuilder('p') ->innerJoin('p.cat', 'c') @@ -45,14 +45,15 @@ class PostRepository extends ServiceEntityRepository ->getOneOrNullResult() ; } - public function findBycat($cat='blog' , $count = 3): array + public function findBycat($cat = 'blog', $count = 3, $page = 1): array { return $this->createQueryBuilder('p') ->innerJoin('p.cat', 'c') ->where('c.code = :cat') ->setParameter('cat', $cat) + ->setFirstResult(($page - 1) * $count) ->setMaxResults($count) - ->orderBy('p.dateSubmit','DESC') + ->orderBy('p.dateSubmit', 'DESC') ->getQuery() ->getResult() ; diff --git a/src/Repository/TreeRepository.php b/src/Repository/TreeRepository.php index 93859dc..7348334 100644 --- a/src/Repository/TreeRepository.php +++ b/src/Repository/TreeRepository.php @@ -16,6 +16,17 @@ class TreeRepository extends ServiceEntityRepository parent::__construct($registry, Tree::class); } + public function findAllByCat($cat = 'guide'): ?array + { + return $this->createQueryBuilder('p') + ->innerJoin('p.cat', 'c') + ->where('c.code = :cat') + ->setParameter('cat', $cat) + ->getQuery() + ->getResult() + ; + } + // /** // * @return Tree[] Returns an array of Tree objects // */ diff --git a/templates/base.html.twig b/templates/base.html.twig index 3d6e824..91daf55 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -5,14 +5,15 @@ - {% set des = twigFunctions.systemSettings.des %} - {% if block('des') is defined %} - {% set _block = block('des') %} - {% endif %} - {% if _block is defined %} + {% if block('des') is not defined %} {% else %} - + + {% endif %} + {% if block('keywords') is not defined %} + + {% else %} + {% endif %} حسابیکس - @@ -45,10 +46,10 @@ <a class="nav-link" href="{{path('app_home')}}">صفحه نخست</a> </li> <li class="nav-item"> - <a class="nav-link" href="{{path('app_home')}}">راهنمای جامع</a> + <a class="nav-link" href="{{path('app_guide')}}">راهنمای جامع</a> </li> <li class="nav-item"> - <a class="nav-link" href="{{path('app_home')}}">وبلاگ</a> + <a class="nav-link" href="{{path('app_blog_home')}}">وبلاگ</a> </li> <li class="nav-item"> <a class="nav-link" href="{{path('app_page',{'url':'sponsors'})}}">حامیان مالی</a> @@ -74,7 +75,7 @@ <a href="{{path('app_page',{'url':'hsx'})}}" class="nav-link px-2">توکن HSX</a> </li> <li class="nav-item"> - <a href="{{path('app_page',{'url':'contact'})}}" class="nav-link px-2">مستندات API</a> + <a href="{{path('app_api_docs',{'url':'home'})}}" class="nav-link px-2">مستندات API</a> </li> <li class="nav-item"> <a href="https://github.com/morrning" target="_blank" class="nav-link px-2">مخازن کد</a> diff --git a/templates/general/home.html.twig b/templates/general/home.html.twig index 99c4e3f..ed6feee 100644 --- a/templates/general/home.html.twig +++ b/templates/general/home.html.twig @@ -105,7 +105,6 @@ </div> </div> {% endfor %} - </div> </div> </div> diff --git a/templates/post/api_docs.html.twig b/templates/post/api_docs.html.twig new file mode 100644 index 0000000..94a7be0 --- /dev/null +++ b/templates/post/api_docs.html.twig @@ -0,0 +1,50 @@ +{% extends 'base.html.twig' %} +{% block keywords %}item.keywords +{% endblock %} +{% block title %} + {{ item.title }} +{% endblock %} + +{% block des %} + {{ item.intro }} +{% endblock %} + +{% block body %} + <style></style> + <div class="container mt-3"> + <h1 class="text-primary fs-3">مستندات استفاده از API حسابیکس</h1> + <div class="row"> + <div class="col-sm-12 col-md-4 mb-2"> + <div class="accordion rounded-3" id="accaccordion"> + {% for tree in trees %} + <div class="accordion-item"> + <h2 class="accordion-header bg-body-tertiary"> + <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#colp{{ loop.index }}" aria-expanded="true" aria-controls="collapseOne"> + {{tree.label}} + </button> + </h2> + <div id="colp{{ loop.index }}" class="accordion-collapse collapse" data-bs-parent="#accordion"> + <div class="accordion-body p-0"> + <ul class="list-group p-0 rounded-0"> + {% for post in tree.getPosts %} + <li class="list-group-item"> + <a href="{{path('app_api_docs',{'url':post.url})}}" class="rul">{{ post.title }}</a> + </li> + {% endfor %} + </ul> + </div> + </div> + </div> + {% endfor %} + </div> + </div> + <div class="col-sm-12 col-md-8 mb-2"> + <div class="rounded-3 shadow p-3"> + <h1 class="text-primary fs-4">{{item.title}}</h1> + <p>{{item.body | raw}}</p> + <p>{{item.plain | raw}}</p> + </div> + </div> + </div> + </div> +{% endblock %} diff --git a/templates/post/blog_home.html.twig b/templates/post/blog_home.html.twig new file mode 100644 index 0000000..fee6fdb --- /dev/null +++ b/templates/post/blog_home.html.twig @@ -0,0 +1,62 @@ +{% extends 'base.html.twig' %} +{% block title %} + وبلاگ +{% endblock %} + +{% block des %} + جدیدترین اطلاعات و خبرها از دنیای حسابداری +{% endblock %} + +{% block body %} + <main class="container mt-2 mb-5"> + <h1 class="text-primary fs-3">وبلاگ حسابیکس</h1> + <div class="row"> + <div class="col-md-12"> + <div class="row"> + {% for post in posts %} + <div class="col-md-4"> + <article class="card mb-4"> + <img src="{{asset('uploaded/'~ post.mainPic)}}" alt="{{post.title}}" class="card-img-top"> + <div class="card-body"> + <h5 class="card-title text-primary">{{ post.title }}</h5> + <p class="card-text">{{ post.intro }}</p> + <a href="{{path('app_blog_post',{'url':post.url})}}" class="btn btn-sm rounded-4 btn-primary stretched-link">ادامه مطلب</a> + </div> + </article> + </div> + {% endfor %} + </div> + <div class="row"> + <nav aria-label="Page navigation example" style="direction: ltr;"> + <ul class="pagination justify-content-center"> + <li class="page-item {% if page == 1 %}disabled{% endif %}"> + <a href="{{ path('app_blog_home',{'page':page -1})}}" class="page-link">صفحه قبل</a> + </li> + <li class="page-item"> + <a class="page-link disabled" href="{{ path('app_blog_home',{'page':page })}}">{{page}}</a> + </li> + {% if (page + 1) <= maxpages %} + <li class="page-item"> + <a class="page-link" href="{{ path('app_blog_home',{'page':page +1})}}">{{page +1}}</a> + </li> + {% endif %} + {% if (page + 2) <= maxpages %} + <li class="page-item"> + <a class="page-link" href="{{ path('app_blog_home',{'page':page +2})}}">{{page + 2}}</a> + </li> + {% endif %} + {% if (page + 3) <= maxpages %} + <li class="page-item"> + <a class="page-link" href="{{ path('app_blog_home',{'page':page +3})}}">{{page + 3}}</a> + </li> + {% endif %} + <li class="page-item"> + <a href="{{ path('app_blog_home',{'page':page +1})}}" class="page-link {% if (page + 1) > maxpages %}disabled{% endif %}">صفحه بعدی</a> + </li> + </ul> + </nav> + </div> + </div> + </div> + </main> +{% endblock %} diff --git a/templates/post/blog_post.html.twig b/templates/post/blog_post.html.twig new file mode 100644 index 0000000..cdb1e08 --- /dev/null +++ b/templates/post/blog_post.html.twig @@ -0,0 +1,60 @@ +{% extends 'base.html.twig' %} +{% block keywords %}item.keywords +{% endblock %} +{% block title %} + {{ item.title }} +{% endblock %} + +{% block des %} + {{ item.intro }} +{% endblock %} + +{% block body %} + {% if item.plain is not null %} + {{ item.plain | raw}} + {% endif %} + {% if item.body is not null %} + <div class="container mt-3"> + <div class="row"> + <div class="col-sm-12 col-md-8"> + <h1 class="text-primary fs-3 my-3">{{item.title}}</h1> + <img class="img-fluid rounded-4" src="{{asset('uploaded/'~ item.mainPic)}}" alt="{{item.title}}"/> + <div class="card bg-body-tertiary my-4"> + <div class="card-body"> + <div class="card-text"> + {{item.intro}} + </div> + <div class="card-text"> + <figure> + <blockquote class="blockquote"> + </blockquote> + <figcaption class="blockquote-footer"> + توسط + {{item.submitter.name}} + <cite title="Source Title"> در تاریخ + {{Jdate.jdate('Y/n/d',item.dateSubmit)}} + </cite> + </figcaption> + </figure> + </div> + </div> + </div> + <p>{{ item.body | raw }}</p> + </div> + <div class="col-sm-12 col-md-4"> + <h3 class="text-primary">جدیدترین‌ها</h3> + {% for post in posts %} + <div class="card mb-2"> + <img src="{{asset('uploaded/'~ post.mainPic)}}" class="card-img-top" alt="{{post.title}}"> + <div class="card-body"> + <a href="{{path('app_blog_post',{'url':post.url})}}" class="rul stretched-link"> + <h5 class="card-title text-primary">{{post.title}}</h5> + </a> + </div> + </div> + {% endfor %} + </div> + </div> + </div> + {% endif %} +{% endblock %} diff --git a/templates/post/guide.html.twig b/templates/post/guide.html.twig new file mode 100644 index 0000000..38b64dd --- /dev/null +++ b/templates/post/guide.html.twig @@ -0,0 +1,50 @@ +{% extends 'base.html.twig' %} +{% block keywords %}item.keywords +{% endblock %} +{% block title %} + {{ item.title }} +{% endblock %} + +{% block des %} + {{ item.intro }} +{% endblock %} + +{% block body %} + <style></style> + <div class="container mt-3"> + <h1 class="text-primary fs-3">راهنمای استفاده از حسابیکس</h1> + <div class="row"> + <div class="col-sm-12 col-md-4 mb-2"> + <div class="accordion rounded-3" id="accaccordion"> + {% for tree in trees %} + <div class="accordion-item"> + <h2 class="accordion-header bg-body-tertiary"> + <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#colp{{ loop.index }}" aria-expanded="true" aria-controls="collapseOne"> + {{tree.label}} + </button> + </h2> + <div id="colp{{ loop.index }}" class="accordion-collapse collapse" data-bs-parent="#accordion"> + <div class="accordion-body p-0"> + <ul class="list-group p-0 rounded-0"> + {% for post in tree.getPosts %} + <li class="list-group-item"> + <a href="{{path('app_guide',{'url':post.url})}}" class="rul">{{ post.title }}</a> + </li> + {% endfor %} + </ul> + </div> + </div> + </div> + {% endfor %} + </div> + </div> + <div class="col-sm-12 col-md-8 mb-2"> + <div class="rounded-3 shadow p-3"> + <h1 class="text-primary fs-4">{{item.title}}</h1> + <p>{{item.body | raw}}</p> + <p>{{item.plain | raw}}</p> + </div> + </div> + </div> + </div> +{% endblock %} diff --git a/templates/post/page.html.twig b/templates/post/page.html.twig index 7283f66..645f28d 100644 --- a/templates/post/page.html.twig +++ b/templates/post/page.html.twig @@ -1,5 +1,5 @@ {% extends 'base.html.twig' %} - +{% block keywords %}item.keywords{% endblock %} {% block title %} {{ item.title }} {% endblock %}