From 5d55842c465710c910735bb6a55fcb42f910984e Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sun, 26 Nov 2023 10:28:25 +0100 Subject: update commit --- index.php | 105 ++++++-------------------------------------------------------- 1 file changed, 9 insertions(+), 96 deletions(-) (limited to 'index.php') diff --git a/index.php b/index.php index 3132381..4f403a3 100644 --- a/index.php +++ b/index.php @@ -1,101 +1,14 @@ $matches[1][$idx], - 'name' => $matches[2][$idx], - 'set' => $matches[3][$idx], - 'number' => $matches[4][$idx], - ]; -} - -/* - * SELECT scryfallId from cardIdentifiers - * JOIN cards ON cardIdentifiers.uuid=cards.uuid - * WHERE cards.setCode='$SETCODE' AND cards.number='$NUMBER'; - */ - -$db = new \PDO('sqlite:AllPrintings.sqlite'); - -$images = []; -foreach ($cards as $card) { - $query = 'SELECT scryfallId from cardIdentifiers JOIN cards on cardIdentifiers.uuid=cards.uuid WHERE cards.setCode=:setCode AND cards.number=:number'; - $statement = $db->prepare($query); - $statement->execute(['setCode' => $card['set'], 'number' => $card['number']]); - - $id = $statement->fetchColumn()?: ''; - - if (empty($id)) { - continue; - } - - // TODO: check double sided - - $images[] = [ - 'quantity' => $card['quantity'], - 'src' => "https://cards.scryfall.io/png/front/" . substr($id, 0, 1) . "/" . substr($id, 1, 1) . "/$id.png", - ]; +if (isset($_POST['decklist'])) { + $_ENV['DECKLIST'] = $_POST['decklist']; + include __DIR__ . '/mtg-pdf.php'; + exit; } -// https://cards.scryfall.io/png/front/substr($scryfallId, 0, 1)/substr($scryfallId, 1, 1)/$scryfallId.png - -/* - curl \ ---request POST 'http://localhost:3000/forms/chromium/convert/html' \ ---form 'files=@"./index.html"' \ --o my.pdf -F marginTop=0.0 -F marginBottom=0.0 -F marginRight=0.0 -F marginLeft=0.0 - */ - -$template = << - - - - - -
{{imgs}}
- - -HTML; - -$imgs = array_map(function ($image) { - return str_repeat("", $image['quantity']); -}, $images); - -$html = str_replace('{{imgs}}', implode('', $imgs), $template); -$request = Gotenberg::chromium('gotenberg:3000') - ->paperSize(8.27, 11.7) # A4 - ->margins(0, 0, 0, 0) - ->outputFilename(date("Ymd_His")) - ->html(Stream::string('index.html', $html)); +?> -Gotenberg::save($request, __DIR__ . '/output'); +
+ + +
-- cgit v1.2.3