aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle
diff options
context:
space:
mode:
authorJeremy Benoist <j0k3r@users.noreply.github.com>2016-01-07 22:15:08 +0100
committerJeremy Benoist <j0k3r@users.noreply.github.com>2016-01-07 22:15:08 +0100
commit39643c6b76d92d509b1af0228b6379d7fdce8a1c (patch)
tree931dceef7dbc8ae9911d01ded709d558417a6cdd /src/Wallabag/CoreBundle
parent488a468e3e11ff0ab6284afe232bf0f7fa68a8eb (diff)
parentb88cf91fc8371194df78e690983c61ea94f266cd (diff)
downloadwallabag-39643c6b76d92d509b1af0228b6379d7fdce8a1c.tar.gz
wallabag-39643c6b76d92d509b1af0228b6379d7fdce8a1c.tar.zst
wallabag-39643c6b76d92d509b1af0228b6379d7fdce8a1c.zip
Merge pull request #1493 from wallabag/v2-pocket-import2.0.0-alpha.1
v2 – 1st draft for Pocket import via API & Wallabag v1 import
Diffstat (limited to 'src/Wallabag/CoreBundle')
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php1
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php13
-rw-r--r--src/Wallabag/CoreBundle/Entity/Config.php9
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php8
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php25
-rw-r--r--src/Wallabag/CoreBundle/Resources/config/services.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml12
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig1
-rwxr-xr-xsrc/Wallabag/CoreBundle/Resources/views/themes/material/public/css/main.css6
9 files changed, 66 insertions, 10 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index 85c4ee90..e791d4dd 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -11,7 +11,6 @@ use Symfony\Component\Console\Output\NullOutput;
11use Symfony\Component\Console\Question\Question; 11use Symfony\Component\Console\Question\Question;
12use Symfony\Component\Console\Question\ConfirmationQuestion; 12use Symfony\Component\Console\Question\ConfirmationQuestion;
13use Symfony\Component\Console\Helper\Table; 13use Symfony\Component\Console\Helper\Table;
14use Wallabag\UserBundle\Entity\User;
15use Wallabag\CoreBundle\Entity\Config; 14use Wallabag\CoreBundle\Entity\Config;
16 15
17class InstallCommand extends ContainerAwareCommand 16class InstallCommand extends ContainerAwareCommand
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index fa580133..37f7ab60 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -48,6 +48,19 @@ class EntryController extends Controller
48 $form->handleRequest($request); 48 $form->handleRequest($request);
49 49
50 if ($form->isValid()) { 50 if ($form->isValid()) {
51 // check for existing entry, if it exists, redirect to it with a message
52 $existingEntry = $this->get('wallabag_core.entry_repository')
53 ->existByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
54
55 if (false !== $existingEntry) {
56 $this->get('session')->getFlashBag()->add(
57 'notice',
58 'Entry already saved on '.$existingEntry['createdAt']->format('d-m-Y')
59 );
60
61 return $this->redirect($this->generateUrl('view', array('id' => $existingEntry['id'])));
62 }
63
51 $this->updateEntry($entry); 64 $this->updateEntry($entry);
52 $this->get('session')->getFlashBag()->add( 65 $this->get('session')->getFlashBag()->add(
53 'notice', 66 'notice',
diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php
index 2ca4182e..d3590f35 100644
--- a/src/Wallabag/CoreBundle/Entity/Config.php
+++ b/src/Wallabag/CoreBundle/Entity/Config.php
@@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\Entity;
5use Doctrine\Common\Collections\ArrayCollection; 5use Doctrine\Common\Collections\ArrayCollection;
6use Doctrine\ORM\Mapping as ORM; 6use Doctrine\ORM\Mapping as ORM;
7use Symfony\Component\Validator\Constraints as Assert; 7use Symfony\Component\Validator\Constraints as Assert;
8use Wallabag\UserBundle\Entity\User;
8 9
9/** 10/**
10 * Config. 11 * Config.
@@ -86,7 +87,7 @@ class Config
86 /* 87 /*
87 * @param User $user 88 * @param User $user
88 */ 89 */
89 public function __construct(\Wallabag\UserBundle\Entity\User $user) 90 public function __construct(User $user)
90 { 91 {
91 $this->user = $user; 92 $this->user = $user;
92 $this->taggingRules = new ArrayCollection(); 93 $this->taggingRules = new ArrayCollection();
@@ -181,7 +182,7 @@ class Config
181 * 182 *
182 * @return Config 183 * @return Config
183 */ 184 */
184 public function setUser(\Wallabag\UserBundle\Entity\User $user = null) 185 public function setUser(User $user = null)
185 { 186 {
186 $this->user = $user; 187 $this->user = $user;
187 188
@@ -225,7 +226,7 @@ class Config
225 /** 226 /**
226 * Set rssLimit. 227 * Set rssLimit.
227 * 228 *
228 * @param string $rssLimit 229 * @param int $rssLimit
229 * 230 *
230 * @return Config 231 * @return Config
231 */ 232 */
@@ -239,7 +240,7 @@ class Config
239 /** 240 /**
240 * Get rssLimit. 241 * Get rssLimit.
241 * 242 *
242 * @return string 243 * @return int
243 */ 244 */
244 public function getRssLimit() 245 public function getRssLimit()
245 { 246 {
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index b413c489..f11a7786 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -245,7 +245,7 @@ class Entry
245 /** 245 /**
246 * Set isArchived. 246 * Set isArchived.
247 * 247 *
248 * @param string $isArchived 248 * @param bool $isArchived
249 * 249 *
250 * @return Entry 250 * @return Entry
251 */ 251 */
@@ -259,7 +259,7 @@ class Entry
259 /** 259 /**
260 * Get isArchived. 260 * Get isArchived.
261 * 261 *
262 * @return string 262 * @return bool
263 */ 263 */
264 public function isArchived() 264 public function isArchived()
265 { 265 {
@@ -276,7 +276,7 @@ class Entry
276 /** 276 /**
277 * Set isStarred. 277 * Set isStarred.
278 * 278 *
279 * @param string $isStarred 279 * @param bool $isStarred
280 * 280 *
281 * @return Entry 281 * @return Entry
282 */ 282 */
@@ -290,7 +290,7 @@ class Entry
290 /** 290 /**
291 * Get isStarred. 291 * Get isStarred.
292 * 292 *
293 * @return string 293 * @return bool
294 */ 294 */
295 public function isStarred() 295 public function isStarred()
296 { 296 {
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index ca71970b..c6763a40 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -223,4 +223,29 @@ class EntryRepository extends EntityRepository
223 ->getQuery() 223 ->getQuery()
224 ->getResult(); 224 ->getResult();
225 } 225 }
226
227 /**
228 * Find an entry by its url and its owner.
229 * If it exists, return the entry otherwise return false.
230 *
231 * @param $url
232 * @param $userId
233 *
234 * @return array|bool
235 */
236 public function existByUrlAndUserId($url, $userId)
237 {
238 $res = $this->createQueryBuilder('e')
239 ->select('e.id, e.createdAt')
240 ->where('e.url = :url')->setParameter('url', $url)
241 ->andWhere('e.user = :user_id')->setParameter('user_id', $userId)
242 ->getQuery()
243 ->getResult();
244
245 if (count($res)) {
246 return current($res);
247 }
248
249 return false;
250 }
226} 251}
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml
index c92b4eb3..96b1c931 100644
--- a/src/Wallabag/CoreBundle/Resources/config/services.yml
+++ b/src/Wallabag/CoreBundle/Resources/config/services.yml
@@ -63,6 +63,7 @@ services:
63 - @wallabag_core.tag_repository 63 - @wallabag_core.tag_repository
64 - @wallabag_core.entry_repository 64 - @wallabag_core.entry_repository
65 65
66 # repository as a service
66 wallabag_core.entry_repository: 67 wallabag_core.entry_repository:
67 class: Wallabag\CoreBundle\Repository\EntryRepository 68 class: Wallabag\CoreBundle\Repository\EntryRepository
68 factory: [ @doctrine.orm.default_entity_manager, getRepository ] 69 factory: [ @doctrine.orm.default_entity_manager, getRepository ]
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
index 7b10dea1..06746584 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
@@ -13,6 +13,7 @@ archive: 'Lus'
13all: 'Tous les articles' 13all: 'Tous les articles'
14tags: 'Tags' 14tags: 'Tags'
15config: 'Configuration' 15config: 'Configuration'
16import: 'Importer'
16howto: 'Aide' 17howto: 'Aide'
17logout: 'Déconnexion' 18logout: 'Déconnexion'
18Filtered: 'Articles filtrés' 19Filtered: 'Articles filtrés'
@@ -128,3 +129,14 @@ Download: 'Télécharger'
128Does this article appear wrong?: "Est-ce que cet article s'affiche mal ?" 129Does this article appear wrong?: "Est-ce que cet article s'affiche mal ?"
129Problems?: 'Un problème ?' 130Problems?: 'Un problème ?'
130Edit title: "Modifier le titre" 131Edit title: "Modifier le titre"
132
133# Import
134Welcome on wallabag importer. Please select your previous service that you want to migrate.: "Bienvenue dans l'outil de migration de wallabag. Choisissez ci-dessous le service depuis lequel vous souhaitez migrer."
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\"."
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.
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
141Upload file: Importer le fichier
142Import contents: "Importer les contenus" \ No newline at end of file
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
index f426e25b..6b8d7adf 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
@@ -45,6 +45,7 @@
45 <li class="bold border-bottom {% if currentRoute == 'all' %}active{% endif %}"><a class="waves-effect" href="{{ path('all') }}">{% trans %}all{% endtrans %}</a></li> 45 <li class="bold border-bottom {% if currentRoute == 'all' %}active{% endif %}"><a class="waves-effect" href="{{ path('all') }}">{% trans %}all{% endtrans %}</a></li>
46 <li class="bold border-bottom {% if currentRoute == 'tags' %}active{% endif %}"><a class="waves-effect" href="{{ path('tag') }}">{% trans %}tags{% endtrans %}</a></li> 46 <li class="bold border-bottom {% if currentRoute == 'tags' %}active{% endif %}"><a class="waves-effect" href="{{ path('tag') }}">{% trans %}tags{% endtrans %}</a></li>
47 <li class="bold {% if currentRoute == 'config' %}active{% endif %}"><a class="waves-effect" href="{{ path('config') }}">{% trans %}config{% endtrans %}</a></li> 47 <li class="bold {% if currentRoute == 'config' %}active{% endif %}"><a class="waves-effect" href="{{ path('config') }}">{% trans %}config{% endtrans %}</a></li>
48 <li class="bold {% if currentRoute == 'import' %}active{% endif %}"><a class="waves-effect" href="{{ path('import') }}">{% trans %}import{% endtrans %}</a></li>
48 <li class="bold {% if currentRoute == 'howto' %}active{% endif %}"><a class="waves-effect" href="{{ path('howto') }}">{% trans %}howto{% endtrans %}</a></li> 49 <li class="bold {% if currentRoute == 'howto' %}active{% endif %}"><a class="waves-effect" href="{{ path('howto') }}">{% trans %}howto{% endtrans %}</a></li>
49 <li class="bold"><a class="waves-effect" class="icon icon-power" href="{{ path('fos_user_security_logout') }}" title="{% trans %}logout{% endtrans %}">{% trans %}logout{% endtrans %}</a></li> 50 <li class="bold"><a class="waves-effect" class="icon icon-power" href="{{ path('fos_user_security_logout') }}" title="{% trans %}logout{% endtrans %}">{% trans %}logout{% endtrans %}</a></li>
50 </ul> 51 </ul>
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/public/css/main.css b/src/Wallabag/CoreBundle/Resources/views/themes/material/public/css/main.css
index 73965571..0ce334a3 100755
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/public/css/main.css
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/public/css/main.css
@@ -500,4 +500,8 @@ footer [class^="icon-"]:hover, footer [class*=" icon-"]:hover {
500/* force height on non-input field in the settings page */ 500/* force height on non-input field in the settings page */
501div.settings div.input-field div, div.settings div.input-field ul { 501div.settings div.input-field div, div.settings div.input-field ul {
502 margin-top: 40px; 502 margin-top: 40px;
503} \ No newline at end of file 503}
504/* but avoid to kill all file input */
505div.settings div.file-field div {
506 margin-top: inherit;
507}