Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 /**
  * Returns a specific content item attribute
  *
  * @param  string $key
  * @return mixed
  */
 public function getAttribute($key)
 {
     return $this->document->get($key);
 }
Ejemplo n.º 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'));
 }
 /**
  * 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)]]);
 }