diff --git a/code/DocumentationManifest.php b/code/DocumentationManifest.php index 0971a14..b7e10cb 100644 --- a/code/DocumentationManifest.php +++ b/code/DocumentationManifest.php @@ -29,8 +29,6 @@ */ class DocumentationManifest { - const TEMPLATES_DIR = 'documentation'; - /** * @config * @@ -119,6 +117,10 @@ class DocumentationManifest { ); $entity->addVersion($version); + + if(isset($details['DefaultEntity']) && $details['DefaultEntity']) { + $entity->setDefaultEntity(true); + } } } @@ -290,6 +292,9 @@ class DocumentationManifest { $this->entity, $basename, $path ); + // populate any meta data + $page->getMarkdown(); + $this->pages[$page->Link()] = array( 'title' => $page->getTitle(), 'filepath' => $path, @@ -302,12 +307,32 @@ class DocumentationManifest { /** * Generate an {@link ArrayList} of the pages to the given page. * + * @param DocumentationPage + * @param DocumentationEntityLanguage + * * @return ArrayList */ - public function generateBreadcrumbs($record) { + public function generateBreadcrumbs($record, $base) { $output = new ArrayList(); - // @todo + $parts = explode('/', $record->getRelativeLink()); + $output->push(new ArrayData(array( + 'Link' => $base->Link(), + 'Title' => $base->Title + ))); + + $progress = $base->Link(); + + foreach($parts as $part) { + if($part) { + $progress = Controller::join_links($progress, $part, '/'); + + $output->push(new ArrayData(array( + 'Link' => $progress, + 'Title' => DocumentationHelper::clean_page_name($part) + ))); + } + } return $output; } @@ -380,24 +405,33 @@ class DocumentationManifest { * * @return ArrayList */ - public function getChildrenFor($base, $record) { + public function getChildrenFor($base, $record, $recursive = true) { $output = new ArrayList(); $depth = substr_count($base, '/'); foreach($this->getPages() as $url => $page) { if(strstr($url, $base) !== false) { - // children if(substr_count($url, '/') == ($depth + 1)) { + // found a child if($base !== $record) { $mode = (strstr($url, $record) !== false) ? 'current' : 'link'; } else { $mode = 'link'; } + $children = new ArrayList(); + + if($mode == 'current') { + if($recursive) { + $children = $this->getChildrenFor($url, $url, false); + } + } + $output->push(new ArrayData(array( 'Link' => $url, 'Title' => $page['title'], - 'LinkingMode' => $mode + 'LinkingMode' => $mode, + 'Children' => $children ))); } } diff --git a/code/controllers/DocumentationViewer.php b/code/controllers/DocumentationViewer.php index 04de103..be9239b 100755 --- a/code/controllers/DocumentationViewer.php +++ b/code/controllers/DocumentationViewer.php @@ -178,7 +178,10 @@ class DocumentationViewer extends Controller { return $response; } - if($response->getStatusCode() !== 200) { + $action = $request->param('Action'); + $allowed = $this->config()->allowed_actions; + + if(!in_array($action, $allowed) || $response->getStatusCode() !== 200) { // look up the manifest to see find the nearest match against the // list of the URL. If the URL exists then set that as the current // page to match against. @@ -292,6 +295,7 @@ class DocumentationViewer extends Controller { 'Title' => $entity->getTitle(), 'Link' => $link, 'LinkingMode' => $mode, + 'DefaultEntity' => $entity, 'Children' => $children ))); } @@ -309,7 +313,7 @@ class DocumentationViewer extends Controller { */ public function getContent() { $page = $this->getPage(); - + return DBField::create_field("HTMLText", $page->getHTML()); } @@ -320,7 +324,10 @@ class DocumentationViewer extends Controller { */ public function getBreadcrumbs() { if($this->record) { - return $this->getManifest()->generateBreadcrumbs($this->record); + return $this->getManifest()->generateBreadcrumbs( + $this->record, + $this->record->getEntity() + ); } } @@ -335,8 +342,8 @@ class DocumentationViewer extends Controller { * * @return string */ - public function getPageTitle() { - return ($this->record) ? $this->record->getBreadcrumbTitle() : null; + public function getTitle() { + return ($this->record) ? $this->record->getTitle() : null; } /** diff --git a/code/models/DocumentationEntity.php b/code/models/DocumentationEntity.php index bd3eef9..35e4a13 100755 --- a/code/models/DocumentationEntity.php +++ b/code/models/DocumentationEntity.php @@ -41,7 +41,16 @@ class DocumentationEntity extends ViewableData { * @var ArrayList $versions */ protected $versions; - + + /** + * If the system is setup to only document one entity then you may only + * want to show a single entity in the URL and the sidebar. Set this when + * you register the entity with the key `DefaultEntity` + * + * @var boolean $default_entity + */ + protected $defaultEntity; + /** * Constructor. You do not need to pass the langs to this as * it will work out the languages from the filesystem @@ -153,10 +162,12 @@ class DocumentationEntity extends ViewableData { * @return string */ public function Link() { - return Controller::join_links( - Config::inst()->get('DocumentationViewer', 'link_base'), - $this->getFolder() - ); + return ($this->getDefaultEntity()) + ? Config::inst()->get('DocumentationViewer', 'link_base') + : Controller::join_links( + Config::inst()->get('DocumentationViewer', 'link_base'), + $this->getFolder() + ); } /** @@ -178,4 +189,17 @@ class DocumentationEntity extends ViewableData { } } } + + /** + * @param boolean $bool + */ + public function setDefaultEntity($bool) { + $this->defaultEntity = $bool; + + return $this; + } + + public function getDefaultEntity() { + return $this->defaultEntity; + } } \ No newline at end of file diff --git a/code/models/DocumentationPage.php b/code/models/DocumentationPage.php index e21cd02..4c47391 100755 --- a/code/models/DocumentationPage.php +++ b/code/models/DocumentationPage.php @@ -115,9 +115,7 @@ class DocumentationPage extends ViewableData { public function getMarkdown($removeMetaData = false) { try { if ($md = file_get_contents($this->path)) { - if ($this->title != 'Index') { - $this->populateMetaDataFromText($md, $removeMetaData); - } + $this->populateMetaDataFromText($md, $removeMetaData); return $md; } diff --git a/css/layout.css b/css/layout.css index e5308de..9c5846b 100644 --- a/css/layout.css +++ b/css/layout.css @@ -393,3 +393,15 @@ html { #content .warningBoxBottom a:hover { color: #f3fbfe; } #content .warningBoxBottom ul { margin: 0 0 0 40px; } #content .warningBoxBottom li { background: none; margin-bottom: 0; } + +.doc-breadcrumbs { + margin-top: -10px; +} + .doc-breadcrumbs p { + font-size: 11px; + margin: 0; + color: #999; + } + .doc-breadcrumbs p a { + color: #999; + } diff --git a/css/typography.css b/css/typography.css index 6e41ad7..93805f3 100644 --- a/css/typography.css +++ b/css/typography.css @@ -121,8 +121,8 @@ ul.third { /*! headers */ h1 { - font-size: 30px; - line-height: 30px; + font-size: 35px; + line-height: 40px; margin-bottom: 10px; margin-top: 0; letter-spacing: -1px; diff --git a/templates/DocumentationViewer.ss b/templates/DocumentationViewer.ss index 878687c..365252a 100755 --- a/templates/DocumentationViewer.ss +++ b/templates/DocumentationViewer.ss @@ -4,7 +4,7 @@
<% base_tag %> -