progress in guide and api_docs

This commit is contained in:
Hesabix 2025-01-10 16:47:54 +00:00
parent 07155a63bc
commit 183d6b7872
15 changed files with 338 additions and 23 deletions

View file

@ -6,6 +6,16 @@ body {
-ms-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; -o-font-feature-settings: "kern" on, "liga" on, "dlig" on;
} }
a.nav-link:hover { a.nav-link:hover {
color: #1743bb; color: #1743bb;
} }
.rul{
text-decoration: none;
}
.accordion-button:after {
margin-right: auto;
margin-left: 0;
}

View file

@ -2,5 +2,10 @@
// customize some Bootstrap variables // customize some Bootstrap variables
$primary: #1743bb; $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 // the ~ allows you to reference things in node_modules
@import "~bootstrap/scss/bootstrap"; @import "~bootstrap/scss/bootstrap";

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

View file

@ -2,7 +2,9 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\Cat;
use App\Entity\Post; use App\Entity\Post;
use App\Entity\Tree;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@ -22,13 +24,25 @@ class PageController extends AbstractController
} }
#[Route('/blog/{page}', name: 'app_blog_home')] #[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'); $perpage = 6;
if (!$item) $posts = $entityManagerInterface->getRepository(Post::class)->findByCat('blog',$perpage,$page);
throw $this->createNotFoundException(); $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', [ 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'); $item = $entityManagerInterface->getRepository(Post::class)->findByUrlFilterCat($url, 'blog');
if (!$item) if (!$item)
throw $this->createNotFoundException(); 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, '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,
]); ]);
} }
} }

View file

@ -71,6 +71,9 @@ class Post
#[ORM\Column(type: Types::TEXT, nullable: true)] #[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $intro = null; private ?string $intro = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $views = null;
public function __construct() public function __construct()
{ {
$this->tree = new ArrayCollection(); $this->tree = new ArrayCollection();
@ -291,4 +294,16 @@ class Post
return $this; return $this;
} }
public function getViews(): ?string
{
return $this->views;
}
public function setViews(?string $views): static
{
$this->views = $views;
return $this;
}
} }

View file

@ -45,12 +45,13 @@ class PostRepository extends ServiceEntityRepository
->getOneOrNullResult() ->getOneOrNullResult()
; ;
} }
public function findBycat($cat='blog' , $count = 3): array public function findBycat($cat = 'blog', $count = 3, $page = 1): array
{ {
return $this->createQueryBuilder('p') return $this->createQueryBuilder('p')
->innerJoin('p.cat', 'c') ->innerJoin('p.cat', 'c')
->where('c.code = :cat') ->where('c.code = :cat')
->setParameter('cat', $cat) ->setParameter('cat', $cat)
->setFirstResult(($page - 1) * $count)
->setMaxResults($count) ->setMaxResults($count)
->orderBy('p.dateSubmit', 'DESC') ->orderBy('p.dateSubmit', 'DESC')
->getQuery() ->getQuery()

View file

@ -16,6 +16,17 @@ class TreeRepository extends ServiceEntityRepository
parent::__construct($registry, Tree::class); 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 // * @return Tree[] Returns an array of Tree objects
// */ // */

View file

@ -5,14 +5,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta lang="fa"> <meta lang="fa">
<meta content="width=device-width,initial-scale=1.0" name="viewport"/> <meta content="width=device-width,initial-scale=1.0" name="viewport"/>
{% set des = twigFunctions.systemSettings.des %} {% if block('des') is not defined %}
{% if block('des') is defined %}
{% set _block = block('des') %}
{% endif %}
{% if _block is defined %}
<meta content="{{twigFunctions.systemSettings.des}}" name="description"/> <meta content="{{twigFunctions.systemSettings.des}}" name="description"/>
{% else %} {% else %}
<meta content="{{block('des')}}" name="description"/> <meta content="{{block('des') | trim}}" name="description"/>
{% endif %}
{% if block('keywords') is not defined %}
<meta content="{{twigFunctions.systemSettings.siteKeywords}}" name="keywords"/>
{% else %}
<meta content="{{block('keywords') | trim}}" name="keywords"/>
{% endif %} {% endif %}
<meta content="Babak Alizadeh" name="author"/> <meta content="Babak Alizadeh" name="author"/>
<title>حسابیکس - <title>حسابیکس -
@ -45,10 +46,10 @@
<a class="nav-link" href="{{path('app_home')}}">صفحه نخست</a> <a class="nav-link" href="{{path('app_home')}}">صفحه نخست</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="{{path('app_home')}}">راهنمای جامع</a> <a class="nav-link" href="{{path('app_guide')}}">راهنمای جامع</a>
</li> </li>
<li class="nav-item"> <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>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="{{path('app_page',{'url':'sponsors'})}}">حامیان مالی</a> <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> <a href="{{path('app_page',{'url':'hsx'})}}" class="nav-link px-2">توکن HSX</a>
</li> </li>
<li class="nav-item"> <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>
<li class="nav-item"> <li class="nav-item">
<a href="https://github.com/morrning" target="_blank" class="nav-link px-2">مخازن کد</a> <a href="https://github.com/morrning" target="_blank" class="nav-link px-2">مخازن کد</a>

View file

@ -105,7 +105,6 @@
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
</div> </div>

View file

@ -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 %}

View file

@ -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 %}

View file

@ -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 %}

View file

@ -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 %}

View file

@ -1,5 +1,5 @@
{% extends 'base.html.twig' %} {% extends 'base.html.twig' %}
{% block keywords %}item.keywords{% endblock %}
{% block title %} {% block title %}
{{ item.title }} {{ item.title }}
{% endblock %} {% endblock %}