Example #1
0
 /**
  * {@inheritDoc}
  */
 public function resolve(Document $document)
 {
     $story = new Story();
     $story->setBody($document->getContent());
     foreach (array('title', 'date') as $required) {
         if (!$document->get($required)) {
             return false;
         }
         $method = 'set' . ucfirst($required);
         $story->{$method}($document->get($required));
     }
     if (!($slug = $document->get('slug'))) {
         $slug = Str::slug($document->get('title'));
     }
     $story->setSlug($slug);
     if ($tags = $document->get('tags')) {
         $tags = array_map('trim', explode(',', $tags));
         $story->setTags($tags);
     }
     return $story;
 }
 /**
  * Sets a new value to a specific content item attribute
  *
  * @param  string $key
  * @param  mixed $value
  * @return mixed
  */
 public function setAttribute($key, $value)
 {
     $this->document->add($key, $value);
 }
Example #3
0
 public function test_document_can_fetch_metadata_by_dot_notation_with_default_value()
 {
     $d = new Document('foo', [], 'baz');
     $this->assertEquals('boo', $d->get('foo.bar', 'boo'));
 }
 /**
  * Parse HTML/Content from markdown.
  *
  * @param  \Kurenai\Document  $content
  * @param  string  $version
  *
  * @return string
  */
 public function parseMarkdown(Document $content, $version)
 {
     return $this->parseContent($content->getHtmlContent(), $version);
 }
 /**
  * Display documentation.
  *
  * @param  string  $version
  * @param  \Kurenai\Document  $toc
  * @param  \Kurenai\Document  $document
  *
  * @return mixed
  */
 public function showDocumentation($version, Document $toc, Document $document)
 {
     set_meta('title', sprintf('%s on v%s', $document->get('title'), $version));
     set_meta('doc:version', $version);
     return view('documentation', ['toc' => $toc, 'document' => $document, 'version' => $version, 'html' => ['toc' => $this->processor->parseMarkdown($toc, $version), 'document' => $this->processor->parseMarkdown($document, $version)]]);
 }