diff --git a/src/AppBundle/Controller/BuilderController.php b/src/AppBundle/Controller/BuilderController.php index 22cf833d..b6fd5d19 100755 --- a/src/AppBundle/Controller/BuilderController.php +++ b/src/AppBundle/Controller/BuilderController.php @@ -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 @@ -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()), @@ -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, ], @@ -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, @@ -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, diff --git a/src/AppBundle/Controller/DecklistsController.php b/src/AppBundle/Controller/DecklistsController.php index 37b544ce..3ed443eb 100644 --- a/src/AppBundle/Controller/DecklistsController.php +++ b/src/AppBundle/Controller/DecklistsController.php @@ -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(); @@ -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'); @@ -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; } diff --git a/src/AppBundle/Controller/IndexController.php b/src/AppBundle/Controller/IndexController.php index 8083b0fd..6197c686 100755 --- a/src/AppBundle/Controller/IndexController.php +++ b/src/AppBundle/Controller/IndexController.php @@ -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(), diff --git a/src/AppBundle/Controller/SearchController.php b/src/AppBundle/Controller/SearchController.php index dcadd821..0f60a53a 100755 --- a/src/AppBundle/Controller/SearchController.php +++ b/src/AppBundle/Controller/SearchController.php @@ -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(), ] @@ -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, @@ -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(), ] @@ -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, @@ -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") { @@ -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 = ""; } @@ -661,25 +670,23 @@ private function formatCardForEmbed($card) { $out = ""; - // Title - $out .= "

" . ($card["uniqueness"] ? "♦ " : "") . $card["title"] . "


"; // Type/subtype if (empty($card["subtype"])) { - $out .= "" . $card["type_name"] . " "; + $out .= $card["type_name"] . " "; } else { - $out .= "" . $card["type_name"] . ": " . $card["subtype"] . " "; + $out .= $card["type_name"] . ": " . $card["subtype"] . " "; } // Stats if ($card["type_code"] == "identity") { - $out .= "(" . $card["minimumdecksize"] . "/" . $card["influencelimit"] . ")
"; + $out .= "(" . $card["minimumdecksize"] . "/" . $card["influencelimit"] . ")\n"; } else if ($card["type_code"] == "agenda") { - $out .= "(" . $card["advancementcost"] . "/" . $card["agendapoints"] . ")
"; + $out .= "(" . $card["advancementcost"] . "/" . $card["agendapoints"] . ")\n"; } else { - $out .= "(" . $card["cost"] . ")
"; + $out .= "(" . $card["cost"] . ")\n"; if (!empty($card["memorycost"])) { - $out .= "MU cost: " . $card["memorycost"] . "
"; + $out .= "MU cost: " . $card["memorycost"] . "\n"; } else if (!empty($card["trashcost"])) { - $out .= "Trash cost: " . $card["trashcost"] . "
"; + $out .= "Trash cost: " . $card["trashcost"] . "\n"; } } // Text diff --git a/src/AppBundle/Controller/SocialController.php b/src/AppBundle/Controller/SocialController.php index 1f3e4bd1..b1573bf6 100755 --- a/src/AppBundle/Controller/SocialController.php +++ b/src/AppBundle/Controller/SocialController.php @@ -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, @@ -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); } @@ -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); } @@ -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); }