Skip to content
This repository has been archived by the owner on Mar 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #4 from BowlOfSoup/I-3
Browse files Browse the repository at this point in the history
Issue 3; Add character switching (multiple chars, one account).
  • Loading branch information
BowlOfSoup committed Jul 4, 2019
2 parents 8d54d7d + f623867 commit 0cacccb
Show file tree
Hide file tree
Showing 19 changed files with 680 additions and 118 deletions.
Binary file added public/images/character.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions public/scripts/bulletin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
$(function() {
$(document.links).filter(function() {
return this.hostname !== window.location.hostname;
}).attr('target', '_blank');
$('#character-content a').attr('target', '_blank');

$('.corporation-bulletin-edit-button').click(function() {
$('#bulletin-edit-editor').show();
Expand Down
9 changes: 9 additions & 0 deletions public/scripts/switch_character.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$(function() {
$('.character-switch').click(function(e) {
$.post($(this).attr('data-target')).done(function() {
document.location.reload();
});

e.stopPropagation();
});
});
167 changes: 134 additions & 33 deletions public/styles/clever.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ body {
}

.logo {
margin: 10px 0px 20px;
margin: 10px 0 20px;
}

.powered-by {
text-align: center;
padding: 0px 22px;
margin: 50px 0px;
padding: 0 22px;
margin: 50px 0;
}

.powered-by-image {
Expand All @@ -37,16 +37,51 @@ a {
text-decoration: underline;
}

.non-styled-link {
color: #212529 !important;
text-decoration: none;
}
.non-styled-link:hover {
text-decoration: none;
}

.sidebar {
border-right: 1px solid #eee;
}

.menu-button-static {
.btn {
font-size: 0.9rem;
}

.btn-group {
width: 100%;
}

.btn {
font-size: 0.9rem;
.page-title img {
margin-right: 10px;
width: 48px;
}

.page-title {
font-size: 130%;
}

.btn-light {
border: 1px dotted #ccc;
}

.editor-statusbar {
padding: 6px 10px !important;
}

.modal-backdrop.show:not(:last-of-type) {
opacity: 0 !important;
}

/* ---------- MENU STYLING ---------- */

.menu-button-static {
width: 100%;
}

.menu-button, .menu-button-static {
Expand All @@ -62,18 +97,9 @@ a {
width: 32px;
}

.page-title img {
margin-right: 10px;
width: 48px;
}

.page-title {
font-size: 130%;
}
/* ---------- END MENU STYLING ---------- */

.modal-backdrop.show:not(:last-of-type) {
opacity: 0 !important;
}
/* ---------- CHARACTER ---------- */

.character-image img {
border-radius: 10%;
Expand Down Expand Up @@ -103,9 +129,9 @@ a {
text-decoration: none;
}

.btn-light {
border: 1px dotted #ccc;
}
/* ---------- END CHARACTER ---------- */

/* ---------- CORPORATION BULLETIN ---------- */

.corporation-bulletin td, .corporation-bulletin th {
border: 1px solid #ddd;
Expand Down Expand Up @@ -142,21 +168,15 @@ a {
width: 100%;
}

.corporation-bulletin h1:not(:first-child) {
padding-top: 5px;
}

.corporation-bulletin h2:not(:first-child) {
padding-top: 5px;
}

.corporation-bulletin h3:not(:first-child) {
.corporation-bulletin h1:not(:first-child),
.corporation-bulletin h2:not(:first-child),
.corporation-bulletin h3:not(:first-child),
.corporation-bulletin h4:not(:first-child) {
padding-top: 5px;
}

.corporation-bulletin h4:not(:first-child) {
font-size: 1.2rem;
padding-top: 5px;
}

#bulletin-edit-editor {
Expand Down Expand Up @@ -188,6 +208,87 @@ a {
display: none;
}

.editor-statusbar {
padding: 6px 10px !important;
}
/* ---------- END CORPORATION BULLETIN ---------- */

/* ---------- DROP DOWN ---------- */

.dropdown-toggle, .dropdown-menu {
width: 300px
}

.btn-group .dropdown-image {
margin-right: 10px;
width: 32px;
height: 32px;
border-radius: 10%;
}

.dropdown-toggle {
padding-right: 50px
}

.dropdown-menu {
margin: 2px 0;
border: 1px dotted #ccc;
width: 100%;
font-size: 0.9rem;
padding: 0;
}

.dropdown-menu li {
padding: 0;
}

.dropdown-toggle .glyphicon {
margin-left: 5px;
}

.dropdown-header {
background: #ccc;
font-size: 14px;
font-weight: 700;
padding-top: 5px;
padding-bottom: 5px;
margin-top: 10px;
margin-bottom: 5px;
}

.btn-characters {
margin-bottom: 10px;
border: 1px dotted #ccc;
text-align: left;
padding: 10px;
}
.btn-characters:focus {
box-shadow: none;
}

.dropdown-menu button, .dropdown-menu a {
width: 100%;
text-align: left;
border-radius: 0;
padding: 10px;
}

.show .btn-characters,
.btn-characters:hover,
.dropdown-menu button:hover,
.dropdown-menu a:hover {
background-color: #e2e6ea;
}

.dropdown-menu button:hover,
.dropdown-menu a:hover {
color: #212529;
border-color: #dae0e5;
}

.dropdown-menu li {
border-bottom: 1px solid #eee;
}

.dropdown-menu li:last-of-type {
border-bottom: 0;
}

/* ---------- END DROP DOWN ---------- */
1 change: 1 addition & 0 deletions src/Command/DiscordConsumerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
)
);
}

$loop->run();
}

Expand Down
27 changes: 7 additions & 20 deletions src/Controller/CallbackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
namespace App\Controller;

use App\Exception\SpamException;
use App\Service\Authenticator;
use App\Service\CharacterService;
use App\Service\CallbackService;
use App\Service\SpamPreventionService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -18,25 +17,19 @@ class CallbackController extends AbstractController
/** @var \App\Service\SpamPreventionService */
private $spamPreventionService;

/** @var \App\Service\Authenticator */
private $authenticator;

/** @var \App\Service\CharacterService */
private $characterService;
/** @var \App\Service\CallbackService */
private $callbackService;

/**
* @param \App\Service\SpamPreventionService $spamPreventionService
* @param \App\Service\Authenticator $authenticator
* @param \App\Service\CharacterService $characterService
* @param \App\Service\CallbackService $callbackService
*/
public function __construct(
SpamPreventionService $spamPreventionService,
Authenticator $authenticator,
CharacterService $characterService
CallbackService $callbackService
) {
$this->spamPreventionService = $spamPreventionService;
$this->authenticator = $authenticator;
$this->characterService = $characterService;
$this->callbackService = $callbackService;
}

/**
Expand Down Expand Up @@ -65,13 +58,7 @@ public function callbackAction(Request $request): Response
return $this->forward('App\Controller\IndexController::indexAction');
}

$authorizationResponse = $this->authenticator->authenticateWithCallbackCode($callbackCode);
$characterId = $this->authenticator->verifyAndGetCharacterId($authorizationResponse->getAccessToken());

$character = $this->characterService->getCharacterById($characterId);
$character = $this->characterService->upsertCharacter($authorizationResponse, $characterId, $character);

$this->authenticator->authenticateCharacterAsUser($character);
$this->callbackService->handleCallbackFromEve($callbackCode);

return $this->redirectToRoute('app_index');
}
Expand Down
31 changes: 21 additions & 10 deletions src/Controller/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Controller;

use App\Service\CharacterService;
use App\Service\ConfigurationService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
Expand All @@ -23,49 +24,59 @@ class IndexController extends AbstractController
/** @var \App\Service\ConfigurationService */
private $configurationService;

/** @var \App\Service\CharacterService */
private $characterService;

/**
* @param \Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface $authorizationChecker
* @param string $clientId
* @param string $callbackUrl
* @param \App\Service\ConfigurationService $configurationService
* @param \App\Service\CharacterService $characterService
*/
public function __construct(
AuthorizationCheckerInterface $authorizationChecker,
string $clientId,
string $callbackUrl,
ConfigurationService $configurationService
ConfigurationService $configurationService,
CharacterService $characterService
) {
$this->authorizationChecker = $authorizationChecker;
$this->clientId = $clientId;
$this->callbackUrl = $callbackUrl;
$this->configurationService = $configurationService;
$this->characterService = $characterService;
}

/**
* @Route("/", name="app_index")
*/
public function indexAction()
{
$ssoConfiguration = [
'clientId' => $this->clientId,
'callbackUrl' => $this->callbackUrl,
'uniqueState' => uniqid(),
'scope' => 'publicData esi-calendar.read_calendar_events.v1 esi-skills.read_skillqueue.v1 esi-wallet.read_character_wallet.v1 esi-killmails.read_killmails.v1 esi-planets.manage_planets.v1 esi-mail.organize_mail.v1 esi-mail.read_mail.v1 esi-industry.read_character_jobs.v1 esi-industry.read_character_mining.v1 esi-industry.read_corporation_mining.v1 esi-characters.read_corporation_roles.v1 esi-killmails.read_corporation_killmails.v1 esi-corporations.read_contacts.v1 esi-corporations.read_corporation_membership.v1 esi-corporations.read_starbases.v1 esi-corporations.read_structures.v1 esi-corporations.read_facilities.v1 esi-characters.read_fw_stats.v1 esi-corporations.read_fw_stats.v1',
];

if (false === $this->authorizationChecker->isGranted('ROLE_USER')) {
return $this->render('authenticate.html.twig', [
'clientId' => $this->clientId,
'callbackUrl' => $this->callbackUrl,
'uniqueState' => uniqid(),
'scope' => 'publicData esi-calendar.read_calendar_events.v1 esi-skills.read_skillqueue.v1 esi-wallet.read_character_wallet.v1 esi-killmails.read_killmails.v1 esi-planets.manage_planets.v1 esi-mail.organize_mail.v1 esi-mail.read_mail.v1 esi-industry.read_character_jobs.v1 esi-industry.read_character_mining.v1 esi-industry.read_corporation_mining.v1 esi-characters.read_corporation_roles.v1 esi-killmails.read_corporation_killmails.v1 esi-corporations.read_contacts.v1 esi-corporations.read_corporation_membership.v1 esi-corporations.read_starbases.v1 esi-corporations.read_structures.v1 esi-corporations.read_facilities.v1 esi-characters.read_fw_stats.v1 esi-corporations.read_fw_stats.v1',
'poweredBy' => $this->configurationService->getPoweredBy(),
]);
return $this->render('authenticate.html.twig', array_merge($ssoConfiguration, [
'poweredBy' => $this->configurationService->getPoweredBy(),
]));
}

/** @var \App\Entity\Character $character */
$character = $this->getUser();

return $this->render('character.html.twig', [
return $this->render('character.html.twig', array_merge($ssoConfiguration, [
'character' => $character,
'otherCharacters' => $this->characterService->getOtherCharactersForAccount($character),
'corporationConfigured' => $this->configurationService->isCharacterCorporationConfigured($character),
'corporationBulletin' => (new \Parsedown())->parse($character->getCorporation()->getBulletin()),
'corporationBulletinRaw' => $character->getCorporation()->getBulletin(),
'isAllowedToEditTheBulletin' => $this->configurationService->isCharacterAllowedToEditTheBulletin($character),
]);
]));
}

/**
Expand Down
Loading

0 comments on commit 0cacccb

Please sign in to comment.