Inheritance: extends ArrayObjec\ArrayObject
コード例 #1
0
ファイル: BuilderTest.php プロジェクト: rlugojr/daux.io
 public function getStaticRoot()
 {
     $config = new Config();
     $config->setDocumentationDirectory('');
     $config['mode'] = Daux::STATIC_MODE;
     $config['index_key'] = 'index.html';
     $config['valid_content_extensions'] = ['md'];
     return new Root($config);
 }
コード例 #2
0
ファイル: ContentTest.php プロジェクト: rlugojr/daux.io
 protected function createContent($content)
 {
     $config = new Config();
     $config->setDocumentationDirectory('');
     $dir = new Directory(new Root($config), '');
     $obj = new Content($dir, '');
     $obj->setContent($content);
     return $obj;
 }
コード例 #3
0
ファイル: LinkRendererTest.php プロジェクト: rlugojr/daux.io
 protected function getTree(Config $config)
 {
     $structure = ['Content' => ['Page.md' => 'some text content'], 'Widgets' => ['Page.md' => 'another page', 'Button.md' => 'another page']];
     $root = vfsStream::setup('root', null, $structure);
     $config->setDocumentationDirectory($root->url());
     $config['valid_content_extensions'] = ['md'];
     $config['mode'] = Daux::STATIC_MODE;
     $config['index_key'] = 'index.html';
     $tree = new Root($config);
     Builder::build($tree, []);
     return $tree;
 }
コード例 #4
0
ファイル: DirectoryTest.php プロジェクト: rlugojr/daux.io
 /**
  * @dataProvider providerSort
  */
 public function testSort($list, $expected)
 {
     shuffle($list);
     $config = new Config();
     $config->setDocumentationDirectory('');
     $directory = new Directory(new Root($config), 'dir');
     foreach ($list as $value) {
         $entry = new Content($directory, $value);
         $entry->setName($value);
     }
     $directory->sort();
     $final = [];
     foreach ($directory->getEntries() as $obj) {
         $final[] = $obj->getName();
     }
     $this->assertEquals($expected, $final);
 }
コード例 #5
0
 public function testCreateHierarchy()
 {
     $config = new Config();
     $config->setDocumentationDirectory($this->root->url());
     $config['valid_content_extensions'] = ['md'];
     $config['mode'] = Daux::STATIC_MODE;
     $config['index_key'] = 'index.html';
     $tree = new Root($config);
     Builder::build($tree, []);
     $this->assertCount(2, $tree);
     $this->assertTrue(array_key_exists('Contents', $tree->getEntries()));
     $this->assertInstanceOf(Directory::class, $tree['Contents']);
     $this->assertTrue(array_key_exists('Widgets', $tree->getEntries()));
     $this->assertInstanceOf(Directory::class, $tree['Widgets']);
     // TODO :: should not be Page.html, this should not depend on the mode
     $this->assertEquals('Page', $tree['Contents']['Page.html']->getTitle());
     $this->assertInstanceOf(Content::class, $tree['Contents']['Page.html']);
 }
コード例 #6
0
ファイル: LinkRenderer.php プロジェクト: rabeckett/propane
 /**
  * @param AbstractInline|Link $inline
  * @param ElementRendererInterface $htmlRenderer
  * @return HtmlElement
  * @throws Exception
  */
 public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
 {
     // This can't be in the method type as
     // the method is an abstract and should
     // have the same interface
     if (!$inline instanceof Link) {
         throw new \RuntimeException('Wrong type passed to ' . __CLASS__ . '::' . __METHOD__ . " the expected type was 'League\\CommonMark\\Inline\\Element\\Link' but '" . get_class($inline) . "' was provided");
     }
     $element = parent::render($inline, $htmlRenderer);
     $url = $inline->getUrl();
     // Absolute urls, empty urls and anchors
     // should not go through the url resolver
     if (empty($url) || $url[0] == '#' || preg_match('|^(?:[a-z]+:)?//|', $url)) {
         return $element;
     }
     $file = $this->resolveInternalFile($url);
     $url = DauxHelper::getRelativePath($this->daux->getCurrentPage()->getUrl(), $file->getUrl());
     $element->setAttribute('href', $url);
     return $element;
 }
コード例 #7
0
ファイル: DauxHelper.php プロジェクト: justinwalsh/daux.io
 protected static function resolveVariant(Config $params)
 {
     if (array_key_exists('theme-variant', $params['html'])) {
         return;
     }
     if (is_dir(realpath($params->getThemesPath() . DIRECTORY_SEPARATOR . $params['html']['theme']))) {
         return;
     }
     $theme = explode('-', $params['html']['theme']);
     // do we have a variant or only a theme ?
     if (isset($theme[1])) {
         $params['html']['theme-variant'] = array_pop($theme);
         $params['html']['theme'] = implode('-', $theme);
     } else {
         $params['html']['theme'] = array_pop($theme);
     }
     if (!is_dir(realpath($params->getThemesPath() . DIRECTORY_SEPARATOR . $params['html']['theme']))) {
         throw new \RuntimeException("Theme '{$params['html']['theme']}' not found");
     }
 }
コード例 #8
0
ファイル: Daux.php プロジェクト: rlugojr/daux.io
 /**
  * @return Config
  */
 public function getParams()
 {
     if ($this->tree && !$this->merged_tree) {
         $this->options['tree'] = $this->tree;
         $this->options['index'] = $this->tree->getIndexPage() ?: $this->tree->getFirstPage();
         if ($this->options->isMultilanguage()) {
             foreach ($this->options['languages'] as $key => $name) {
                 $this->options['entry_page'][$key] = $this->tree->getEntries()[$key]->getFirstPage();
             }
         } else {
             $this->options['entry_page'] = $this->tree->getFirstPage();
         }
         $this->merged_tree = true;
     }
     return $this->options;
 }
コード例 #9
0
ファイル: LinkRenderer.php プロジェクト: justinwalsh/daux.io
 /**
  * @param AbstractInline|Link $inline
  * @param ElementRendererInterface $htmlRenderer
  * @return HtmlElement
  * @throws LinkNotFoundException
  */
 public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
 {
     // This can't be in the method type as
     // the method is an abstract and should
     // have the same interface
     if (!$inline instanceof Link) {
         throw new \RuntimeException('Wrong type passed to ' . __CLASS__ . '::' . __METHOD__ . " the expected type was 'League\\CommonMark\\Inline\\Element\\Link' but '" . get_class($inline) . "' was provided");
     }
     $element = parent::render($inline, $htmlRenderer);
     $url = $inline->getUrl();
     // empty urls and anchors should
     // not go through the url resolver
     if (!$this->isValidUrl($url)) {
         return $element;
     }
     // Absolute urls, shouldn't either
     if ($this->isExternalUrl($url)) {
         $element->setAttribute('class', 'external');
         return $element;
     }
     // if there's a hash component in the url, ensure we
     // don't put that part through the resolver.
     $urlAndHash = explode('#', $url);
     $url = $urlAndHash[0];
     try {
         $file = $this->resolveInternalFile($url);
         $url = DauxHelper::getRelativePath($this->daux->getCurrentPage()->getUrl(), $file->getUrl());
     } catch (LinkNotFoundException $e) {
         if ($this->daux->isStatic()) {
             throw $e;
         }
         $element->setAttribute('class', 'broken');
     }
     if (isset($urlAndHash[1])) {
         $url .= '#' . $urlAndHash[1];
     }
     $element->setAttribute('href', $url);
     return $element;
 }
コード例 #10
0
ファイル: Daux.php プロジェクト: LuziaSol/LuziaDocs
 /**
  * @return Config
  */
 public function getParams()
 {
     if (!$this->merged_defaults) {
         $default = ['multilanguage' => !empty($this->options['languages']), 'mode' => $this->mode, 'local_base' => $this->local_base, 'docs_path' => $this->docs_path, 'themes_path' => $this->themes_path, 'templates' => 'templates'];
         $this->options->conservativeMerge($default);
         $this->options['index_key'] = 'index.html';
         $this->options['base_page'] = $this->options['base_url'] = '';
         $this->merged_defaults = true;
     }
     if ($this->tree && !$this->merged_tree) {
         $this->options['tree'] = $this->tree;
         $this->options['index'] = $this->tree->getIndexPage() ?: $this->tree->getFirstPage();
         if ($this->options['multilanguage']) {
             foreach ($this->options['languages'] as $key => $name) {
                 $this->options['entry_page'][$key] = $this->tree->getEntries()[$key]->getFirstPage();
             }
         } else {
             $this->options['entry_page'] = $this->tree->getFirstPage();
         }
         $this->merged_tree = true;
     }
     return $this->options;
 }
コード例 #11
0
ファイル: ContentType.php プロジェクト: justinwalsh/daux.io
 public function convert($raw, Content $node)
 {
     $this->config->setCurrentPage($node);
     return $this->converter->convertToHtml($raw);
 }
コード例 #12
0
ファイル: ConfigTest.php プロジェクト: justinwalsh/daux.io
 function testHTMLConfigCreation()
 {
     $config = new MainConfig(['html' => ['edit_on' => 'test']]);
     $this->assertInstanceOf(Config::class, $config->getHTML());
     $this->assertEquals('test', $config->getHTML()['edit_on']);
 }