Init
This commit is contained in:
9
app/resources/mail/@layout.latte
Normal file
9
app/resources/mail/@layout.latte
Normal file
@@ -0,0 +1,9 @@
|
||||
{layout $_defaults->layout}
|
||||
|
||||
{block #title}
|
||||
Webapp Skeleton
|
||||
{/block}
|
||||
|
||||
{block #copyright}
|
||||
Webapp Skeleton
|
||||
{/block}
|
||||
10
app/resources/mail/signIn/signIn.latte
Normal file
10
app/resources/mail/signIn/signIn.latte
Normal file
@@ -0,0 +1,10 @@
|
||||
{layout $_config->layout}
|
||||
|
||||
{block #header}
|
||||
Automatické přihlášení
|
||||
{/block}
|
||||
|
||||
{block #content}
|
||||
<h2>Přihlášení</h2>
|
||||
<a href="{link Admin:SignIn:, do => auth, token => $token}" target="_blank">Přihlásit se</a>
|
||||
{/block}
|
||||
171
app/resources/pdf/example.latte
Normal file
171
app/resources/pdf/example.latte
Normal file
@@ -0,0 +1,171 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
|
||||
<title>{$title}</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<img src="https://heatbadger.now.sh/github/readme/contributte/pdf/">
|
||||
<h2>Lorem ipsum</h2>
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Neque porro quisquam est, qui dolorem ipsum quia
|
||||
dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et
|
||||
dolore magnam aliquam quaerat voluptatem. Sed elit dui, pellentesque a, faucibus vel, interdum nec, diam.
|
||||
Etiam posuere lacus quis dolor. Aliquam ante. Sed vel lectus. Donec odio tempus molestie, porttitor ut,
|
||||
iaculis quis, sem. Aliquam erat volutpat. Fusce wisi. Cum sociis natoque penatibus et magnis dis parturient
|
||||
montes, nascetur ridiculus mus. Nullam eget nisl. Etiam bibendum elit eget erat.
|
||||
</p>
|
||||
<h1 id="readme">ReadMe</h1>
|
||||
<h2 id="usage">Usage</h2>
|
||||
<h3 id="how-to-prepare-pdf-from-template">How to prepare PDF from template</h3>
|
||||
<pre><code class="lang-php"><span class="hljs-comment">// in a Presenter</span>
|
||||
<span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span
|
||||
class="hljs-title">actionPdf</span><span class="hljs-params">()</span>
|
||||
</span>{
|
||||
$template = <span class="hljs-keyword">$this</span>->createTemplate();
|
||||
$template->setFile(<span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">"/path/to/template.latte"</span>);
|
||||
$template->someValue = <span class="hljs-number">123</span>;
|
||||
<span class="hljs-comment">// Tip: In template to make a new page use <pagebreak></span>
|
||||
|
||||
$pdf = <span class="hljs-keyword">new</span> \Contributte\PdfResponse\PdfResponse($template);
|
||||
|
||||
<span class="hljs-comment">// optional</span>
|
||||
$pdf->documentTitle = date(<span class="hljs-string">"Y-m-d"</span>) . <span class="hljs-string">" My super title"</span>; <span
|
||||
class="hljs-comment">// creates filename 2012-06-30-my-super-title.pdf</span>
|
||||
$pdf->pageFormat = <span class="hljs-string">"A4-L"</span>; <span class="hljs-comment">// wide format</span>
|
||||
$pdf->getMPDF()->setFooter(<span class="hljs-string">"|© www.mysite.com|"</span>); <span class="hljs-comment">// footer</span>
|
||||
|
||||
<span class="hljs-comment">// do something with $pdf</span>
|
||||
<span class="hljs-keyword">$this</span>->sendResponse($pdf);
|
||||
}
|
||||
</code></pre>
|
||||
<h3 id="save-file-to-server">Save file to server</h3>
|
||||
<pre><code class="lang-php"><span class="hljs-keyword">public</span> <span class="hljs-function"><span
|
||||
class="hljs-keyword">function</span> <span class="hljs-title">actionPdf</span><span
|
||||
class="hljs-params">()</span>
|
||||
</span>{
|
||||
$template = <span class="hljs-keyword">$this</span>->createTemplate();
|
||||
$template->setFile(<span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">"/path/to/template.latte"</span>);
|
||||
|
||||
$pdf = <span class="hljs-keyword">new</span> \Contributte\PdfResponse\PdfResponse($template);
|
||||
|
||||
$pdf->save(<span class="hljs-keyword">__DIR__</span> . <span
|
||||
class="hljs-string">"/path/to/directory"</span>); <span class="hljs-comment">// as a filename $this->documentTitle will be used</span>
|
||||
$pdf->save(<span class="hljs-keyword">__DIR__</span> . <span
|
||||
class="hljs-string">"/path/to/directory"</span>, <span class="hljs-string">"filename"</span>); <span
|
||||
class="hljs-comment">// OR use a custom name</span>
|
||||
}
|
||||
</code></pre>
|
||||
<h3 id="attach-file-to-an-email">Attach file to an email</h3>
|
||||
<pre><code class="lang-php"><span class="hljs-keyword">public</span> <span class="hljs-function"><span
|
||||
class="hljs-keyword">function</span> <span class="hljs-title">actionPdf</span><span
|
||||
class="hljs-params">()</span>
|
||||
</span>{
|
||||
$template = <span class="hljs-keyword">$this</span>->createTemplate();
|
||||
$template->setFile(<span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">"/path/to/template.latte"</span>);
|
||||
|
||||
$pdf = <span class="hljs-keyword">new</span> \Contributte\PdfResponse\PdfResponse($template);
|
||||
|
||||
$savedFile = $pdf->save(<span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">"/path/to/directory"</span>);
|
||||
$mail = <span class="hljs-keyword">new</span> Nette\Mail\Message;
|
||||
$mail->addTo(<span class="hljs-string">"john@doe.com"</span>);
|
||||
$mail->addAttachment($savedFile);
|
||||
$mailer = <span class="hljs-keyword">new</span> SendmailMailer();
|
||||
$mailer->send($mail);
|
||||
}
|
||||
</code></pre>
|
||||
<h3 id="force-file-to-download">Force file to download</h3>
|
||||
<pre><code class="lang-php"><span class="hljs-keyword">public</span> <span class="hljs-function"><span
|
||||
class="hljs-keyword">function</span> <span class="hljs-title">actionPdf</span><span
|
||||
class="hljs-params">()</span>
|
||||
</span>{
|
||||
$template = <span class="hljs-keyword">$this</span>->createTemplate();
|
||||
$template->setFile(<span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">"/path/to/template.latte"</span>);
|
||||
|
||||
$pdf = <span class="hljs-keyword">new</span> \Contributte\PdfResponse\PdfResponse($template);
|
||||
$pdf->setSaveMode(PdfResponse::DOWNLOAD); <span class="hljs-comment">//default behavior</span>
|
||||
<span class="hljs-keyword">$this</span>->sendResponse($pdf);
|
||||
}
|
||||
</code></pre>
|
||||
<h3 id="force-file-to-display-in-a-browser">Force file to display in a browser</h3>
|
||||
<pre><code class="lang-php"><span class="hljs-keyword">public</span> <span class="hljs-function"><span
|
||||
class="hljs-keyword">function</span> <span class="hljs-title">actionPdf</span><span
|
||||
class="hljs-params">()</span>
|
||||
</span>{
|
||||
$template = <span class="hljs-keyword">$this</span>->createTemplate();
|
||||
$template->setFile(<span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">"/path/to/template.latte"</span>);
|
||||
|
||||
$pdf = <span class="hljs-keyword">new</span> \Contributte\PdfResponse\PdfResponse($template);
|
||||
$pdf->setSaveMode(PdfResponse::INLINE);
|
||||
<span class="hljs-keyword">$this</span>->sendResponse($pdf);
|
||||
}
|
||||
</code></pre>
|
||||
<h3 id="set-a-pdf-background-easily">Set a pdf background easily</h3>
|
||||
<pre><code class="lang-php"><span class="hljs-keyword">public</span> <span class="hljs-function"><span
|
||||
class="hljs-keyword">function</span> <span class="hljs-title">actionPdf</span><span
|
||||
class="hljs-params">()</span>
|
||||
</span>{
|
||||
$pdf = <span class="hljs-keyword">new</span> \Contributte\PdfResponse\PdfResponse(<span
|
||||
class="hljs-string">''</span>);
|
||||
$pdf->setBackgroundTemplate(<span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">"/path/to/an/existing/file.pdf"</span>);
|
||||
|
||||
<span class="hljs-comment">// to write into an existing document use the following statements</span>
|
||||
$mpdf = $pdf->getMPDF();
|
||||
$mpdf->WriteFixedPosHTML(<span class="hljs-string">'hello world'</span>, <span
|
||||
class="hljs-number">1</span>, <span class="hljs-number">10</span>, <span class="hljs-number">10</span>, <span
|
||||
class="hljs-number">10</span>);
|
||||
|
||||
<span class="hljs-comment">// to write to another page</span>
|
||||
$mpdf->AddPage();
|
||||
|
||||
<span class="hljs-comment">// to move to exact page, use</span>
|
||||
$mpdf->page = <span class="hljs-number">3</span>; <span class="hljs-comment">// = move to 3rd page</span>
|
||||
|
||||
<span class="hljs-keyword">$this</span>->sendResponse($pdf);
|
||||
}
|
||||
</code></pre>
|
||||
<h3 id="create-pdf-with-latte-only">Create pdf with latte only</h3>
|
||||
<pre><code class="lang-php"><span class="hljs-keyword">public</span> <span class="hljs-function"><span
|
||||
class="hljs-keyword">function</span> <span class="hljs-title">actionPdf</span><span
|
||||
class="hljs-params">()</span>
|
||||
</span>{
|
||||
$latte = <span class="hljs-keyword">new</span> Latte\Engine;
|
||||
$latte->setTempDirectory(<span class="hljs-string">'/path/to/cache'</span>);
|
||||
$latte->addFilter(<span class="hljs-string">'money'</span>, <span class="hljs-function"><span
|
||||
class="hljs-keyword">function</span><span class="hljs-params">($val)</span> </span>{ <span
|
||||
class="hljs-keyword">return</span> ...; }); <span
|
||||
class="hljs-comment">// formerly registerHelper()</span>
|
||||
|
||||
$latte->onCompile[] = <span class="hljs-function"><span class="hljs-keyword">function</span><span
|
||||
class="hljs-params">($latte)</span> </span>{
|
||||
$latte->addMacro(...); <span class="hljs-comment">// when you want add some own macros, see http://goo.gl/d5A1u2</span>
|
||||
};
|
||||
|
||||
$template = $latte->renderToString(<span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">"/path/to/template.latte"</span>);
|
||||
|
||||
$pdf = <span class="hljs-keyword">new</span> \Contributte\PdfResponse\PdfResponse($template);
|
||||
<span class="hljs-keyword">$this</span>->sendResponse($pdf);
|
||||
}
|
||||
</code></pre>
|
||||
<h3 id="configuration-of-custom-temp-dir-for-mpdf-in-pdfresponse">
|
||||
Configuration of custom temp dir for mPDF in PdfResponse
|
||||
</h3>
|
||||
<pre><code class="lang-yml">services:
|
||||
-<span class="ruby"></span> factory: Contributte\PdfResponse\PdfResponse
|
||||
setup:
|
||||
-<span class="ruby"> $mpdfConfig([<span class="hljs-symbol">tempDir:</span> %tempDir<span
|
||||
class="hljs-string">%/mpdf])</span></span>
|
||||
</code></pre>
|
||||
<h2 id="see-also">See also</h2>
|
||||
<ul>
|
||||
<li><a href="https://forum.nette.org/cs/3726-addon-pdfresponse-pdfresponse">Nette forum</a> (czech)</li>
|
||||
<li><a href="https://componette.com/joseki/pdfresponse/">Componette</a></li>
|
||||
</ul>
|
||||
<hr>
|
||||
<p>Thanks for testing, reporting and contributing.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
4
app/resources/tracy/500.json
Normal file
4
app/resources/tracy/500.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"code": 500,
|
||||
"error": "Internal server error"
|
||||
}
|
||||
250
app/resources/tracy/500.phtml
Normal file
250
app/resources/tracy/500.phtml
Normal file
@@ -0,0 +1,250 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Server Error</title>
|
||||
<style>
|
||||
/**/
|
||||
:root {
|
||||
--main-color: #eaeaea;
|
||||
--stroke-color: black;
|
||||
}
|
||||
|
||||
/**/
|
||||
body {
|
||||
background: var(--main-color);
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 100px auto 0 auto;
|
||||
color: var(--stroke-color);
|
||||
font-family: 'Encode Sans Semi Condensed', Verdana, sans-serif;
|
||||
font-size: 10rem;
|
||||
line-height: 10rem;
|
||||
font-weight: 200;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 20px auto 30px auto;
|
||||
font-family: 'Encode Sans Semi Condensed', Verdana, sans-serif;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 200;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1, h2 {
|
||||
-webkit-transition: opacity 0.5s linear, margin-top 0.5s linear; /* Safari */
|
||||
transition: opacity 0.5s linear, margin-top 0.5s linear;
|
||||
}
|
||||
|
||||
.loading h1, .loading h2 {
|
||||
margin-top: 0px;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.gears {
|
||||
position: relative;
|
||||
margin: 0 auto;
|
||||
width: auto;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.gear {
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
margin: 0 auto;
|
||||
border-radius: 50%;
|
||||
background: var(--stroke-color);
|
||||
}
|
||||
|
||||
.gear:before {
|
||||
position: absolute;
|
||||
left: 5px;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
bottom: 5px;
|
||||
z-index: 2;
|
||||
content: "";
|
||||
border-radius: 50%;
|
||||
background: var(--main-color);
|
||||
}
|
||||
|
||||
.gear:after {
|
||||
position: absolute;
|
||||
left: 25px;
|
||||
top: 25px;
|
||||
z-index: 3;
|
||||
content: "";
|
||||
width: 70px;
|
||||
height: 70px;
|
||||
border-radius: 50%;
|
||||
border: 5px solid var(--stroke-color);
|
||||
box-sizing: border-box;
|
||||
background: var(--main-color);
|
||||
}
|
||||
|
||||
.gear.one {
|
||||
left: -130px;
|
||||
}
|
||||
|
||||
.gear.two {
|
||||
top: -75px;
|
||||
}
|
||||
|
||||
.gear.three {
|
||||
top: -235px;
|
||||
left: 130px;
|
||||
}
|
||||
|
||||
.gear .bar {
|
||||
position: absolute;
|
||||
left: -15px;
|
||||
top: 50%;
|
||||
z-index: 0;
|
||||
width: 150px;
|
||||
height: 30px;
|
||||
margin-top: -15px;
|
||||
border-radius: 5px;
|
||||
background: var(--stroke-color);
|
||||
}
|
||||
|
||||
.gear .bar:before {
|
||||
position: absolute;
|
||||
left: 5px;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
bottom: 5px;
|
||||
z-index: 1;
|
||||
content: "";
|
||||
border-radius: 2px;
|
||||
background: var(--main-color);
|
||||
}
|
||||
|
||||
.gear .bar:nth-child(2) {
|
||||
transform: rotate(60deg);
|
||||
-webkit-transform: rotate(60deg);
|
||||
}
|
||||
|
||||
.gear .bar:nth-child(3) {
|
||||
transform: rotate(120deg);
|
||||
-webkit-transform: rotate(120deg);
|
||||
}
|
||||
|
||||
@-webkit-keyframes clockwise {
|
||||
0% {
|
||||
-webkit-transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes anticlockwise {
|
||||
0% {
|
||||
-webkit-transform: rotate(360deg);
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: rotate(0deg);
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes clockwiseError {
|
||||
0% {
|
||||
-webkit-transform: rotate(0deg);
|
||||
}
|
||||
20% {
|
||||
-webkit-transform: rotate(30deg);
|
||||
}
|
||||
40% {
|
||||
-webkit-transform: rotate(25deg);
|
||||
}
|
||||
60% {
|
||||
-webkit-transform: rotate(30deg);
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: rotate(0deg);
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes anticlockwiseErrorStop {
|
||||
0% {
|
||||
-webkit-transform: rotate(0deg);
|
||||
}
|
||||
20% {
|
||||
-webkit-transform: rotate(-30deg);
|
||||
}
|
||||
60% {
|
||||
-webkit-transform: rotate(-30deg);
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: rotate(0deg);
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes anticlockwiseError {
|
||||
0% {
|
||||
-webkit-transform: rotate(0deg);
|
||||
}
|
||||
20% {
|
||||
-webkit-transform: rotate(-30deg);
|
||||
}
|
||||
40% {
|
||||
-webkit-transform: rotate(-25deg);
|
||||
}
|
||||
60% {
|
||||
-webkit-transform: rotate(-30deg);
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: rotate(0deg);
|
||||
}
|
||||
}
|
||||
|
||||
.gear.one {
|
||||
-webkit-animation: anticlockwiseErrorStop 2s linear infinite;
|
||||
}
|
||||
|
||||
.gear.two {
|
||||
-webkit-animation: anticlockwiseError 2s linear infinite;
|
||||
}
|
||||
|
||||
.gear.three {
|
||||
-webkit-animation: clockwiseError 2s linear infinite;
|
||||
}
|
||||
|
||||
.loading .gear.one, .loading .gear.three {
|
||||
-webkit-animation: clockwise 3s linear infinite;
|
||||
}
|
||||
|
||||
.loading .gear.two {
|
||||
-webkit-animation: anticlockwise 3s linear infinite;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>500</h1>
|
||||
<h2>Unexpected Error <b>:(</b></h2>
|
||||
<div class="gears">
|
||||
<div class="gear one">
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
</div>
|
||||
<div class="gear two">
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
</div>
|
||||
<div class="gear three">
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
1
app/resources/tracy/500.txt
Normal file
1
app/resources/tracy/500.txt
Normal file
@@ -0,0 +1 @@
|
||||
Internal server error
|
||||
Reference in New Issue
Block a user