Skip to content

Commit

Permalink
Merge pull request #783 from distributive/informative-embeds
Browse files Browse the repository at this point in the history
Improved and added some more page descriptions
  • Loading branch information
distributive authored Dec 1, 2023
2 parents b67ea59 + 7b5e48d commit 49e3290
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 33 deletions.
13 changes: 9 additions & 4 deletions src/AppBundle/Controller/BuilderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ public function buildformAction(string $side_text, EntityManagerInterface $entit

'/Builder/initbuild.html.twig',
[
'pagetitle' => "New deck",
"identities" => $identities,
"banned_cards" => $banned_cards,
"factions" => $factions
'pagetitle' => "New deck",
'pagedescription' => "Choose your identity to start building a custom deck.",
"identities" => $identities,
"banned_cards" => $banned_cards,
"factions" => $factions
],

$response
Expand Down Expand Up @@ -116,6 +117,7 @@ public function initbuildAction(string $card_code, EntityManagerInterface $entit
'/Builder/deck.html.twig',
[
'pagetitle' => "Deckbuilder",
'pagedescription' => "Build your own custom deck with the help of a powerful deckbuilder.",
'deck' => [
'side_name' => mb_strtolower($card->getSide()
->getName()),
Expand Down Expand Up @@ -156,6 +158,7 @@ public function importAction(EntityManagerInterface $entityManager)
'/Builder/directimport.html.twig',
[
'pagetitle' => "Import a deck",
'pagedescription' => "Import a deck from outside of NetrunnerDB.",
'list_mwl' => $list_mwl,
],

Expand Down Expand Up @@ -907,6 +910,7 @@ public function editAction(string $deck_uuid, EntityManagerInterface $entityMana
'/Builder/deck.html.twig',
[
'pagetitle' => "Deckbuilder",
'pagedescription' => "Build your own custom deck with the help of a powerful deckbuilder.",
'deck' => $deck,
'published_decklists' => $published_decklists,
'parent_decklists' => $parent_decklists,
Expand Down Expand Up @@ -1046,6 +1050,7 @@ public function viewAction(string $deck_uuid, EntityManagerInterface $entityMana
'/Builder/deckview.html.twig',
[
'pagetitle' => "Deckbuilder",
'pagedescription' => "Build your own custom deck with the help of a powerful deckbuilder.",
'deck' => $deck,
'published_decklists' => $published_decklists,
'parent_decklists' => $parent_decklists,
Expand Down
16 changes: 8 additions & 8 deletions src/AppBundle/Controller/DecklistsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function listAction(string $type, int $page = 1, Request $request, Entity
$result = $decklistManager->favorites($user->getId(), $start, $limit);
}
$pagetitle = "Favorite Decklists";
$pagedescription = "View your favourited decklists.";
$pagedescription = "Browse your favourited decklists.";
break;
case 'mine':
$response->setPrivate();
Expand All @@ -68,32 +68,32 @@ public function listAction(string $type, int $page = 1, Request $request, Entity
$result = $decklistManager->by_author($user->getId(), $start, $limit);
}
$pagetitle = "My Decklists";
$pagedescription = "View your own published decklists.";
$pagedescription = "Browse your own published decklists.";
break;
case 'recent':
$result = $decklistManager->recent($start, $limit);
$pagetitle = "Recent Decklists";
$pagedescription = "View recently published decklists.";
$pagedescription = "Browse recently published decklists.";
break;
case 'dotw':
$result = $decklistManager->dotw($start, $limit);
$pagetitle = "Decklist of the week";
$pagedescription = "View the decklists of the week.";
$pagedescription = "Browse the decklists of the week.";
break;
case 'halloffame':
$result = $decklistManager->halloffame($start, $limit);
$pagetitle = "Hall of Fame";
$pagedescription = "View the most loved decklists from all of NetrunnerDB history.";
$pagedescription = "Browse the most loved decklists from all of NetrunnerDB history.";
break;
case 'hottopics':
$result = $decklistManager->hottopics($start, $limit);
$pagetitle = "Hot Topics";
$pagedescription = "View decklists currently receiving attention.";
$pagedescription = "Browse decklists currently receiving attention.";
break;
case 'tournament':
$result = $decklistManager->tournaments($start, $limit);
$pagetitle = "Tournaments";
$pagedescription = "View decklists that placed in tournaments.";
$pagedescription = "Browse decklists that placed in tournaments.";
break;
case 'trashed':
$this->denyAccessUnlessGranted('ROLE_MODERATOR');
Expand All @@ -109,7 +109,7 @@ public function listAction(string $type, int $page = 1, Request $request, Entity
default:
$result = $decklistManager->popular($start, $limit);
$pagetitle = "Popular Decklists";
$pagedescription = "View popular recently published decklists.";
$pagedescription = "Browse recent popular decklists.";
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/AppBundle/Controller/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function indexAction(Request $request, EntityManagerInterface $entityMana
'Default/index.html.twig',
[
'pagetitle' => "Android: Netrunner Cards and Deckbuilder",
'pagedescription' => "Build your deck for Android: Netrunner, the LCG by Fantasy Flight Games. Browse the cards and the thousand of decklists submitted by the community. Publish your own decks and get feedback.",
'pagedescription' => "Build your deck for Android: Netrunner, the card game run by Null Signal Games, originally released by Fantasy Flight Games. Browse the cards and the thousand of decklists submitted by the community. Publish your own decks and get feedback.",
'decklists' => $decklists_recent,
'decklist' => $decklist,
'url' => $request->getRequestUri(),
Expand Down
33 changes: 20 additions & 13 deletions src/AppBundle/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public function zoomAction(string $card_code, Request $request, EntityManagerInt
'view' => 'card',
'sort' => 'set',
'title' => $card->getTitle(),
'description' => $formatCardForEmbed($card),
'image' => "https://card-images.netrunnerdb.com/v1" . $cards[0]["medium_image_path"],
'meta' => $meta,
'locale' => $request->getLocale(),
]
Expand Down Expand Up @@ -198,6 +200,7 @@ public function listAction(string $pack_code, string $view, string $sort, int $p
'sort' => $sort,
'page' => $page,
'title' => $pack->getName(),
'description' => "View all cards from the " . $pack->getName() . " pack.",
'meta' => $meta,
'locale' => $request->getLocale(),
'currentPack' => $pack,
Expand Down Expand Up @@ -234,6 +237,7 @@ public function cycleAction(string $cycle_code, string $view, string $sort, int
'sort' => $sort,
'page' => $page,
'title' => $cycle->getName(),
'description' => "View all cards from the " . $cycle->getName() . " cycle.",
'meta' => $meta,
'locale' => $request->getLocale(),
]
Expand Down Expand Up @@ -365,6 +369,8 @@ public function displayAction(
string $sort,
int $page = 1,
string $title = "",
string $description = "",
string $image = "",
string $meta = "",
string $locale = null,
array $locales = null,
Expand Down Expand Up @@ -448,6 +454,7 @@ public function displayAction(
$view = 'zoom';
}

// Catch the edge case where only a single cycle xor pack was searched but the page title/description wasn't set
if ($title == "") {
if (count($conditions) == 1 && count($conditions[0]) == 3 && $conditions[0][1] == ":") {
if ($conditions[0][0] == "e") {
Expand Down Expand Up @@ -613,19 +620,21 @@ public function displayAction(
"view_options" => self::VIEW_OPTIONS,
]);

if (empty($title)) {
$title = $q;
}
// Default values for page titles and descriptions
if (empty($description)) {
if (count($cards) == 0) {
$description = "This search query has no results.";
} else if (count($cards) > 1) {
$description = "View all " . strval(count($cards)) . " results of this card search query.";
} else {
$title = $cards[0]["title"];
$description = $this->formatCardForEmbed($cards[0]);
$image = "https://card-images.netrunnerdb.com/v1" . $cards[0]["medium_image_path"]; // Hardcoding the link because
$image = "https://card-images.netrunnerdb.com/v1" . $cards[0]["medium_image_path"];
}
}
if (empty($title)) {
$title = $q;
}
if (empty($image)) {
$image = "";
}
Expand Down Expand Up @@ -661,25 +670,23 @@ private function formatCardForEmbed($card)
{
$out = "";

// Title
$out .= "<h2>" . ($card["uniqueness"] ? "" : "") . $card["title"] . "</h2><br>";
// Type/subtype
if (empty($card["subtype"])) {
$out .= "<b>" . $card["type_name"] . "</b> ";
$out .= $card["type_name"] . " ";
} else {
$out .= "<b>" . $card["type_name"] . ":</b> " . $card["subtype"] . " ";
$out .= $card["type_name"] . ": " . $card["subtype"] . " ";
}
// Stats
if ($card["type_code"] == "identity") {
$out .= "(" . $card["minimumdecksize"] . "/" . $card["influencelimit"] . ")<br>";
$out .= "(" . $card["minimumdecksize"] . "/" . $card["influencelimit"] . ")\n";
} else if ($card["type_code"] == "agenda") {
$out .= "(" . $card["advancementcost"] . "/" . $card["agendapoints"] . ")<br>";
$out .= "(" . $card["advancementcost"] . "/" . $card["agendapoints"] . ")\n";
} else {
$out .= "(" . $card["cost"] . ")<br>";
$out .= "(" . $card["cost"] . ")\n";
if (!empty($card["memorycost"])) {
$out .= "<b>MU cost:</b> " . $card["memorycost"] . "<br>";
$out .= "MU cost: " . $card["memorycost"] . "\n";
} else if (!empty($card["trashcost"])) {
$out .= "<b>Trash cost:</b> " . $card["trashcost"] . "<br>";
$out .= "Trash cost: " . $card["trashcost"] . "\n";
}
}
// Text
Expand Down
38 changes: 31 additions & 7 deletions src/AppBundle/Controller/SocialController.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,18 @@ public function viewAction(string $decklist_uuid, EntityManagerInterface $entity
WHERE s.decklist_id=?
ORDER BY y.position ASC, p.position ASC", [$decklist_id])->fetchAll();

$description = 'A public decklist by ' . $decklist['username'] . ".";
if (!empty(trim($decklist['rawdescription']))) {
$description .= "User description:\n" . $decklist['rawdescription'];
}

$imagePath = $entityManager->getRepository('AppBundle:Card')->findOneBy(['code' => $decklist['identity_code']])->getMediumImagePath();
$image = "https://card-images.netrunnerdb.com/v1" . $imagePath;

return $this->render('/Decklist/decklist.html.twig', [
'pagetitle' => $decklist['name'],
'pagedescription' => $description,
'pageimage' => $image,
'decklist' => $decklist,
'commenters' => $commenters,
'precedent_decklists' => $precedent_decklists,
Expand Down Expand Up @@ -1013,12 +1023,24 @@ public function profileAction(User $user, EntityManagerInterface $entityManager)
$reviews = $entityManager->getRepository('AppBundle:Review')->findBy(['user' => $user]);
$nbreviews = count($reviews);

$description = "A NetrunnerDB member since " . $user->getCreation()->format('d F Y');
if ($nbdecklists == 1) {
$description .= "One published decklist\n";
} else {
$description .= ($nbdecklists == 0 ? "No" : strval($nbdecklists)) . " published decklists\n";
}
if ($nbreviews == 1) {
$description .= "One published review\n";
} else {
$description .= ($nbreviews == 0 ? "No" : strval($nbreviews)) . " published reviews";
}

return $this->render('/Default/public_profile.html.twig', [
'pagetitle' => $user->getUsername(),
'user' => $user,
'nbdecklists' => $nbdecklists,
'nbreviews' => $nbreviews,
'pagetitle' => $user->getUsername(),
'pagedescription' => $description,
'user' => $user,
'nbdecklists' => $nbdecklists,
'nbreviews' => $nbreviews,
], $response);
}

Expand Down Expand Up @@ -1270,6 +1292,7 @@ public function donatorsAction(EntityManagerInterface $entityManager)

return $this->render('/Default/donators.html.twig', [
'pagetitle' => 'The Gracious Donators',
'pagedescription' => "NetrunnerDB wouldn't be the same without them. Many, many thanks.",
'donators' => $users,
], $response);
}
Expand Down Expand Up @@ -1299,9 +1322,10 @@ public function activityAction(int $days, EntityManagerInterface $entityManager,
$entityManager->flush();

return $this->render('/Activity/activity.html.twig', [
'pagetitle' => 'Activity',
'items_by_day' => $items_by_day,
'max' => $days,
'pagetitle' => 'Activity',
'pagedescription' => 'The latest activity from NetrunnerDB users.',
'items_by_day' => $items_by_day,
'max' => $days,
], $response);
}

Expand Down

0 comments on commit 49e3290

Please sign in to comment.