Merge pull request #1612 from wallabag/v2-settings-page

Settings page
This commit is contained in:
Nicolas Lœuillet
2016-02-04 15:59:57 +01:00
40 changed files with 510 additions and 245 deletions

View File

@ -15,6 +15,7 @@ class PocketController extends Controller
{
return $this->render('WallabagImportBundle:Pocket:index.html.twig', [
'import' => $this->get('wallabag_import.pocket.import'),
'has_consumer_key' => '' == trim($this->get('craue_config')->get('pocket_consumer_key')) ? false : true,
]);
}

View File

@ -11,6 +11,7 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Helper\ContentProxy;
use Craue\ConfigBundle\Util\Config;
class PocketImport implements ImportInterface
{
@ -24,12 +25,12 @@ class PocketImport implements ImportInterface
private $importedEntries = 0;
protected $accessToken;
public function __construct(TokenStorageInterface $tokenStorage, EntityManager $em, ContentProxy $contentProxy, $consumerKey)
public function __construct(TokenStorageInterface $tokenStorage, EntityManager $em, ContentProxy $contentProxy, Config $craueConfig)
{
$this->user = $tokenStorage->getToken()->getUser();
$this->em = $em;
$this->contentProxy = $contentProxy;
$this->consumerKey = $consumerKey;
$this->consumerKey = $craueConfig->get('pocket_consumer_key');
$this->logger = new NullLogger();
}

View File

@ -17,7 +17,7 @@ services:
- "@security.token_storage"
- "@doctrine.orm.entity_manager"
- "@wallabag_core.content_proxy"
- %pocket_consumer_key%
- "@craue_config"
calls:
- [ setClient, [ "@wallabag_import.pocket.client" ] ]
- [ setLogger, [ "@logger" ]]

View File

@ -5,6 +5,12 @@
<div class="row">
<div class="col s12">
<div class="card-panel settings">
{% if not has_consumer_key %}
<div class="card-panel red darken-1">
{% trans %}Pocket import isn't configured. You need to define pocket_consumer_key.{% endtrans %}
</div>
{% endif %}
<blockquote>{{ import.description|trans }}</blockquote>
<p>{% trans %}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.{% endtrans %}</p>
<form method="post" action="{{ path('import_pocket_auth') }}">

View File

@ -55,11 +55,20 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
$config = $this->getMockBuilder('Craue\ConfigBundle\Util\Config')
->disableOriginalConstructor()
->getMock();
$config->expects($this->any())
->method('get')
->with('pocket_consumer_key')
->willReturn($consumerKey);
$pocket = new PocketImportMock(
$this->tokenStorage,
$this->em,
$this->contentProxy,
$consumerKey
$config
);
$this->logHandler = new TestHandler();