Merge branch 'master' of localhost:gergelypolonkaiweb

This commit is contained in:
Polonkai Gergely 2012-10-06 13:26:14 +02:00
commit fade19d16c
17 changed files with 1874 additions and 21 deletions

1
.gitignore vendored
View File

@ -13,7 +13,6 @@ web/bundles/*
app/config/parameters.ini
# Composer related files
composer.lock
vendor/composer/installed.json
# Assetic-generated .js and .css files

View File

@ -7,7 +7,7 @@
"repositories": [
{
"type": "vcs",
"url": "https://github.com/w00d5t0ck/IoTcpdfBundle"
"url": "https://github.com/gergelypolonkai/IoTcpdfBundle"
}
],
"require": {
@ -45,9 +45,6 @@
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"config": {
"bin-dir": "bin"
},
"minimum-stability": "dev",
"extra": {
"symfony-app-dir": "app",

1726
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,7 @@ class AdminController extends Controller
* @Route("/blog/post/{id}", name="GergelyPolonkaiFrontBundle_adminEditBlogPost", defaults={"id": null})
* @Template
*/
public function newBlogPostAction($id = null)
public function editBlogPostAction($id = null)
{
if (is_numeric($id)) {
$post = $this->getDoctrine()->getRepository('GergelyPolonkaiFrontBundle:Post')->findOneById($id);
@ -73,8 +73,8 @@ class AdminController extends Controller
if ($request->getMethod() === 'POST') {
$form->bind($request);
if ($form->isValid()) {
$tagManager = $this->get('fpn_tag.tag_manager');
if (($tags = $form->get('tags')->getData()) != '') {
$tagManager = $this->get('fpn_tag.tag_manager');
$tagNames = $tagManager->splitTagNames($tags);
$tagList = $tagManager->loadOrCreateTags($tagNames);
$tagManager->addTags($tagList, $post);

View File

@ -4,9 +4,11 @@ namespace GergelyPolonkai\FrontBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Doctrine\ORM\Tools\Pagination\Paginator;
use GergelyPolonkai\FrontBundle\Entity\Post;
use GergelyPolonkai\FrontBundle\Entity\Tag;
/**
* Description of BlogController
@ -17,6 +19,9 @@ use GergelyPolonkai\FrontBundle\Entity\Post;
*/
class BlogController extends Controller
{
// TODO: Make this a config parameter
private $postsPerPage = 10;
/**
* @Route("/", name="GergelyPolonkaiFrontBundle_blogListing")
* @Route("/page/{cPage}", name="GergelyPolonkaiFrontBundle_blogListingPage", requirements={"cPage": "\d+"})
@ -24,16 +29,14 @@ class BlogController extends Controller
*/
public function listAction($cPage = 1)
{
// TODO: Make this a config parameter
$postsPerPage = 10;
--$cPage;
$query = $this
->getDoctrine()
->getEntityManager()
->createQuery("SELECT p FROM GergelyPolonkaiFrontBundle:Post p WHERE p.draft = FALSE ORDER BY p.createdAt DESC")
->setFirstResult($cPage * $postsPerPage)
->setMaxResults($postsPerPage);
->setFirstResult($cPage * $this->postsPerPage)
->setMaxResults($this->postsPerPage);
$paginator = new Paginator($query, $fetchJoinCollection = true);
$tagManager = $this->get('fpn_tag.tag_manager');
@ -42,13 +45,13 @@ class BlogController extends Controller
}
$count = $paginator->count();
$pageCount = ceil($count / $postsPerPage);
$pageCount = ceil($count / $this->postsPerPage);
return array(
'cpage' => $cPage,
'count' => $pageCount,
'posts' => $paginator,
'perPage' => $postsPerPage,
'perPage' => $this->postsPerPage,
);
}
@ -93,4 +96,43 @@ class BlogController extends Controller
'posts' => $posts,
);
}
/**
* @Route("/tag/{name}/", name="GergelyPolonkaiFrontBundle_blogTagList")
* @Route("/tag/{name}/page/{cPage}", name="GergelyPolonkaiFrontBundle_blogListingPage", requirements={"cPage": "\d+"})
* @Template("GergelyPolonkaiFrontBundle:Blog:list.html.twig")
* @ParamConverter("tag")
*/
public function tagListAction(Tag $tag, $cPage = 1)
{
$tagRepository = $this->getDoctrine()->getRepository('GergelyPolonkaiFrontBundle:Tag');
$ids = $tagRepository->getResourceIdsForTag('gergelypolonkaifront_post', $tag->getName());
--$cPage;
$query = $this
->getDoctrine()
->getEntityManager()
->createQuery("SELECT p FROM GergelyPolonkaiFrontBundle:Post p WHERE p.draft = FALSE AND p.id IN (:idList) ORDER BY p.createdAt DESC")
->setParameter('idList', $ids)
->setFirstResult($cPage * $this->postsPerPage)
->setMaxResults($this->postsPerPage);
$paginator = new Paginator($query, $fetchJoinCollection = true);
$tagManager = $this->get('fpn_tag.tag_manager');
foreach ($paginator as $post) {
$tagManager->loadTagging($post);
}
$count = $paginator->count();
$pageCount = ceil($count / $this->postsPerPage);
return array(
'cpage' => $cPage,
'count' => $pageCount,
'posts' => $paginator,
'perPage' => $this->postsPerPage,
);
}
}

View File

@ -189,4 +189,4 @@ class CodeChunk
{
return $this->content;
}
}
}

View File

@ -195,4 +195,4 @@ class Comment
{
return $this->user;
}
}
}

View File

@ -293,4 +293,4 @@ class Post implements Taggable
{
return $this->id;
}
}
}

View File

@ -9,7 +9,7 @@ use FPN\TagBundle\Entity\Tag as BaseTag;
*
* @author polesz
*
* @ORM\Entity
* @ORM\Entity(repositoryClass="DoctrineExtensions\Taggable\Entity\TagRepository")
* @ORM\Table(name="tags")
*/
class Tag extends BaseTag
@ -31,4 +31,4 @@ class Tag extends BaseTag
* @ORM\OneToMany(targetEntity="Tagging", mappedBy="tag", fetch="EAGER")
*/
protected $tagging;
}
}

View File

@ -33,4 +33,4 @@ class Tagging extends BaseTagging
* @ORM\ManyToOne(targetEntity="Tag")
*/
protected $tag;
}
}

View File

@ -135,4 +135,4 @@ class User implements UserInterface
{
return $this->password;
}
}
}

View File

@ -165,4 +165,33 @@ dd p {
#more-posts {
margin-top: 1em;
text-align: right;
}
#tag-cloud a {
color: #b3b3b3;
text-decoration: none;
}
#tag-cloud .size0 {
font-size: 80%;
}
#tag-cloud .size1 {
font-size: 90%;
}
#tag-cloud .size2 {
font-size: 100%;
}
#tag-cloud .size3 {
font-size: 110%;
}
#tag-cloud .size4 {
font-size: 130%;
}
#tag-cloud .size5 {
font-size: 150%;
}

View File

@ -26,6 +26,9 @@
{% block content %}
{{ block('paginator') }}
{% if posts|length == 0 %}
No posts found.
{% endif %}
{% for post in posts %}
{% include 'GergelyPolonkaiFrontBundle:Blog:postViewer.html.twig' with {'post': post, 'title_links': true} %}
{% endfor %}

View File

@ -5,7 +5,7 @@
{% if post.tags|length > 0 %}
<p class="article-tags">Tags:
{% for tag in post.tags %}
{{ tag.name }}
<a href="{{ path('GergelyPolonkaiFrontBundle_blogTagList', { name: tag.name }) }}">{{ tag.name }}</a>
{% endfor %}
</p>
{% endif %}

View File

@ -34,6 +34,13 @@
</div>
<div id="content">
<div id="content-padding"></div>
{% if tagCloud|length > 0 %}
<div id="tag-cloud">
{% for cloudItem in tagCloud %}
<a href="{{ path('GergelyPolonkaiFrontBundle_blogTagList', { name: cloudItem.name }) }}" class="size{{ cloudItem.size }}">{{ cloudItem.name }}</a>
{% endfor %}
</div>
{% endif %}
<div id="menu">
<ul>
<li><a href="{{ path('GergelyPolonkaiFrontBundle_about') }}">About me</a></li>

View File

@ -0,0 +1,50 @@
<?php
namespace GergelyPolonkai\FrontBundle\Twig;
use Symfony\Bridge\Doctrine\RegistryInterface;
use JMS\DiExtraBundle\Annotation as DI;
/**
* Description of tagCloud
*
* @author polesz
*
* @DI\Service
* @DI\Tag("twig.extension")
*/
class TagCloud extends \Twig_Extension
{
/**
* @var Symfony\Bridge\Doctrine\RegistryInterface $doctrine
*/
private $doctrine;
/**
* @DI\InjectParams()
*/
public function __construct(RegistryInterface $doctrine) {
$this->doctrine = $doctrine;
}
public function getGlobals()
{
$tagCloudQuery = $this->doctrine->getEntityManager()->createQuery('SELECT t, count(tg) ct FROM GergelyPolonkaiFrontBundle:Tag t LEFT JOIN t.tagging tg GROUP BY t.id ORDER BY t.name');
$tagCloudList = $tagCloudQuery->getResult();
$tagCloud = array();
foreach ($tagCloudList as $cloudElement) {
$tag = $cloudElement[0];
$tagCount = $cloudElement['ct'];
$size = ($tagCount == 0) ? 0 : floor(log($tagCount, 10));
if ($size > 5) $size = 5;
$tagCloud[] = array('name' => $tag->getName(), 'size' => $size);
}
return array(
'tagCloud' => $tagCloud,
);
}
public function getName() {
return 'gergelypolonkaifront_tagcloud';
}
}