Add tag support
This commit is contained in:
parent
ce10245c51
commit
ae440be40c
24 changed files with 475 additions and 15 deletions
File diff suppressed because one or more lines are too long
|
|
@ -70,4 +70,28 @@
|
||||||
font-size: 1.25rem;
|
font-size: 1.25rem;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tags {
|
||||||
|
margin-top: 2rem;
|
||||||
|
background-color: colors.$primaryGrey;
|
||||||
|
|
||||||
|
.list {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1rem;
|
||||||
|
margin: 0;
|
||||||
|
list-style: none;
|
||||||
|
padding: 0.5rem 0.5rem;
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
a {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
37
migrations/Version20260608193439.php
Normal file
37
migrations/Version20260608193439.php
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20260608193439 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE TABLE photos_tag (photos_id INT NOT NULL, tag_id INT NOT NULL, PRIMARY KEY (photos_id, tag_id))');
|
||||||
|
$this->addSql('CREATE INDEX IDX_CBE2DE88301EC62 ON photos_tag (photos_id)');
|
||||||
|
$this->addSql('CREATE INDEX IDX_CBE2DE88BAD26311 ON photos_tag (tag_id)');
|
||||||
|
$this->addSql('ALTER TABLE photos_tag ADD CONSTRAINT FK_CBE2DE88301EC62 FOREIGN KEY (photos_id) REFERENCES photos (id) ON DELETE CASCADE');
|
||||||
|
$this->addSql('ALTER TABLE photos_tag ADD CONSTRAINT FK_CBE2DE88BAD26311 FOREIGN KEY (tag_id) REFERENCES tag (id) ON DELETE CASCADE');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE photos_tag DROP CONSTRAINT FK_CBE2DE88301EC62');
|
||||||
|
$this->addSql('ALTER TABLE photos_tag DROP CONSTRAINT FK_CBE2DE88BAD26311');
|
||||||
|
$this->addSql('DROP TABLE photos_tag');
|
||||||
|
}
|
||||||
|
}
|
||||||
55
src/Controller/Brain/BrainCategoryController.php
Normal file
55
src/Controller/Brain/BrainCategoryController.php
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller\Brain;
|
||||||
|
|
||||||
|
use App\Entity\Category;
|
||||||
|
use App\Form\CategoryType;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
|
final class BrainCategoryController extends AbstractController
|
||||||
|
{
|
||||||
|
#[Route('/brain/category/list', name: 'brain_categories_list')]
|
||||||
|
public function index(EntityManagerInterface $entityManager): Response
|
||||||
|
{
|
||||||
|
|
||||||
|
$categories = $entityManager->getRepository(Category::class)->findAll();
|
||||||
|
return $this->render('brain/taxonomy/index.html.twig', [
|
||||||
|
'taxonomy' => $categories,
|
||||||
|
'type' => 'Category'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/brain/category/new', name: 'brain_categories_new')]
|
||||||
|
public function new(EntityManagerInterface $entityManager, Request $request): Response
|
||||||
|
{
|
||||||
|
|
||||||
|
$form = $this->createForm(CategoryType::class);
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isSubmitted()) {
|
||||||
|
$data = $form->getData();
|
||||||
|
$category = new Category();
|
||||||
|
|
||||||
|
$category->setTitle($data->getTitle());
|
||||||
|
|
||||||
|
$entityManager->persist($category);
|
||||||
|
|
||||||
|
$entityManager->flush();
|
||||||
|
|
||||||
|
return $this->redirectToRoute('brain_categories_list');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('brain/taxonomy/create.html.twig', [
|
||||||
|
'action' => 'New',
|
||||||
|
'form' => $form,
|
||||||
|
'type' => 'Category'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -43,6 +43,10 @@ final class BrainPhotosController extends AbstractController
|
||||||
$photos->setText($data->getText());
|
$photos->setText($data->getText());
|
||||||
$photos->setUrl($data->getUrl());
|
$photos->setUrl($data->getUrl());
|
||||||
|
|
||||||
|
foreach ($data->getTags() as $tag) {
|
||||||
|
$photos->addTag($tag);
|
||||||
|
}
|
||||||
|
|
||||||
$tax = $request->request->all('photos');
|
$tax = $request->request->all('photos');
|
||||||
|
|
||||||
if ($data->getCategory() == null) {
|
if ($data->getCategory() == null) {
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,10 @@ final class BrainPostController extends AbstractController
|
||||||
$post->SetPublished(false);
|
$post->SetPublished(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($data->getTags() as $tag) {
|
||||||
|
$post->addTag($tag);
|
||||||
|
}
|
||||||
|
|
||||||
$tax = $request->request->all('post');
|
$tax = $request->request->all('post');
|
||||||
|
|
||||||
if ($data->getCategory() == null) {
|
if ($data->getCategory() == null) {
|
||||||
|
|
|
||||||
56
src/Controller/Brain/BrainTagController.php
Normal file
56
src/Controller/Brain/BrainTagController.php
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller\Brain;
|
||||||
|
|
||||||
|
use App\Entity\Tag;
|
||||||
|
use App\Form\TagType;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
|
final class BrainTagController extends AbstractController
|
||||||
|
{
|
||||||
|
#[Route('/brain/tag/list', name: 'brain_tags_list')]
|
||||||
|
public function index(EntityManagerInterface $entityManager): Response
|
||||||
|
{
|
||||||
|
|
||||||
|
$tags = $entityManager->getRepository(Tag::class)->findAll();
|
||||||
|
|
||||||
|
return $this->render('brain/taxonomy/index.html.twig', [
|
||||||
|
'taxonomy' => $tags,
|
||||||
|
'type' => 'Tag'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/brain/tag/new', name: 'brain_tags_new')]
|
||||||
|
public function new(EntityManagerInterface $entityManager, Request $request): Response
|
||||||
|
{
|
||||||
|
|
||||||
|
$form = $this->createForm(TagType::class);
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isSubmitted()) {
|
||||||
|
$data = $form->getData();
|
||||||
|
$Tag = new Tag();
|
||||||
|
|
||||||
|
$Tag->setTitle($data->getTitle());
|
||||||
|
|
||||||
|
$entityManager->persist($Tag);
|
||||||
|
|
||||||
|
$entityManager->flush();
|
||||||
|
|
||||||
|
return $this->redirectToRoute('brain_tags_list');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('brain/taxonomy/create.html.twig', [
|
||||||
|
'action' => 'New',
|
||||||
|
'form' => $form,
|
||||||
|
'type' => 'Tag'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
48
src/Controller/FrontEnd/TagController.php
Normal file
48
src/Controller/FrontEnd/TagController.php
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller\FrontEnd;
|
||||||
|
|
||||||
|
use App\Entity\Tag;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
|
final class TagController extends AbstractController
|
||||||
|
{
|
||||||
|
#[Route('/tags', name: 'front_end_tag_list', priority: 1)]
|
||||||
|
public function index(EntityManagerInterface $entityManager): Response
|
||||||
|
{
|
||||||
|
$tags = $entityManager->getRepository(Tag::class)->findAll();
|
||||||
|
|
||||||
|
$tagsDisplay = [];
|
||||||
|
|
||||||
|
foreach ($tags as $index => $tag) {
|
||||||
|
$tagsDisplay[] = [
|
||||||
|
'title' => $tag->getTitle(),
|
||||||
|
'urlSafeTitle' => strtolower(str_replace(' ', '-', $tag->getTitle())),
|
||||||
|
'count' => $tag->getCount(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('front/tag/index.html.twig', [
|
||||||
|
'tags' => $tagsDisplay
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/tags/{tagTitle}', name: 'front_end_tag_detail')]
|
||||||
|
public function detail(EntityManagerInterface $entityManager, string $tagTitle): Response
|
||||||
|
{
|
||||||
|
$formattedTitle = ucwords(str_replace('-', ' ', $tagTitle));
|
||||||
|
$tag = $entityManager->getRepository(tag::class)->findOneBy(['title' => $formattedTitle]);
|
||||||
|
|
||||||
|
return $this->render('front/tag/detail.html.twig', [
|
||||||
|
'title' => $tag->getTitle(),
|
||||||
|
'posts' => $tag->getPosts(),
|
||||||
|
'photos' => $tag->getPhotos(),
|
||||||
|
'count' => $tag->getCount()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -40,9 +40,16 @@ class Photos
|
||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255)]
|
||||||
private ?string $thumbnail = null;
|
private ?string $thumbnail = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection<int, Tag>
|
||||||
|
*/
|
||||||
|
#[ORM\ManyToMany(targetEntity: Tag::class, inversedBy: 'photos')]
|
||||||
|
private Collection $tags;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->uploads = new ArrayCollection();
|
$this->uploads = new ArrayCollection();
|
||||||
|
$this->tags = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
|
|
@ -151,4 +158,28 @@ class Photos
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, Tag>
|
||||||
|
*/
|
||||||
|
public function getTags(): Collection
|
||||||
|
{
|
||||||
|
return $this->tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addTag(Tag $tag): static
|
||||||
|
{
|
||||||
|
if (!$this->tags->contains($tag)) {
|
||||||
|
$this->tags->add($tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeTag(Tag $tag): static
|
||||||
|
{
|
||||||
|
$this->tags->removeElement($tag);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,16 @@ class Tag
|
||||||
#[ORM\ManyToMany(targetEntity: Post::class, mappedBy: 'tags')]
|
#[ORM\ManyToMany(targetEntity: Post::class, mappedBy: 'tags')]
|
||||||
private Collection $posts;
|
private Collection $posts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection<int, Photos>
|
||||||
|
*/
|
||||||
|
#[ORM\ManyToMany(targetEntity: Photos::class, mappedBy: 'tags')]
|
||||||
|
private Collection $photos;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->posts = new ArrayCollection();
|
$this->posts = new ArrayCollection();
|
||||||
|
$this->photos = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
|
|
@ -72,4 +79,46 @@ class Tag
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, Photos>
|
||||||
|
*/
|
||||||
|
public function getPhotos(): Collection
|
||||||
|
{
|
||||||
|
return $this->photos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addPhoto(Photos $photo): static
|
||||||
|
{
|
||||||
|
if (!$this->photos->contains($photo)) {
|
||||||
|
$this->photos->add($photo);
|
||||||
|
$photo->addTag($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removePhoto(Photos $photo): static
|
||||||
|
{
|
||||||
|
if ($this->photos->removeElement($photo)) {
|
||||||
|
$photo->removeTag($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCount() : int
|
||||||
|
{
|
||||||
|
return $this->posts->count() + $this->photos->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUrlSafeTitle() : string
|
||||||
|
{
|
||||||
|
return strtolower(str_replace(' ', '-', $this->title));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDisplaySafeTitle(string $urlSafeTitle) : string
|
||||||
|
{
|
||||||
|
return ucwords(str_replace('-', ' ', $urlSafeTitle));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
26
src/Form/CategoryType.php
Normal file
26
src/Form/CategoryType.php
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Form;
|
||||||
|
|
||||||
|
use App\Entity\Category;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
|
||||||
|
class CategoryType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
{
|
||||||
|
$builder->add('title')
|
||||||
|
->add('save', SubmitType::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => Category::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ namespace App\Form;
|
||||||
use App\Entity\Photos;
|
use App\Entity\Photos;
|
||||||
|
|
||||||
use App\Form\CategoryAutocompleteField;
|
use App\Form\CategoryAutocompleteField;
|
||||||
|
use App\Form\TagAutocompleteField;
|
||||||
use App\Form\PhotoType;
|
use App\Form\PhotoType;
|
||||||
use App\Form\DataTransformer\UploadDataTransformer;
|
use App\Form\DataTransformer\UploadDataTransformer;
|
||||||
|
|
||||||
|
|
@ -25,6 +26,7 @@ class PhotosType extends AbstractType
|
||||||
->add('title')
|
->add('title')
|
||||||
->add('date', DateType::class)
|
->add('date', DateType::class)
|
||||||
->add('category', CategoryAutocompleteField::class)
|
->add('category', CategoryAutocompleteField::class)
|
||||||
|
->add('tags', TagAutocompleteField::class, ['required' => false])
|
||||||
->add('text')
|
->add('text')
|
||||||
->add('thumbnail', FileType::class, [
|
->add('thumbnail', FileType::class, [
|
||||||
'label' => 'Thumbnail',
|
'label' => 'Thumbnail',
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,11 @@ use App\Form\CategoryAutocompleteField;
|
||||||
use App\Form\TagAutocompleteField;
|
use App\Form\TagAutocompleteField;
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Form\FormEvent;
|
|
||||||
use Symfony\Component\Form\FormEvents;
|
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class PostType extends AbstractType
|
class PostType extends AbstractType
|
||||||
|
|
@ -28,7 +24,7 @@ class PostType extends AbstractType
|
||||||
->add('date', DateType::class)
|
->add('date', DateType::class)
|
||||||
->add('text', TextareaType::class)
|
->add('text', TextareaType::class)
|
||||||
->add('category', CategoryAutocompleteField::class)
|
->add('category', CategoryAutocompleteField::class)
|
||||||
//->add('tags', TagAutocompleteField::class, ['required' => false])
|
->add('tags', TagAutocompleteField::class, ['required' => false])
|
||||||
->add('url', TextType::class)
|
->add('url', TextType::class)
|
||||||
->add('published')
|
->add('published')
|
||||||
->add('save', SubmitType::class, ['label' => 'Save'])
|
->add('save', SubmitType::class, ['label' => 'Save'])
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,6 @@ class TagAutocompleteField extends AbstractType
|
||||||
'choice_label' => 'title',
|
'choice_label' => 'title',
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
/* TODO this isn't natively supported collections/choice type
|
|
||||||
so we're going to manually do it for now
|
|
||||||
*/
|
|
||||||
/*'tom_select_options' => [
|
|
||||||
'create' => true,
|
|
||||||
] */
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
27
src/Form/TagType.php
Normal file
27
src/Form/TagType.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Form;
|
||||||
|
|
||||||
|
use App\Entity\Tag;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
|
||||||
|
class TagType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
{
|
||||||
|
$builder->add('title')
|
||||||
|
->add('save', SubmitType::class);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => Tag::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -23,7 +23,9 @@
|
||||||
<li class="level-1--item sub-menu">
|
<li class="level-1--item sub-menu">
|
||||||
<span class="sub-menu--link">Taxonomy</span>
|
<span class="sub-menu--link">Taxonomy</span>
|
||||||
<menu class="level-2">
|
<menu class="level-2">
|
||||||
|
<li class="level-2--item"><a href="/brain/category/list">All Categories</a></li>
|
||||||
<li class="level-2--item"><a href="/brain/category/new">Add New Category</a></li>
|
<li class="level-2--item"><a href="/brain/category/new">Add New Category</a></li>
|
||||||
|
<li class="level-2--item"><a href="/brain/tag/list">All Tags</a></li>
|
||||||
<li class="level-2--item"><a href="/brain/tag/new">Add New Tag</a></li>
|
<li class="level-2--item"><a href="/brain/tag/new">Add New Tag</a></li>
|
||||||
</menu>
|
</menu>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,9 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{{ form_row(form.category) }}
|
{{ form_row(form.category) }}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
{{ form_row(form.tags) }}
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{{ form_row(form.thumbnail) }}
|
{{ form_row(form.thumbnail) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{{ form_row(form.category) }}
|
{{ form_row(form.category) }}
|
||||||
</div>
|
</div>
|
||||||
{# <div class="row">
|
<div class="row">
|
||||||
{{ form_row(form.tags) }}
|
{{ form_row(form.tags) }}
|
||||||
</div> #}
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{{ form_row(form.url) }}
|
{{ form_row(form.url) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
23
templates/brain/taxonomy/create.html.twig
Normal file
23
templates/brain/taxonomy/create.html.twig
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
{% extends 'brain/base.html.twig' %}
|
||||||
|
|
||||||
|
{% block title %}{{ action|capitalize }} {{ type }} {% endblock %}
|
||||||
|
|
||||||
|
{% block page_title %}<h1>Add New {{ type }}</h1>{% endblock %}
|
||||||
|
|
||||||
|
{# {% block actions%}Actions here{% endblock %} #}
|
||||||
|
|
||||||
|
{% block admin %}
|
||||||
|
<section class="add-new--{{type|lower}}">
|
||||||
|
{{ form_start(form) }}
|
||||||
|
<div class="form-errors">
|
||||||
|
{{ form_errors(form) }}
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
{{ form_row(form.title) }}
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
{{ form_rest(form) }}
|
||||||
|
</div>
|
||||||
|
{{ form_end(form) }}
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
||||||
27
templates/brain/taxonomy/index.html.twig
Normal file
27
templates/brain/taxonomy/index.html.twig
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
{% extends 'brain/base.html.twig' %}
|
||||||
|
|
||||||
|
{% block title %}{{ type }} {% endblock %}
|
||||||
|
|
||||||
|
{% block page_title %}<h1>All {{ type }}</h1>{% endblock %}
|
||||||
|
|
||||||
|
{# {% block actions%}Actions here{% endblock %} #}
|
||||||
|
|
||||||
|
{% block admin %}
|
||||||
|
<div class="list">
|
||||||
|
<h2><a href="/brain/{{type|lower}}/new">New {{ type }}</a></h2>
|
||||||
|
<table class="posts">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>Title</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for term in taxonomy %}
|
||||||
|
<tr>
|
||||||
|
<td>{{term.title}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends 'home.html.twig' %}
|
{% extends 'home.html.twig' %}
|
||||||
|
|
||||||
{% block title %}Hello | Alex Daniels{% endblock %}
|
{% block title %}Alex Daniels{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
{% block nav %}
|
{% block nav %}
|
||||||
|
|
|
||||||
|
|
@ -17,5 +17,13 @@
|
||||||
<div class="text">
|
<div class="text">
|
||||||
{{ post.text|raw }}
|
{{ post.text|raw }}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tags">
|
||||||
|
<ul class="list">
|
||||||
|
<p>More like this:</p>
|
||||||
|
{% for tag in post.tags %}
|
||||||
|
<li class="tag"><a href="/tags/{{tag.getUrlSafeTitle()}}">{{ tag.title }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul
|
||||||
|
</div>
|
||||||
</article>
|
</article>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
28
templates/front/tag/detail.html.twig
Normal file
28
templates/front/tag/detail.html.twig
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block title %}Tags | Alex Daniels{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<section class="tag">
|
||||||
|
{% if posts|length %}
|
||||||
|
<div class="posts">
|
||||||
|
<h2>Posts</h2>
|
||||||
|
<ul>
|
||||||
|
{% for post in posts %}
|
||||||
|
<li><a href="/words/{{post.url}}">{{post.title}}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if photos|length %}
|
||||||
|
<div class="photos">
|
||||||
|
<h2>Photos</h2>
|
||||||
|
<ul>
|
||||||
|
{% for photo in photos %}
|
||||||
|
<li><a href="/photos/{{photo.url}}">{{photo.title}}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
||||||
16
templates/front/tag/index.html.twig
Normal file
16
templates/front/tag/index.html.twig
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block title %}Tags | Alex Daniels{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<section class="tags">
|
||||||
|
<h2>Tags</h2>
|
||||||
|
<ul>
|
||||||
|
{% for tag in tags %}
|
||||||
|
<li>
|
||||||
|
<a href="/tags/{{tag['urlSafeTitle']}}">{{tag['title']}} ({{tag['count']}})</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue