From: Jeremy Benoist Date: Mon, 10 Oct 2016 14:58:15 +0000 (+0200) Subject: Merge pull request #2403 from wallabag/cleanup-install-process-in-doc X-Git-Tag: 2.1.2~21 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=bccf7a70bc22171904a5bb82d282e9c956684abc;hp=fa4c39b37c1e1a1b52739a070775e9ba0fafe802;p=github%2Fwallabag%2Fwallabag.git Merge pull request #2403 from wallabag/cleanup-install-process-in-doc Cleaned up documentation for installation process --- diff --git a/app/Resources/static/themes/material/css/main.css b/app/Resources/static/themes/material/css/main.css index b66c88f9..d91b469f 100755 --- a/app/Resources/static/themes/material/css/main.css +++ b/app/Resources/static/themes/material/css/main.css @@ -414,9 +414,10 @@ main ul.row { max-width: 50%; } -.card .card-entry-labels li { +.card .card-entry-labels li, +.card-tag-labels li { margin: 10px 10px 10px auto; - padding: 5px 12px 5px 16px; + padding: 5px 12px 5px 16px !important; background-color: rgba(0, 151, 167, 0.85); border-radius: 0 3px 3px 0; color: #fff; @@ -447,6 +448,7 @@ main ul.row { .card-entry-tags a, .card-entry-labels a, +.card-tag-labels a, .card-entry-labels-hidden a, #list .chip a { text-decoration: none; diff --git a/app/config/config.yml b/app/config/config.yml index 75d7299c..bcc4c8eb 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -30,7 +30,7 @@ framework: assets: ~ wallabag_core: - version: 2.1.1 + version: 2.1.2-dev paypal_url: "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9UBA65LG3FX9Y&lc=gb" languages: en: 'English' diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index ed31c536..9997913d 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -387,7 +387,7 @@ class WallabagRestController extends FOSRestController $tags = $this->getDoctrine() ->getRepository('WallabagCoreBundle:Tag') - ->findAllTagsWithEntries($this->getUser()->getId()); + ->findAllTags($this->getUser()->getId()); $json = $this->get('serializer')->serialize($tags, 'json'); diff --git a/src/Wallabag/ApiBundle/Entity/AccessToken.php b/src/Wallabag/ApiBundle/Entity/AccessToken.php index 2ff63a83..c09a0c80 100644 --- a/src/Wallabag/ApiBundle/Entity/AccessToken.php +++ b/src/Wallabag/ApiBundle/Entity/AccessToken.php @@ -19,7 +19,7 @@ class AccessToken extends BaseAccessToken protected $id; /** - * @ORM\ManyToOne(targetEntity="Client") + * @ORM\ManyToOne(targetEntity="Client", inversedBy="accessTokens") * @ORM\JoinColumn(nullable=false) */ protected $client; diff --git a/src/Wallabag/ApiBundle/Entity/RefreshToken.php b/src/Wallabag/ApiBundle/Entity/RefreshToken.php index 6d0cab68..822a02d8 100644 --- a/src/Wallabag/ApiBundle/Entity/RefreshToken.php +++ b/src/Wallabag/ApiBundle/Entity/RefreshToken.php @@ -19,7 +19,7 @@ class RefreshToken extends BaseRefreshToken protected $id; /** - * @ORM\ManyToOne(targetEntity="Client") + * @ORM\ManyToOne(targetEntity="Client", inversedBy="refreshTokens") * @ORM\JoinColumn(nullable=false) */ protected $client; diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index cc7c2c94..8e438229 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\NullOutput; +use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Question\Question; @@ -97,7 +97,8 @@ class InstallCommand extends ContainerAwareCommand try { $this->getContainer()->get('doctrine')->getManager()->getConnection()->connect(); } catch (\Exception $e) { - if (false === strpos($e->getMessage(), 'Unknown database')) { + if (false === strpos($e->getMessage(), 'Unknown database') + && false === strpos($e->getMessage(), 'database "'.$this->getContainer()->getParameter('database_name').'" does not exist')) { $fulfilled = false; $status = 'ERROR!'; $help = 'Can\'t connect to the database: '.$e->getMessage(); @@ -420,16 +421,18 @@ class InstallCommand extends ContainerAwareCommand } $this->getApplication()->setAutoExit(false); - $exitCode = $this->getApplication()->run(new ArrayInput($parameters), new NullOutput()); + + $output = new BufferedOutput(); + $exitCode = $this->getApplication()->run(new ArrayInput($parameters), $output); if (0 !== $exitCode) { $this->getApplication()->setAutoExit(true); - $errorMessage = sprintf('The command "%s" terminated with an error code: %u.', $command, $exitCode); - $this->defaultOutput->writeln("$errorMessage"); - $exception = new \Exception($errorMessage, $exitCode); + $this->defaultOutput->writeln(''); + $this->defaultOutput->writeln('The command "'.$command.'" generates some errors: '); + $this->defaultOutput->writeln($output->fetch()); - throw $exception; + die(); } // PDO does not always close the connection after Doctrine commands. diff --git a/src/Wallabag/CoreBundle/Command/TagAllCommand.php b/src/Wallabag/CoreBundle/Command/TagAllCommand.php index db1a9ab7..3f9bb04d 100644 --- a/src/Wallabag/CoreBundle/Command/TagAllCommand.php +++ b/src/Wallabag/CoreBundle/Command/TagAllCommand.php @@ -34,10 +34,13 @@ class TagAllCommand extends ContainerAwareCommand } $tagger = $this->getContainer()->get('wallabag_core.rule_based_tagger'); - $output->write(sprintf('Tagging entries for user « %s »... ', $user->getUserName())); + $output->write(sprintf('Tagging entries for user « %s »... ', $user->getUserName())); $entries = $tagger->tagAllForUser($user); + $output->writeln('Done.'); + $output->write(sprintf('Persist entries ... ', $user->getUserName())); + $em = $this->getDoctrine()->getManager(); foreach ($entries as $entry) { $em->persist($entry); diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php index c5746734..5acc6852 100644 --- a/src/Wallabag/CoreBundle/Controller/TagController.php +++ b/src/Wallabag/CoreBundle/Controller/TagController.php @@ -86,10 +86,25 @@ class TagController extends Controller { $tags = $this->getDoctrine() ->getRepository('WallabagCoreBundle:Tag') - ->findAllTagsWithEntries($this->getUser()->getId()); + ->findAllTags($this->getUser()->getId()); + + $flatTags = []; + + foreach ($tags as $key => $tag) { + $nbEntries = $this->getDoctrine() + ->getRepository('WallabagCoreBundle:Entry') + ->countAllEntriesByUserIdAndTagId($this->getUser()->getId(), $tag['id']); + + $flatTags[] = [ + 'id' => $tag['id'], + 'label' => $tag['label'], + 'slug' => $tag['slug'], + 'nbEntries' => $nbEntries, + ]; + } return $this->render('WallabagCoreBundle:Tag:tags.html.twig', [ - 'tags' => $tags, + 'tags' => $flatTags, ]); } diff --git a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php index 239d09ae..b490e209 100644 --- a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php +++ b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php @@ -55,6 +55,7 @@ class RuleBasedTagger { $rules = $this->getRulesForUser($user); $entries = []; + $tagsCache = []; foreach ($rules as $rule) { $qb = $this->entryRepository->getBuilderForAllByUser($user->getId()); @@ -62,7 +63,12 @@ class RuleBasedTagger foreach ($entries as $entry) { foreach ($rule->getTags() as $label) { - $tag = $this->getTag($label); + // avoid new tag duplicate by manually caching them + if (!isset($tagsCache[$label])) { + $tagsCache[$label] = $this->getTag($label); + } + + $tag = $tagsCache[$label]; $entry->addTag($tag); } diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 75127b7d..cd2b47b9 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -309,4 +309,24 @@ class EntryRepository extends EntityRepository return $qb->getQuery()->getSingleScalarResult(); } + + /** + * Count all entries for a tag and a user. + * + * @param int $userId + * @param int $tagId + * + * @return int + */ + public function countAllEntriesByUserIdAndTagId($userId, $tagId) + { + $qb = $this->createQueryBuilder('e') + ->select('count(e.id)') + ->leftJoin('e.tags', 't') + ->where('e.user=:userId')->setParameter('userId', $userId) + ->andWhere('t.id=:tagId')->setParameter('tagId', $tagId) + ; + + return $qb->getQuery()->getSingleScalarResult(); + } } diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php index 9d127da7..e76878d4 100644 --- a/src/Wallabag/CoreBundle/Repository/TagRepository.php +++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php @@ -33,19 +33,23 @@ class TagRepository extends EntityRepository } /** - * Find all tags with associated entries per user. + * Find all tags per user. * * @param int $userId * * @return array */ - public function findAllTagsWithEntries($userId) + public function findAllTags($userId) { return $this->createQueryBuilder('t') + ->select('t.slug', 't.label', 't.id') ->leftJoin('t.entries', 'e') ->where('e.user = :userId')->setParameter('userId', $userId) + ->groupBy('t.slug') + ->addGroupBy('t.label') + ->addGroupBy('t.id') ->getQuery() - ->getResult(); + ->getArrayResult(); } /** diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 2652a102..bb23b5fe 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -195,7 +195,7 @@ entry: description: 'Vises artiklen forkert?' edit_title: 'Rediger titel' original_article: 'original' - # annotations_on_the_entry: '{0} No annotations|{1} One annotation|]1,Inf[ %nbAnnotations% annotations' + # annotations_on_the_entry: '{0} No annotations|{1} One annotation|]1,Inf[ %count% annotations' created_at: 'Oprettelsesdato' new: page_title: 'Gem ny artikel' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index e0f29b61..079cfece 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -195,7 +195,7 @@ entry: description: 'Erscheint dieser Artikel falsch?' edit_title: 'Titel ändern' original_article: 'original' - annotations_on_the_entry: '{0} Keine Anmerkungen|{1} Eine Anmerkung|]1,Inf[ %nbAnnotations% Anmerkungen' + annotations_on_the_entry: '{0} Keine Anmerkungen|{1} Eine Anmerkung|]1,Inf[ %count% Anmerkungen' created_at: 'Erstellungsdatum' new: page_title: 'Neuen Artikel speichern' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index b8e98112..34a6f74e 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -195,7 +195,7 @@ entry: description: 'Does this article appear wrong?' edit_title: 'Edit title' original_article: 'original' - annotations_on_the_entry: '{0} No annotations|{1} One annotation|]1,Inf[ %nbAnnotations% annotations' + annotations_on_the_entry: '{0} No annotations|{1} One annotation|]1,Inf[ %count% annotations' created_at: 'Creation date' new: page_title: 'Save new entry' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index 70633bd7..29f0676e 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -195,7 +195,7 @@ entry: description: '¿Este artículo no se muestra bien?' edit_title: 'Modificar el título' original_article: 'original' - annotations_on_the_entry: '{0} Sin anotaciones|{1} Una anotación|]1,Inf[ %nbAnnotations% anotaciones' + annotations_on_the_entry: '{0} Sin anotaciones|{1} Una anotación|]1,Inf[ %count% anotaciones' created_at: 'Fecha de creación' new: page_title: 'Guardar un nuevo artículo' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 6d85a5ae..55453b6c 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -195,7 +195,7 @@ entry: description: "Est-ce que cet article s'affiche mal ?" edit_title: 'Modifier le titre' original_article: 'original' - annotations_on_the_entry: '{0} Aucune annotation|{1} Une annotation|]1,Inf[ %nbAnnotations% annotations' + annotations_on_the_entry: '{0} Aucune annotation|{1} Une annotation|]1,Inf[ %count% annotations' created_at: 'Date de création' new: page_title: 'Sauvegarder un nouvel article' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 15f7e774..67205c6d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -195,7 +195,7 @@ entry: description: 'Questo contenuto viene visualizzato male?' edit_title: 'Modifica titolo' original_article: 'originale' - annotations_on_the_entry: '{0} Nessuna annotazione|{1} Una annotazione|]1,Inf[ %nbAnnotations% annotazioni' + annotations_on_the_entry: '{0} Nessuna annotazione|{1} Una annotazione|]1,Inf[ %count% annotazioni' created_at: 'Data di creazione' new: page_title: 'Salva un nuovo contenuto' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index 1d10be2a..25e5f05a 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -195,7 +195,7 @@ entry: description: "Marca mal la presentacion d'aqueste article ?" edit_title: 'Modificar lo títol' original_article: 'original' - annotations_on_the_entry: "{0} Pas cap d'anotacion|{1} Una anotacion|]1,Inf[ %nbAnnotations% anotacions" + annotations_on_the_entry: "{0} Pas cap d'anotacion|{1} Una anotacion|]1,Inf[ %count% anotacions" created_at: 'Data de creacion' new: page_title: 'Enregistrar un novèl article' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index 547e9c8b..392f9c19 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -195,7 +195,7 @@ entry: description: 'Czy ten artykuł wygląda źle?' edit_title: 'Edytuj tytuł' original_article: 'oryginalny' - annotations_on_the_entry: '{0} Nie ma adnotacji |{1} Jedna adnotacja |]1,Inf[ %nbAnnotations% adnotacji' + annotations_on_the_entry: '{0} Nie ma adnotacji |{1} Jedna adnotacja |]1,Inf[ %count% adnotacji' created_at: 'Czas stworzenia' new: page_title: 'Zapisz nowy wpis' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 2b1d4f6d..152d5020 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -195,7 +195,7 @@ entry: description: 'Îți pare ciudat articolul?' edit_title: 'Editează titlul' original_article: 'original' - # annotations_on_the_entry: '{0} No annotations|{1} One annotation|]1,Inf[ %nbAnnotations% annotations' + # annotations_on_the_entry: '{0} No annotations|{1} One annotation|]1,Inf[ %count% annotations' created_at: 'Data creării' new: page_title: 'Salvează un nou articol' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index 8cfc245a..a2eca59b 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -194,7 +194,7 @@ entry: description: 'Bu makalede herhangi bir yanlışlık mı var?' edit_title: 'Başlığı düzenle' original_article: 'orijinal' - # annotations_on_the_entry: '{0} No annotations|{1} One annotation|]1,Inf[ %nbAnnotations% annotations' + # annotations_on_the_entry: '{0} No annotations|{1} One annotation|]1,Inf[ %count% annotations' created_at: 'Oluşturulma tarihi' new: page_title: 'Yeni makaleyi kaydet' diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig index b1aabf9b..3689159b 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig @@ -54,7 +54,6 @@ {% endif %} - {% set nbAnnotations = entry.annotations | length %} comment {{ 'entry.view.annotations_on_the_entry'|transchoice(entry.annotations | length) }}