Skip to content

Commit

Permalink
added example, sources moved to srr/
Browse files Browse the repository at this point in the history
  • Loading branch information
castamir committed Feb 6, 2014
1 parent 566046e commit a628358
Show file tree
Hide file tree
Showing 30 changed files with 1,092 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
},
"license": "LGPL-3.0",
"autoload": {
"classmap": ["Joseki"]
"classmap": ["src"]
}
}
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
temp/cache*
2 changes: 2 additions & 0 deletions example/app/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Order Allow,Deny
Deny from all
21 changes: 21 additions & 0 deletions example/app/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

require __DIR__ . '/shortcuts.php';
require __DIR__ . '/../../libs/autoload.php';

$configurator = new Nette\Configurator;

$configurator->enableDebugger(__DIR__ . '/../log');

$configurator->setTempDirectory(__DIR__ . '/../temp');

$configurator->createRobotLoader()
->addDirectory(__DIR__)
->register();

$configurator->addConfig(__DIR__ . '/config/config.neon');
$configurator->addConfig(__DIR__ . '/config/config.local.neon');

$container = $configurator->createContainer();

return $container;
3 changes: 3 additions & 0 deletions example/app/config/config.local.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
parameters:

nette:
27 changes: 27 additions & 0 deletions example/app/config/config.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# SECURITY WARNING: it is CRITICAL that this file & directory are NOT accessible directly via a web browser!
#
# If you don't protect this directory from direct web access, anybody will be able to see your passwords.
# http://nette.org/security-warning
#
parameters:


php:
date.timezone: Europe/Prague
# zlib.output_compression: yes


nette:
application:
errorPresenter: Error
mapping:
*: App\*Module\*Presenter

session:
expiration: 14 days


services:
- App\RouterFactory
router: @App\RouterFactory::createRouter
13 changes: 13 additions & 0 deletions example/app/presenters/BasePresenter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App;

use Nette;

/**
* Base presenter for all application presenters.
*/
abstract class BasePresenter extends Nette\Application\UI\Presenter
{

}
23 changes: 23 additions & 0 deletions example/app/presenters/HomepagePresenter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App;

use Joseki\Application\Responses\PdfResponse;

/**
* Homepage presenter.
*/
class HomepagePresenter extends BasePresenter
{
public function actionPdf()
{
$template = $this->createTemplate()->setFile(__DIR__ . "/../templates/Homepage/default.latte");

$pdf = new PdfResponse($template);

$pdf->setSaveMode(PdfResponse::INLINE);

$this->sendResponse($pdf);
}
}

26 changes: 26 additions & 0 deletions example/app/router/RouterFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App;

use Nette,
Nette\Application\Routers\RouteList,
Nette\Application\Routers\Route;


/**
* Router factory.
*/
class RouterFactory
{

/**
* @return \Nette\Application\IRouter
*/
public function createRouter()
{
$router = new RouteList();
$router[] = new Route('<presenter>/<action>[/<id>]', 'Homepage:default');
return $router;
}

}
39 changes: 39 additions & 0 deletions example/app/shortcuts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use Nette\Diagnostics\Debugger;


/**
* @return Nette\Callback
*/
function callback($callback, $m = NULL)
{
return new Nette\Callback($callback, $m);
}


/**
* Nette\Diagnostics\Debugger::dump() shortcut.
*/
function dump($var)
{
foreach (func_get_args() as $arg) {
Debugger::dump($arg);
}
return $var;
}


/**
* Nette\Diagnostics\Debugger::log() shortcut.
*/
function dlog($var = NULL)
{
if (func_num_args() === 0) {
Debugger::log(new Exception, 'dlog');
}
foreach (func_get_args() as $arg) {
Debugger::log($arg, 'dlog');
}
return $var;
}
33 changes: 33 additions & 0 deletions example/app/templates/@layout.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{**
* My Application layout template.
*
* @param string $basePath web base path
* @param string $robots tell robots how to index the content of a page (optional)
* @param array $flashes flash messages
*}

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="robots" content="{$robots}" n:ifset="$robots">

<title>{block title|striptags|upper}Nette Application Skeleton{/block}</title>

<link rel="stylesheet" media="screen,projection,tv" href="{$basePath}/css/screen.css">
<link rel="stylesheet" media="print" href="{$basePath}/css/print.css">
<link rel="shortcut icon" href="{$basePath}/favicon.ico">
{block head}{/block}
</head>

<body>
<script> document.documentElement.className+=' js' </script>

<div n:foreach="$flashes as $flash" class="flash {$flash->type}">{$flash->message}</div>

{include content}

{block scripts}{/block}
</body>
</html>
Loading

0 comments on commit a628358

Please sign in to comment.