Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Implemented landing page
Browse files Browse the repository at this point in the history
This patch implements a landing page for the documentation. To do so, it
replaces the contents generated by mkdocs with bespoke contents that detail
marketing features and how to get started.

This patch also iterates through all generated HTML pages to add the
`class="img-responsive"` attribute to any images detected, ensuring that the
layout is consistent across all pages.
  • Loading branch information
weierophinney committed Jan 26, 2016
1 parent 05fa352 commit 95155d8
Show file tree
Hide file tree
Showing 11 changed files with 235 additions and 1 deletion.
Binary file added doc/book/images/checkmark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/book/images/installer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/book/images/lambda.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/book/images/nodes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/book/images/pencil.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/book/images/syringe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/book/images/warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
171 changes: 171 additions & 0 deletions doc/book/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<div class="container">
<div class="jumbotron">
<h1>Expressive</h1>

<p>PSR-7 Middleware in Minutes</p>
</div>
</div>

<div class="container features">
<div class="row row-flex row-flex-wrap">
<div class="col-sm-6 col-md-4">
<div class="panel panel-success"><div class="panel-content">
<img src="images/checkmark.png" alt="PSR-7" /><br />

<h3>PSR-7</h3>

<p>
Built to consume <a href="http://www.php-fig.org/psr/psr-7/">PSR-7</a>!
</p>
</div></div>
</div>

<div class="col-sm-6 col-md-4">
<div class="panel panel-success"><div class="panel-content center-block">
<img src="images/lambda.png" alt="Middleware" /><br />

<h3>Middleware</h3>

<p>
Create <a href="https://github.com/zendframework/zend-stratigility/blob/master/doc/book/middleware.md">middleware</a>
applications, using as many layers as you want, and the architecture
your project needs.
</p>
</div></div>
</div>

<div class="col-sm-6 col-md-4">
<div class="panel panel-success"><div class="panel-content center-block">
<img src="images/nodes.png" alt="Routing" /><br />

<h3>Routing</h3>

<p>
Route requests to middleware using <a href="features/router/intro/">the routing library of your choice</a>.
</p>
</div></div>
</div>
</div>

<div class="row row-flex row-flex-wrap">
<div class="col-sm-6 col-md-4">
<div class="panel panel-success"><div class="panel-content">
<img src="images/syringe.png" alt="Dependency Injection" /><br />

<h3>Dependency Injection</h3>

<p>
Make your code flexible and robust, using the
<a href="features/container/intro/">dependency injection container of your choice</a>.
</p>
</div></div>
</div>

<div class="col-sm-6 col-md-4">
<div class="panel panel-success"><div class="panel-content center-block">
<img src="images/pencil.png" alt="Templating" /><br />

<h3>Templating</h3>

<p>
Create <a href="features/template/intro/">templated responses</a>, using
a variety of template engines.
</p>
</div></div>
</div>

<div class="col-sm-6 col-md-4">
<div class="panel panel-success"><div class="panel-content center-block">
<img src="images/warning.png" alt="Error Handling" /><br />

<h3>Error Handling</h3>

<p>
<a href="features/error-handling/">Handle errors gracefully</a>, using
templated error pages, <a href="http://filp.github.io/whoops/">whoops</a>,
or your own solution!
</p>
</div></div>
</div>
</div>
</div>

<div class="container install">
<div class="row"><div class="panel"><div class="panel-content">
<h2>Get Started Now!</h2>

<p>Installation is only a <a href="https://getcomposer.org">Composer</a> command away!</p>

<pre><code class="language-bash" data-trim>
$ composer create-project -s rc zendframework/zend-expressive-skeleton expressive
</code></pre>

<h3>Choose what you want</h3>

<p>
Expressive provides interfaces for routing and templating, letting <em>you</em>
choose what to use, and how you want to implement it.
</p>

<p>
Our unique installer allows you to select <em>your</em> choices when starting
your project!
</p>

<div class="container"><div class="row">
<div class="col-xs-8">
<img class="img-responsive" src="images/installer.png" alt="Expressive Installer" /><br />
</div>

<div class="col-xs-4">
<button type="btn btn-lg btn-primary"><a href="getting-started/skeleton/">Learn more</a></button>
</div>
</div></div>

<h3>Applications, Simplified</h3>

<div class="container"><div class="row">
<div class="col-xs-8">
<p>Write middleware:</p>

<pre><code class="language-php" data-trim>
$pathMiddleware = function (
ServerRequestInterface $request,
ResponseInterface $response,
callable $next
) {
$uri = $request->getUri();
$path = $uri->getPath();

$response->getBody()->write('You visited ' . $path);
return $next($request, $response->withHeader('X-Path', $path));
};
</code></pre>

<p>And add it to an application:</p>

<pre><code class="language-php" data-trim>
$app->get('/path', $pathMiddleware);
</code></pre>
</div>

<div class="col-xs-4">
<button type="btn btn-lg btn-primary"><a href="features/application/">Learn more</a></button>
</div>
</div></div>
</div></div></div>
</div>

<div class="container">
<div class="row"><div class="panel"><div class="panel-content">
<h2>Learn more</h2>

<ul>
<li><a href="getting-started/features/">Features overview</a></li>
<li><a href="getting-started/standalone/">Getting Started: Standalone installation</a></li>
<li><a href="getting-started/standalone/">Getting Started: Skeleton Installer</a></li>
</ul>

<p>Or use the menu to navigate to the section you're interested in.</p>
</div></div></div>
</div>
12 changes: 11 additions & 1 deletion doc/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

# Get documentation templates and assets
if [[ ! -d zf-mkdoc-theme ]];then
wget -O zf-mkdoc-theme.tgz https://github.com/weierophinney/zf-mkdoc-theme/archive/0.1.6.tar.gz ;
echo "Fetching and installing theme" ;
wget -O zf-mkdoc-theme.tgz https://github.com/weierophinney/zf-mkdoc-theme/archive/0.1.7.tar.gz ;
mkdir zf-mkdoc-theme ;
(
cd zf-mkdoc-theme ;
Expand All @@ -23,6 +24,7 @@ if [[ ! -d zf-mkdoc-theme ]];then
fi

# Update the mkdocs.yml
echo "Building documentation"
cp mkdocs.yml mkdocs.yml.orig
echo "site_url: ${SITE_URL}"
echo "markdown_extensions:" >> mkdocs.yml
Expand All @@ -33,3 +35,11 @@ echo "theme_dir: zf-mkdoc-theme" >> mkdocs.yml

mkdocs build --clean
mv mkdocs.yml.orig mkdocs.yml

# Make images responsive
echo "Making images responsive"
php doc/img_responsive.php

# Replace landing page content
echo "Replacing landing page content"
php doc/swap_index.php
38 changes: 38 additions & 0 deletions doc/img_responsive.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Adds `class="img-responsive"` to images in generated HTML files.
*
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2016 Zend Technologies USA Inc. (http://www.zend.com)
*/

$rdi = new RecursiveDirectoryIterator(__DIR__ . '/html');
$rii = new RecursiveIteratorIterator($rdi, RecursiveIteratorIterator::SELF_FIRST);
$files = new RegexIterator($rii, '/\.html$/', RecursiveRegexIterator::GET_MATCH);

$process = function () use ($files) {
$fileInfo = $files->getInnerIterator()->current();
if (! $fileInfo->isFile()) {
return true;
}

if ($fileInfo->getBasename('.html') === $fileInfo->getBasename()) {
return true;
}

$file = $fileInfo->getRealPath();
$html = file_get_contents($file);
if (! preg_match('#<p><img alt="[^"]*" src="[^"]+" \/><\/p>#s', $html)) {
return true;
}
$html = preg_replace(
'#(<p><img alt="[^"]*" src="[^"]+" )(\/><\/p>)#s',
'$1class="img-responsive"$2',
$html
);
file_put_contents($file, $html);

return true;
};

iterator_apply($files, $process);
15 changes: 15 additions & 0 deletions doc/swap_index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* Swaps the generated HTML for hand-crafted HTML in the landing page.
*
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2016 Zend Technologies USA Inc. (http://www.zend.com)
*/

$target = file_get_contents(__DIR__ . '/html/index.html');
$source = file_get_contents(__DIR__ . '/book/index.html');

file_put_contents(
__DIR__ . '/html/index.html',
preg_replace('#\<\!-- content:begin --\>.*\<\!-- content:end --\>#s', $source, $target)
);

0 comments on commit 95155d8

Please sign in to comment.