Skip to content

Commit

Permalink
Migrate to SSP
Browse files Browse the repository at this point in the history
  • Loading branch information
jovenden committed Jul 17, 2017
1 parent dd94891 commit da5791d
Show file tree
Hide file tree
Showing 46 changed files with 178 additions and 80 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/assets/
/htdocs/2.4/
/htdocs/master/
/htdocs/3.*/
/vendor/
/modulesource/
/en/
32 changes: 32 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On

# "Symlink" the root to the latest release (with "moved temporarily")
RewriteRule ^/?$ /en/3.6/ [R=302,L]

# Remove trailing slashes, ensures the redirect to en works
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R]

# Lookup script (used to be a SS app, now just a simple script)
RewriteCond %{REQUEST_URI} ^/search/lookup$
RewriteRule ^search/lookup /search/lookup.php [L,R=301,QSA]

# "Symlink" a "current" folder to the latest release
RewriteRule ^.*/current.*?(.*)? /en/3.6/$1 [R=301,L]

# Rewrite trunk to master
RewriteRule ^.*/trunk/.*(.*)? /en/master/$1 [L,R=301]

# Docs are stored in en - serve from there
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^.*/en/.*$ [NC]
RewriteRule .* /en%{REQUEST_URI} [L,R=301]

# Rewrite PHPDocumentor links for apigen
RewriteCond %{REQUEST_FILENAME} !^class-
RewriteRule ^/?(trunk|[23]\.[0-9])/.*/(.+)\.html$ /$1/class-$2.html [R=301]

ErrorDocument 404 /errors/404.html
</IfModule>
12 changes: 12 additions & 0 deletions .platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
infrastructure: ^3
shared_dirs:
mysite:
modulesource: {}
en: {}
crons:
mytask:
time: "0 3 * * *"
command: "/var/www/mysite/www/makedoc.sh | logger -t SilverStripe_cron"
url_rules:
mysite:
- '^.*html': 'apache'
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,17 @@ generated through [APIGen](http://apigen.org/).

### Add a New Version
* Copy a version section block in `makedoc.sh` and update the version number
* Update the .gitignore to ignore any new files generated in `htdocs` (you don't want to commit the static generated files!)
* Update the .gitignore to ignore any new files generated in `en` which is a directory synlinked outside of the web root (you don't want to commit the static generated files!)
* Run `makedoc.sh` and confirm the generation runs through properly
* Make a commit of the updated `makedoc.sh`
* Update the redirections in `htdocs/.htaccess` to the stable version number
* Update the redirections in `.htaccess` to the stable version number
* Make a separate commit with the redirection (explained in deployment below)

**Please note:** Often the `master` branch will be representing an unstable major version (currently 4). When this needs
to be updated, please edit `htdocs/search/lookup.php`.
to be updated, please edit `search/lookup.php`.

### Deployment to production
1. Raise a ticket with ops team (they have to run a script after deployment)
2. Login to SilverStripe Platform (you'll need to ensure you have "api" stack permissions)
3. Deploy the commit that contains the update to `makedoc.sh`
4. Ops will run this script to generate the new static files.
5. Once this is complete, deploy the commit with the redirects.
This is now hosted on SilverStripe Platform, you can deploy from the dashboard. `makedoc.sh` is run on a nightly cron as defined in `platform.yml`.


### Symbol Lookup
Expand Down
File renamed without changes.
67 changes: 32 additions & 35 deletions conf/apigen/templates/@layout.latte
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,27 @@ the file LICENSE.md that was distributed with this source code.
<meta name="generator" content="{$generator} {$version}">
<meta name="robots" content="noindex" n:if="!$robots">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

<title>{include #title}{if 'overview' !== $active && $config->title} | {$config->title}{/if}</title>
{var typeKitJS = '//use.typekit.net/emt4dhq.js'}

<link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/favicon-194x194.png" sizes="194x194">
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="/android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
<link rel="apple-touch-icon" sizes="57x57" href="/resources/images/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/resources/images/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/resources/images/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/resources/images/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/resources/images/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/resources/images/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/resources/images/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/resources/images/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/resources/images/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="/resources/images/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/resources/images/favicon-194x194.png" sizes="194x194">
<link rel="icon" type="image/png" href="/resources/images/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="/resources/images/android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="/resources/images/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/manifest.json"> <!-- Controls which icon to use for Android Chrome -->
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<link rel="mask-icon" href="/resources/images/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#005b94">
<meta name="msapplication-TileImage" content="/mstile-144x144.png">
<meta name="msapplication-TileImage" content="/resources/images/mstile-144x144.png">
<meta name="theme-color" content="#1b354c">

<script type="text/javascript" src="{$typeKitJS|staticFile}"></script>
Expand All @@ -51,28 +50,26 @@ the file LICENSE.md that was distributed with this source code.
}catch(e){}
</script>

{var combinedJs = 'resources/combined.js'}
{var combinedJs = '/resources/js/combined.js'}
<script type="text/javascript" src="{$combinedJs|staticFile}"></script>
{var elementListJs = 'elementlist.js'}
<script type="text/javascript" src="{$elementListJs|staticFile}"></script>

<link href="resources/bootstrap.min.css" rel="stylesheet">
<script src="resources/bootstrap.js"></script>
<script src="resources/responsive-tables.js"></script>

{var styleCss = 'resources/style.css'}
<link rel="stylesheet" type="text/css" media="all" href="{$styleCss|staticFile}">
<link n:if="$config->googleCseId" rel="search" type="application/opensearchdescription+xml" title="{$config->title}" href="{$config->baseUrl}/opensearch.xml">

{* CUSTOM: Toolbar support *}
<link rel="stylesheet" type="text/css" href="//www.silverstripe.org/themes/ssv3/css/toolbar.css" />

{* CUSTOM: CSS *}
{var customCss = 'resources/custom.css'}
<link rel="stylesheet" type="text/css" href="{$customCss|staticFile}" />
{var ionicons = 'resources/ionicons.min.css'}
<link rel="stylesheet" type="text/css" href="{$ionicons|staticFile}" />

<link n:if="$config->googleCseId" rel="search" type="application/opensearchdescription+xml" title="{$config->title}" href="{$config->baseUrl}/opensearch.xml">

{* CUSTOM: Toolbar support *}
<link rel="stylesheet" type="text/css" href="//www.silverstripe.org/themes/ssv3/css/toolbar.css" />

<script>
(function(i,s,o,g,r,a,m){ i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
Expand Down Expand Up @@ -162,20 +159,20 @@ the file LICENSE.md that was distributed with this source code.
<div id="left">

<div id="versions" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" data-target="#" href="/master">
<a class="dropdown-toggle" data-toggle="dropdown" data-target="#" href="/en/master">
Version: <span class="version">master</span>
<b class="caret"></b>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu">
<li><a tabindex="-1" href="/master">master</a></li>
<li><a tabindex="-1" href="/3.6">3.6</a></li>
<li><a tabindex="-1" href="/3.5">3.5</a></li>
<li><a tabindex="-1" href="/3.4">3.4</a></li>
<li><a tabindex="-1" href="/3.3">3.3</a></li>
<li><a tabindex="-1" href="/3.2">3.2</a></li>
<li><a tabindex="-1" href="/3.1">3.1</a></li>
<li><a tabindex="-1" href="/3.0">3.0</a></li>
<li><a tabindex="-1" href="/2.4">2.4</a></li>
<li><a tabindex="-1" href="/en/master">master</a></li>
<li><a tabindex="-1" href="/en/3.6">3.6</a></li>
<li><a tabindex="-1" href="/en/3.5">3.5</a></li>
<li><a tabindex="-1" href="/en/3.4">3.4</a></li>
<li><a tabindex="-1" href="/en/3.3">3.3</a></li>
<li><a tabindex="-1" href="/en/3.2">3.2</a></li>
<li><a tabindex="-1" href="/en/3.1">3.1</a></li>
<li><a tabindex="-1" href="/en/3.0">3.0</a></li>
<li><a tabindex="-1" href="/en/2.4">2.4</a></li>
</ul>
</div>

Expand Down
24 changes: 24 additions & 0 deletions errors/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!doctype html>
<!--[if lt IE 7 ]><html lang="en-GB" class="no-js lte6 lte7 lte8 lte9 lte10"><![endif]-->
<!--[if IE 7 ]><html lang="en-GB" class="no-js lte7 lte8 lte9 lte10"><![endif]-->
<!--[if IE 8 ]><html lang="en-GB" class="no-js lte8 lte9 lte10"><![endif]-->
<!--[if IE 9 ]><html lang="en-GB" class="no-js lte9 lte10"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en-GB" class="no-js"><!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>Page not found &raquo; SilverStripe API docs</title>
<link rel="stylesheet" type="text/css" href="/errors/error-styles.css">
</head>
<body>
<div class="gif_holder">
<div class="color_overlay">
<div class="text_container">
<h2>Whoa 404, either we broke something or you had a typing mishap :-/</h2>
<h3> Let's go back <a href="/">home.</a></h3>
</div>
</div>
</body>
</html>
56 changes: 56 additions & 0 deletions errors/error-styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.gif_holder {
background-image: url('https://www.silverstripe.com/themes/ssv3/img/banners/page-not-found.gif');
position: relative;
z-index: 807;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-position: 50% 50%;
background-repeat: no-repeat;
background-attachment: scroll;
padding: 200px 0;
height: 100vh;
width: 100%;
}

.color_overlay {
background-color: rgba(0,91,148,.8);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

.text_container {
color: white;
font-weight: 700;
font-size: 50px;
font-family: proxima-nova,'Helvetica Neue',Helvetica,Arial,sans-serif;
margin: 0 auto;
}

h2 {
margin: 200px 0 100px 0;
text-align: center;
}

h3 {
margin: 0;
text-align: center;
}

a {
text-decoration: none;
color: #43c7f4;
}

a:hover {
text-decoration: underline;
}

body {
padding: 0;
margin: 0;"
}
18 changes: 0 additions & 18 deletions htdocs/.htaccess

This file was deleted.

4 changes: 2 additions & 2 deletions makedoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
cd $(dirname "$0");

# Where the module source code should be stored
STORAGE_DIR="assets/src"
STORAGE_DIR="modulesource"

#=== FUNCTION ==================================================================
# NAME: checkout
Expand Down Expand Up @@ -36,7 +36,7 @@ function checkout {
#
#===============================================================================
function generate {
vendor/bin/apigen generate --config conf/apigen/apigen.neon --source "$STORAGE_DIR"/$1 --destination htdocs/$1 --title "$2"
vendor/bin/apigen generate --config conf/apigen/apigen.neon --source "$STORAGE_DIR"/$1 --destination en/$1 --title "$2"
}

# Ensure storage directory exists
Expand Down
File renamed without changes.
Binary file added resources/.DS_Store
Binary file not shown.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -1278,12 +1278,12 @@ $(function() {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')
};
// Set current version title based on path (easier than generating version-specific templates in ApiGen)
var path = document.location.pathname.replace(/\/$/, ''), title;
var path = document.location.pathname.replace(/\/([^\/]+|)$/, ''), title;
$('#versions .dropdown-menu a').each(function() {
var matcher = new RegExp('^' + RegExp.escape(path));
if(matcher.test($(this).attr('href'))) {
title = $(this).text();
}
}
});
if(title) $('#versions .dropdown-toggle .version').text(title);
});
2 changes: 1 addition & 1 deletion htdocs/search/lookup.php → search/lookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// to their URL representation in the API docs. Redirects to this URL.
// See README for more info.

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

$lookup = new SilverStripe\ApiDocs\Lookup($_GET);

Expand Down
2 changes: 1 addition & 1 deletion src/Lookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function handle($return = false)
$paths[] = 'modules/' . $this->getArg('module');
}

$paths[] = $this->getVersion();
$paths[] = 'en/'.$this->getVersion();

// Search
if ($searchOrig = $this->getArg('q')) {
Expand Down
20 changes: 10 additions & 10 deletions tests/LookupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,43 +51,43 @@ public function handleProvider()
return array(
array(
array('q' => 'DataExtension', 'version' => '4'),
'http://mockserver/master/class-SilverStripe.ORM.DataExtension.html'
'http://mockserver/en/master/class-SilverStripe.ORM.DataExtension.html'
),
array(
array('q' => 'DataExtension'),
'http://mockserver/master/class-SilverStripe.ORM.DataExtension.html'
'http://mockserver/en/master/class-SilverStripe.ORM.DataExtension.html'
),
array(
array('q' => 'SomeClass'),
'http://mockserver/master/class-SomeClass.html'
'http://mockserver/en/master/class-SomeClass.html'
),
array(
array('q' => 'SomeClass', 'version' => '3'),
'http://mockserver/3.6/class-SomeClass.html'
'http://mockserver/en/3.6/class-SomeClass.html'
),
array(
array('q' => 'SomeClass', 'version' => '3.4'),
'http://mockserver/3.4/class-SomeClass.html'
'http://mockserver/en/3.4/class-SomeClass.html'
),
array(
array('q' => '\Already\Fully\Qualified', 'version' => '3.4'),
'http://mockserver/3.4/class-Already.Fully.Qualified.html'
'http://mockserver/en/3.4/class-Already.Fully.Qualified.html'
),
array(
array('q' => '\\\\Already\\\\Fully\\\\Qualified', 'version' => '3.4'),
'http://mockserver/3.4/class-Already.Fully.Qualified.html'
'http://mockserver/en/3.4/class-Already.Fully.Qualified.html'
),
array(
array('q' => 'Director', 'module' => 'framework'),
'http://mockserver/master/class-SilverStripe.Control.Director.html'
'http://mockserver/en/master/class-SilverStripe.Control.Director.html'
),
array(
array('q' => 'SiteTree::write()', 'module' => 'cms'),
'http://mockserver/master/class-SilverStripe.CMS.Model.SiteTree.html#_write'
'http://mockserver/en/master/class-SilverStripe.CMS.Model.SiteTree.html#_write'
),
array(
array('q' => 'SiteTree::$allowed_children', 'module' => 'cms'),
'http://mockserver/master/class-SilverStripe.CMS.Model.SiteTree.html#$allowed_children'
'http://mockserver/en/master/class-SilverStripe.CMS.Model.SiteTree.html#$allowed_children'
),
);
}
Expand Down

0 comments on commit da5791d

Please sign in to comment.