forked from wallabag/wallabag
Merge pull request #1493 from wallabag/v2-pocket-import
v2 – 1st draft for Pocket import via API & Wallabag v1 import
This commit is contained in:
@ -11,7 +11,6 @@ use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\Config;
|
||||
|
||||
class InstallCommand extends ContainerAwareCommand
|
||||
|
||||
@ -48,6 +48,19 @@ class EntryController extends Controller
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
// check for existing entry, if it exists, redirect to it with a message
|
||||
$existingEntry = $this->get('wallabag_core.entry_repository')
|
||||
->existByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
|
||||
|
||||
if (false !== $existingEntry) {
|
||||
$this->get('session')->getFlashBag()->add(
|
||||
'notice',
|
||||
'Entry already saved on '.$existingEntry['createdAt']->format('d-m-Y')
|
||||
);
|
||||
|
||||
return $this->redirect($this->generateUrl('view', array('id' => $existingEntry['id'])));
|
||||
}
|
||||
|
||||
$this->updateEntry($entry);
|
||||
$this->get('session')->getFlashBag()->add(
|
||||
'notice',
|
||||
|
||||
@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\Entity;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* Config.
|
||||
@ -86,7 +87,7 @@ class Config
|
||||
/*
|
||||
* @param User $user
|
||||
*/
|
||||
public function __construct(\Wallabag\UserBundle\Entity\User $user)
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->taggingRules = new ArrayCollection();
|
||||
@ -181,7 +182,7 @@ class Config
|
||||
*
|
||||
* @return Config
|
||||
*/
|
||||
public function setUser(\Wallabag\UserBundle\Entity\User $user = null)
|
||||
public function setUser(User $user = null)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
@ -225,7 +226,7 @@ class Config
|
||||
/**
|
||||
* Set rssLimit.
|
||||
*
|
||||
* @param string $rssLimit
|
||||
* @param int $rssLimit
|
||||
*
|
||||
* @return Config
|
||||
*/
|
||||
@ -239,7 +240,7 @@ class Config
|
||||
/**
|
||||
* Get rssLimit.
|
||||
*
|
||||
* @return string
|
||||
* @return int
|
||||
*/
|
||||
public function getRssLimit()
|
||||
{
|
||||
|
||||
@ -245,7 +245,7 @@ class Entry
|
||||
/**
|
||||
* Set isArchived.
|
||||
*
|
||||
* @param string $isArchived
|
||||
* @param bool $isArchived
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
@ -259,7 +259,7 @@ class Entry
|
||||
/**
|
||||
* Get isArchived.
|
||||
*
|
||||
* @return string
|
||||
* @return bool
|
||||
*/
|
||||
public function isArchived()
|
||||
{
|
||||
@ -276,7 +276,7 @@ class Entry
|
||||
/**
|
||||
* Set isStarred.
|
||||
*
|
||||
* @param string $isStarred
|
||||
* @param bool $isStarred
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
@ -290,7 +290,7 @@ class Entry
|
||||
/**
|
||||
* Get isStarred.
|
||||
*
|
||||
* @return string
|
||||
* @return bool
|
||||
*/
|
||||
public function isStarred()
|
||||
{
|
||||
|
||||
@ -223,4 +223,29 @@ class EntryRepository extends EntityRepository
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an entry by its url and its owner.
|
||||
* If it exists, return the entry otherwise return false.
|
||||
*
|
||||
* @param $url
|
||||
* @param $userId
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public function existByUrlAndUserId($url, $userId)
|
||||
{
|
||||
$res = $this->createQueryBuilder('e')
|
||||
->select('e.id, e.createdAt')
|
||||
->where('e.url = :url')->setParameter('url', $url)
|
||||
->andWhere('e.user = :user_id')->setParameter('user_id', $userId)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
if (count($res)) {
|
||||
return current($res);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,6 +63,7 @@ services:
|
||||
- @wallabag_core.tag_repository
|
||||
- @wallabag_core.entry_repository
|
||||
|
||||
# repository as a service
|
||||
wallabag_core.entry_repository:
|
||||
class: Wallabag\CoreBundle\Repository\EntryRepository
|
||||
factory: [ @doctrine.orm.default_entity_manager, getRepository ]
|
||||
|
||||
@ -13,6 +13,7 @@ archive: 'Lus'
|
||||
all: 'Tous les articles'
|
||||
tags: 'Tags'
|
||||
config: 'Configuration'
|
||||
import: 'Importer'
|
||||
howto: 'Aide'
|
||||
logout: 'Déconnexion'
|
||||
Filtered: 'Articles filtrés'
|
||||
@ -128,3 +129,14 @@ Download: 'Télécharger'
|
||||
Does this article appear wrong?: "Est-ce que cet article s'affiche mal ?"
|
||||
Problems?: 'Un problème ?'
|
||||
Edit title: "Modifier le titre"
|
||||
|
||||
# Import
|
||||
Welcome 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."
|
||||
"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"
|
||||
@ -45,6 +45,7 @@
|
||||
<li class="bold border-bottom {% if currentRoute == 'all' %}active{% endif %}"><a class="waves-effect" href="{{ path('all') }}">{% trans %}all{% endtrans %}</a></li>
|
||||
<li class="bold border-bottom {% if currentRoute == 'tags' %}active{% endif %}"><a class="waves-effect" href="{{ path('tag') }}">{% trans %}tags{% endtrans %}</a></li>
|
||||
<li class="bold {% if currentRoute == 'config' %}active{% endif %}"><a class="waves-effect" href="{{ path('config') }}">{% trans %}config{% endtrans %}</a></li>
|
||||
<li class="bold {% if currentRoute == 'import' %}active{% endif %}"><a class="waves-effect" href="{{ path('import') }}">{% trans %}import{% endtrans %}</a></li>
|
||||
<li class="bold {% if currentRoute == 'howto' %}active{% endif %}"><a class="waves-effect" href="{{ path('howto') }}">{% trans %}howto{% endtrans %}</a></li>
|
||||
<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>
|
||||
</ul>
|
||||
|
||||
@ -500,4 +500,8 @@ footer [class^="icon-"]:hover, footer [class*=" icon-"]:hover {
|
||||
/* force height on non-input field in the settings page */
|
||||
div.settings div.input-field div, div.settings div.input-field ul {
|
||||
margin-top: 40px;
|
||||
}
|
||||
}
|
||||
/* but avoid to kill all file input */
|
||||
div.settings div.file-field div {
|
||||
margin-top: inherit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user