This commit is contained in:
2022-01-13 18:41:03 +01:00
commit 0fb9f639da
159 changed files with 13183 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
<?php declare(strict_types = 1);
namespace App\Modules\Admin;
use App\Model\App;
use App\Modules\Base\SecuredPresenter;
use Nette\Application\UI\ComponentReflection;
abstract class BaseAdminPresenter extends SecuredPresenter
{
/**
* @param ComponentReflection|mixed $element
* @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
*/
public function checkRequirements($element): void
{
parent::checkRequirements($element);
if (!$this->user->isAllowed('Admin:Home')) {
$this->flashError('You cannot access this with user role');
$this->redirect(App::DESTINATION_FRONT_HOMEPAGE);
}
}
}

View File

@@ -0,0 +1,31 @@
<?php declare(strict_types = 1);
namespace App\Modules\Admin\Home;
use App\Domain\Order\Event\OrderCreated;
use App\Modules\Admin\BaseAdminPresenter;
use Nette\Application\UI\Form;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
final class HomePresenter extends BaseAdminPresenter
{
/** @var EventDispatcherInterface @inject */
public $dispatcher;
protected function createComponentOrderForm(): Form
{
$form = new Form();
$form->addText('order', 'Order name')
->setRequired(true);
$form->addSubmit('send', 'OK');
$form->onSuccess[] = function (Form $form): void {
$this->dispatcher->dispatch(new OrderCreated($form->values->order), OrderCreated::NAME);
};
return $form;
}
}

View File

@@ -0,0 +1,8 @@
{block #content}
<h1>SECRET PAGE!</h1>
<a n:href="Sign:out" class="btn btn-danger">Logout</a>
<hr>
<h2>Orders</h2>
{control orderForm}

View File

@@ -0,0 +1,75 @@
<?php declare(strict_types = 1);
namespace App\Modules\Admin\Sign;
use App\Model\App;
use App\Model\Exception\Runtime\AuthenticationException;
use App\Modules\Admin\BaseAdminPresenter;
use App\UI\Form\BaseForm;
use App\UI\Form\FormFactory;
use Nette\Application\UI\ComponentReflection;
final class SignPresenter extends BaseAdminPresenter
{
/** @var string @persistent */
public $backlink;
/** @var FormFactory @inject */
public $formFactory;
/**
* @param ComponentReflection|mixed $element
* @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
*/
public function checkRequirements($element): void
{
}
public function actionIn(): void
{
if ($this->user->isLoggedIn()) {
$this->redirect(App::DESTINATION_AFTER_SIGN_IN);
}
}
public function actionOut(): void
{
if ($this->user->isLoggedIn()) {
$this->user->logout();
$this->flashSuccess('_front.sign.out.success');
}
$this->redirect(App::DESTINATION_AFTER_SIGN_OUT);
}
protected function createComponentLoginForm(): BaseForm
{
$form = $this->formFactory->forBackend();
$form->addEmail('email')
->setRequired(true);
$form->addPassword('password')
->setRequired(true);
$form->addCheckbox('remember')
->setDefaultValue(true);
$form->addSubmit('submit');
$form->onSuccess[] = [$this, 'processLoginForm'];
return $form;
}
public function processLoginForm(BaseForm $form): void
{
try {
$this->user->setExpiration($form->values->remember ? '14 days' : '20 minutes');
$this->user->login($form->values->email, $form->values->password);
} catch (AuthenticationException $e) {
$form->addError('Invalid username or password');
return;
}
$this->redirect(App::DESTINATION_AFTER_SIGN_IN);
}
}

View File

@@ -0,0 +1,29 @@
{block #content}
<form n:name="loginForm" class="form-signin">
<div class="text-center mb-4">
<img class="mb-4" src="https://avatars0.githubusercontent.com/u/99965?s=200&v=4" alt="" width="72" height="72">
<h1 class="h3 mb-3 font-weight-normal">Webapp Skeleton Admin</h1>
</div>
<div n:foreach="$form->errors as $error" class="alert alert-danger" role="alert">
{$error}
</div>
<div class="form-label-group">
<input type="email" n:name="email" class="form-control" placeholder="Email address" required autofocus>
<label n:name="email">Email address</label>
</div>
<div class="form-label-group">
<input type="password" n:name="password" class="form-control" placeholder="Password" required>
<label n:name="password">Password</label>
</div>
<div class="checkbox mb-3">
<label>
<input n:name="remember" type="checkbox"> Remember me
</label>
</div>
<button n:name="submit" class="btn btn-lg btn-primary btn-block">Sign in</button>
<p class="mt-5 mb-3 text-muted text-center">&copy; {=date('Y')}</p>
</form>

View File

@@ -0,0 +1,7 @@
{layout '../../Base/templates/@layout.latte'}
{block #head}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/css/bootstrap.min.css" defer />
<link rel="stylesheet" href="{$basePath}/assets/admin.css" defer />
<script src="{$basePath}/assets/admin.js" defer></script>
{/block}

View File

@@ -0,0 +1,44 @@
<?php declare(strict_types = 1);
namespace App\Modules\Base;
use App\Model\Exception\Runtime\InvalidStateException;
use Nette\Application\BadRequestException;
use Nette\Application\Request;
use Nette\Application\UI\ComponentReflection;
abstract class BaseError4xxPresenter extends SecuredPresenter
{
/**
* Common presenter method
*/
public function startup(): void
{
parent::startup();
if ($this->getRequest() !== null && $this->getRequest()->isMethod(Request::FORWARD)) {
return;
}
$this->error();
}
public function renderDefault(BadRequestException $exception): void
{
$rf1 = new ComponentReflection(static::class);
$fileName = $rf1->getFileName();
// Validate if class is not in PHP core
if ($fileName === false) {
throw new InvalidStateException('Class is defined in the PHP core or in a PHP extension');
}
$dir = dirname($fileName);
// Load template 403.latte or 404.latte or ... 4xx.latte
$file = $dir . '/templates/' . $exception->getCode() . '.latte';
$this->template->setFile(is_file($file) ? $file : $dir . '/templates/4xx.latte');
}
}

View File

@@ -0,0 +1,57 @@
<?php declare(strict_types = 1);
namespace App\Modules\Base;
use Nette\Application\BadRequestException;
use Nette\Application\Helpers;
use Nette\Application\IResponse as AppResponse;
use Nette\Application\Request;
use Nette\Application\Responses\CallbackResponse;
use Nette\Application\Responses\ForwardResponse;
use Nette\Http\IRequest;
use Nette\Http\IResponse;
use Psr\Log\LogLevel;
use Throwable;
use Tracy\Debugger;
use Tracy\ILogger;
abstract class BaseErrorPresenter extends SecuredPresenter
{
/**
* @return ForwardResponse|CallbackResponse
*/
public function run(Request $request): AppResponse
{
$e = $request->getParameter('exception');
if ($e instanceof Throwable) {
$code = $e->getCode();
$level = ($code >= 400 && $code <= 499) ? LogLevel::WARNING : LogLevel::ERROR;
Debugger::log(sprintf(
'Code %s: %s in %s:%s',
$code,
$e->getMessage(),
$e->getFile(),
$e->getLine()
), $level);
Debugger::log($e, ILogger::EXCEPTION);
}
if ($e instanceof BadRequestException) {
[$module, , $sep] = Helpers::splitName($request->getPresenterName());
return new ForwardResponse($request->setPresenterName($module . $sep . 'Error4xx'));
}
return new CallbackResponse(function (IRequest $httpRequest, IResponse $httpResponse): void {
$header = $httpResponse->getHeader('Content-Type');
if ($header !== null && preg_match('#^text/html(?:;|$)#', $header)) {
require __DIR__ . '/templates/500.phtml';
}
});
}
}

View File

@@ -0,0 +1,23 @@
<?php declare(strict_types = 1);
namespace App\Modules\Base;
use App\Model\Latte\TemplateProperty;
use App\Model\Security\SecurityUser;
use App\UI\Control\TFlashMessage;
use App\UI\Control\TModuleUtils;
use Contributte\Application\UI\Presenter\StructuredTemplates;
use Nette\Application\UI\Presenter;
/**
* @property-read TemplateProperty $template
* @property-read SecurityUser $user
*/
abstract class BasePresenter extends Presenter
{
use StructuredTemplates;
use TFlashMessage;
use TModuleUtils;
}

View File

@@ -0,0 +1,30 @@
<?php declare(strict_types = 1);
namespace App\Modules\Base;
use App\Model\App;
use Nette\Application\UI\ComponentReflection;
use Nette\Security\IUserStorage;
abstract class SecuredPresenter extends BasePresenter
{
/**
* @param ComponentReflection|mixed $element
* @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
*/
public function checkRequirements($element): void
{
if (!$this->user->isLoggedIn()) {
if ($this->user->getLogoutReason() === IUserStorage::INACTIVITY) {
$this->flashInfo('You have been logged out for inactivity');
}
$this->redirect(
App::DESTINATION_SIGN_IN,
['backlink' => $this->storeRequest()]
);
}
}
}

View File

@@ -0,0 +1,8 @@
<?php declare(strict_types = 1);
namespace App\Modules\Base;
abstract class UnsecuredPresenter extends BasePresenter
{
}

View File

@@ -0,0 +1,27 @@
<!DOCTYPE html><!-- "' --></textarea></script></style></pre></xmp></a></audio></button></canvas></datalist></details></dialog></iframe></listing></meter></noembed></noframes></noscript></optgroup></option></progress></rp></select></table></template></title></video>
<meta charset="utf-8">
<meta name="robots" content="noindex">
<title>Server Error</title>
<style>
#nette-error { all: initial; position: absolute; top: 0; left: 0; right: 0; height: 70vh; min-height: 400px; display: flex; align-items: center; justify-content: center; z-index: 1000 }
#nette-error div { all: initial; max-width: 550px; background: white; color: #333; display: block }
#nette-error h1 { all: initial; font: bold 50px/1.1 sans-serif; display: block; margin: 40px }
#nette-error p { all: initial; font: 20px/1.4 sans-serif; margin: 40px; display: block }
#nette-error small { color: gray }
</style>
<div id=nette-error>
<div>
<h1>Server Error</h1>
<p>We're sorry! The server encountered an internal error and
was unable to complete your request. Please try again later.</p>
<p><small>error 500</small></p>
</div>
</div>
<script>
document.body.insertBefore(document.getElementById('nette-error'), document.body.firstChild);
</script>

View File

@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="shortcut icon" href="{$basePath}/favicon.ico">
<!-- Seo -->
<title>{block #title|stripHtml|trim}Webapp Skeleton{/} | Contributte</title>
<!-- Meta -->
<meta name="description" n:ifset="#description" content="{include #description}">
<meta name="keywords" n:ifset="#keywords" content="{include #keywords}">
<meta name="robots" content="index,follow">
<meta name="googlebot" content="snippet,archive">
<meta name="author" content="f3l1x">
{block #head}{/}
</head>
<body>
{block #main}
<div class="container">
{include #content}
</div>
{/}
</body>
</html>

View File

@@ -0,0 +1,10 @@
<?php declare(strict_types = 1);
namespace App\Modules\Front;
use App\Modules\Base\UnsecuredPresenter;
abstract class BaseFrontPresenter extends UnsecuredPresenter
{
}

View File

@@ -0,0 +1,10 @@
<?php declare(strict_types = 1);
namespace App\Modules\Front\Error;
use App\Modules\Base\BaseErrorPresenter;
final class ErrorPresenter extends BaseErrorPresenter
{
}

View File

@@ -0,0 +1,10 @@
<?php declare(strict_types = 1);
namespace App\Modules\Front\Error4xx;
use App\Modules\Base\BaseError4xxPresenter;
final class Error4xxPresenter extends BaseError4xxPresenter
{
}

View File

@@ -0,0 +1,7 @@
{block #content}
<h1 n:block=title>Access Denied</h1>
<p>You do not have permission to view this page. Please try contact the web
site administrator if you believe you should be able to view this page.</p>
<p><small>error 403</small></p>

View File

@@ -0,0 +1,8 @@
{block #content}
<h1 n:block=title>Page Not Found</h1>
<p>The page you requested could not be found. It is possible that the address is
incorrect, or that the page no longer exists. Please use a search engine to find
what you are looking for.</p>
<p><small>error 404</small></p>

View File

@@ -0,0 +1,6 @@
{block #content}
<h1 n:block=title>Method Not Allowed</h1>
<p>The requested method is not allowed for the URL.</p>
<p><small>error 405</small></p>

View File

@@ -0,0 +1,6 @@
{block #content}
<h1 n:block=title>Page Not Found</h1>
<p>The page you requested has been taken off the site. We apologize for the inconvenience.</p>
<p><small>error 410</small></p>

View File

@@ -0,0 +1,4 @@
{block #content}
<h1 n:block=title>Oops...</h1>
<p>Your browser sent a request that this server could not understand or process.</p>

View File

@@ -0,0 +1,10 @@
<?php declare(strict_types = 1);
namespace App\Modules\Front\Home;
use App\Modules\Front\BaseFrontPresenter;
final class HomePresenter extends BaseFrontPresenter
{
}

View File

@@ -0,0 +1,2 @@
{block #content}
Welcome

View File

@@ -0,0 +1,38 @@
{layout '../../Base/templates/@layout.latte'}
{block #head}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css" defer/>
<link rel="stylesheet" href="{$basePath}/assets/front.css" defer/>
<script src="{$basePath}/assets/front.js" defer></script>
{/}
{block #main}
<div class="cover-container d-flex w-100 h-100 p-3 mx-auto flex-column">
<header class="masthead mb-auto">
<div class="inner">
<h3 class="masthead-brand">Webapp</h3>
<nav class="nav nav-masthead justify-content-center">
<a n:class="$presenter->isLinkCurrent(':Front:Home:') ? active, nav-link" n:href=":Front:Home:">Home</a>
<a n:class="$presenter->isLinkCurrent(':Admin:Home:') ? active, nav-link" n:href=":Admin:Home:">Admin</a>
<a n:class="$presenter->isLinkCurrent(':Pdf:Home:') ? active, nav-link" n:href=":Pdf:Home:">PDF example</a>
</nav>
</div>
</header>
<main role="main" class="inner cover">
<h1 class="cover-heading">Webapp skeleton.</h1>
<p class="lead">This is example project based on <a href="https://nette.org">Nette Framework</a></p>
<p class="lead">And also many <a href="https://contributte.org">Contributte + Nettrine</a> packages.</p>
<div class="lead">
<a href="https://github.com/contributte/webapp-skeleton" class="btn btn-lg btn-secondary">Learn more in docs</a>
</div>
</main>
<footer class="mastfoot mt-auto">
<div class="inner">
<p>Cover template for <a href="https://getbootstrap.com/">Bootstrap</a>, by
<a href="https://twitter.com/mdo">@mdo</a>.</p>
</div>
</footer>
</div>
{/}

View File

@@ -0,0 +1,35 @@
<?php declare(strict_types = 1);
namespace App\Modules\Mailing\Home;
use Contributte\Mailing\IMailBuilderFactory;
use Nette\Application\UI\Presenter;
class HomePresenter extends Presenter
{
/** @var IMailBuilderFactory */
private $mailBuilderFactory;
public function __construct(IMailBuilderFactory $mailBuilderFactory)
{
parent::__construct();
$this->mailBuilderFactory = $mailBuilderFactory;
}
public function actionDefault(): void
{
$mail = $this->mailBuilderFactory->create();
$mail->setSubject('Example');
$mail->addTo('foo@example.com');
$mail->setTemplateFile(__DIR__ . '/templates/Emails/email.latte');
$mail->setParameters([
'title' => 'Title',
'content' => 'Lorem ipsum dolor sit amet',
]);
$mail->send();
}
}

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>{ifset title}{include title|stripHtml} | {/ifset}Nette Web</title>
</head>
<body>
<div n:foreach="$flashes as $flash" n:class="flash, $flash->type">{$flash->message}</div>
{include content}
{block scripts}
<script src="https://nette.github.io/resources/js/netteForms.min.js"></script>
{/block}
</body>
</html>

View File

@@ -0,0 +1,9 @@
{layout $_config->layout}
{block #header}
{$title}
{/block}
{block #content}
{$content}
{/block}

View File

@@ -0,0 +1,38 @@
{* This is the welcome page, you can delete it *}
{block content}
<div id="banner">
<h1 n:block=title>Congratulations!</h1>
</div>
<div id="content">
<h2>You have successfully created your <a href="https://nette.org">Nette</a> Web project.</h2>
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABVCAYAAAD0bJKxAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAACudJREFUeNrMXG1sFMcZfvfu7ECw7+xDaQL+AApE1B+EJLapSNs4QIhtVWpSVTJNVIkqatX+II1apf8SoTZSq/KHiv5oqRolVaUS5UfgD04qtRAcUGipSrDdjxjHxDa0xOIcDBiMOU9nZj9udndmZ2Y/zjen0d7uzs7u+8z7Pu87H7sGCFLvrqfWGABbwMyBqfW5C5BrvhFYBkFFpiMvP3HlQ94JgwPI43izD+du1dpbn8XArLlRmaLLW+Qiznte3n7lPS4wPU/uyuHN6zg/rXpPwzAvb+kfhSzWGJTMg0fHBfGe3ZQ+hbORonIQcN5wAdOz80kCygnWbOrzeWhsbITabBZyuSz/ptYNjU3HwaidXhIBw6SF4i2YW5iGIlownz+FAUpTKLpfsTQnYwqI9tmgVFVVwUMPb4F8fqWjTsW7RQtiDio43WMsg3S6puwChtXE6lQNrKi6D67dnoC5uzOAiqY8qTS1mHWkTGrXjp1rcB0v2hdtfHAj1pAcLBaLUFxkcvEuzkUr33WdIxipZm1QUMiskHLLmiFtVNHyWAzyfGt/8ufPfc3WmD0swCMj/6RZyCucYy35Mcimb8bCJShZog1MBBysNcRyjmawGW1RIdige4vMAy2RgNIqRfUv4mwCgzUGoTo/XbNUgpTuiipJwGg3qHPIV0Sqij47FHckLqBi/Uiwn1F9JkNYMyqft0EJWh+yhEQ2MAINUeEWFzYoPg5ZMgJmrs2UorQQ3CIhGZSghkSqBsnNIhOKW3wgSmRACVoSitdUEVLkGCOoLxDyAcvlwWR1I+4Jg88xOtzCtaSKETAi+fqVQf8mcZFvbAJGMSUf+YbgFtEDLbmAEJLzXO46KrdYWobEalB+ARN11zG3cFkFFNSLVGkhtLsWAVkm4kVJgcfGM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3vU5jRGGeEwigdgmjirTGVoRxSP129d+dxTDdU4CrPJy+KitqL0EHsSv8OlOy6bMrzIdoRrzhZYWst2DzxKTqqukFox1BkFSoGo5+fSb8frP+sc/sTkG3j/zAfl6YDfOn4WOY2JuQV2uCfM2iq0p1RiUTJVBrMb5iJlxbba0EulLW79IFrQdAOuDXqpp01cLULv6TqjWLstcEacqEpUQTslU0xCFgNL982+O08nw6xgTB5izj9bBjtFF+r9106a1YH5B8XHcZ6rDLNwddLPN35iBXOMCVFySjgFRD/TLX3+vcMA+dnJwEO7Mz4PhcT6Gwtb5v/P5mrpVGzMPkclMywwMS63dW0CGrba0bMnFSx0fHR803P/NGNRA1mchzW4f2Zrn7DKIBqvc4wCv/XDmhAc+15bUmeYJzcmi4ynBcVkdPOB57Y04HY8wr1UtKlzvnDOs6FcmUCrgWNgt+98LDvuQixwBFz3nZFtRPUIgw4ASJHBKsB+UvfcAjvCybH/gxGD2Fz3gpphjwNn3BbcZibmkJMdk/1MKZhekMSigpXn/FxXKiupzmVIqwP5l/KLDRTJiB0WegSBuAL33TET7XI+k6p1AAigEAGAodM2C3mlBgmMywlbZAjjrqtSTobEvKwsaGgMhQFPd56b/CzAArAe2YDJd4I4AAAAASUVORK5CYII=" alt="">
If you are exploring Nette for the first time, you should read the
<a href="https://doc.nette.org/quickstart">Quick Start</a>, <a href="https://doc.nette.org">documentation</a>,
<a href="https://pla.nette.org">tutorials</a> and <a href="https://forum.nette.org">forum</a>.</p>
<h2>We hope you enjoy Nette!</h2>
</div>
<style>
html { font: normal 18px/1.3 Georgia, "New York CE", utopia, serif; color: #666; -webkit-text-stroke: 1px rgba(0,0,0,0); overflow-y: scroll; }
body { background: #3484d2; color: #333; margin: 2em auto; padding: 0 .5em; max-width: 600px; min-width: 320px; }
a { color: #006aeb; padding: 3px 1px; }
a:hover, a:active, a:focus { background-color: #006aeb; text-decoration: none; color: white; }
#banner { border-radius: 12px 12px 0 0; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAB5CAMAAADPursXAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAGBQTFRFD1CRDkqFDTlmDkF1D06NDT1tDTNZDk2KEFWaDTZgDkiCDTtpDT5wDkZ/DTBVEFacEFOWD1KUDTRcDTFWDkV9DkR7DkN4DkByDTVeDC9TDThjDTxrDkeADkuIDTRbDC9SbsUaggAAAEdJREFUeNqkwYURgAAQA7DH3d3335LSKyxAYpf9vWCpnYbf01qcOdFVXc14w4BznNTjkQfsscAdU3b4wIh9fDVYc4zV8xZgAAYaCMI6vPgLAAAAAElFTkSuQmCC); }
h1 { font: inherit; color: white; font-size: 50px; line-height: 121px; margin: 0; padding-left: 4%; background: url(https://files.nette.org/images/logo-nette@2.png) no-repeat 95%; background-size: 130px auto; text-shadow: 1px 1px 0 rgba(0, 0, 0, .9); }
@media (max-width: 600px) {
h1 { background: none; font-size: 40px; }
}
#content { background: white; border: 1px solid #eff4f7; border-radius: 0 0 12px 12px; padding: 10px 4%; overflow: hidden; }
h2 { font: inherit; padding: 1.2em 0; margin: 0; }
img { border: none; float: right; margin: 0 0 1em 3em; }
</style>

View File

@@ -0,0 +1,46 @@
<?php declare(strict_types = 1);
namespace App\Modules\Pdf\Home;
use App\Modules\Base\BasePresenter;
use Contributte\PdfResponse\PdfResponse;
use Nette\Bridges\ApplicationLatte\Template;
class HomePresenter extends BasePresenter
{
/** @inject */
public PdfResponse $pdfResponse;
private function createPdf(): PdfResponse
{
/** @var Template $template */
$template = $this->createTemplate();
$template->setFile(__DIR__ . '/../../../resources/pdf/example.latte');
$template->title = 'Contributte PDF example';
$this->pdfResponse->setTemplate($template->renderToString());
$this->pdfResponse->documentTitle = 'Contributte PDF example'; // creates filename 2012-06-30-my-super-title.pdf
$this->pdfResponse->pageFormat = 'A4-L'; // wide format
$this->pdfResponse->getMPDF()->SetFooter('|Contributte PDF|'); // footer
return $this->pdfResponse;
}
public function actionViewPdf(): void
{
$pdf = $this->createPdf();
$pdf->setSaveMode(PdfResponse::INLINE);
$this->sendResponse($pdf);
}
public function actionDownloadPdf(): void
{
$pdf = $this->createPdf();
$pdf->setSaveMode(PdfResponse::DOWNLOAD);
$this->sendResponse($pdf);
}
}

View File

@@ -0,0 +1,34 @@
{block #content}
<div id="banner">
<h1 n:block=title>Contributte PDF example</h1>
</div>
<div id="content">
<h2>Welcome in example of using contributte/pdf.</h2>
<a n:href="Home:viewPdf" target="_blank">View generated PDF</a>
<br><br>
<a n:href="Home:downloadPdf" target="_blank">Download generated PDF</a>
<p></p>
</div>
<style>
html { font: normal 18px/1.3 Georgia, "New York CE", utopia, serif; color: #666; -webkit-text-stroke: 1px rgba(0,0,0,0); overflow-y: scroll; }
body { background: #3484d2; color: #333; margin: 2em auto; padding: 0 .5em; max-width: 800px; min-width: 320px; }
a { color: #006aeb; padding: 3px 1px; }
a:hover, a:active, a:focus { background-color: #006aeb; text-decoration: none; color: white; }
#banner { border-radius: 12px 12px 0 0; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAB5CAMAAADPursXAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAGBQTFRFD1CRDkqFDTlmDkF1D06NDT1tDTNZDk2KEFWaDTZgDkiCDTtpDT5wDkZ/DTBVEFacEFOWD1KUDTRcDTFWDkV9DkR7DkN4DkByDTVeDC9TDThjDTxrDkeADkuIDTRbDC9SbsUaggAAAEdJREFUeNqkwYURgAAQA7DH3d3335LSKyxAYpf9vWCpnYbf01qcOdFVXc14w4BznNTjkQfsscAdU3b4wIh9fDVYc4zV8xZgAAYaCMI6vPgLAAAAAElFTkSuQmCC); }
h1 { font: inherit; color: white; font-size: 50px; line-height: 121px; margin: 0; padding-left: 4%; background: url(https://files.nette.org/images/logo-nette@2.png) no-repeat 95%; background-size: 130px auto; text-shadow: 1px 1px 0 rgba(0, 0, 0, .9); }
@media (max-width: 600px) {
h1 { background: none; font-size: 40px; }
}
#content { background: white; border: 1px solid #eff4f7; border-radius: 0 0 12px 12px; padding: 10px 4%; overflow: hidden; }
h2 { font: inherit; padding: 1.2em 0; margin: 0; }
img { border: none; float: right; margin: 0 0 1em 3em; }
</style>

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>{ifset title}{include title|stripHtml} | {/ifset}Nette Web</title>
</head>
<body>
<div n:foreach="$flashes as $flash" n:class="flash, $flash->type">{$flash->message}</div>
{include content}
{block scripts}
<script src="https://nette.github.io/resources/js/3/netteForms.min.js"></script>
{/block}
</body>
</html>