<?php require_once 'vendor/autoload.php'; $title = 'Group and shorten links with Linkadept.com'; $announcement = \Linkadept\LocalData::getAnnouncement(); $stylesheet = \Linkadept\Misc::getCorrespondingStylesheet(); $popularLinks = \Linkadept\Misc::getPopularLinks(); $pageVars = array('title' => $title, 'announcement' => $announcement, 'stylesheet' => $stylesheet, 'popularLinks' => $popularLinks); //Set up Twig Templating Engine $loader = new Twig_Loader_Filesystem('views'); $twig = new Twig_Environment($loader, array('cache' => 'views/cache', 'debug' => true)); $klein = new \Klein\Klein(); $klein->respond('GET', '/', function () use($twig, $pageVars) { $pageVars['stylesheet'] = 'index.css'; return $twig->render('View.indexInputs.php', ['pageVars' => $pageVars]); }); $klein->respond('GET', '/[:groupKey]', function () use($twig, $pageVars) { $linksObj = new \Linkadept\Links(); $links = $linksObj->getLinks(); return $twig->render('View.indexOutputs.php', ['pageVars' => $pageVars, 'links' => $links, 'groupKey' => $linksObj->groupKey]); }); $klein->respond('POST', '/', function ($request, $response) use($twig, $pageVars) { $pageVars['stylesheet'] = 'index.css'; $links = new \Linkadept\Links(); $upload = $links->uploadLink(); if ($upload['error']) { return $twig->render('View.indexInputs.php', ['pageVars' => $pageVars, 'errors' => $upload['messages']]); } $response->redirect($links->groupKey, 302); }); $klein->respond('GET', '/page/tos', function () use($twig, $pageVars) {