-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes dashboard notices and moves the notices file to a php sub folder
- Loading branch information
Showing
2 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
<?php | ||
|
||
function endsWith( $haystack, $needle ) { | ||
$length = strlen( $needle ); | ||
|
||
return $length === 0 || | ||
( substr( $haystack, -$length ) === $needle ); | ||
} | ||
|
||
require( __DIR__. '/yaml.php' ); | ||
|
||
// Begin default dashboard. | ||
?> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Varying Vagrant Vagrants Dashboard</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" type="text/css" href="//vvv.test/dashboard/style.css?t=<?php echo filemtime( __DIR__.'/style.css' ); ?>"> | ||
</head> | ||
<body> | ||
|
||
<h2 id="vvv_logo"><img src="//vvv.test/dashboard/vvv-tight.png"/> Varying Vagrant Vagrants</h2> | ||
|
||
<?php | ||
require_once( __DIR__.'/php/notices.php' ); | ||
?> | ||
<div class="box alt-box"> | ||
<p>VVV is a local web development environment powered by Vagrant and Virtual Machines.</p> | ||
<p>To add, remove, or change sites, modify <code>vvv-custom.yml</code> then reprovision using <code>vagrant reload --provision</code></p> | ||
</div> | ||
<div class="grid"> | ||
<div class="column left-column"> | ||
|
||
<div class="box"> | ||
<h3>Bundled Environments</h3> | ||
<p>VVV reads a config file to discover and provision sites named <code>vvv-custom.yml</code>. If it doesn't exist, it falls back to <code>vvv-config.yml</code>. | ||
<?php if ( ! file_exists( '/vagrant/vvv-custom.yml' ) ) { ?> | ||
<b><code>vvv-custom.yml</code> does not exist! Please copy <code>vvv-config.yml</code> to <code>vvv-custom.yml</code></b> | ||
<?php } else { ?> | ||
Below is a list of the sites in <code>vvv-custom.yml</code>, remember to reprovision if you change it! | ||
<?php } ?> | ||
</div> | ||
<div class="grid50"> | ||
<?php | ||
$yaml = new Alchemy\Component\Yaml\Yaml(); | ||
|
||
$data = $yaml->load( (file_exists('/vagrant/vvv-custom.yml')) ? '/vagrant/vvv-custom.yml' : '/vagrant/vvv-config.yml' ); | ||
foreach ( $data['sites'] as $name => $site ) { | ||
|
||
$classes = []; | ||
$description = 'A WordPress installation'; | ||
if ( 'wordpress-default' === $name ) { | ||
$description = 'WordPress stable'; | ||
} else if ( 'wordpress-develop' === $name ) { | ||
$description = 'A dev build of WordPress, with a trunk build in the <code>src</code> subfolder, and a grunt build in the <code>build</code> folder'; | ||
} | ||
if ( !empty( $site['description'] ) ) { | ||
$description = $site['description']; | ||
} | ||
$skip_provisioning = false; | ||
if ( !empty( $site['skip_provisioning'] ) ) { | ||
$skip_provisioning = $site['skip_provisioning']; | ||
$classes[] = 'site_skip_provision'; | ||
} | ||
?> | ||
<div class="box <?php echo implode( ',', $classes ); ?>"> | ||
<h4><?php | ||
echo $name; | ||
if ( true == $skip_provisioning ) { | ||
echo ' <a target="_blank" href="https://varyingvagrantvagrants.org/docs/en-US/vvv-config/#skip_provisioning"><small class="site_badge">provisioning skipped</small></a>'; | ||
} | ||
?></h4> | ||
<p><?php echo $description; ?></p> | ||
<p><strong>URL:</strong> <?php | ||
$has_dev = false; | ||
$has_local = false; | ||
if ( !empty( $site['hosts'] ) ) { | ||
foreach( $site['hosts'] as $host ) { | ||
?> | ||
<a href="<?php echo 'http://'.$host; ?>" target="_blank"><?php echo 'http://'.$host; ?></a>, | ||
<?php | ||
if ( false === $has_dev ){ | ||
$has_dev = endsWith( $host, '.dev' ); | ||
} | ||
if ( false === $has_local ){ | ||
$has_local = endsWith( $host, '.local' ); | ||
} | ||
} | ||
} | ||
?><br/> | ||
<strong>Folder:</strong> <code>www/<?php echo $name; ?></code></p> | ||
<?php | ||
$warnings = []; | ||
if ( $has_dev ) { | ||
$warnings[] = ' | ||
<p><strong>Warning:</strong> the <code>.dev</code> TLD is owned by Google, and will not work in Chrome 58+, you should migrate to URLs ending with <code>.test</code></p>'; | ||
} | ||
if ( $has_local ) { | ||
$warnings[] = ' | ||
<p><strong>Warning:</strong> the <code>.local</code> TLD is used by Macs/Bonjour/Zeroconf as quick access to a local machine, this can cause clashes that prevent the loading of sites in VVV. E.g. a MacBook named <code>test</code> can be reached at <code>test.local</code>. You should migrate to URLs ending with <code>.test</code></p>'; | ||
} | ||
if ( $has_dev || $has_local ) { | ||
$warnings[] = '<p><a class="button" href="https://varyingvagrantvagrants.org/docs/en-US/troubleshooting/dev-tld/">Click here for instructions for switching to .test</a></p>'; | ||
} | ||
if ( ! empty( $warnings ) ) { | ||
echo '<div class="warning">'; | ||
echo implode( '', $warnings ); | ||
echo '</div>'; | ||
} | ||
?> | ||
</div> | ||
<?php | ||
} | ||
?> | ||
</div> | ||
<div class="box alt-box"> | ||
<h3>Adding a New Site</h3> | ||
<p>Modify <code>vvv-custom.yml</code> under the sites section to add a site, here's an example:</p> | ||
<pre> | ||
newsite: | ||
repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template | ||
description: "A WordPress subdir multisite install" | ||
skip_provisioning: false | ||
hosts: | ||
- newsite.test | ||
custom: | ||
wp_type: subdirectory | ||
</pre> | ||
<p>This will create a site in <code>www/newsite</code> at <code>http://newsite.test</code></p> | ||
<p><em>Remember</em>, in YAML whitespace matters, and you need to reprovision on changes, so run <code>vagrant reload --provision</code></p> | ||
<p>For more information, visit our docs:</p> | ||
<a class="button" href="https://varyingvagrantvagrants.org/docs/en-US/adding-a-new-site/">How to add a new site</a></p> | ||
</div> | ||
</div> | ||
<div class="column right-column"> | ||
<div class="box"> | ||
<h3>Search the Documentation</h3> | ||
<form method="get" action="https://varyingvagrantvagrants.org/search/" > | ||
<input type="text" name="q" placeholder="search query"/> | ||
<input type="submit" value="Search"/> | ||
</form> | ||
</div> | ||
<div class="box"> | ||
<h3>Find out more about VVV</h3> | ||
<a class="button" href="https://varyingvagrantvagrants.org/" target="_blank">Help & Documentation</a> | ||
<a class="button" href="https://github.com/varying-vagrant-vagrants/vvv/" target="_blank">View the code on GitHub</a> | ||
</div> | ||
|
||
<div class="box"> | ||
<h3>Bundled Tools</h3> | ||
|
||
<a class="button" href="//vvv.test/database-admin/" target="_blank">phpMyAdmin</a> | ||
<a class="button" href="//vvv.test/memcached-admin/" target="_blank">phpMemcachedAdmin</a> | ||
<a class="button" href="//vvv.test/opcache-status/opcache.php" target="_blank">Opcache Status</a> | ||
<a class="button" href="http://vvv.test:1080" target="_blank">Mailcatcher</a> | ||
<a class="button" href="//vvv.test/webgrind/" target="_blank">Webgrind</a> | ||
<a class="button" href="//vvv.test/phpinfo/" target="_blank">PHP Info</a> | ||
<a class="button" href="php-status?html&full" target="_blank">PHP Status</a> | ||
</div> | ||
<div class="box"> | ||
<h3>VVV 1.x Sites not Showing?</h3> | ||
<p>Sites need to be listed in <code>vvv-custom.yml</code> for VVV to find them, luckily it's super easy and fast to add them back! click below to find out how to migrate your sites.</p> | ||
<a class="button" href="https://varyingvagrantvagrants.org/docs/en-US/adding-a-new-site/migrating-from-vvv-1-4-x/">Migrating VVV 1 sites</a> | ||
</div> | ||
<div class="box"> | ||
<h3>Contribute to WordPress</h3> | ||
<p>Whether you're at a contributor day, or just feel like giving back, you can add the WordPress.org Meta environment. This will give you everything from WordCamp to buddypress.org test sites</p> | ||
<a class="button" href="https://github.com/WordPress/meta-environment">Find out more</a> | ||
</div> | ||
<div class="box"> | ||
<h3>Terminal Power!</h3> | ||
<p>VVV has powerful commands preinstalled, if you need WP CLI or PHP Codesniffer, run <code>vagrant ssh</code> to enter the virtual machine, and get a full command line experience</p> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<div id="vvv_provision_fail" class="top-notice box" style="display:none"> | ||
<p><strong>Problem:</strong> Could not load the site, this implies that provisioning the site failed, please check there were no errors during provisioning, and reprovision.</p> | ||
<p><em><strong>Note</strong>, sometimes this is because provisioning hasn't finished yet, if it's still running, wait and refresh the page.</em> If that doesn't fix the issue, re-read our docs on adding sites, check the syntax of all your provisioner files, and double check our troubleshooting page:</p> | ||
<p><a class="button" href="https://varyingvagrantvagrants.org/docs/en-US/troubleshooting/">Troubleshooting</a> <a href="https://varyingvagrantvagrants.org/docs/en-US/adding-a-new-site/" class="button">Adding a Site</a> | ||
</div> | ||
<div id="vvv_hosts_fail" class="top-notice box" style="display:none"> | ||
<p><strong>Info:</strong> It appears you've accessed the dashboard via the IP, you should visit <a href="http://vvv.test">http://vvv.test</a>, but if this isn't working, make sure you've installed the hosts updater vagrant plugin</p> | ||
<p>If you're trying to access a site, you need to visit the host/domain given to the site if one was set.</p> | ||
<p><a href="http://vvv.test" class="button">Visit the Dashboard</a></p> | ||
</div> | ||
|
||
<?php | ||
if ( ! file_exists('/vagrant/vvv-custom.yml') ) { | ||
?> | ||
<div id="vvv_custom_missing" class="top-notice-box box"> | ||
<p><strong>Super Important:</strong> You need to copy <code>vvv-config.yml</code> to <code>vvv-custom.yml</code> or your changes will be destroyed when you update!</p> | ||
</div> | ||
<?php | ||
} | ||
?> | ||
|
||
<script> | ||
// If it's not vvv.test then this site has failed to provision, let the user know | ||
// also notify if the dashboard is being shown on the raw IP | ||
if ( location.hostname.indexOf( "192.168") !== -1 ) { | ||
var notice = document.getElementById( 'vvv_hosts_fail' ); | ||
notice.style.display = 'block'; | ||
} else if ( ( location.hostname != "vvv.dev" ) | ||
&& ( location.hostname != "vvv.test" ) | ||
&& ( location.hostname != "vvv.local" ) | ||
&& ( location.hostname != "vvv.localhost" ) ) | ||
{ | ||
var notice = document.getElementById( 'vvv_provision_fail' ); | ||
notice.style.display = 'block'; | ||
} | ||
</script> |