Last active
December 10, 2015 11:19
-
-
Save ahmednuaman/4426965 to your computer and use it in GitHub Desktop.
A single-page site PHP HTML boilerplate
This file contains hidden or 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
<?php | |
define('ENVIRONMENT', $_SERVER['HTTP_HOST'] === 'domain.dev' ? 'development' : 'production'); | |
include 'version.php'; | |
function get_assets($ext, $template) | |
{ | |
$folders = array( | |
'assets/' . $ext . '/vendor', | |
'assets/' . $ext | |
); | |
foreach ($folders as $folder) | |
{ | |
$files = scandir($folder); | |
foreach ($files as $file) | |
{ | |
if (strstr($file, $ext)) | |
{ | |
printf($template . "\n", '/' . $folder . '/' . $file); | |
} | |
} | |
} | |
} | |
?> | |
<!DOCTYPE html> | |
<html class="no-js"> | |
<head> | |
<meta charset="utf-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0" /> | |
<?php if (ENVIRONMENT !== 'production'): ?> | |
<?php get_assets('css', '<link rel="stylesheet" href="%s" />'); ?> | |
<?php else: ?> | |
<link rel="stylesheet" href="<?php echo site_url('/assets/css/packaged-min.css?' . VERSION); ?>" /> | |
<?php endif; ?> | |
<title></title> | |
</head> | |
<body> | |
<?php if (ENVIRONMENT !== 'production'): ?> | |
<?php get_assets('js', '<script src="%s"></script>'); ?> | |
<?php else: ?> | |
<script src="<?php echo site_url('assets/js/packaged-min.js?' . VERSION); ?>"></script> | |
<script> | |
var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']]; | |
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0]; | |
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js'; | |
s.parentNode.insertBefore(g,s)}(document,'script')); | |
</script> | |
<?php endif; ?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment