Code Style and refactorings

This commit is contained in:
Stéphane Goetz 2015-07-20 15:59:52 +02:00 committed by Stéphane Goetz
parent f903b0060c
commit 061ea5ea55
21 changed files with 193 additions and 145 deletions

BIN
daux.phar Normal file → Executable file

Binary file not shown.

View File

@ -66,7 +66,5 @@ software, even if advised of the possibility of such damage.
require_once("vendor/autoload.php");
\Todaymade\Daux\Daux::initConstants();
$application = new \Todaymade\Daux\Generator\Application();
$application->run();

View File

@ -84,6 +84,4 @@ if (file_exists('vendor/autoload.php')) {
throw new Exception("Impossible to load Daux, missing vendor and phar");
}
\Todaymade\Daux\Daux::initConstants();
\Todaymade\Daux\Server\Server::serve($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], $_REQUEST);

View File

@ -53,22 +53,32 @@ class Daux
}
}
public static function initConstants()
{
define("DS", DIRECTORY_SEPARATOR);
}
/**
* @param string $override_file
* @throws Exception
*/
public function initialize($override_file = 'config.json')
{
//global.json (docs dir, markdown files)
$this->loadConfig();
// global.json
$this->loadBaseConfiguration();
//config.json
$this->loadConfigOverrides($override_file);
// Check the documentation path
$this->docs_path = $this->options['docs_directory'];
if (!is_dir($this->docs_path) &&
!is_dir($this->docs_path = $this->local_base . DIRECTORY_SEPARATOR . $this->docs_path)
) {
throw new Exception('The Docs directory does not exist. Check the path again : ' . $this->docs_path);
}
// <docs>/config.json, <overrides.json>
$this->loadConfigurationOverrides($override_file);
// Set a valid default timezone
if (isset($this->options['timezone'])) {
date_default_timezone_set($this->options['timezone']);
} elseif (!ini_get('date.timezone')) {
date_default_timezone_set('GMT');
}
}
/**
@ -76,31 +86,18 @@ class Daux
*
* @throws Exception
*/
private function loadConfig()
protected function loadBaseConfiguration()
{
$default_config = [
$this->options = new Config();
// Set the default configuration
$this->options->merge([
'docs_directory' => 'docs',
'valid_content_extensions' => ['md', 'markdown']
];
]);
$global_config_file = $this->local_base . DS . 'global.json';
if (!file_exists($global_config_file)) {
throw new Exception('The Global Config file is missing. Requested File : ' . $global_config_file);
}
$default_config = array_merge($default_config, json_decode(file_get_contents($global_config_file), true));
if (!isset($default_config)) {
throw new Exception('The Global Config file is corrupt. Check that the JSON encoding is correct');
}
$this->docs_path = $default_config['docs_directory'];
if (!is_dir($this->docs_path) && !is_dir($this->docs_path = $this->local_base . DS . $this->docs_path)) {
throw new Exception('The Docs directory does not exist. Check the path again : ' . $this->docs_path);
}
$this->options = new Config();
$this->options->merge($default_config);
// Load the global configuration
$this->loadConfiguration($this->local_base . DIRECTORY_SEPARATOR . 'global.json', false);
}
/**
@ -111,33 +108,37 @@ class Daux
* @param string $override_file
* @throws Exception
*/
private function loadConfigOverrides($override_file)
protected function loadConfigurationOverrides($override_file)
{
// Read documentation overrides
$config_file = $this->docs_path . DS . 'config.json';
if (file_exists($config_file)) {
$config = json_decode(file_get_contents($config_file), true);
if (!isset($config)) {
throw new Exception('The local config file is missing. Check path : ' . $config_file);
}
$this->options->merge($config);
}
$this->loadConfiguration($this->docs_path . DIRECTORY_SEPARATOR . 'config.json');
// Read command line overrides
$config_file = $this->local_base . DS . $override_file;
if (!is_null($override_file) && file_exists($config_file)) {
$config = json_decode(file_get_contents($config_file), true);
if (!isset($config)) {
throw new Exception('The local config file is missing. Check path : ' . $config_file);
if (!is_null($override_file)) {
$this->loadConfiguration($this->local_base . DIRECTORY_SEPARATOR . $override_file);
}
}
/**
* @param string $config_file
* @param bool $optional
* @throws Exception
*/
protected function loadConfiguration($config_file, $optional = true)
{
if (!file_exists($config_file)) {
if ($optional) {
return;
}
$this->options->merge($config);
throw new Exception('The configuration file is missing. Check path : ' . $config_file);
}
if (isset($this->options['timezone'])) {
date_default_timezone_set($this->options['timezone']);
} elseif (!ini_get('date.timezone')) {
date_default_timezone_set('GMT');
$config = json_decode(file_get_contents($config_file), true);
if (!isset($config)) {
throw new Exception('The configuration file "' . $config_file . '" is corrupt. Is your JSON well-formed ?');
}
$this->options->merge($config);
}
/**
@ -169,7 +170,7 @@ class Daux
'mode' => $this->mode,
'local_base' => $this->local_base,
'docs_path' => $this->docs_path,
'templates' => $this->internal_base . DS . 'templates',
'templates' => $this->internal_base . DIRECTORY_SEPARATOR . 'templates',
];
$this->options->conservativeMerge($default);

View File

@ -4,6 +4,12 @@ use Todaymade\Daux\Tree\Directory;
class DauxHelper
{
/**
* Set a new base_url for the configuration
*
* @param Config $config
* @param string $base_url
*/
public static function rebaseConfiguration(Config $config, $base_url)
{
// Avoid changing the url if it is already correct
@ -24,12 +30,13 @@ class DauxHelper
*/
public static function getTheme($params, $current_url)
{
$theme_folder = $params['local_base'] . DS . 'resources' . DS . 'themes' . DS . $params['html']['theme'];
$theme_folder = $params['local_base'] . DIRECTORY_SEPARATOR . 'resources' .
DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $params['html']['theme'];
$theme_url = $params['base_url'] . "resources/themes/" . $params['html']['theme'] . '/';
$theme = array();
if (is_file($theme_folder . DS . "config.json")) {
$theme = json_decode(file_get_contents($theme_folder . DS . "config.json"), true);
if (is_file($theme_folder . DIRECTORY_SEPARATOR . "config.json")) {
$theme = json_decode(file_get_contents($theme_folder . DIRECTORY_SEPARATOR . "config.json"), true);
if (!$theme) {
$theme = array();
}
@ -44,7 +51,7 @@ class DauxHelper
'require-jquery' => false,
'bootstrap-js' => false,
'favicon' => '<base_url>resources/img/favicon.png',
'templates' => $theme_folder . DS . 'templates',
'templates' => $theme_folder . DIRECTORY_SEPARATOR . 'templates',
];
$substitutions = [

View File

@ -49,6 +49,17 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
*/
public function render(AbstractInline $inline, HtmlRendererInterface $htmlRenderer)
{
// This can't be in the method type as
// the method is an abstract and should
// have the same interface
if (!$inline instanceof Link) {
throw new \RuntimeException(
"Wrong type passed to " . __CLASS__ . "::" . __METHOD__ .
" the expected type was 'League\\CommonMark\\Inline\\Element\\Link' but '" .
get_class($inline) . "' was provided"
);
}
$element = parent::render($inline, $htmlRenderer);
$url = $inline->getUrl();

View File

@ -15,6 +15,17 @@ class LinkRenderer extends \Todaymade\Daux\Format\Base\CommonMark\LinkRenderer
*/
public function render(AbstractInline $inline, HtmlRendererInterface $htmlRenderer)
{
// This can't be in the method type as
// the method is an abstract and should
// have the same interface
if (!$inline instanceof Link) {
throw new \RuntimeException(
"Wrong type passed to " . __CLASS__ . "::" . __METHOD__ .
" the expected type was 'League\\CommonMark\\Inline\\Element\\Link' but '" .
get_class($inline) . "' was provided"
);
}
// Default handling
$element = parent::render($inline, $htmlRenderer);
$url = $inline->getUrl();

View File

@ -31,6 +31,9 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
$this->converter = new CommonMarkConverter(['daux' => $this->daux->getParams()]);
}
/**
* {@inheritdoc}
*/
public function generateAll(InputInterface $input, OutputInterface $output, $width)
{
$params = $this->daux->getParams();

View File

@ -25,7 +25,7 @@ class Publisher
protected $previous_title;
/**
* @var string terminal width
* @var integer terminal width
*/
public $width;

View File

@ -39,14 +39,14 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
$params = $this->daux->getParams();
if (is_null($destination)) {
$destination = $this->daux->local_base . DS . 'static';
$destination = $this->daux->local_base . DIRECTORY_SEPARATOR . 'static';
}
$this->runAction(
"Copying Static assets ...",
$output,
$width,
function () use ($destination) {
function() use ($destination) {
Helper::copyAssets($destination, $this->daux->local_base);
}
);
@ -76,7 +76,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
foreach ($tree->getEntries() as $key => $node) {
if ($node instanceof Directory) {
$new_output_dir = $output_dir . DS . $key;
$new_output_dir = $output_dir . DIRECTORY_SEPARATOR . $key;
mkdir($new_output_dir);
$this->generateRecursive($node, $new_output_dir, $params, $output, $width, '../' . $base_url);
@ -87,14 +87,14 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
"- " . $node->getUrl(),
$output,
$width,
function () use ($node, $output_dir, $key, $params) {
function() use ($node, $output_dir, $key, $params) {
if (!$node instanceof Content) {
copy($node->getPath(), $output_dir . DS . $key);
copy($node->getPath(), $output_dir . DIRECTORY_SEPARATOR . $key);
return;
}
$generated = $this->generateOne($node, $params);
file_put_contents($output_dir . DS . $key, $generated->getContent());
file_put_contents($output_dir . DIRECTORY_SEPARATOR . $key, $generated->getContent());
}
);
}

View File

@ -5,8 +5,6 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Todaymade\Daux\Daux;
use Todaymade\Daux\Format\HTML\Generator as HTMLGenerator;
use Todaymade\Daux\Format\Confluence\Generator as ConfluenceGenerator;
class Command extends SymfonyCommand
{
@ -53,7 +51,7 @@ class Command extends SymfonyCommand
}
$class = $daux->getProcessorClass();
if ($class) {
if (!empty($class)) {
$daux->setProcessor(new $class($daux, $output, $width));
}
}

View File

@ -16,8 +16,11 @@ class Helper
mkdir($path);
}
mkdir($path . DS . 'resources');
static::copyRecursive($local_base . DS . 'resources', $path . DS . 'resources');
mkdir($path . DIRECTORY_SEPARATOR . 'resources');
static::copyRecursive(
$local_base . DIRECTORY_SEPARATOR . 'resources',
$path . DIRECTORY_SEPARATOR . 'resources'
);
}
/**

View File

@ -25,7 +25,7 @@ class Server
$daux->initialize();
$class = $daux->getProcessorClass();
if ($class) {
if (!empty($class)) {
$daux->setProcessor(new $class($daux, new NullOutput(), 0));
}
@ -101,7 +101,7 @@ class Server
* Handle an incoming request
*
* @param array $query
* @return \Todaymade\Daux\Tree\Entry
* @return \Todaymade\Daux\Format\Base\Page
* @throws Exception
* @throws NotFoundException
*/
@ -120,7 +120,7 @@ class Server
/**
* @param string $request
* @return \Todaymade\Daux\Tree\Entry
* @return \Todaymade\Daux\Format\Base\Page
* @throws NotFoundException
*/
private function getPage($request)

View File

@ -27,7 +27,7 @@ class Builder
continue;
}
$path = $node->getPath() . DS . $file;
$path = $node->getPath() . DIRECTORY_SEPARATOR . $file;
if (is_dir($path) && in_array($file, $ignore['folders'])) {
continue;
@ -37,9 +37,9 @@ class Builder
}
if (is_dir($path)) {
$new = new Directory($node, static::getUriFromFilename(static::getFilename($path)), $path);
$new = new Directory($node, static::removeSortingInformations(static::getFilename($path)), $path);
$new->setName(DauxHelper::pathinfo($path)['filename']);
$new->setTitle(static::getTitleFromFilename($new->getName()));
$new->setTitle(static::removeSortingInformations($new->getName(), ' '));
static::build($new, $ignore);
} else {
static::createContent($node, $path);
@ -61,14 +61,14 @@ class Builder
$config = $parent->getConfig();
if (!in_array(pathinfo($path, PATHINFO_EXTENSION), $config['valid_content_extensions'])) {
$entry = new Raw($parent, static::getUriFromFilename(static::getFilename($path)), $path, filemtime($path));
$entry->setTitle(static::getTitleFromFilename($name));
$entry = new Raw($parent, static::removeSortingInformations(static::getFilename($path)), $path, filemtime($path));
$entry->setTitle(static::removeSortingInformations($name, ' '));
$entry->setName($name);
return $entry;
}
$uri = static::getUriFromFilename($name);
$uri = static::removeSortingInformations($name);
if ($config['mode'] === Daux::STATIC_MODE) {
$uri .= '.html';
}
@ -82,7 +82,7 @@ class Builder
$entry->setTitle($parent->getTitle());
}
} else {
$entry->setTitle(static::getTitleFromFilename($name));
$entry->setTitle(static::removeSortingInformations($name, ' '));
}
$entry->setName($name);
@ -104,7 +104,7 @@ class Builder
* @param string $filename
* @return string
*/
protected static function getTitleFromFilename($filename)
protected static function removeSortingInformations($filename, $separator = '_')
{
$filename = explode('_', $filename);
if ($filename[0] == '' || is_numeric($filename[0])) {
@ -115,26 +115,7 @@ class Builder
$filename[0] = substr($t, 1);
}
}
$filename = implode(' ', $filename);
return $filename;
}
/**
* @param string $filename
* @return string
*/
protected static function getUriFromFilename($filename)
{
$filename = explode('_', $filename);
if ($filename[0] == '' || is_numeric($filename[0])) {
unset($filename[0]);
} else {
$t = $filename[0];
if ($t[0] == '-') {
$filename[0] = substr($t, 1);
}
}
$filename = implode('_', $filename);
$filename = implode($separator, $filename);
return $filename;
}

View File

@ -58,7 +58,7 @@ class Directory extends Entry
}
/**
* @return Content|false
* @return Content|null
*/
public function getFirstPage()
{
@ -87,7 +87,7 @@ class Directory extends Entry
}
}
return false;
return null;
}
/**

View File

@ -3,27 +3,33 @@
<?php if ($params['html']['date_modified']) { ?>
<div class="page-header sub-header clearfix">
<h1><?php
if ($page['breadcrumbs']) echo $this->get_breadcrumb_title($page, $base_page);
else echo $page['title'];
if ($page['breadcrumbs']) {
echo $this->get_breadcrumb_title($page, $base_page);
} else {
echo $page['title'];
}
?>
</h1>
<span style="float: left; font-size: 10px; color: gray;">
<?php echo date("l, F j, Y", $page['modified_time']); ?>
<?= date("l, F j, Y", $page['modified_time']); ?>
</span>
<span style="float: right; font-size: 10px; color: gray;">
<?php echo date("g:i A", $page['modified_time']); ?>
<?= date("g:i A", $page['modified_time']); ?>
</span>
</div>
<?php } else { ?>
<div class="page-header">
<h1><?php
if ($page['breadcrumbs']) echo $this->get_breadcrumb_title($page, $base_page);
else echo $page['title'];
if ($page['breadcrumbs']) {
echo $this->get_breadcrumb_title($page, $base_page);
} else {
echo $page['title'];
}
?>
</h1>
</div>
<?php } ?>
<?php echo $page['content']; ?>
<?= $page['content']; ?>
</article>

View File

@ -2,8 +2,8 @@
<article>
<div class="page-header">
<h1><?php echo $page['title']; ?></h1>
<h1><?= $page['title']; ?></h1>
</div>
<?php echo $page['content']; ?>
<?= $page['content']; ?>
</article>

View File

@ -5,19 +5,23 @@
</div>
</div>
<?php if ($params['html']['repo']) { ?>
<a href="https://github.com/<?php echo $params['html']['repo']; ?>" target="_blank" id="github-ribbon" class="hidden-print"><img src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<a href="https://github.com/<?= $params['html']['repo']; ?>" target="_blank" id="github-ribbon" class="hidden-print"><img src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<?php } ?>
<div class="homepage-hero well container-fluid">
<div class="container">
<div class="row">
<div class="text-center col-sm-12">
<?php if ($params['tagline']) echo '<h2>' . $params['tagline'] . '</h2>'; ?>
<?php if ($params['tagline']) {
echo '<h2>' . $params['tagline'] . '</h2>';
} ?>
</div>
</div>
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<?php if ($params['image']) echo '<img class="homepage-image img-responsive" src="' . $params['image'] . '" alt="' . $params['title'] . '">'; ?>
<?php if ($params['image']) {
echo '<img class="homepage-image img-responsive" src="' . $params['image'] . '" alt="' . $params['title'] . '">';
} ?>
</div>
</div>
</div>
@ -28,8 +32,12 @@
<div class="row">
<div class="text-center col-sm-12">
<?php
if ($params['html']['repo']) echo '<a href="https://github.com/' . $params['html']['repo'] . '" class="btn btn-secondary btn-hero">View On GitHub</a>';
foreach ($page['entry_page'] as $key => $node) echo '<a href="' . $node . '" class="btn btn-primary btn-hero">' . $key . '</a>';
if ($params['html']['repo']) {
echo '<a href="https://github.com/' . $params['html']['repo'] . '" class="btn btn-secondary btn-hero">View On GitHub</a>';
}
foreach ($page['entry_page'] as $key => $node) {
echo '<a href="' . $node . '" class="btn btn-primary btn-hero">' . $key . '</a>';
}
?>
</div>
</div>
@ -40,7 +48,7 @@
<div class="container">
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<?php echo $page['content'];?>
<?= $page['content']; ?>
</div>
</div>
</div>
@ -52,7 +60,9 @@
<div class="col-sm-5 col-sm-offset-1">
<?php if (!empty($params['html']['links'])) { ?>
<ul class="footer-nav">
<?php foreach ($params['html']['links'] as $name => $url) echo '<li><a href="' . $url . '" target="_blank">' . $name . '</a></li>'; ?>
<?php foreach ($params['html']['links'] as $name => $url) {
echo '<li><a href="' . $url . '" target="_blank">' . $name . '</a></li>';
} ?>
</ul>
<?php } ?>
</div>
@ -60,10 +70,10 @@
<div class="pull-right">
<?php
if (!empty($params['html']['twitter'])) {
foreach($params['html']['twitter'] as $handle) {
foreach ($params['html']['twitter'] as $handle) {
?>
<div class="twitter">
<iframe allowtransparency="true" frameborder="0" scrolling="no" style="width:162px; height:20px;" src="https://platform.twitter.com/widgets/follow_button.html?screen_name=<?php echo $handle;?>&amp;show_count=false"></iframe>
<iframe allowtransparency="true" frameborder="0" scrolling="no" style="width:162px; height:20px;" src="https://platform.twitter.com/widgets/follow_button.html?screen_name=<?= $handle; ?>&amp;show_count=false"></iframe>
</div>
<?php
}

View File

@ -4,20 +4,24 @@
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<title><?php echo $page['title']; ?></title>
<meta name="description" content="<?php echo $params['tagline'];?>" />
<meta name="author" content="<?php echo $params['author']; ?>">
<title><?= $page['title']; ?></title>
<meta name="description" content="<?= $params['tagline']; ?>" />
<meta name="author" content="<?= $params['author']; ?>">
<meta charset="UTF-8">
<link rel="icon" href="<?php echo $params['theme']['favicon']; ?>" type="image/x-icon">
<link rel="icon" href="<?= $params['theme']['favicon']; ?>" type="image/x-icon">
<!-- Mobile -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Font -->
<?php foreach ($params['theme']['fonts'] as $font) echo "<link href='$font' rel='stylesheet' type='text/css'>"; ?>
<?php foreach ($params['theme']['fonts'] as $font) {
echo "<link href='$font' rel='stylesheet' type='text/css'>";
} ?>
<!-- CSS -->
<?php foreach ($params['theme']['css'] as $css) echo "<link href='$css' rel='stylesheet' type='text/css'>"; ?>
<?php foreach ($params['theme']['css'] as $css) {
echo "<link href='$css' rel='stylesheet' type='text/css'>";
} ?>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
@ -26,27 +30,35 @@
<body>
<?= $this->section('content'); ?>
<?php if ($params['html']['google_analytics']) {
$this->insert('theme::partials/google_analytics', ['analytics' => $params['html']['google_analytics'], 'host' => array_key_exists('host', $params)? $params['host'] : '']);
} ?>
<?php if ($params['html']['piwik_analytics']) {
<?php
if ($params['html']['google_analytics']) {
$this->insert('theme::partials/google_analytics', ['analytics' => $params['html']['google_analytics'], 'host' => array_key_exists('host', $params) ? $params['host'] : '']);
}
if ($params['html']['piwik_analytics']) {
$this->insert('theme::partials/piwik_analytics', ['url' => $params['html']['piwik_analytics'], 'id' => $params['html']['piwik_analytics_id']]);
} ?>
}
?>
<!-- jQuery -->
<?php
if ($params['theme']['require-jquery']) echo '<script src="' . $base_url . 'resources/js/jquery-1.11.0.min.js' . '"></script>';
if ($params['theme']['bootstrap-js']) echo '<script src="' . $base_url . 'resources/js/bootstrap.min.js' . '"></script>';
if ($params['theme']['require-jquery']) {
echo '<script src="' . $base_url . 'resources/js/jquery-1.11.0.min.js' . '"></script>';
}
if ($params['theme']['bootstrap-js']) {
echo '<script src="' . $base_url . 'resources/js/bootstrap.min.js' . '"></script>';
}
?>
<!-- hightlight.js -->
<script src="<?php echo $base_url; ?>resources/js/highlight.min.js"></script>
<script src="<?= $base_url; ?>resources/js/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<!-- JS -->
<?php foreach ($params['theme']['js'] as $js) echo '<script src="' . $js . '"></script>'; ?>
<?php foreach ($params['theme']['js'] as $js) {
echo '<script src="' . $js . '"></script>';
} ?>
<script src="<?php echo $base_url; ?>resources/js/custom.js"></script>
<script src="<?= $base_url; ?>resources/js/custom.js"></script>
</body>
</html>

View File

@ -1,7 +1,7 @@
<?php $this->layout('theme::layout/00_layout') ?>
<?php if ($params['html']['repo']) { ?>
<a href="https://github.com/<?php echo $params['html']['repo']; ?>" target="_blank" id="github-ribbon" class="hidden-print"><img src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<a href="https://github.com/<?= $params['html']['repo']; ?>" target="_blank" id="github-ribbon" class="hidden-print"><img src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<?php } ?>
<div class="container-fluid fluid-height wrapper">
<div class="navbar navbar-fixed-top hidden-print">
@ -22,29 +22,38 @@
<div id="sub-nav-collapse" class="sub-nav-collapse">
<!-- Navigation -->
<?php
if ($page['language'] !== '') echo $this->get_navigation($tree->value[$page['language']], $page['language'], isset($params['request'])? $params['request'] : '', $base_page, $params['mode']);
else echo $this->get_navigation($tree, '', isset($params['request'])? $params['request'] : '', $base_page, $params['mode']);
if ($page['language'] !== '') {
echo $this->get_navigation($tree->value[$page['language']], $page['language'], isset($params['request']) ? $params['request'] : '', $base_page, $params['mode']);
} else {
echo $this->get_navigation($tree, '', isset($params['request']) ? $params['request'] : '', $base_page, $params['mode']);
}
?>
<?php if (!empty($params['html']['links']) || !empty($params['html']['twitter']) || $params['html']['toggle_code']) { ?>
<div class="well well-sidebar">
<!-- Links -->
<?php foreach ($params['html']['links'] as $name => $url) echo '<a href="' . $url . '" target="_blank">' . $name . '</a><br>'; ?>
<?php if ($params['html']['toggle_code']) echo '<a href="#" id="toggleCodeBlockBtn" onclick="toggleCodeBlocks();">Show Code Blocks Inline</a><br>'; ?>
<?php
foreach ($params['html']['links'] as $name => $url) {
echo '<a href="' . $url . '" target="_blank">' . $name . '</a><br>';
}
if ($params['html']['toggle_code']) {
echo '<a href="#" id="toggleCodeBlockBtn" onclick="toggleCodeBlocks();">Show Code Blocks Inline</a><br>';
}
?>
<!-- Twitter -->
<?php foreach ($params['html']['twitter'] as $handle) { ?>
<div class="twitter">
<hr/>
<iframe allowtransparency="true" frameborder="0" scrolling="no" style="width:162px; height:20px;" src="https://platform.twitter.com/widgets/follow_button.html?screen_name=<?php echo $handle;?>&amp;show_count=false"></iframe>
<iframe allowtransparency="true" frameborder="0" scrolling="no" style="width:162px; height:20px;" src="https://platform.twitter.com/widgets/follow_button.html?screen_name=<?= $handle; ?>&amp;show_count=false"></iframe>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
</div>
<div class="right-column <?php echo ($params['html']['float']?'float-view':''); ?> content-area col-sm-9">
<div class="right-column <?= $params['html']['float'] ? 'float-view' : ''; ?> content-area col-sm-9">
<div class="content-page">
<?= $this->section('content'); ?>
</div>

View File

@ -1,2 +1,2 @@
<a class="brand navbar-brand pull-left" href="<?= $params['base_page'] . $params['index']->getUri(); ?>"><?php echo $params['title']; ?></a>
<a class="brand navbar-brand pull-left" href="<?= $params['base_page'] . $params['index']->getUri(); ?>"><?= $params['title']; ?></a>
<p class="navbar-text pull-right">Generated by <a href="http://daux.io">Daux.io</a></p>