Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

společná hlavička a postranní panel pro WP a Nette #3

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
temp/cache/*
temp/btfj.dat
.directory
48 changes: 1 addition & 47 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
/**
* My Application bootstrap file.
*/
use Nette\Application\Routers\Route;


// Load Nette Framework or autoloader generated by Composer
require LIBS_DIR . '/autoload.php';
Expand All @@ -29,51 +27,7 @@
$container = $configurator->createContainer();

// Setup router
// ================= "funkcni" a prevedene stranky ================
$container->router[] = new Route('index.php', 'Homepage:default', Route::ONE_WAY);
$container->router[] = new Route('novinky', 'Homepage:news');
$container->router[] = new Route('news', 'Homepage:news', Route::ONE_WAY);

// souteze
$container->router[] = new Route('souteze', 'Homepage:competition');
$container->router[] = new Route('competitions.aspx', 'Homepage:competition', Route::ONE_WAY);
$container->router[] = new Route('competitions/<name>.aspx', 'Homepage:competition', Route::ONE_WAY);

$container->router[] = new Route('kontakt', 'Homepage:contact');
$container->router[] = new Route('contact.aspx', 'Homepage:contact', Route::ONE_WAY);

// ================= rozpracovane a nedodelane ================
// about
$container->router[] = new Route('o-projektu', 'Homepage:about');
$container->router[] = new Route('about.aspx', 'Homepage:about', Route::ONE_WAY);
$container->router[] = new Route('about/history.aspx', 'Homepage:about', Route::ONE_WAY);
$container->router[] = new Route('about/seminars.aspx', 'Homepage:about', Route::ONE_WAY); // stary obsah - spis na Junior Camp?
$container->router[] = new Route('download.aspx', 'Homepage:about', Route::ONE_WAY); // asi dame casem ke stazeni loga (pripadne na 'media'?)

// konference
$container->router[] = new Route('konference', 'Homepage:conference');
$container->router[] = new Route('conference.aspx', 'Homepage:conference', Route::ONE_WAY);

// pro media
$container->router[] = new Route('pro-media', 'Homepage:media');
$container->router[] = new Route('mediaroom.aspx', 'Homepage:media', Route::ONE_WAY);
$container->router[] = new Route('mediaroom/<name>.aspx', 'Homepage:media', Route::ONE_WAY); // how-to-promote, wrote-about-us, press-releases

// pribehy vitezu / success stories
$container->router[] = new Route('pribehy-vitezu', 'Homepage:successStories');

// Předchozí ročníky
$container->router[] = new Route('predchozi-rocniky', 'Homepage:previous');
$container->router[] = new Route('winners.aspx', 'Homepage:previous', Route::ONE_WAY);
$container->router[] = new Route('winners/year/<year>.aspx', 'Homepage:previous', Route::ONE_WAY);
$container->router[] = new Route('winners/competition/<competition>.aspx', 'Homepage:previous', Route::ONE_WAY);

// Výzva
$container->router[] = new Route('hledame-dalsiho-viteze', 'Homepage:appeal', Route::ONE_WAY);
$container->router[] = new Route('hledame-viteze', 'Homepage:appeal');

// ostatni -> da se flash message, ze jsme ji smazali
$container->router[] = new Route('<action>[.aspx]', 'Homepage:default');
$container->router = require 'routes.php';

// Configure and run the application!
$container->application->run();
2 changes: 2 additions & 0 deletions app/presenters/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public function beforeRender()
$this->template->registerHelper('texy', callback($texy, 'process'));

$this->template->urlToCompetitionSystem = $this->context->parameters['urlToCompetitionSystem'];

NetteLink::$function = callback($this, 'link');
}

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

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

$router = new RouteList;

// ================= "funkcni" a prevedene stranky ================
$router[] = new Route('index.php', 'Homepage:default', Route::ONE_WAY);
$router[] = new Route('novinky', 'Homepage:news');
$router[] = new Route('news', 'Homepage:news', Route::ONE_WAY);

// souteze
$router[] = new Route('souteze', 'Homepage:competition');
$router[] = new Route('competitions.aspx', 'Homepage:competition', Route::ONE_WAY);
$router[] = new Route('competitions/<name>.aspx', 'Homepage:competition', Route::ONE_WAY);

$router[] = new Route('kontakt', 'Homepage:contact');
$router[] = new Route('contact.aspx', 'Homepage:contact', Route::ONE_WAY);

// ================= rozpracovane a nedodelane ================
// about
$router[] = new Route('o-projektu', 'Homepage:about');
$router[] = new Route('about.aspx', 'Homepage:about', Route::ONE_WAY);
$router[] = new Route('about/history.aspx', 'Homepage:about', Route::ONE_WAY);
$router[] = new Route('about/seminars.aspx', 'Homepage:about', Route::ONE_WAY); // stary obsah - spis na Junior Camp?
$router[] = new Route('download.aspx', 'Homepage:about', Route::ONE_WAY); // asi dame casem ke stazeni loga (pripadne na 'media'?)

// konference
$router[] = new Route('konference', 'Homepage:conference');
$router[] = new Route('conference.aspx', 'Homepage:conference', Route::ONE_WAY);

// pro media
$router[] = new Route('pro-media', 'Homepage:media');
$router[] = new Route('mediaroom.aspx', 'Homepage:media', Route::ONE_WAY);
$router[] = new Route('mediaroom/<name>.aspx', 'Homepage:media', Route::ONE_WAY); // how-to-promote, wrote-about-us, press-releases

// pribehy vitezu / success stories
$router[] = new Route('pribehy-vitezu', 'Homepage:successStories');

// Předchozí ročníky
$router[] = new Route('predchozi-rocniky', 'Homepage:previous');
$router[] = new Route('winners.aspx', 'Homepage:previous', Route::ONE_WAY);
$router[] = new Route('winners/year/<year>.aspx', 'Homepage:previous', Route::ONE_WAY);
$router[] = new Route('winners/competition/<competition>.aspx', 'Homepage:previous', Route::ONE_WAY);

// Výzva
$router[] = new Route('hledame-dalsiho-viteze', 'Homepage:appeal', Route::ONE_WAY);
$router[] = new Route('hledame-viteze', 'Homepage:appeal');

// ostatni -> da se flash message, ze jsme ji smazali
$router[] = new Route('<action>[.aspx]', 'Homepage:default');

return $router;
9 changes: 1 addition & 8 deletions app/templates/@layout.latte
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@
{/define}

{define #mainNav}
<div class="nav mainnav" role="navigation">
<a n:href="news">Aktuálně</a>
<a n:href="previous">Předchozí&nbsp;ročníky</a>
<a n:href="successStories">Příběhy&nbsp;vítězů</a>
<a n:href="about">O&nbsp;projektu</a>
<a n:href="media">Pro&nbsp;média</a>
<a n:href="contact">Kontakt</a>
</div>
{include mainNav.php}
{/define}

<!doctype html>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/Homepage/about.latte
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Věříme, že Junior Internet může být jedinečnou příležitost pro mnoho
</div>
</div>

{include 'aside.latte'}
{include 'aside.php'}

</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<h4>Soutěže</h4>
<p>Ukaž co v tobě je. Přihlaš projekt do soutěže a vyhraj hodnotné ceny.</p>
<p>
<a class="btn btn-primary" href="{!$urlToCompetitionSystem}">přihlásit projekt</a>
<a class="btn btn-primary" href="<?php $url = $urlToCompetitionSystem ?: get_option('urlToCompetitionSystem'); echo $url ?>">přihlásit projekt</a>
<span class="line-break-tablet"></span>
<a n:href="competition">více informací</a>
<a href="<?php echo netteLink('Homepage:competition') ?>">více informací</a>
</p>
</div>
<div class="organise">
Expand All @@ -17,4 +17,4 @@
<p>Registrace na konferenci se otevřou v únoru 2013.</p>
</div>

</div>
</div>
2 changes: 1 addition & 1 deletion app/templates/Homepage/contact.latte
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Together Czech Republic, o.s. je občanské sdružení vedené mladými lidmi za
</div>
</div>

{include 'aside.latte'}
{include 'aside.php'}

</div>

Expand Down
23 changes: 1 addition & 22 deletions app/templates/Homepage/default.latte
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,7 @@
{block #title}Junior Internet{/block}

{block #content}
<div role="banner" class="clearfix banner primary">
<div class="inner">
<span class="year">2013 &mdash; 14. ročník</span>
<h1 class="logo">Junior Internet</h1>
<h2>Odrazový můstek <span class="line-break"></span>pro mladé internetové nadšence.</h2>
<p>Již 14 let pomáháme mladým lidem poznávat internetové technologie, potkávat zajímavé lidi a prosadit se na internetu.</p>
<p n:foreach="$flashes as $flash" class="flash {$flash->type}">{$flash->message}</p>
<p class="nav quicknav" role="navigation">
Organizujeme:
<a n:href="competition">Soutěže</a>

<!-- <a href="/konference">Konference</a> -->
<span class="wip" title="V přípravě">Konference (registrace se otevřou v průběhu února)</span>

<!-- <a href="/junior-camp">Junior&nbsp;Camp</a>
<span class="wip" title="V přípravě">Junior&nbsp;Camp</span> -->
</p>

{include #mainNav}
</div>

</div>
{include ../headerBanner.php}

<div role="main" class="content clearfix secondary competition">

Expand Down
2 changes: 1 addition & 1 deletion app/templates/Homepage/media.latte
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Logo Junior Internet ("PDF":http://www.juniorinternet.cz/files/logo.pdf, "AI":ht
</div>
</div>

{include 'aside.latte'}
{include 'aside.php'}

</div>

Expand Down
2 changes: 1 addition & 1 deletion app/templates/Homepage/news.latte
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@

</div>

{include 'aside.latte'}
{include 'aside.php'}

</div>

Expand Down
2 changes: 1 addition & 1 deletion app/templates/Homepage/previous.latte
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Bude doplněno
</div>
</div>

{include 'aside.latte'}
{include 'aside.php'}

</div>

Expand Down
2 changes: 1 addition & 1 deletion app/templates/Homepage/successStories.latte
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Jste bývalý vítěz a chcete přidat svůj příběh? "Napište nám ho":info@
</div>
</div>

{include 'aside.latte'}
{include 'aside.php'}

</div>

Expand Down
24 changes: 24 additions & 0 deletions app/templates/headerBanner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div role="banner" class="clearfix banner primary">
<div class="inner">
<span class="year">2013 &mdash; 14. ročník</span>
<h1 class="logo">Junior Internet</h1>
<h2>Odrazový můstek <span class="line-break"></span>pro mladé internetové nadšence.</h2>
<p>Již 14 let pomáháme mladým lidem poznávat internetové technologie, potkávat zajímavé lidi a prosadit se na internetu.</p>
<?php foreach( $flashes as $flash ): ?>
<p class="flash <?php echo $flash->type ?>"><?php echo $flash->message ?></p>
<?php endforeach ?>
<p class="nav quicknav" role="navigation">
Organizujeme:
<a href="<?php echo netteLink('Homepage:competition'); ?>">Soutěže</a>

<!-- <a href="/konference">Konference</a> -->
<span class="wip" title="V přípravě">Konference (registrace se otevřou v průběhu února)</span>

<!-- <a href="/junior-camp">Junior&nbsp;Camp</a>
<span class="wip" title="V přípravě">Junior&nbsp;Camp</span> -->
</p>

<?php require APP_DIR. '/templates/mainNav.php' ?>
</div>

</div>
9 changes: 9 additions & 0 deletions app/templates/headerBannerClassic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div role="banner" class="clearfix banner primary small-banner">
<div class="inner">
<span class="year">2013 &mdash; 14. ročník</span>

<p class="main-text">Co se <strong>aktuálně</strong> děje <span class="line-break-mobile"></span> v projektu <a href="/"><span>Junior Internet</span></a></p>

<?php require APP_DIR. '/templates/mainNav.php' ?>
</div>
</div>
8 changes: 8 additions & 0 deletions app/templates/mainNav.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="nav mainnav" role="navigation">
<a href="<?php echo netteLink('Homepage:news') ?>">Aktuálně</a>
<a href="<?php echo netteLink('Homepage:previous') ?>">Předchozí&nbsp;ročníky</a>
<a href="<?php echo netteLink('Homepage:successStories') ?>">Příběhy&nbsp;vítězů</a>
<a href="<?php echo netteLink('Homepage:about') ?>">O&nbsp;projektu</a>
<a href="<?php echo netteLink('Homepage:media') ?>">Pro&nbsp;média</a>
<a href="<?php echo netteLink('Homepage:contact') ?>">Kontakt</a>
</div>
35 changes: 35 additions & 0 deletions libs/NetteLink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

class NetteLink
{
/** @var Nette\Application\Routers\RouteList */
public static $router;

/**
* Function to be used for the link generating.
* @var Nette\Callback
*/
public static $function;

public static function link($destination)
{
if ( isset(self::$function) ) return self::$function->invoke($destination);

if ( !isset(self::$router) ) throw new MissingAttributeException("Either NetteLink::\$router or NetteLink::\$function must be set for this method to work!");

$a = strrpos($destination, ':');
$presenter = substr($destination, 0, $a);
$action = $a === strlen($destination) - 1 ? NULL : substr($destination, $a + 1);

$request = new Nette\Application\Request( $presenter, 'GET', array('action' => $action) );

return self::$router->constructUrl( $request, new Nette\Http\Url( home_url("/") ) );
}
}

class MissingAttributeException extends Exception {}

function netteLink($destination)
{
return NetteLink::link($destination);
}
4 changes: 4 additions & 0 deletions novinky/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@
*/
define('WP_USE_THEMES', true);

require_once ('../www/consts.php');

require_once (LIBS_DIR. '/autoload.php');

/** Loads the WordPress Environment and Template */
require('./wp-blog-header.php');
5 changes: 4 additions & 1 deletion novinky/wp-content/themes/juniorinternet/functions.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php

require_once LIBS_DIR. '/NetteLink.php';
NetteLink::$router = require APP_DIR. '/routes.php';

add_filter('stylesheet_uri', function() {
return get_stylesheet_directory_uri(). '/assets/css/screen.css';
});

add_option('urlToCompetitionSystem', 'http://souteze.juniorinternet.cz/register/');
add_option('urlToCompetitionSystem', 'http://souteze.juniorinternet.cz/register/');
14 changes: 3 additions & 11 deletions novinky/wp-content/themes/juniorinternet/header-classic.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
<?php get_template_part( 'html_head' ); ?>
<?php get_template_part( 'html_head' ) ?>

<body <?php body_class('page-classic') ?>>

<?php get_template_part( 'old_browser' ); ?>
<?php require APP_DIR. '/templates/old_browser.php' ?>

<div role="banner" class="clearfix banner primary small-banner">
<div class="inner">
<span class="year">2013 &mdash; 14. ročník</span>

<p class="main-text">Co se <strong>aktuálně</strong> děje <span class="line-break-mobile"></span> v projektu <a href="/"><span>Junior Internet</span></a></p>

<?php get_template_part( 'navigation' ); ?>
</div>
</div>
<?php require APP_DIR. '/templates/headerBannerClassic.php' ?>
9 changes: 0 additions & 9 deletions novinky/wp-content/themes/juniorinternet/navigation.php

This file was deleted.

Loading