Пример #1
0
 /**
  * Show a documentation page.
  *
  * @param  string $version
  * @param  string|null $page
  * @return Response
  */
 public function show($version, $page = null)
 {
     if (!$this->isVersion($version)) {
         return redirect('docs/' . DEFAULT_VERSION . '/' . $version, 301);
     }
     if (!defined('CURRENT_VERSION')) {
         define('CURRENT_VERSION', $version);
     }
     $sectionPage = $page ?: 'installation';
     $content = $this->docs->get($version, $sectionPage);
     if (is_null($content)) {
         abort(404);
     }
     $title = (new Crawler($content))->filterXPath('//h1');
     $section = '';
     if ($this->docs->sectionExists($version, $page)) {
         $section .= '/' . $page;
     } elseif (!is_null($page)) {
         return redirect('/docs/' . $version);
     }
     $canonical = null;
     if ($this->docs->sectionExists(DEFAULT_VERSION, $sectionPage)) {
         $canonical = 'docs/' . DEFAULT_VERSION . '/' . $sectionPage;
     }
     return view('docs', ['title' => count($title) ? $title->text() : null, 'index' => $this->docs->getIndex($version), 'content' => $content, 'currentVersion' => $version, 'versions' => Documentation::getDocVersions(), 'currentSection' => $section, 'canonical' => $canonical]);
 }
 /**
  * Show a documentation page.
  *
  * @param      $version
  * @param null $page
  *
  * @return \Illuminate\Http\Response
  */
 public function show($version, $page = null)
 {
     if (!$this->isVersion($version)) {
         return redirect('docs/' . $this->docs->defaultVersion() . '/' . $version, 301);
     }
     if (!$this->docs->sectionExists($version, $page ?: 'installation')) {
         abort(404);
     }
     $section = '/' . $page;
     $doc = $this->docs->get($version, $page ?: 'installation');
     return view('docs', ['title' => $doc['title'], 'index' => $this->docs->getIndex($version), 'content' => $doc['content'], 'currentVersion' => $version, 'versionTitle' => $this->versionTitle($version), 'versions' => $this->getEnabledVersions(), 'currentSection' => $section]);
 }