From 5c072d2b57b2b5f95b25411909ac8a6af2ef6ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 9 Jan 2016 14:34:49 +0100 Subject: Quickstart for beginners --- .../CoreBundle/Controller/EntryController.php | 7 ++- .../CoreBundle/Controller/StaticController.php | 11 +++++ .../CoreBundle/DataFixtures/ORM/LoadConfigData.php | 9 ++++ .../CoreBundle/Repository/EntryRepository.php | 19 ++++++++ .../Resources/translations/messages.fr.yml | 38 +++++++++++++--- .../views/themes/baggy/Static/quickstart.html.twig | 40 +++++++++++++++++ .../views/themes/material/Entry/new_form.html.twig | 2 +- .../themes/material/Static/quickstart.html.twig | 50 ++++++++++++++++++++++ .../Tests/Controller/EntryControllerTest.php | 38 ++++++++++++++-- .../UserBundle/DataFixtures/ORM/LoadUserData.php | 11 +++++ 10 files changed, 212 insertions(+), 13 deletions(-) create mode 100644 src/Wallabag/CoreBundle/Resources/views/themes/baggy/Static/quickstart.html.twig create mode 100644 src/Wallabag/CoreBundle/Resources/views/themes/material/Static/quickstart.html.twig (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 37f7ab60..3d22c7bc 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -166,6 +166,11 @@ class EntryController extends Controller */ public function showUnreadAction(Request $request, $page) { + // load the quickstart if no entry in database + if ($page == 1 && $this->get('wallabag_core.entry_repository')->countAllEntriesByUsername($this->getUser()->getId()) == 0) { + return $this->redirect($this->generateUrl('quickstart')); + } + return $this->showEntries('unread', $request, $page); } @@ -211,7 +216,7 @@ class EntryController extends Controller */ private function showEntries($type, Request $request, $page) { - $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry'); + $repository = $this->get('wallabag_core.entry_repository'); switch ($type) { case 'starred': diff --git a/src/Wallabag/CoreBundle/Controller/StaticController.php b/src/Wallabag/CoreBundle/Controller/StaticController.php index 64875a66..9ada371b 100644 --- a/src/Wallabag/CoreBundle/Controller/StaticController.php +++ b/src/Wallabag/CoreBundle/Controller/StaticController.php @@ -28,4 +28,15 @@ class StaticController extends Controller array() ); } + + /** + * @Route("/quickstart", name="quickstart") + */ + public function quickstartAction() + { + return $this->render( + 'WallabagCoreBundle:Static:quickstart.html.twig', + array() + ); + } } diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php index 3b3c1e97..85084960 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php @@ -40,6 +40,15 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface $this->addReference('bob-config', $bobConfig); + $emptyConfig = new Config($this->getReference('empty-user')); + $emptyConfig->setTheme('material'); + $emptyConfig->setItemsPerPage(10); + $emptyConfig->setLanguage('en'); + + $manager->persist($emptyConfig); + + $this->addReference('empty-config', $emptyConfig); + $manager->flush(); } diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index c6763a40..a16be9e0 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -122,6 +122,8 @@ class EntryRepository extends EntityRepository /** * Fetch an entry with a tag. Only used for tests. * + * @param int $userId + * * @return Entry */ public function findOneWithTags($userId) @@ -248,4 +250,21 @@ class EntryRepository extends EntityRepository return false; } + + /** + * Count all entries for a user. + * + * @param int $userId + * + * @return integer + */ + public function countAllEntriesByUsername($userId) + { + $qb = $this->createQueryBuilder('e') + ->select('count(e)') + ->where('e.user=:userId')->setParameter('userId', $userId) + ; + + return $qb->getQuery()->getSingleScalarResult(); + } } diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 06746584..941237bf 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -53,7 +53,7 @@ Username: "Nom d'utilisateur" # Entries 'estimated reading time': 'durée de lecture' -original: original +original: "original" Toggle mark as read: 'Marquer comme lu/non lu' Toggle favorite: 'Marquer comme favori' Delete: 'Supprimer' @@ -97,7 +97,7 @@ via Paypal: "via Paypal" via Flattr: "via Flattr" # Howto -Form: Formulaire +Form: "Formulaire" Thanks to this form: "Grâce à ce formulaire" Browser addons: "Extensions de navigateur" Mobile apps: "Applications smartphone" @@ -135,8 +135,32 @@ Welcome on wallabag importer. Please select your previous service that you want "This importer will import all your Pocket data. Pocket doesn't allow us to retrieve content from their service, so the readable content of each article will be re-fetched by wallabag.": "Cet outil va importer toutes vos données de Pocket. Pocket ne nous autorise pas à récupérer le contenu depuis leur service, donc wallabag doit reparcourir chaque article pour récupérer son contenu." "This importer will import all your wallabag v1 articles. On your config page, click on \"JSON export\" in the \"Export your wallabag data\" section. You will have a \"wallabag-export-1-xxxx-xx-xx.json\" file.": "Cet outil va importer toutes vos données de wallabag v1. Sur votre page de configuration de wallabag v1, cliquez sur \"Export JSON\" dans la section \"Exporter vos données de wallabag\". Vous allez récupérer un fichier \"wallabag-export-1-xxxx-xx-xx.json\"." "You can import your data from your Pocket account. You just have to click on the below button and authorize the application to connect to getpocket.com.": "Vous pouvez importer vos données depuis votre compte Pocket. Vous n'avez qu'à cliquer sur le bouton ci-dessous et à autoriser wallabag à se connecter à getpocket.com." -Connect to Pocket and import data: Se connecter à Pocket et importer les données. -Please select your wallabag export and click on the below button to upload and import it.: Choisissez le fichier de votre export wallabag v1 et cliquez sur le bouton ci-dessous pour l'importer. -File: Fichier -Upload file: Importer le fichier -Import contents: "Importer les contenus" \ No newline at end of file +Connect to Pocket and import data: "Se connecter à Pocket et importer les données." +Please select your wallabag export and click on the below button to upload and import it.: "Choisissez le fichier de votre export wallabag v1 et cliquez sur le bouton ci-dessous pour l'importer." +File: "Fichier" +Upload file: "Importer le fichier" +Import contents: "Importer les contenus" + +# Quickstart +Welcome on wallabag!: "Bienvenue sur wallabag !" +We'll accompany you to visit wallabag and show you some features which can interess you.: "Nous allons vous accompagner pour vous faire faire le tour de la maison et vous présenter quelques fonctionnalités qui pourraient vous intéresser pour vous approprier cet outil." +Follow us!: "Suivez-nous !" +Configure the application: "Configurez l'application" +Change language and design: "Changez la langue et le design de l'application" +Enable RSS feeds: "Activez les flux RSS" +First steps: "Premiers pas" +Save your first article: "Ajoutez votre premier article" +And classify it!: "Et rangez-le !" +Migrate from an existing service: "Migrer depuis un service existant" +You're using an other service? We'll help you to retrieve your data on wallabag.: "Vous êtes un ancien utilisateur d'un service existant ? Nous allons vous aider à récupérer vos données sur wallabag." +Migrate from Pocket: "Migrer depuis Pocket" +Migrate from wallabag v1: "Migrer depuis wallabag v1" +Full documentation: "Documentation complète" +Convert your articles into ePUB or PDF: "Convertissez vos articles en ePub ou en PDF" +See how you can look for an article by using search engine and filters: "Apprenez à utiliser le moteur de recherche et les filtres pour retrouver l'article qui vous intéresse" +And so many other articles!: "Et encore plein d'autres choses !" +Support: "Support" +If you need some help, we are here for you.: "Parce que vous avez peut-être besoin de nous poser une question, nous sommes disponibles pour vous." +On GitHub: "Sur GitHub" +By email: "Par email" +On Gitter: "Sur Gitter" \ No newline at end of file diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Static/quickstart.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Static/quickstart.html.twig new file mode 100644 index 00000000..f57673c5 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Static/quickstart.html.twig @@ -0,0 +1,40 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title %}{% trans %}Quickstart{% endtrans %}{% endblock %} + +{% block content %} + +

{% trans %}Welcome on wallabag!{% endtrans %}

+

{% trans %}We'll accompany you to visit wallabag and show you some features which can interess you.{% endtrans %}

+

{% trans %}Follow us!{% endtrans %}

+

{% trans %}Configure the application{% endtrans %}

+ +

{% trans %}First steps{% endtrans %}

+ +

{% trans %}Migrate from an existing service{% endtrans %}

+

{% trans %}You're using an other service? We'll help you to retrieve your data on wallabag.{% endtrans %}

+ +

{% trans %}Full documentation{% endtrans %}

+ +

{% trans %}Support{% endtrans %}

+

{% trans %}If you need some help, we are here for you.{% endtrans %}

+ + +{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/new_form.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/new_form.html.twig index fda53e5b..47e3bc78 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/new_form.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/new_form.html.twig @@ -8,7 +8,7 @@ {{ form_errors(form.url) }} {% endif %} - {{ form_widget(form.url, { 'attr': {'autocomplete': 'off'} }) }} + {{ form_widget(form.url, { 'attr': {'autocomplete': 'off', 'placeholder': 'http://website'} }) }} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Static/quickstart.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Static/quickstart.html.twig new file mode 100644 index 00000000..e1f6fd5c --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Static/quickstart.html.twig @@ -0,0 +1,50 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title %}{% trans %}Quickstart{% endtrans %}{% endblock %} + +{% block content %} + +
+
+
+ +
+

{% trans %}Welcome on wallabag!{% endtrans %}

+

{% trans %}We'll accompany you to visit wallabag and show you some features which can interess you.{% endtrans %}

+

{% trans %}Follow us!{% endtrans %}

+

{% trans %}Configure the application{% endtrans %}

+ +

{% trans %}First steps{% endtrans %}

+ +

{% trans %}Migrate from an existing service{% endtrans %}

+

{% trans %}You're using an other service? We'll help you to retrieve your data on wallabag.{% endtrans %}

+ +

{% trans %}Full documentation{% endtrans %}

+ +

{% trans %}Support{% endtrans %}

+

{% trans %}If you need some help, we are here for you.{% endtrans %}

+ +
+ +
+
+
+ +{% endblock %} diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 96f402b0..3a775182 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php @@ -19,6 +19,36 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertContains('login', $client->getResponse()->headers->get('location')); } + public function testQuickstart() + { + $this->logInAs('empty'); + $client = $this->getClient(); + + $client->request('GET', '/unread/list'); + $client->followRedirect(); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertContains('We\'ll accompany you to visit wallabag', $client->getResponse()->getContent()); + + // Test if quickstart is disabled when user has 1 entry + $crawler = $client->request('GET', '/new'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + + $form = $crawler->filter('button[type=submit]')->form(); + + $data = array( + 'entry[url]' => 'https://www.wallabag.org/blog/2016/01/08/wallabag-alpha1-v2', + ); + + $client->submit($form, $data); + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + $client->followRedirect(); + + $client->request('GET', '/unread/list'); + $this->assertContains('There is one entry.', $client->getResponse()->getContent()); + } + public function testGetNew() { $this->logInAs('admin'); @@ -42,9 +72,9 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertCount(4, $crawler->filter('div[class=entry]')); // Good URL - $crawler = $client->request('GET', '/bookmarklet', array('url' => $this->url)); + $client->request('GET', '/bookmarklet', array('url' => $this->url)); $this->assertEquals(302, $client->getResponse()->getStatusCode()); - $crawler = $client->followRedirect(); + $client->followRedirect(); $crawler = $client->request('GET', '/'); $this->assertCount(5, $crawler->filter('div[class=entry]')); @@ -125,7 +155,7 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertEquals(302, $client->getResponse()->getStatusCode()); - $crawler = $client->followRedirect(); + $client->followRedirect(); $em = $client->getContainer() ->get('doctrine.orm.entity_manager'); @@ -455,7 +485,7 @@ class EntryControllerTest extends WallabagCoreTestCase $parameters = '?entry_filter%5BreadingTime%5D%5Bleft_number%5D=&entry_filter%5BreadingTime%5D%5Bright_number%5D='; - $crawler = $client->request('GET', 'unread/list'.$parameters); + $client->request('GET', 'unread/list'.$parameters); $this->assertContains($parameters, $client->getResponse()->getContent()); diff --git a/src/Wallabag/UserBundle/DataFixtures/ORM/LoadUserData.php b/src/Wallabag/UserBundle/DataFixtures/ORM/LoadUserData.php index d48855da..26dbda3b 100644 --- a/src/Wallabag/UserBundle/DataFixtures/ORM/LoadUserData.php +++ b/src/Wallabag/UserBundle/DataFixtures/ORM/LoadUserData.php @@ -37,6 +37,17 @@ class LoadUserData extends AbstractFixture implements OrderedFixtureInterface $this->addReference('bob-user', $bobUser); + $emptyUser = new User(); + $emptyUser->setName('Empty'); + $emptyUser->setEmail('empty@wallabag.org'); + $emptyUser->setUsername('empty'); + $emptyUser->setPlainPassword('mypassword'); + $emptyUser->setEnabled(true); + + $manager->persist($emptyUser); + + $this->addReference('empty-user', $emptyUser); + $manager->flush(); } -- cgit v1.2.3