Skip to content

Commit

Permalink
Auto-format documentation _run
Browse files Browse the repository at this point in the history
  • Loading branch information
leongersen committed May 4, 2019
1 parent 9e386c5 commit 718c4b8
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 120 deletions.
4 changes: 2 additions & 2 deletions documentation/_run/404.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$title = "noUiSlider - Page not found";
$description = "";
$title = "noUiSlider - Page not found";
$description = "";
?>

Oops, this page is missing.
77 changes: 40 additions & 37 deletions documentation/_run/helpers.php
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
<?php

function fgc ( $name ) {
return file_get_contents( './' . $GLOBALS['page'] . '/' .$name);
}

function code ( $name, $encode = false ) {

$c = fgc($name . '.js');

if ( $encode ) {
$c = htmlentities($c);
}

echo "\r\n".'<pre><code>' . $c . '</code></pre>';
}

function run ( $name ){
echo "\r\n".'<script>'."\r\n" . fgc($name . '.js') . '</script>';
}

function loadShowCSS ( $name ) {

$content = fgc($name . '.css');

echo "\r\n".'<style>' . $content . '</style>' .
'<pre class="language-css"><code>' . $content . '</code></pre>';
}

function showCSS ( $name ) {

$content = fgc($name . '.css');

echo "\r\n".'<pre class="language-css"><code>' . $content . '</code></pre>';
}

function sect ( $title ) {
echo '<a href="#section-' . $title . '" id="section-' . $title . '" class="section-link">&sect;</a>';
}
function fgc($name)
{
return file_get_contents('./' . $GLOBALS['page'] . '/' . $name);
}

function code($name, $encode = false)
{
$c = fgc($name . '.js');

if ($encode) {
$c = htmlentities($c);
}

echo "\r\n" . '<pre><code>' . $c . '</code></pre>';
}

function run($name)
{
echo "\r\n" . '<script>' . "\r\n" . fgc($name . '.js') . '</script>';
}

function loadShowCSS($name)
{
$content = fgc($name . '.css');

echo "\r\n" . '<style>' . $content . '</style>' .
'<pre class="language-css"><code>' . $content . '</code></pre>';
}

function showCSS($name)
{
$content = fgc($name . '.css');

echo "\r\n" . '<pre class="language-css"><code>' . $content . '</code></pre>';
}

function sect($title)
{
echo '<a href="#section-' . $title . '" id="section-' . $title . '" class="section-link">&sect;</a>';
}
81 changes: 43 additions & 38 deletions documentation/_run/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,72 @@

<head>

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="<?php echo $description; ?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="<?php echo $description; ?>">

<title><?php echo $title; ?> | Refreshless.com</title>
<title><?php echo $title; ?> | Refreshless.com</title>

<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet">

<link href="/nouislider/documentation/assets/base.css?v=2" rel="stylesheet">
<link href="/nouislider/documentation/assets/prism.css" rel="stylesheet">
<script src="/nouislider/documentation/assets/wNumb.js"></script>
<link href="/nouislider/documentation/assets/base.css?v=2" rel="stylesheet">
<link href="/nouislider/documentation/assets/prism.css" rel="stylesheet">
<script src="/nouislider/documentation/assets/wNumb.js"></script>

<link href="<?php echo $distribute; ?>/nouislider.css?v=<?php echo $plain_version; ?>" rel="stylesheet">
<script src="<?php echo $distribute; ?>/nouislider.js?v=<?php echo $plain_version; ?>"></script>
<link href="<?php echo $distribute; ?>/nouislider.css?v=<?php echo $plain_version; ?>" rel="stylesheet">
<script src="<?php echo $distribute; ?>/nouislider.js?v=<?php echo $plain_version; ?>"></script>

<link rel="canonical" href="<?php echo $canonical; ?>">
<link rel="canonical" href="<?php echo $canonical; ?>">

</head>

<body class="language-javascript">

<?php if ( $page == 'index' ): ?>
<?php if ($page == 'index'): ?>

<div class="index-demo">
<div class="index-demo">

<h1>noUiSlider</h1>
<h2>JavaScript Range Slider</h2>
<h1>noUiSlider</h1>
<h2>JavaScript Range Slider</h2>

<div class="quick">
<div class="quick">

<div id="slider"></div>
<?php run('minimal'); ?>
<?php code('minimal'); ?>
<pre><code class="language-console">npm <span class="token function">install</span> <span class="token keyword">nouislider</span></code></pre>
<pre><code class="language-console">yarn <span class="token function">add</span> <span class="token keyword">nouislider</span></code></pre>
<div id="slider"></div>
<?php run('minimal'); ?>
<?php code('minimal'); ?>
<pre><code class="language-console">npm <span class="token function">install</span> <span
class="token keyword">nouislider</span></code></pre>
<pre><code class="language-console">yarn <span class="token function">add</span> <span
class="token keyword">nouislider</span></code></pre>

<iframe style="margin: 30px auto 0; display: block;" src="https://ghbtns.com/github-btn.html?user=leongersen&repo=noUiSlider&type=star&count=true&size=large" frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
</div>
</div>
<iframe style="margin: 30px auto 0; display: block;"
src="https://ghbtns.com/github-btn.html?user=leongersen&repo=noUiSlider&type=star&count=true&size=large"
frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
</div>
</div>

<?php endif; ?>
<?php endif; ?>

<?php include $file_menu; ?>
<?php include $file_menu; ?>

<div class="content">
<?php echo $content; ?>
</div>
<div class="content">
<?php echo $content; ?>
</div>

<script>
<script>

var headers = document.getElementsByClassName('viewer-header');
var headers = document.getElementsByClassName('viewer-header');

for ( var i = 0; i < headers.length; i++ ) {
headers[i].addEventListener('click', function(){
this.classList.toggle('open');
});
}
for (var i = 0; i < headers.length; i++) {
headers[i].addEventListener('click', function () {
this.classList.toggle('open');
});
}

</script>
</script>

<script src="/nouislider/documentation/assets/prism.js"></script>
<script src="/nouislider/documentation/assets/prism.js"></script>

<?php $t = $_SERVER['DOCUMENT_ROOT'] . '/private'; if ( file_exists($t) ) include $t; ?>
<?php $t = $_SERVER['DOCUMENT_ROOT'] . '/private';
if (file_exists($t)) include $t; ?>

</body>
20 changes: 10 additions & 10 deletions documentation/_run/menu.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<div class="bar-group">
<a class="bar-link project" href="/nouislider/">noUiSlider</a>
<a class="bar-link" href="/nouislider/slider-values/">Slider Range and Handles</a>
<a class="bar-link" href="/nouislider/slider-read-write/">Reading &amp; Setting Values</a>
<a class="bar-link" href="/nouislider/slider-options/">Options</a>
<a class="bar-link" href="/nouislider/behaviour-option/">Tapping, Dragging &amp; Fixed Ranges</a>
<a class="bar-link" href="/nouislider/examples/">Examples</a>
<a class="bar-link" href="/nouislider/events-callbacks/">Events</a>
<a class="bar-link" href="/nouislider/pips/">Scale/Pips</a>
<a class="bar-link" href="/nouislider/more/">Updating, Disabling &amp; Styling</a>
<a class="bar-link download" href="/nouislider/download/">Download</a>
<a class="bar-link project" href="/nouislider/">noUiSlider</a>
<a class="bar-link" href="/nouislider/slider-values/">Slider Range and Handles</a>
<a class="bar-link" href="/nouislider/slider-read-write/">Reading &amp; Setting Values</a>
<a class="bar-link" href="/nouislider/slider-options/">Options</a>
<a class="bar-link" href="/nouislider/behaviour-option/">Tapping, Dragging &amp; Fixed Ranges</a>
<a class="bar-link" href="/nouislider/examples/">Examples</a>
<a class="bar-link" href="/nouislider/events-callbacks/">Events</a>
<a class="bar-link" href="/nouislider/pips/">Scale/Pips</a>
<a class="bar-link" href="/nouislider/more/">Updating, Disabling &amp; Styling</a>
<a class="bar-link download" href="/nouislider/download/">Download</a>
</div>
66 changes: 33 additions & 33 deletions documentation/_run/router.php
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
<?php

chdir(__DIR__.'/..');
chdir(__DIR__ . '/..');

$url = strtolower($_SERVER['REQUEST_URI']);
$url = strtolower($_SERVER['REQUEST_URI']);

if ( strpos($url, '.js') || strpos($url, '.css') || strpos($url, '.html') ) {
return false;
}
if (strpos($url, '.js') || strpos($url, '.css') || strpos($url, '.html')) {
return false;
}

$request = parse_url($url);
$page = rtrim(substr($request['path'], strlen('/nouislider/')), '/');
$request = parse_url($url);
$page = rtrim(substr($request['path'], strlen('/nouislider/')), '/');

if ( !$page ) {
$page = 'index';
}
if (!$page) {
$page = 'index';
}

$file = $page . '.php';
$file_menu = '_run/menu.php';
$file = $page . '.php';
$file_menu = '_run/menu.php';

require '_run/helpers.php';
require '_run/helpers.php';

if ( !file_exists($file) ){
header('HTTP/1.0 404 Not Found');
$file = '_run/404.php';
}
if (!file_exists($file)) {
header('HTTP/1.0 404 Not Found');
$file = '_run/404.php';
}

// Defaults
$title = "";
$description = "";
$canonical = "";
// Defaults
$title = "";
$description = "";
$canonical = "";

$package = json_decode(file_get_contents('./../package.json'));
$version = $package->version;
$plain_version = str_replace('.', '', $version);
$package = json_decode(file_get_contents('./../package.json'));
$version = $package->version;
$plain_version = str_replace('.', '', $version);

ob_start();
ob_start();

include $file;
$content = ob_get_contents();
include $file;
$content = ob_get_contents();

ob_end_clean();
ob_end_clean();

if ($canonical) {
$canonical = 'https://refreshless.com'.$canonical;
}
if ($canonical) {
$canonical = 'https://refreshless.com' . $canonical;
}

$distribute = '/nouislider/distribute';
include '_run/index.php';
$distribute = '/nouislider/distribute';
include '_run/index.php';

0 comments on commit 718c4b8

Please sign in to comment.