Skip to content

Commit

Permalink
Bump
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Oct 4, 2015
0 parents commit ad7a18a
Show file tree
Hide file tree
Showing 92 changed files with 3,611 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# IDE
.idea

# Nette
app/config/config.local.neon
log/*
temp/*
bin/*

# Composer
vendor/*
composer.lock

# Files
!.gitignore
!.htaccess
2 changes: 2 additions & 0 deletions 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 app/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

require __DIR__ . '/../vendor/autoload.php';

$configurator = new Nette\Configurator;

$configurator->setDebugMode(TRUE);
$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;
4 changes: 4 additions & 0 deletions app/config/app/components.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
- App\Modules\Front\Controls\PackageList\IPackageListFactory
- App\Modules\Front\Controls\PackageMeta\IPackageMetaFactory
- App\Modules\Front\Controls\PackageDetail\IPackageDetailFactory
8 changes: 8 additions & 0 deletions app/config/app/latte.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
# Filters ==============================================
latte.latteFactory:
setup:
- addFilter('count', ['App\Core\Latte\Filters', 'count'])
- addFilter('timeDelta', ['App\Core\Latte\Filters', 'timeDelta'])
- addFilter('timeAgo', ['App\Core\Latte\Filters', 'timeAgo'])
- addFilter('timeAge', ['App\Core\Latte\Filters', 'timeAge'])
25 changes: 25 additions & 0 deletions app/config/app/model.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
services:

# Github ===============================================
- App\Model\WebServices\Github\Client(%github.token%)
- App\Model\WebServices\Github\Service

# Composer =============================================
- App\Model\WebServices\Composer\Client
- App\Model\WebServices\Composer\Service

# Content Managing =====================================
#- App\Model\Packages\Content\ContentManager(Nette\Caching\Storages\FileStorage(%appDir%/cache, ...))

# Search ===============================================
- App\Model\Search\SearchFactory
search:
factory: @App\Model\Search\SearchFactory::create

# Model ================================================
- App\Model\ORM\PackagesFacade

# Tasks ================================================
- App\Tasks\Packages\GenerateContentTask
- App\Tasks\Packages\UpdateMetadataTask
- App\Tasks\Packages\UpdateComposerTask
8 changes: 8 additions & 0 deletions app/config/app/other.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:

# Routing ==============================================
- App\Model\Routing\RouterFactory
routing.router: @App\Model\Routing\RouterFactory::create

# Portal ===============================================
- App\Model\Portal
7 changes: 7 additions & 0 deletions app/config/app/parameters.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
system:
error:
presenter: Front:Error

build:
rev: 1.0a
13 changes: 13 additions & 0 deletions app/config/config.local.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
parameters:

# Database
database:
host:
dbname:
user:
password:

# Error mail
system:
error:
email:
47 changes: 47 additions & 0 deletions app/config/config.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
php:
date.timezone: Europe/Prague
# session.save_path: %tempDir%/session
# zlib.output_compression: true

parameters:
database:
driver: mysqli

includes:
- engine.neon

latte:
xhtml: no

session:
debugger: %debugMode%
expiration: 1 year
autoStart: smart

application:
catchExceptions: %productionMode%
errorPresenter: %system.error.presenter%
mapping:
*: App\Modules\*\*Presenter

di:
debugger: yes

tracy:
email: %system.error.email%
strictMode: yes

database:
default:
dsn: '%database.driver%:host=%database.host%;dbname=%database.dbname%'
user: %database.user%
password: %database.password%
debugger: %debugMode%
explain: %debugMode%
options:
lazy: yes

services:
nette.userStorage:
setup:
- setNamespace(Nette\Packages)
13 changes: 13 additions & 0 deletions app/config/engine.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
includes:

# APPLICATION ==========================================
- app/components.neon
- app/latte.neon
- app/model.neon
- app/other.neon
- app/parameters.neon

# EXTENSIONS ===========================================
- ext/dbal.neon
- ext/orm.neon
- ext/parsedown.neon
10 changes: 10 additions & 0 deletions app/config/ext/dbal.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
extensions:
dbal: Nextras\Dbal\Bridges\NetteDI\DbalExtension

dbal:
driver: %database.driver%
host: %database.host%
database: %database.dbname%
username: %database.user%
password: %database.password%
connectionTz: '+2:00'
5 changes: 5 additions & 0 deletions app/config/ext/orm.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extensions:
orm: Nextras\Orm\Bridges\NetteDI\OrmExtension

orm:
model: App\Model\ORM\Model
2 changes: 2 additions & 0 deletions app/config/ext/parsedown.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extensions:
parsedown: Minetro\Parsedown\DI\ParsedownExtraExtension
19 changes: 19 additions & 0 deletions app/core/http/Url.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Core\Http;

use Nette\Http\Url as NUrl;

final class Url extends NUrl
{

/**
* @param string $path
* @return self
*/
public function appendPath($path)
{
$this->setPath($this->getPath() . $path);
return $this;
}
}
84 changes: 84 additions & 0 deletions app/core/latte/Filters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

namespace App\Core\Latte;

use Nette\Utils\DateTime;

final class Filters
{

/**
* @param mixed $count
* @return mixed
*/
public static function count($count)
{
if (is_numeric($count)) {
return $count;
} else {
return 'N/A';
}
}

/**
* @param mixed $time
* @return int
*/
public static function timeDelta($time)
{
if (!$time) {
return FALSE;
} elseif (is_numeric($time)) {
$time = (int)$time;
} elseif ($time instanceof DateTime) {
$time = $time->format('U');
} else {
$time = strtotime($time);
}

return time() - $time;
}

/**
* @param mixed $time
* @return string
*/
public static function timeAge($time)
{
$delta = self::timeDelta($time);
if ($delta === FALSE) return FALSE;

$delta = round($delta / 60);
if ($delta < 1) return 'up-to-date';
if ($delta < 10) return 'before-minutes';
if ($delta < 90) return 'before-hour';
if ($delta < 2880) return 'before-day';
if ($delta < 43200) return 'before-days';
if ($delta < 86400) return 'before-month';
if ($delta < 525960) return 'before-months';
if ($delta < 1051920) return 'before-year';
return 'before-years';
}

/**
* @param mixed $time
* @return string
*/
public static function timeAgo($time)
{
$delta = self::timeDelta($time);
if ($delta === FALSE) return FALSE;

$delta = round($delta / 60);
if ($delta < 1) return 'up-to-date';
if ($delta < 10) return '< 10min';
if ($delta < 90) return '< 1h';
if ($delta < 2880) return '< 24h';
if ($delta < 43200) return '< ' . round($delta / 1440) . 'd';
if ($delta < 86400) return '< 30d';
if ($delta < 525960) return '< ' . round($delta / 43200) * 30 . 'd';
if ($delta < 1051920) return '< 1y';
return '< ' . round($delta / 525960) . 'y';
}

}
10 changes: 10 additions & 0 deletions app/core/ui/BaseControl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Core\UI;

use Nette\Application\UI\Control;

abstract class BaseControl extends Control
{

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

namespace App\Model;

use App\Model\ORM\PackagesRepository;
use Nette\Caching\Cache;
use Nette\Caching\IStorage;
use Nette\Utils\DateTime;

final class Portal
{

/** @var array */
private $cached = [];

/** @var Cache */
private $cache;

/** @var PackagesRepository */
private $packagesRepository;

/**
* @param IStorage $storage
* @param PackagesRepository $packagesRepository
*/
function __construct(
IStorage $storage,
PackagesRepository $packagesRepository
)
{
$this->cache = new Cache($storage, 'Portal');
$this->packagesRepository = $packagesRepository;

$this->build();
}

protected function build()
{
$this->cached = $this->cache->load('cached', function (&$dependencies) {
$cached = [];
$dependencies[Cache::EXPIRE] = new DateTime('+1 day');

// Package counts
$cached['packages'] = $this->packagesRepository->findActive()->count();

return $cached;
});
}

/*
* @return int
*/
public function getPackages()
{
return $this->cached['packages'];
}

}
7 changes: 7 additions & 0 deletions app/model/exceptions/LogicException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace App\Model\Exceptions;

class LogicException extends \LogicException
{
}
7 changes: 7 additions & 0 deletions app/model/exceptions/RuntimeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace App\Model\Exceptions;

class RuntimeException extends \RuntimeException
{
}
Loading

0 comments on commit ad7a18a

Please sign in to comment.