mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 11:05:56 +02:00
BUGFIX: fixed path to jquery and incorrect file path location
This commit is contained in:
parent
416a8ce79c
commit
aa2c0cadc3
@ -23,7 +23,7 @@ class DocumentationViewer extends Controller {
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
static $ignored_files = array('.', '..', '.DS_Store', '.svn', '.git');
|
static $ignored_files = array('.', '..', '.DS_Store', '.svn', '.git', 'assets');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Documentation Home
|
* Documentation Home
|
||||||
@ -101,14 +101,12 @@ class DocumentationViewer extends Controller {
|
|||||||
$class = $request->param('Class');
|
$class = $request->param('Class');
|
||||||
$module = $request->param('Module');
|
$module = $request->param('Module');
|
||||||
|
|
||||||
if(!stripos($class, '.md')) $class .= '.md';
|
|
||||||
|
|
||||||
$this->writeHeader($class, $module);
|
$this->writeHeader($class, $module);
|
||||||
|
|
||||||
$base = Director::baseURL();
|
$base = Director::baseURL();
|
||||||
|
|
||||||
// find page
|
// find page
|
||||||
$path = BASE_PATH . '/'. $module .'/doc/';
|
$path = BASE_PATH . '/'. $module .'/doc';
|
||||||
|
|
||||||
echo "<div id='LeftColumn'><div class='box'>";
|
echo "<div id='LeftColumn'><div class='box'>";
|
||||||
if($page = $this->findPage($path, $class)) {
|
if($page = $this->findPage($path, $class)) {
|
||||||
@ -120,7 +118,7 @@ class DocumentationViewer extends Controller {
|
|||||||
|
|
||||||
echo "</div></div> <div id='RightColumn'></div>";
|
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>
|
<script type="text/javascript" src="'. Director::absoluteBaseURL() .'sapphiredocs/javascript/DocumentationViewer.js"></script>
|
||||||
';
|
';
|
||||||
|
|
||||||
@ -202,13 +200,17 @@ class DocumentationViewer extends Controller {
|
|||||||
|
|
||||||
if($handle) {
|
if($handle) {
|
||||||
while (false !== ($file = readdir($handle))) {
|
while (false !== ($file = readdir($handle))) {
|
||||||
|
$newpath = $path .'/'. $file;
|
||||||
|
|
||||||
if(!in_array($file, self::$ignored_files)) {
|
if(!in_array($file, self::$ignored_files)) {
|
||||||
if(is_dir($path.$file)) {
|
|
||||||
|
if(is_dir($newpath)) {
|
||||||
// keep looking down the tree
|
// 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,7 +253,9 @@ class DocumentationViewer extends Controller {
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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>";
|
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);
|
$title = str_ireplace('-', ' ', $title);
|
||||||
|
|
||||||
// remove extension
|
// remove extension
|
||||||
$title = str_ireplace('.md', ' ', $title);
|
$title = str_ireplace('.md', '', $title);
|
||||||
|
|
||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,11 @@ ul { margin: 8px 16px 20px 20px; }
|
|||||||
li { font-size: 12px; line-height: 18px; margin-bottom: 8px;}
|
li { font-size: 12px; line-height: 18px; margin-bottom: 8px;}
|
||||||
|
|
||||||
|
|
||||||
h1 { font-size: 24px; margin-bottom: 18px; }
|
h1 { font-size: 30px; margin-bottom: 18px; }
|
||||||
h2 { font-size: 18px; margin-bottom: 16px; }
|
h2 { font-size: 24px; margin-bottom: 16px; }
|
||||||
h3 { font-size: 16px; margin-bottom: 16px; }
|
h3 { font-size: 18px; margin-bottom: 16px; }
|
||||||
h4 { font-size: 14px; margin-bottom: 8px; }
|
h4 { font-size: 16px; margin-bottom: 6px; line-height: 16px;}
|
||||||
|
h5 { font-size: 14px; line-height: 18px; margin-bottom: 6px;}
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
margin-bottom: 18px;
|
margin-bottom: 18px;
|
||||||
@ -59,7 +60,7 @@ pre {
|
|||||||
-moz-border-radius: 4px;
|
-moz-border-radius: 4px;
|
||||||
-webkit-border-radius: 4px;
|
-webkit-border-radius: 4px;
|
||||||
}
|
}
|
||||||
.box h2 {
|
#Home .box h2 {
|
||||||
background: #535360;
|
background: #535360;
|
||||||
border: 1px solid #535360;
|
border: 1px solid #535360;
|
||||||
-moz-border-top-radius: 4px;
|
-moz-border-top-radius: 4px;
|
||||||
@ -70,7 +71,7 @@ pre {
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
.box h2 a {
|
#Home .box h2 a {
|
||||||
background: url(../images/readme.png) no-repeat right center;
|
background: url(../images/readme.png) no-repeat right center;
|
||||||
padding: 2px 20px 0 0;
|
padding: 2px 20px 0 0;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
@ -106,3 +107,28 @@ pre {
|
|||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
font-style: italic;
|
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;
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var toc = '<div class="box"><ul id="toc">';
|
var toc = '<div class="box"><ul id="toc">';
|
||||||
toc += '<h4 style="margin-top: 0; margin-bottom: 5px; font-weight: bold;">In this document:</h4>';
|
toc += '<h4>In this document:</h4>';
|
||||||
$('h1, h2, h3, h4').each(function(i) {
|
$('#LeftColumn h1, #LeftColumn h2, #LeftColumn h3, #LeftColumn h4').each(function(i) {
|
||||||
var current = $(this);
|
var current = $(this);
|
||||||
current.attr('id', 'title' + i);
|
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>';
|
toc += '<li class="' + current.attr("tagName").toLowerCase() + '"><a id="link' + i + '" href="#title' + i + '" title="' + current.html() + '">' + current.html() + '</a></li>';
|
||||||
|
Loading…
Reference in New Issue
Block a user