1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-07-22 17:18:37 +00:00

Moved Pocket token to user config

This commit is contained in:
Jeremy Benoist 2016-09-16 22:22:25 +02:00
parent 4fc998245c
commit ebe0787e09
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
34 changed files with 161 additions and 44 deletions

View file

@ -316,11 +316,6 @@ class InstallCommand extends ContainerAwareCommand
'value' => '1',
'section' => 'export',
],
[
'name' => 'pocket_consumer_key',
'value' => null,
'section' => 'import',
],
[
'name' => 'import_with_redis',
'value' => '0',

View file

@ -20,6 +20,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface
$adminConfig->setItemsPerPage(30);
$adminConfig->setReadingSpeed(1);
$adminConfig->setLanguage('en');
$adminConfig->setPocketConsumerKey('xxxxx');
$manager->persist($adminConfig);
@ -30,6 +31,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface
$bobConfig->setItemsPerPage(10);
$bobConfig->setReadingSpeed(1);
$bobConfig->setLanguage('fr');
$bobConfig->setPocketConsumerKey(null);
$manager->persist($bobConfig);
@ -40,6 +42,7 @@ class LoadConfigData extends AbstractFixture implements OrderedFixtureInterface
$emptyConfig->setItemsPerPage(10);
$emptyConfig->setReadingSpeed(1);
$emptyConfig->setLanguage('en');
$emptyConfig->setPocketConsumerKey(null);
$manager->persist($emptyConfig);

View file

@ -90,11 +90,6 @@ class LoadSettingData extends AbstractFixture implements OrderedFixtureInterface
'value' => '1',
'section' => 'export',
],
[
'name' => 'pocket_consumer_key',
'value' => null,
'section' => 'import',
],
[
'name' => 'import_with_redis',
'value' => '0',

View file

@ -80,6 +80,13 @@ class Config
*/
private $readingSpeed;
/**
* @var string
*
* @ORM\Column(name="pocket_consumer_key", type="string", nullable=true)
*/
private $pocketConsumerKey;
/**
* @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config")
*/
@ -278,6 +285,30 @@ class Config
return $this->readingSpeed;
}
/**
* Set pocketConsumerKey.
*
* @param string $pocketConsumerKey
*
* @return Config
*/
public function setPocketConsumerKey($pocketConsumerKey)
{
$this->pocketConsumerKey = $pocketConsumerKey;
return $this;
}
/**
* Get pocketConsumerKey.
*
* @return string
*/
public function getPocketConsumerKey()
{
return $this->pocketConsumerKey;
}
/**
* @param TaggingRule $rule
*

View file

@ -52,6 +52,9 @@ class ConfigType extends AbstractType
'choices' => array_flip($this->languages),
'label' => 'config.form_settings.language_label',
])
->add('pocket_consumer_key', null, [
'label' => 'config.form_settings.pocket_consumer_key_label',
])
->add('save', SubmitType::class, [
'label' => 'config.form.save',
])

View file

@ -68,6 +68,7 @@ config:
# 200_word: 'I read ~200 words per minute'
# 300_word: 'I read ~300 words per minute'
# 400_word: 'I read ~400 words per minute'
pocket_consumer_key_label: Brugers nøgle til Pocket for at importere materialer
form_rss:
description: 'RSS-feeds fra wallabag gør det muligt at læse de artikler, der gemmes i wallabag, med din RSS-læser. Det kræver, at du genererer et token først.'
token_label: 'RSS-Token'

View file

@ -68,6 +68,7 @@ config:
200_word: 'Ich lese ~200 Wörter pro Minute'
300_word: 'Ich lese ~300 Wörter pro Minute'
400_word: 'Ich lese ~400 Wörter pro Minute'
pocket_consumer_key_label: Consumer-Key für Pocket, um Inhalte zu importieren
form_rss:
description: 'Die RSS-Feeds von wallabag erlauben es dir, deine gespeicherten Artikel mit deinem bevorzugten RSS-Reader zu lesen. Vorher musst du jedoch einen Token erstellen.'
token_label: 'RSS-token'

View file

@ -68,6 +68,7 @@ config:
200_word: 'I read ~200 words per minute'
300_word: 'I read ~300 words per minute'
400_word: 'I read ~400 words per minute'
pocket_consumer_key_label: Consumer key for Pocket to import contents
form_rss:
description: 'RSS feeds provided by wallabag allow you to read your saved articles with your favourite RSS reader. You need to generate a token first.'
token_label: 'RSS token'

View file

@ -68,6 +68,7 @@ config:
200_word: 'Leo ~200 palabras por minuto'
300_word: 'Leo ~300 palabras por minuto'
400_word: 'Leo ~400 palabras por minuto'
# pocket_consumer_key_label: Consumer key for Pocket to import contents
form_rss:
description: 'Los feeds RSS de wallabag permiten leer los artículos guardados con su lector RSS favorito. Necesita generar un token primero'
token_label: 'RSS token'

View file

@ -68,6 +68,7 @@ config:
200_word: 'من تقریباً ۲۰۰ واژه را در دقیقه می‌خوانم'
300_word: 'من تقریباً ۳۰۰ واژه را در دقیقه می‌خوانم'
400_word: 'من تقریباً ۴۰۰ واژه را در دقیقه می‌خوانم'
pocket_consumer_key_label: کلید کاربری Pocket برای درون‌ریزی مطالب
form_rss:
description: 'با خوراک آر-اس-اس که wallabag در اختیارتان می‌گذارد، می‌توانید مقاله‌های ذخیره‌شده را در نرم‌افزار آر-اس-اس دلخواه خود بخوانید. برای این کار نخست باید یک کد بسازید.'
token_label: 'کد آر-اس-اس'

View file

@ -68,6 +68,7 @@ config:
200_word: 'Je lis environ 200 mots par minute'
300_word: 'Je lis environ 300 mots par minute'
400_word: 'Je lis environ 400 mots par minute'
pocket_consumer_key_label: Clé d'authentification Pocket pour importer les données
form_rss:
description: "Les flux RSS fournis par wallabag vous permettent de lire vos articles sauvegardés dans votre lecteur de flux préféré. Pour pouvoir les utiliser, vous devez d'abord créer un jeton."
token_label: 'Jeton RSS'

View file

@ -68,6 +68,7 @@ config:
200_word: 'Leggo ~200 parole al minuto'
300_word: 'Leggo ~300 parole al minuto'
400_word: 'Leggo ~400 parole al minuto'
pocket_consumer_key_label: Consumer key per Pocket per importare i contenuti
form_rss:
description: 'I feed RSS generati da wallabag ti permettono di leggere i tuoi contenuti salvati con il tuo lettore di RSS preferito. Prima, devi generare un token.'
token_label: 'RSS token'

View file

@ -68,6 +68,7 @@ config:
200_word: "Legissi a l'entorn de 200 mots per minuta"
300_word: "Legissi a l'entorn de 300 mots per minuta"
400_word: "Legissi a l'entorn de 400 mots per minuta"
pocket_consumer_key_label: Clau d'autentificacion Pocket per importar las donadas
form_rss:
description: "Los fluxes RSS fornits per wallabag vos permeton de legir vòstres articles salvagardats dins vòstre lector de fluxes preferit. Per los poder emplegar, vos cal, d'en primièr crear un geton."
token_label: 'Geton RSS'

View file

@ -68,6 +68,7 @@ config:
200_word: 'Czytam ~200 słów na minutę'
300_word: 'Czytam ~300 słów na minutę'
400_word: 'Czytam ~400 słów na minutę'
pocket_consumer_key_label: Klucz klienta Pocket do importu zawartości
form_rss:
description: 'Kanały RSS prowadzone przez wallabag pozwalają Ci na czytanie twoich zapisanych artykułów w twoium ulubionym czytniku RSS. Musisz najpierw wynegenerować tokena.'
token_label: 'Token RSS'

View file

@ -68,6 +68,7 @@ config:
# 200_word: 'I read ~200 words per minute'
# 300_word: 'I read ~300 words per minute'
# 400_word: 'I read ~400 words per minute'
pocket_consumer_key_label: Cheie consumator pentru importarea contentului din Pocket
form_rss:
description: 'Feed-urile RSS oferite de wallabag îți permit să-ți citești articolele salvate în reader-ul tău preferat RSS.'
token_label: 'RSS-Token'

View file

@ -68,6 +68,7 @@ config:
# 200_word: 'I read ~200 words per minute'
# 300_word: 'I read ~300 words per minute'
# 400_word: 'I read ~400 words per minute'
# pocket_consumer_key_label: Consumer key for Pocket to import contents
form_rss:
description: 'wallabag RSS akışı kaydetmiş olduğunuz makalelerini favori RSS okuyucunuzda görüntülemenizi sağlar. Bunu yapabilmek için öncelikle belirteç (token) oluşturmalısınız.'
token_label: 'RSS belirteci (token)'

View file

@ -44,6 +44,18 @@
</div>
</fieldset>
<fieldset class="w500p inline">
<div class="row">
{{ form_label(form.config.pocket_consumer_key) }}
{{ form_errors(form.config.pocket_consumer_key) }}
{{ form_widget(form.config.pocket_consumer_key) }}
<p>
&raquo;
<a href="https://getpocket.com/developer/docs/authentication">https://getpocket.com/developer/docs/authentication</a>
</p>
</div>
</fieldset>
{{ form_rest(form.config) }}
</form>

View file

@ -62,6 +62,18 @@
</div>
</div>
<div class="row">
<div class="input-field col s12">
{{ form_label(form.config.pocket_consumer_key) }}
{{ form_errors(form.config.pocket_consumer_key) }}
{{ form_widget(form.config.pocket_consumer_key) }}
<p>
&raquo;
<a href="https://getpocket.com/developer/docs/authentication">https://getpocket.com/developer/docs/authentication</a>
</p>
</div>
</div>
{{ form_widget(form.config.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
{{ form_rest(form.config) }}
</form>

View file

@ -44,7 +44,7 @@ class PocketController extends Controller
return $this->render('WallabagImportBundle:Pocket:index.html.twig', [
'import' => $this->getPocketImportService(),
'has_consumer_key' => '' == trim($this->get('craue_config')->get('pocket_consumer_key')) ? false : true,
'has_consumer_key' => '' === trim($this->getUser()->getConfig()->getPocketConsumerKey()) ? false : true,
'form' => $form->createView(),
]);
}

View file

@ -13,16 +13,14 @@ use Craue\ConfigBundle\Util\Config;
class PocketImport extends AbstractImport
{
private $client;
private $consumerKey;
private $accessToken;
const NB_ELEMENTS = 5000;
public function __construct(EntityManager $em, ContentProxy $contentProxy, Config $craueConfig)
public function __construct(EntityManager $em, ContentProxy $contentProxy)
{
$this->em = $em;
$this->contentProxy = $contentProxy;
$this->consumerKey = $craueConfig->get('pocket_consumer_key');
$this->logger = new NullLogger();
}
@ -72,7 +70,7 @@ class PocketImport extends AbstractImport
$request = $this->client->createRequest('POST', 'https://getpocket.com/v3/oauth/request',
[
'body' => json_encode([
'consumer_key' => $this->consumerKey,
'consumer_key' => $this->user->getConfig()->getPocketConsumerKey(),
'redirect_uri' => $redirectUri,
]),
]
@ -102,7 +100,7 @@ class PocketImport extends AbstractImport
$request = $this->client->createRequest('POST', 'https://getpocket.com/v3/oauth/authorize',
[
'body' => json_encode([
'consumer_key' => $this->consumerKey,
'consumer_key' => $this->user->getConfig()->getPocketConsumerKey(),
'code' => $code,
]),
]
@ -131,7 +129,7 @@ class PocketImport extends AbstractImport
$request = $this->client->createRequest('POST', 'https://getpocket.com/v3/get',
[
'body' => json_encode([
'consumer_key' => $this->consumerKey,
'consumer_key' => $this->user->getConfig()->getPocketConsumerKey(),
'access_token' => $this->accessToken,
'detailType' => 'complete',
'state' => 'all',

View file

@ -12,11 +12,7 @@
<div class="card-panel red white-text">
{{ 'import.pocket.config_missing.description'|trans }}
{% if is_granted('ROLE_SUPER_ADMIN') %}
{{ 'import.pocket.config_missing.admin_message'|trans({'%keyurls%': '<a href="' ~ path('craue_config_settings_modify') ~ '#set-import">', '%keyurle%':'</a>'})|raw }}
{% else %}
{{ 'import.pocket.config_missing.user_message'|trans }}
{% endif %}
{{ 'import.pocket.config_missing.admin_message'|trans({'%keyurls%': '<a href="' ~ path('config') ~ '">', '%keyurle%':'</a>'})|raw }}
</div>
{% endif %}
@ -31,7 +27,7 @@
{{ form_label(form.mark_as_read) }}
</div>
</div>
<button class="btn waves-effect waves-light" type="submit" name="action">
<button class="btn waves-effect waves-light" type="submit" name="action" {% if not has_consumer_key %}disabled="disabled"{% endif %}>
{{ 'import.pocket.connect_to_pocket'|trans }}
</button>
</form>