Add anilist example config file, and make the interface a bit more helpful

This commit is contained in:
Timothy Warren 2023-07-13 14:17:51 -04:00
parent 91c435cdac
commit c8b642be1c
6 changed files with 43 additions and 30 deletions

View File

@ -1,5 +1,8 @@
# Changelog # Changelog
## Version 5.3
* Update PHP requirement to 8.2
## Version 5.2 ## Version 5.2
* Updated PHP requirement to 8.1 * Updated PHP requirement to 8.1
* Updated to support PHP 8.2 * Updated to support PHP 8.2

View File

@ -0,0 +1,6 @@
################################################################################
# Anilist API #
################################################################################
client_id = "your_client_id"
client_secret = "your_client_secret"
username = "user123"

View File

@ -0,0 +1,24 @@
<?php if ( ! $hasRequiredAnilistConfig): ?>
<p class="static-message info">See the <a href="https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient/wiki/anilist">wiki</a> to learn how to set up Anilist integration. </p>
<?php else: ?>
<?php $auth = $anilistModel->checkAuth(); ?>
<?php if (array_key_exists('errors', $auth)): ?>
<p class="static-message error">Anilist API Client is Not Authorized.</p>
<?= $helper->a(
$url->generate('anilist-redirect'),
'Link Anilist Account',
['class' => 'bracketed user-btn']
) ?>
<?php else: ?>
<?php $expires = $config->get(['anilist', 'access_token_expires']); ?>
<p class="static-message info">
Linked to Anilist. Your access token will expire around <?= date('F j, Y, g:i a T', $expires) ?>
</p>
<?php require __DIR__ . '/_form.php' ?>
<?= $helper->a(
$url->generate('anilist-redirect'),
'Update Access Token',
['class' => 'bracketed user-btn']
) ?>
<?php endif ?>
<?php endif ?>

View File

@ -28,29 +28,11 @@ $nestedPrefix = 'config';
/> />
<label for="settings-tab<?= $i ?>"><h3><?= $sectionMapping[$section] ?></h3></label> <label for="settings-tab<?= $i ?>"><h3><?= $sectionMapping[$section] ?></h3></label>
<section class="content"> <section class="content">
<?php if ($section === 'anilist'): ?> <?php
<?php $auth = $anilistModel->checkAuth(); ?> ($section === 'anilist')
<?php if (array_key_exists('errors', $auth)): ?> ? require __DIR__ . '/_anilist.php'
<p class="static-message error">Not Authorized.</p> : require __DIR__ . '/_form.php'
<?= $helper->a( ?>
$url->generate('anilist-redirect'),
'Link Anilist Account'
) ?>
<?php else: ?>
<?php $expires = $config->get(['anilist', 'access_token_expires']); ?>
<p class="static-message info">
Linked to Anilist. Your access token will expire around <?= date('F j, Y, g:i a T', $expires) ?>
</p>
<?php require __DIR__ . '/_form.php' ?>
<?= $helper->a(
$url->generate('anilist-redirect'),
'Update Access Token',
['class' => 'bracketed user-btn']
) ?>
<?php endif ?>
<?php else: ?>
<?php require __DIR__ . '/_form.php' ?>
<?php endif ?>
</section> </section>
<?php $i++; ?> <?php $i++; ?>
<?php endforeach ?> <?php endforeach ?>
@ -62,7 +44,3 @@ $nestedPrefix = 'config';
<button type="submit">Save Changes</button> <button type="submit">Save Changes</button>
</main> </main>
</form> </form>

View File

@ -46,7 +46,7 @@
"laminas/laminas-httphandlerrunner": "^2.6.1", "laminas/laminas-httphandlerrunner": "^2.6.1",
"maximebf/consolekit": "^1.0.3", "maximebf/consolekit": "^1.0.3",
"monolog/monolog": "^3.0.0", "monolog/monolog": "^3.0.0",
"php": ">= 8.1.0", "php": ">= 8.2.0",
"psr/http-message": "^1.0.1", "psr/http-message": "^1.0.1",
"symfony/polyfill-mbstring": "^1.0.0", "symfony/polyfill-mbstring": "^1.0.0",
"symfony/polyfill-util": "^1.0.0", "symfony/polyfill-util": "^1.0.0",

View File

@ -57,13 +57,15 @@ final class Settings extends BaseController
$auth = $this->container->get('auth'); $auth = $this->container->get('auth');
$form = $this->settingsModel->getSettingsForm(); $form = $this->settingsModel->getSettingsForm();
$hasAnilistLogin = $this->config->has(['anilist', 'access_token']); $hasRequiredAnilistConfig = $this->config->has(['anilist', 'client_secret']) &&
$this->config->has(['anilist', 'client_id']) &&
$this->config->has(['anilist', 'username']);
$this->outputHTML('settings/settings', [ $this->outputHTML('settings/settings', [
'anilistModel' => $this->anilistModel, 'anilistModel' => $this->anilistModel,
'auth' => $auth, 'auth' => $auth,
'form' => $form, 'form' => $form,
'hasAnilistLogin' => $hasAnilistLogin, 'hasRequiredAnilistConfig' => $hasRequiredAnilistConfig,
'config' => $this->config, 'config' => $this->config,
'title' => $this->config->get('whose_list') . "'s Settings", 'title' => $this->config->get('whose_list') . "'s Settings",
]); ]);