Skip to content

Commit

Permalink
upgrade to nette 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
castamir committed Jan 17, 2014
1 parent 1e0652a commit b09777a
Show file tree
Hide file tree
Showing 97 changed files with 1,777 additions and 3,178 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ storage/*

!libs/netterobots.txt
.DS_Store
!.gitignore
!.htaccess
!*.gitignore
!*.htaccess
!web.config
app/config/config.local.neon
www/webtemp/*
29 changes: 2 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,2 @@
sandbox for nette 2.1 (dev)
=======
Original nette/sandbox: https://github.com/nette/sandbox

Main differences
----
- Admin & Front modules by default (including routes)
- custom ErrorPresenter for each module (including nested modules) - here should be name of a nice guy, who send me this addon, but i have fotgot his name =(
- composer and robotloader are now more synced
- changed composer vendor dir to libs/composer
- netterobots.txt disallows libs/composer
- app dir reorganized
- app/modules for custom app modules
- app/services contains all services defined in config.neon
- custom dependencies
- LeanMapper
- DatePicker

Install
----
via Composer

composer create-project castamir/sandbox sandbox

Licence
----
MIT
netiso
======
5 changes: 4 additions & 1 deletion app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

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

\Nette\Diagnostics\Debugger::$maxDepth = 6;

$configurator = new Configurator;

// Enable Nette Debugger for error visualisation & logging
//$configurator->setDebugMode(TRUE);
$configurator->setDebugMode(TRUE);
//$configurator->setDebugMode(FALSE);
$configurator->enableDebugger(__DIR__ . '/../log');

// Specify folder for cache
Expand All @@ -23,6 +25,7 @@

// Create Dependency Injection container from config.neon file
$configurator->addConfig(__DIR__ . '/config/config.neon');
$configurator->addConfig(__DIR__ . '/config/config.model.neon');
$configurator->addConfig(__DIR__ . '/config/config.local.neon');
$container = $configurator->createContainer();

Expand Down
86 changes: 86 additions & 0 deletions app/components/VisualPaginator/VisualPaginator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

/**
* Nette Framework Extras
*
* This source file is subject to the New BSD License.
*
* For more information please see http://extras.nettephp.com
*
* @copyright Copyright (c) 2009 David Grudl
* @license New BSD License
* @link http://extras.nettephp.com
* @package Nette Extras
* @version $Id: VisualPaginator.php 4 2009-07-14 15:22:02Z [email protected] $
*/

use Nette\Application\UI\Control;
use Nette\Utils\Paginator;

/**
* Visual paginator control.
*
* @author David Grudl
* @copyright Copyright (c) 2009 David Grudl
* @package Nette Extras
* @property Nette\Templating\IFileTemplate $template
*/
class VisualPaginator extends Control
{
/** @var Paginator */
private $paginator;

/** @persistent */
public $page = 1;

/**
* @return Paginator
*/
public function getPaginator()
{
if (!$this->paginator) {
$this->paginator = new Paginator;
}
return $this->paginator;
}

/**
* Renders paginator.
* @return void
*/
public function render()
{
$paginator = $this->getPaginator();
$page = $paginator->page;
if ($paginator->pageCount < 2) {
$steps = array($page);

} else {
$arr = range(max($paginator->firstPage, $page - 3), min($paginator->lastPage, $page + 3));
$count = 4;
$quotient = ($paginator->pageCount - 1) / $count;
for ($i = 0; $i <= $count; $i++) {
$arr[] = round($quotient * $i) + $paginator->firstPage;
}
sort($arr);
$steps = array_values(array_unique($arr));
}

$this->template->steps = $steps;
$this->template->paginator = $paginator;
$this->template->setFile(dirname(__FILE__) . '/template.latte');
$this->template->render();
}

/**
* Loads state informations.
* @param array
* @return void
*/
public function loadState(array $params)
{
parent::loadState($params);
$this->getPaginator()->page = $this->page;
}

}
31 changes: 31 additions & 0 deletions app/components/VisualPaginator/example.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
(c) 2009 David Grudl. All rights reserved.
*/

.paginator {
margin: 1em 0;
font-size: 90%;
}

.paginator a, .paginator span {
margin-right: 0.1em;
padding: 0.2em 0.5em;
color: #999999;
}

.paginator a {
border: 1px solid #9AAFE5;
text-decoration: none;
color: #105CB6;
}

.paginator span.button {
border: 1px solid #DDDDDD;
}

.paginator .current {
background: #2E6AB1;
border: 1px solid #2E6AB1;
color: white;
font-weight: bold;
}
32 changes: 32 additions & 0 deletions app/components/VisualPaginator/template.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{*
* @version $Id: template.phtml 2 2009-07-13 20:58:52Z [email protected] $
* @param Paginator $paginator
* @param array $steps
*}

{if $paginator->pageCount > 1}
<div class="paginator">
{if $paginator->isFirst()}
<span class="button">« Previous</span>
{else}
<a href="{link this, 'page' => $paginator->page - 1}">« Previous</a>
{/if}

{foreach $steps as $step}
{if $step == $paginator->page}
<span class="current">{$step}</span>
{else}
<a href="{link this, 'page' => $step}">{$step}</a>
{/if}
{if $iterator->nextValue > $step + 1}
<span>…</span>
{/if}
{/foreach}

{if $paginator->isLast()}
<span class="button">Next »</span>
{else}
<a href="{link this, 'page' => $paginator->page + 1}">Next »</a>
{/if}
</div>
{/if}
22 changes: 14 additions & 8 deletions app/config/config.local.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
parameters:

nette:
database:
dsn: 'mysql:host=localhost;dbname=test'
user:
password:
options:
lazy: yes
db:
host: 127.0.0.1
driver: mysql
database: netiso_new
user: root
password:
profiler: TRUE
mailer:
smtp: true
host: smtp.gmail.com
port: 465
username: [email protected]
password: mirasman
secure: ssl

services:

Expand Down
5 changes: 5 additions & 0 deletions app/config/config.model.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:

- Model\Tables\UserRepository
- Model\Tables\Fakturace\ZakaznikRepository
- Model\Tables\RoleRepository
46 changes: 39 additions & 7 deletions app/config/config.neon
Original file line number Diff line number Diff line change
@@ -1,28 +1,60 @@
#
# 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:
libsDir: %appDir%/../libs

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

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

mailer:
smtp: %mailer.smtp%
host: %mailer.host%
port: %mailer.port%
username: %mailer.username%
password: %mailer.password%
secure: %mailer.secure%

session:
expiration: 14 days
name: netiso

extensions:
webloader: WebLoader\Nette\Extension

services:
- App\RouterFactory
router: @App\RouterFactory::createRouter

wlCssFilter: WebLoader\Filter\CssUrlsFilter(%wwwDir%)
cssMin: Services\CssMin

- Services\Security\Authenticator

- LeanMapper\Connection(%db%)
- Model\StandardMapper

factories:

webloader:
css:
default:
files:
- screen.css
- tables.css
filters:
- @wlCssFilter
- @cssMin
js:
default:
remoteFiles:
- http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js
- http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js
- http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/i18n/jquery-ui-i18n.min.js
files:
- %libsDir%/composer/nette/nette/client-side/netteForms.js
- %libsDir%/composer/castamir/datepicker/client-side/datepicker-init.js
- {files: ["*.js"], from: %wwwDir%/js} # Nette\Utils\Finder support
13 changes: 0 additions & 13 deletions app/config/example.config.local.neon

This file was deleted.

2 changes: 1 addition & 1 deletion app/modules/Admin/presenters/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Base presenter for all application presenters.
*/
abstract class BasePresenter extends \BasePresenter
abstract class BasePresenter extends \App\BasePresenter
{

}
31 changes: 2 additions & 29 deletions app/modules/Admin/presenters/ErrorPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,11 @@

namespace App\AdminModule;

use Nette,
Model,
Nette\Diagnostics\Debugger;


/**
* Error presenter.
*/
class ErrorPresenter extends BasePresenter
{

/**
* @param Exception
* @return void
*/
public function renderDefault($exception)
{
if ($this->isAjax()) { // AJAX request? Just note this error in payload.
$this->payload->error = TRUE;
$this->terminate();

} elseif ($exception instanceof Nette\Application\BadRequestException) {
$code = $exception->getCode();
// load template 403.latte or 404.latte or ... 4xx.latte
$this->setView(in_array($code, array(403, 404, 405, 410, 500)) ? $code : '4xx');
// log to access.log
Debugger::log("HTTP code $code: {$exception->getMessage()} in {$exception->getFile()}:{$exception->getLine()}", 'access');

} else {
$this->setView('500'); // load template 500.latte
Debugger::log($exception, Debugger::ERROR); // and log exception
}
}
class ErrorPresenter extends \App\ErrorPresenter
{

}
Loading

0 comments on commit b09777a

Please sign in to comment.