BUGFIX: fixed path to jquery and incorrect file path location

This commit is contained in:
Will Rossiter 2010-03-26 02:50:30 +00:00
parent 416a8ce79c
commit aa2c0cadc3
3 changed files with 51 additions and 21 deletions

View File

@ -23,7 +23,7 @@ class DocumentationViewer extends Controller {
*
* @var array
*/
static $ignored_files = array('.', '..', '.DS_Store', '.svn', '.git');
static $ignored_files = array('.', '..', '.DS_Store', '.svn', '.git', 'assets');
/**
* Documentation Home
@ -101,14 +101,12 @@ class DocumentationViewer extends Controller {
$class = $request->param('Class');
$module = $request->param('Module');
if(!stripos($class, '.md')) $class .= '.md';
$this->writeHeader($class, $module);
$base = Director::baseURL();
// find page
$path = BASE_PATH . '/'. $module .'/doc/';
$path = BASE_PATH . '/'. $module .'/doc';
echo "<div id='LeftColumn'><div class='box'>";
if($page = $this->findPage($path, $class)) {
@ -120,7 +118,7 @@ class DocumentationViewer extends Controller {
echo "</div></div> <div id='RightColumn'></div>";
echo '<script type="text/javascript" src="'. Director::absoluteBaseURL(). 'sapphire/thirdparty/jquery/jquery.min.js"></script>
echo '<script type="text/javascript" src="'. Director::absoluteBaseURL(). 'sapphire/thirdparty/jquery/jquery.js"></script>
<script type="text/javascript" src="'. Director::absoluteBaseURL() .'sapphiredocs/javascript/DocumentationViewer.js"></script>
';
@ -202,18 +200,22 @@ class DocumentationViewer extends Controller {
if($handle) {
while (false !== ($file = readdir($handle))) {
$newpath = $path .'/'. $file;
if(!in_array($file, self::$ignored_files)) {
if(is_dir($path.$file)) {
if(is_dir($newpath)) {
// keep looking down the tree
return $this->findPage($path.$file, $name);
return $this->findPage($newpath, $name);
}
elseif(strtolower($file) == strtolower($name)) {
return $path .'/'. $file;
elseif(strtolower($this->formatStringForTitle($file)) == strtolower($name)) {
return $newpath;
}
}
}
}
return false;
}
@ -251,7 +253,9 @@ class DocumentationViewer extends Controller {
}
else {
$file = str_ireplace('.md', '', $file);
$offset = (strpos($file,'-') > 0) ? strpos($file,'-') + 1 : 0;
$file = substr(str_ireplace('.md', '', $file), $offset);
echo "<li class='page'><a href='". Director::absoluteBaseURL() . 'dev/docs/' . $module .'/'. $file . "'>". $this->formatStringForTitle($file) ."</a></li>";
}
@ -279,7 +283,7 @@ class DocumentationViewer extends Controller {
$title = str_ireplace('-', ' ', $title);
// remove extension
$title = str_ireplace('.md', ' ', $title);
$title = str_ireplace('.md', '', $title);
return $title;
}

View File

@ -21,10 +21,11 @@ ul { margin: 8px 16px 20px 20px; }
li { font-size: 12px; line-height: 18px; margin-bottom: 8px;}
h1 { font-size: 24px; margin-bottom: 18px; }
h2 { font-size: 18px; margin-bottom: 16px; }
h3 { font-size: 16px; margin-bottom: 16px; }
h4 { font-size: 14px; margin-bottom: 8px; }
h1 { font-size: 30px; margin-bottom: 18px; }
h2 { font-size: 24px; margin-bottom: 16px; }
h3 { font-size: 18px; margin-bottom: 16px; }
h4 { font-size: 16px; margin-bottom: 6px; line-height: 16px;}
h5 { font-size: 14px; line-height: 18px; margin-bottom: 6px;}
pre {
margin-bottom: 18px;
@ -59,7 +60,7 @@ pre {
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
}
.box h2 {
#Home .box h2 {
background: #535360;
border: 1px solid #535360;
-moz-border-top-radius: 4px;
@ -70,7 +71,7 @@ pre {
color: #fff;
font-size: 13px;
}
.box h2 a {
#Home .box h2 a {
background: url(../images/readme.png) no-repeat right center;
padding: 2px 20px 0 0;
font-size: 11px;
@ -105,4 +106,29 @@ pre {
clear: both;
padding-top: 10px;
font-style: italic;
}
}
/**
* TOC
*/
ul#toc {
margin: 0;
padding: 10px;
background: #f4f4f4;
width: 220px;
position: fixed;
}
ul#toc li {
list-style: none;
margin: 0 0 4px 0;
}
ul#toc li.h2 {
margin-left: 10px;
}
ul#toc li.h3 {
margin-left: 20px;
}
ul#toc li.h4 {
margin-right: 30px;
}

View File

@ -1,7 +1,7 @@
$(document).ready(function() {
var toc = '<div class="box"><ul id="toc">';
toc += '<h4 style="margin-top: 0; margin-bottom: 5px; font-weight: bold;">In this document:</h4>';
$('h1, h2, h3, h4').each(function(i) {
toc += '<h4>In this document:</h4>';
$('#LeftColumn h1, #LeftColumn h2, #LeftColumn h3, #LeftColumn h4').each(function(i) {
var current = $(this);
current.attr('id', 'title' + i);
toc += '<li class="' + current.attr("tagName").toLowerCase() + '"><a id="link' + i + '" href="#title' + i + '" title="' + current.html() + '">' + current.html() + '</a></li>';