Beispiel #1
0
 protected function createContent($content)
 {
     $dir = new Directory(new Root(new Config(), ''), '');
     $obj = new Content($dir, '');
     $obj->setContent($content);
     return $obj;
 }
Beispiel #2
0
 protected function createContent($content)
 {
     $config = new Config();
     $config->setDocumentationDirectory('');
     $dir = new Directory(new Root($config), '');
     $obj = new Content($dir, '');
     $obj->setContent($content);
     return $obj;
 }
Beispiel #3
0
 public function testGetOrCreatePageExisting()
 {
     $directory = new Directory($this->getStaticRoot(), 'dir');
     $existingEntry = new Content($directory, 'A_Page.html');
     $existingEntry->setContent('-');
     $entry = Builder::getOrCreatePage($directory, 'A Page.md');
     $this->assertSame($directory, $entry->getParent());
     $this->assertSame($existingEntry, $entry);
     $this->assertEquals('dir/A_Page.html', $entry->getUrl());
     $this->assertEquals('A_Page.html', $entry->getUri());
     $this->assertInstanceOf('Todaymade\\Daux\\Tree\\Content', $entry);
 }
Beispiel #4
0
 /**
  * @param Directory $parent
  * @param string $path
  * @return Content
  */
 public static function getOrCreatePage(Directory $parent, $path)
 {
     $title = static::getName($path);
     // If the file doesn't have an extension, set .md as a default
     if (pathinfo($path, PATHINFO_EXTENSION) == '') {
         $path .= '.md';
     }
     $uri = $slug = DauxHelper::slug($title);
     if ($parent->getConfig()['mode'] === Daux::STATIC_MODE) {
         $uri = $slug . ".html";
     }
     if (array_key_exists($uri, $parent->getEntries())) {
         return $parent->getEntries()[$uri];
     }
     $page = new Content($parent, $uri);
     $page->setContent("-");
     //set an almost empty content to avoid problems
     if ($title == 'index') {
         // TODO :: clarify the difference between 'index' and '_index'
         $page->setName('_index' . pathinfo($path, PATHINFO_EXTENSION));
         $page->setTitle($parent->getTitle());
     } else {
         $page->setName($path);
         $page->setTitle($title);
     }
     return $page;
 }