Merge branch 'master' of github.com:epicwhale/daux.io into epicwhale-master

Conflicts:
	libs/functions.php
This commit is contained in:
Justin Walsh 2013-07-22 10:53:28 -05:00
commit cd4ded1120
4 changed files with 90 additions and 21 deletions

View File

@ -3,7 +3,7 @@ php_flag display_errors on
php_flag html_errors on php_flag html_errors on
RewriteEngine On RewriteEngine On
RewriteBase / #RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-d

View File

@ -6,7 +6,7 @@
<h3>Features</h3> <h3>Features</h3>
<hr/> <hr/>
<img src="/img/app-thumbs.png" alt="alt text" class="pull-right" style="margin-bottom:20px;"> <img src="img/app-thumbs.png" alt="alt text" class="pull-right" style="margin-bottom:20px;">
* 100% Mobile Responsive * 100% Mobile Responsive
* Supports GitHub Flavored Markdown * Supports GitHub Flavored Markdown

View File

@ -66,7 +66,7 @@ software, even if advised of the possibility of such damage.
require_once('libs/functions.php'); require_once('libs/functions.php');
$options = get_options(); $options = get_options();
$tree = get_tree("docs"); $tree = get_tree("docs", $base_url);
$homepage_url = homepage_url($tree); $homepage_url = homepage_url($tree);
$docs_url = docs_url($tree); $docs_url = docs_url($tree);
@ -81,16 +81,15 @@ if ($homepage && $homepage_url !== '/') {
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]--> <!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<html>
<head> <head>
<title><?php echo $options['title']; ?></title> <title><?php echo $options['title']; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="<?php echo $options['tagline'];?>" /> <meta name="description" content="<?php echo $options['tagline'];?>" />
<meta name="author" content="<?php echo $options['title']; ?>"> <meta name="author" content="<?php echo $options['title']; ?>">
<?php if ($options['colors']) { ?> <?php if ($options['colors']) { ?>
<link rel="icon" href="/img/favicon.png" type="image/x-icon"> <link rel="icon" `<?php echo $base_url ?>img/favicon.png" type="image/x-icon">
<?php } else { ?> <?php } else { ?>
<link rel="icon" href="/img/favicon-<?php echo $options['theme'];?>.png" type="image/x-icon"> <link rel="icon" href="<?php echo $base_url ?>/img/favicon-<?php echo $options['theme'];?>.png" type="image/x-icon">
<?php } ?> <?php } ?>
<!-- Mobile --> <!-- Mobile -->
<meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-capable" content="yes" />
@ -105,20 +104,20 @@ if ($homepage && $homepage_url !== '/') {
<?php foreach($options['colors'] as $k => $v) { ?> <?php foreach($options['colors'] as $k => $v) { ?>
@<?php echo $k;?>: <?php echo $v;?>; @<?php echo $k;?>: <?php echo $v;?>;
<?php } ?> <?php } ?>
@import "/less/import/daux-base.less"; @import "<?php echo $base_url ?>/less/import/daux-base.less";
</style> </style>
<script src="/js/less.min.js"></script> <script src="<?php echo $base_url ?>/js/less.min.js"></script>
<?php } else { ?> <?php } else { ?>
<link rel="stylesheet" href="/css/daux-<?php echo $options['theme'];?>.css"> <link rel="stylesheet" href="<?php echo $base_url ?>/css/daux-<?php echo $options['theme'];?>.css">
<?php } ?> <?php } ?>
<!-- hightlight.js --> <!-- hightlight.js -->
<script src="/js/highlight.min.js"></script> <script src="<?php echo $base_url ?>/js/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script> <script>hljs.initHighlightingOnLoad();</script>
<!-- Navigation --> <!-- Navigation -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<script src="/js/custom.js"></script> <script src="<?php echo $base_url ?>/js/custom.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]--> <![endif]-->
@ -129,7 +128,7 @@ if ($homepage && $homepage_url !== '/') {
<div class="navbar navbar-fixed-top"> <div class="navbar navbar-fixed-top">
<div class="navbar-inner"> <div class="navbar-inner">
<div class="container"> <div class="container">
<a class="brand pull-left" href="<?php echo $homepage_url;?>"><?php echo $options['title']; ?></a> <a class="brand pull-left" href="<?php echo $base_url ?>/<?php echo $homepage_url;?>"><?php echo $options['title']; ?></a>
<p class="navbar-text pull-right"> <p class="navbar-text pull-right">
Generated by <a href="http://daux.io">Daux.io</a> Generated by <a href="http://daux.io">Daux.io</a>
</p> </p>
@ -149,7 +148,7 @@ if ($homepage && $homepage_url !== '/') {
<div class="row"> <div class="row">
<div class="span10 offset1"> <div class="span10 offset1">
<?php if ($options['image']) { ?> <?php if ($options['image']) { ?>
<img class="homepage-image" src="<?php echo $options['image'];?>" alt="<?php echo $options['title'];?>"> <img class="homepage-image" src="<?php echo $base_url ?>/<?php echo $options['image'];?>" alt="<?php echo $options['title'];?>">
<?php } ?> <?php } ?>
</div> </div>
</div> </div>
@ -218,7 +217,7 @@ if ($homepage && $homepage_url !== '/') {
<div class="container-fluid fluid-height wrapper"> <div class="container-fluid fluid-height wrapper">
<div class="navbar navbar-fixed-top"> <div class="navbar navbar-fixed-top">
<div class="navbar-inner"> <div class="navbar-inner">
<a class="brand pull-left" href="<?php echo $homepage_url;?>"><?php echo $options['title']; ?></a> <a class="brand pull-left" href="<?php echo $base_url ?><?php echo $homepage_url;?>"><?php echo $options['title']; ?></a>
<p class="navbar-text pull-right"> <p class="navbar-text pull-right">
Generated by <a href="http://daux.io">Daux.io</a> Generated by <a href="http://daux.io">Daux.io</a>
</p> </p>

View File

@ -16,11 +16,15 @@ error_reporting(E_ALL);
require_once('libs/markdown_extended.php'); require_once('libs/markdown_extended.php');
// Check for homepage // Check for homepage
$path = url_path(); $homepage = (get_uri(false) === "") ? true : false;
if ($path === '/' || $path === '') {
$homepage = true; // Stores the base url under which daux is running
} else { $base_url = '/';
$homepage = false;
// Set the base url of where the script is located
if (isset($_SERVER['SCRIPT_NAME']))
{
$base_url = substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'] , '/')); // find the full URL to this application from server root
} }
// Daux.io Functions // Daux.io Functions
@ -138,7 +142,7 @@ function url_path() {
} }
function url_params() { function url_params() {
$url = url_path(); $url = get_uri();
$params = explode('/', trim($url, '/')); $params = explode('/', trim($url, '/'));
return $params; return $params;
} }
@ -288,4 +292,70 @@ function get_tree($path = '.', $clean_path = '', $title = ''){
return $tree; return $tree;
} }
?>
/**
* Get's the current "pretty" URI from the URL. It will also correct the QUERY_STRING server var and the $_GET array.
* It supports all forms of mod_rewrite and the following forms of URL:
*
* http://example.com/index.php/foo (returns '/foo')
* http://example.com/index.php?/foo (returns '/foo')
* http://example.com/index.php/foo?baz=bar (returns '/foo')
* http://example.com/index.php?/foo?baz=bar (returns '/foo')
*
* Similarly using mod_rewrite to remove index.php:
* http://example.com/foo (returns '/foo')
* http://example.com/foo?baz=bar (returns '/foo')
*
* @author Dan Horrigan <http://dhorrigan.com>
* @copyright Dan Horrigan
* @license MIT License <http://www.opensource.org/licenses/mit-license.php>
* @param bool $prefix_slash whether to return the uri with a '/' in front
* @return string the uri
*/
function get_uri($prefix_slash = true)
{
if (isset($_SERVER['PATH_INFO']))
{
$uri = $_SERVER['PATH_INFO'];
}
elseif (isset($_SERVER['REQUEST_URI']))
{
$uri = $_SERVER['REQUEST_URI'];
if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
{
$uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
}
elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
{
$uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
}
// This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
// URI is found, and also fixes the QUERY_STRING server var and $_GET array.
if (strncmp($uri, '?/', 2) === 0)
{
$uri = substr($uri, 2);
}
$parts = preg_split('#\?#i', $uri, 2);
$uri = $parts[0];
if (isset($parts[1]))
{
$_SERVER['QUERY_STRING'] = $parts[1];
parse_str($_SERVER['QUERY_STRING'], $_GET);
}
else
{
$_SERVER['QUERY_STRING'] = '';
$_GET = array();
}
$uri = parse_url($uri, PHP_URL_PATH);
}
else
{
// Couldn't determine the URI, so just return false
return false;
}
// Do some final cleaning of the URI and return it
return ($prefix_slash ? '/' : '').str_replace(array('//', '../'), '/', trim($uri, '/'));
}