aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle
diff options
context:
space:
mode:
authorNicolas Lœuillet <nicolas@loeuillet.org>2016-01-09 14:34:49 +0100
committerNicolas Lœuillet <nicolas.loeuillet@smile.fr>2016-01-15 15:01:30 +0100
commit5c072d2b57b2b5f95b25411909ac8a6af2ef6ebe (patch)
tree1224140aff058371464d2737a6a3d6ae17f34d06 /src/Wallabag/CoreBundle
parent0aafb8dfcb098ae586dc87f3487b4948f8ae2314 (diff)
downloadwallabag-5c072d2b57b2b5f95b25411909ac8a6af2ef6ebe.tar.gz
wallabag-5c072d2b57b2b5f95b25411909ac8a6af2ef6ebe.tar.zst
wallabag-5c072d2b57b2b5f95b25411909ac8a6af2ef6ebe.zip
Quickstart for beginners
Diffstat (limited to 'src/Wallabag/CoreBundle')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php7
-rw-r--r--src/Wallabag/CoreBundle/Controller/StaticController.php11
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/ORM/LoadConfigData.php9
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php19
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml38
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Static/quickstart.html.twig40
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/new_form.html.twig2
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Static/quickstart.html.twig50
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php38
9 files changed, 201 insertions, 13 deletions
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
166 */ 166 */
167 public function showUnreadAction(Request $request, $page) 167 public function showUnreadAction(Request $request, $page)
168 { 168 {
169 // load the quickstart if no entry in database
170 if ($page == 1 && $this->get('wallabag_core.entry_repository')->countAllEntriesByUsername($this->getUser()->getId()) == 0) {
171 return $this->redirect($this->generateUrl('quickstart'));
172 }
173
169 return $this->showEntries('unread', $request, $page); 174 return $this->showEntries('unread', $request, $page);
170 } 175 }
171 176
@@ -211,7 +216,7 @@ class EntryController extends Controller
211 */ 216 */
212 private function showEntries($type, Request $request, $page) 217 private function showEntries($type, Request $request, $page)
213 { 218 {
214 $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry'); 219 $repository = $this->get('wallabag_core.entry_repository');
215 220
216 switch ($type) { 221 switch ($type) {
217 case 'starred': 222 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
28 array() 28 array()
29 ); 29 );
30 } 30 }
31
32 /**
33 * @Route("/quickstart", name="quickstart")
34 */
35 public function quickstartAction()
36 {
37 return $this->render(
38 'WallabagCoreBundle:Static:quickstart.html.twig',
39 array()
40 );
41 }
31} 42}
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
40 40
41 $this->addReference('bob-config', $bobConfig); 41 $this->addReference('bob-config', $bobConfig);
42 42
43 $emptyConfig = new Config($this->getReference('empty-user'));
44 $emptyConfig->setTheme('material');
45 $emptyConfig->setItemsPerPage(10);
46 $emptyConfig->setLanguage('en');
47
48 $manager->persist($emptyConfig);
49
50 $this->addReference('empty-config', $emptyConfig);
51
43 $manager->flush(); 52 $manager->flush();
44 } 53 }
45 54
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
122 /** 122 /**
123 * Fetch an entry with a tag. Only used for tests. 123 * Fetch an entry with a tag. Only used for tests.
124 * 124 *
125 * @param int $userId
126 *
125 * @return Entry 127 * @return Entry
126 */ 128 */
127 public function findOneWithTags($userId) 129 public function findOneWithTags($userId)
@@ -248,4 +250,21 @@ class EntryRepository extends EntityRepository
248 250
249 return false; 251 return false;
250 } 252 }
253
254 /**
255 * Count all entries for a user.
256 *
257 * @param int $userId
258 *
259 * @return integer
260 */
261 public function countAllEntriesByUsername($userId)
262 {
263 $qb = $this->createQueryBuilder('e')
264 ->select('count(e)')
265 ->where('e.user=:userId')->setParameter('userId', $userId)
266 ;
267
268 return $qb->getQuery()->getSingleScalarResult();
269 }
251} 270}
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"
53 53
54# Entries 54# Entries
55'estimated reading time': 'durée de lecture' 55'estimated reading time': 'durée de lecture'
56original: original 56original: "original"
57Toggle mark as read: 'Marquer comme lu/non lu' 57Toggle mark as read: 'Marquer comme lu/non lu'
58Toggle favorite: 'Marquer comme favori' 58Toggle favorite: 'Marquer comme favori'
59Delete: 'Supprimer' 59Delete: 'Supprimer'
@@ -97,7 +97,7 @@ via Paypal: "via Paypal"
97via Flattr: "via Flattr" 97via Flattr: "via Flattr"
98 98
99# Howto 99# Howto
100Form: Formulaire 100Form: "Formulaire"
101Thanks to this form: "Grâce à ce formulaire" 101Thanks to this form: "Grâce à ce formulaire"
102Browser addons: "Extensions de navigateur" 102Browser addons: "Extensions de navigateur"
103Mobile apps: "Applications smartphone" 103Mobile apps: "Applications smartphone"
@@ -135,8 +135,32 @@ Welcome on wallabag importer. Please select your previous service that you want
135"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." 135"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."
136"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\"." 136"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\"."
137"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." 137"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."
138Connect to Pocket and import data: Se connecter à Pocket et importer les données. 138Connect to Pocket and import data: "Se connecter à Pocket et importer les données."
139Please 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. 139Please 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."
140File: Fichier 140File: "Fichier"
141Upload file: Importer le fichier 141Upload file: "Importer le fichier"
142Import contents: "Importer les contenus" \ No newline at end of file 142Import contents: "Importer les contenus"
143
144# Quickstart
145Welcome on wallabag!: "Bienvenue sur wallabag !"
146We'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."
147Follow us!: "Suivez-nous !"
148Configure the application: "Configurez l'application"
149Change language and design: "Changez la langue et le design de l'application"
150Enable RSS feeds: "Activez les flux RSS"
151First steps: "Premiers pas"
152Save your first article: "Ajoutez votre premier article"
153And classify it!: "Et rangez-le !"
154Migrate from an existing service: "Migrer depuis un service existant"
155You'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."
156Migrate from Pocket: "Migrer depuis Pocket"
157Migrate from wallabag v1: "Migrer depuis wallabag v1"
158Full documentation: "Documentation complète"
159Convert your articles into ePUB or PDF: "Convertissez vos articles en ePub ou en PDF"
160See 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"
161And so many other articles!: "Et encore plein d'autres choses !"
162Support: "Support"
163If 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."
164On GitHub: "Sur GitHub"
165By email: "Par email"
166On 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 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %}
2
3{% block title %}{% trans %}Quickstart{% endtrans %}{% endblock %}
4
5{% block content %}
6
7 <h2>{% trans %}Welcome on wallabag!{% endtrans %}</h2>
8 <p>{% trans %}We'll accompany you to visit wallabag and show you some features which can interess you.{% endtrans %}</p>
9 <p>{% trans %}Follow us!{% endtrans %}</p>
10 <h4>{% trans %}Configure the application{% endtrans %}</h4>
11 <ul>
12 <li><a href="{{ path('config') }}">{% trans %}Change language and design{% endtrans %}</a></li>
13 <li><a href="{{ path('config') }}#set2">{% trans %}Enable RSS feeds{% endtrans %}</a></li>
14 </ul>
15 <h3>{% trans %}First steps{% endtrans %}</h3>
16 <ul>
17 <li><a href="{{ path('new') }}">{% trans %}Save your first article{% endtrans %}</a></li>
18 <li><a href="{{ path('unread') }}">{% trans %}And classify it!{% endtrans %}</a></li>
19 </ul>
20 <h3>{% trans %}Migrate from an existing service{% endtrans %}</h3>
21 <p>{% trans %}You're using an other service? We'll help you to retrieve your data on wallabag.{% endtrans %}</p>
22 <ul>
23 <li><a href="{{ path('import_pocket') }}">{% trans %}Migrate from Pocket{% endtrans %}</a></li>
24 <li><a href="{{ path('import_wallabag_v1') }}">{% trans %}Migrate from wallabag v1{% endtrans %}</a></li>
25 </ul>
26 <h3>{% trans %}Full documentation{% endtrans %}</h3>
27 <ul>
28 <li><a href="http://wallabag.readthedocs.org">{% trans %}Convert your articles into ePUB or PDF{% endtrans %}</a></li>
29 <li><a href="http://wallabag.readthedocs.org">{% trans %}See how you can look for an article by using search engine and filters{% endtrans %}</a></li>
30 <li><a href="http://wallabag.readthedocs.org">{% trans %}And so many other articles!{% endtrans %}</a></li>
31 </ul>
32 <h3>{% trans %}Support{% endtrans %}</h3>
33 <p>{% trans %}If you need some help, we are here for you.{% endtrans %}</p>
34 <ul>
35 <li><a href="https://github.com/wallabag/wallabag/issues/">{% trans %}On GitHub{% endtrans %}</a></li>
36 <li><a href="mailto:hello@wallabag.org">{% trans %}By email{% endtrans %}</a></li>
37 <li><a href="https://gitter.im/wallabag/wallabag">{% trans %}On Gitter{% endtrans %}</a></li>
38 </ul>
39
40{% 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 @@
8 <span class="black-text">{{ form_errors(form.url) }}</span> 8 <span class="black-text">{{ form_errors(form.url) }}</span>
9 {% endif %} 9 {% endif %}
10 10
11 {{ form_widget(form.url, { 'attr': {'autocomplete': 'off'} }) }} 11 {{ form_widget(form.url, { 'attr': {'autocomplete': 'off', 'placeholder': 'http://website'} }) }}
12 12
13 <div class="hidden">{{ form_rest(form) }}</div> 13 <div class="hidden">{{ form_rest(form) }}</div>
14</form> 14</form>
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 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %}
2
3{% block title %}{% trans %}Quickstart{% endtrans %}{% endblock %}
4
5{% block content %}
6
7 <div class="row">
8 <div class="col s12">
9 <div class="card-panel settings">
10
11 <div class="row">
12 <h3>{% trans %}Welcome on wallabag!{% endtrans %}</h3>
13 <p>{% trans %}We'll accompany you to visit wallabag and show you some features which can interess you.{% endtrans %}</p>
14 <p>{% trans %}Follow us!{% endtrans %}</p>
15 <h4>{% trans %}Configure the application{% endtrans %}</h4>
16 <ul>
17 <li><a href="{{ path('config') }}">{% trans %}Change language and design{% endtrans %}</a></li>
18 <li><a href="{{ path('config') }}#set2">{% trans %}Enable RSS feeds{% endtrans %}</a></li>
19 </ul>
20 <h4>{% trans %}First steps{% endtrans %}</h4>
21 <ul>
22 <li><a href="{{ path('new') }}">{% trans %}Save your first article{% endtrans %}</a></li>
23 <li><a href="{{ path('unread') }}">{% trans %}And classify it!{% endtrans %}</a></li>
24 </ul>
25 <h4>{% trans %}Migrate from an existing service{% endtrans %}</h4>
26 <p>{% trans %}You're using an other service? We'll help you to retrieve your data on wallabag.{% endtrans %}</p>
27 <ul>
28 <li><a href="{{ path('import_pocket') }}">{% trans %}Migrate from Pocket{% endtrans %}</a></li>
29 <li><a href="{{ path('import_wallabag_v1') }}">{% trans %}Migrate from wallabag v1{% endtrans %}</a></li>
30 </ul>
31 <h4>{% trans %}Full documentation{% endtrans %}</h4>
32 <ul>
33 <li><a href="http://wallabag.readthedocs.org">{% trans %}Convert your articles into ePUB or PDF{% endtrans %}</a></li>
34 <li><a href="http://wallabag.readthedocs.org">{% trans %}See how you can look for an article by using search engine and filters{% endtrans %}</a></li>
35 <li><a href="http://wallabag.readthedocs.org">{% trans %}And so many other articles!{% endtrans %}</a></li>
36 </ul>
37 <h4>{% trans %}Support{% endtrans %}</h4>
38 <p>{% trans %}If you need some help, we are here for you.{% endtrans %}</p>
39 <ul>
40 <li><a href="https://github.com/wallabag/wallabag/issues/">{% trans %}On GitHub{% endtrans %}</a></li>
41 <li><a href="mailto:hello@wallabag.org">{% trans %}By email{% endtrans %}</a></li>
42 <li><a href="https://gitter.im/wallabag/wallabag">{% trans %}On Gitter{% endtrans %}</a></li>
43 </ul>
44 </div>
45
46 </div>
47 </div>
48 </div>
49
50{% 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
19 $this->assertContains('login', $client->getResponse()->headers->get('location')); 19 $this->assertContains('login', $client->getResponse()->headers->get('location'));
20 } 20 }
21 21
22 public function testQuickstart()
23 {
24 $this->logInAs('empty');
25 $client = $this->getClient();
26
27 $client->request('GET', '/unread/list');
28 $client->followRedirect();
29
30 $this->assertEquals(200, $client->getResponse()->getStatusCode());
31 $this->assertContains('We\'ll accompany you to visit wallabag', $client->getResponse()->getContent());
32
33 // Test if quickstart is disabled when user has 1 entry
34 $crawler = $client->request('GET', '/new');
35
36 $this->assertEquals(200, $client->getResponse()->getStatusCode());
37
38 $form = $crawler->filter('button[type=submit]')->form();
39
40 $data = array(
41 'entry[url]' => 'https://www.wallabag.org/blog/2016/01/08/wallabag-alpha1-v2',
42 );
43
44 $client->submit($form, $data);
45 $this->assertEquals(302, $client->getResponse()->getStatusCode());
46 $client->followRedirect();
47
48 $client->request('GET', '/unread/list');
49 $this->assertContains('There is one entry.', $client->getResponse()->getContent());
50 }
51
22 public function testGetNew() 52 public function testGetNew()
23 { 53 {
24 $this->logInAs('admin'); 54 $this->logInAs('admin');
@@ -42,9 +72,9 @@ class EntryControllerTest extends WallabagCoreTestCase
42 $this->assertCount(4, $crawler->filter('div[class=entry]')); 72 $this->assertCount(4, $crawler->filter('div[class=entry]'));
43 73
44 // Good URL 74 // Good URL
45 $crawler = $client->request('GET', '/bookmarklet', array('url' => $this->url)); 75 $client->request('GET', '/bookmarklet', array('url' => $this->url));
46 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 76 $this->assertEquals(302, $client->getResponse()->getStatusCode());
47 $crawler = $client->followRedirect(); 77 $client->followRedirect();
48 $crawler = $client->request('GET', '/'); 78 $crawler = $client->request('GET', '/');
49 $this->assertCount(5, $crawler->filter('div[class=entry]')); 79 $this->assertCount(5, $crawler->filter('div[class=entry]'));
50 80
@@ -125,7 +155,7 @@ class EntryControllerTest extends WallabagCoreTestCase
125 155
126 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 156 $this->assertEquals(302, $client->getResponse()->getStatusCode());
127 157
128 $crawler = $client->followRedirect(); 158 $client->followRedirect();
129 159
130 $em = $client->getContainer() 160 $em = $client->getContainer()
131 ->get('doctrine.orm.entity_manager'); 161 ->get('doctrine.orm.entity_manager');
@@ -455,7 +485,7 @@ class EntryControllerTest extends WallabagCoreTestCase
455 485
456 $parameters = '?entry_filter%5BreadingTime%5D%5Bleft_number%5D=&amp;entry_filter%5BreadingTime%5D%5Bright_number%5D='; 486 $parameters = '?entry_filter%5BreadingTime%5D%5Bleft_number%5D=&amp;entry_filter%5BreadingTime%5D%5Bright_number%5D=';
457 487
458 $crawler = $client->request('GET', 'unread/list'.$parameters); 488 $client->request('GET', 'unread/list'.$parameters);
459 489
460 $this->assertContains($parameters, $client->getResponse()->getContent()); 490 $this->assertContains($parameters, $client->getResponse()->getContent());
461 491