Skip to content

Commit

Permalink
Merge branch 'release/1.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
reliq committed Feb 26, 2018
2 parents 9e04f52 + d471ce5 commit 0a2527e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 33 deletions.
15 changes: 11 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"name": "reliqarts/docweaver",
"description": "Highly configurable Laravel 5.x package for product documentation.",
"keywords": ["doc", "package", "generation", "documentation", "laravel5", "content"],
"keywords": [
"doc",
"package",
"generation",
"documentation",
"laravel5",
"content"
],
"type": "library",
"license": "MIT",
"authors": [
Expand All @@ -20,11 +27,11 @@
"monolog/monolog": "~1.11",
"nesbot/carbon": "^1.22.1",
"symfony/browser-kit": "^3.3",
"symfony/process": "^3.3",
"symfony/process": "^3.3|~4.0",
"symfony/yaml": "^3.3"
},
"require-dev": {
"phpunit/phpunit": "^5.6",
"phpunit/phpunit": "^5.6|~7.0",
"orchestra/testbench-browser-kit": "~3.1"
},
"autoload": {
Expand All @@ -45,4 +52,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion resources/views/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<h6 class="dropdown-header">Versions</h6>
@foreach ($currentProduct->getVersions() as $versionTag => $versionName)
@if ($currentVersion != $versionTag)
<a class="dropdown-item" href="{!! route('docs.show', [$currentProduct->key, $versionTag]) !!}">{{ $versionName }}</a>
<a class="dropdown-item" href="{!! route('docs.show', [$currentProduct->key, $versionTag, $page]) !!}">{{ $versionName }}</a>
@endif
@endforeach
</div>
Expand Down
35 changes: 17 additions & 18 deletions src/Http/Controllers/DocumentationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace ReliQArts\Docweaver\Http\Controllers;

use Log;
use Illuminate\View\View;
use Illuminate\Http\RedirectResponse;
use ReliQArts\Docweaver\Models\Product;
use Symfony\Component\DomCrawler\Crawler;
use ReliQArts\Docweaver\Models\Documentation;
Expand Down Expand Up @@ -56,7 +58,7 @@ public function __construct(Documentation $docs)
/**
* Show the documentation home page (docs).
*
* @return Response
* @return RedirectResponse
*/
public function index()
{
Expand All @@ -80,7 +82,7 @@ public function index()
*
* @param string $product
*
* @return Response
* @return RedirectResponse
*/
public function productIndex($productName)
{
Expand All @@ -105,7 +107,7 @@ public function productIndex($productName)
* @param string $version
* @param string|null $page
*
* @return Response
* @return View|RedirectResponse
*/
public function show($productKey, $version, $page = null)
{
Expand All @@ -124,14 +126,12 @@ public function show($productKey, $version, $page = null)
}

// get page content
$sectionPage = $page ?: 'installation';
$content = $this->docs->getPage($product, $version, $sectionPage);
$page = $page ?: 'installation';
$content = $this->docs->getPage($product, $version, $page);

// ensure page has content
if (is_null($content)) {
Log::warning("Documentation page ({$page}) for {$product->getName()} has no content.", [
'product' => $product]
);
Log::warning("Documentation page ({$page}) for {$product->getName()} has no content.", ['product' => $product]);
abort(404);
}

Expand All @@ -148,23 +148,22 @@ public function show($productKey, $version, $page = null)

// set canonical
$canonical = null;
if ($this->docs->sectionExists($product, $defaultVersion, $sectionPage)) {
$canonical = route($routeNames['product_page'], [$product->key, $defaultVersion, $sectionPage]);
if ($this->docs->sectionExists($product, $defaultVersion, $page)) {
$canonical = route($routeNames['product_page'], [$product->key, $defaultVersion, $page]);
}

// dd($version);

return view('docweaver::page', [
'title' => count($title) ? $title->text() : null,
'index' => $this->docs->getIndex($product, $version),
'currentProduct' => $product,
'canonical' => $canonical,
'content' => $content,
'currentProduct' => $product,
'currentSection' => $section,
'currentVersion' => $version,
'index' => $this->docs->getIndex($product, $version),
'page' => $page,
'routeConfig' => $routeConfig,
'title' => count($title) ? $title->text() : null,
'versions' => $product->getVersions(),
'currentSection' => $section,
'canonical' => $canonical,
'viewTemplateInfo' => $this->viewTemplateInfo,
'routeConfig' => $routeConfig,
]);
}
}
20 changes: 10 additions & 10 deletions src/Services/Publisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Exception;
use ReflectionException;
use InvalidArgumentException;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Symfony\Component\Process\Process;
use ReliQArts\Docweaver\Models\Product;
Expand Down Expand Up @@ -57,7 +58,6 @@ class Publisher implements PublisherContract
* Create a new Publisher.
*
* @param Filesystem $files
*
* @return void
*/
public function __construct(Filesystem $files)
Expand Down Expand Up @@ -111,8 +111,8 @@ public function publish($name, $source, &$callingCommand = null)
*
* @param string $dir Product directory.
* @param string $source Git repository.
* @param \Illuminate\Console\Command $callingCommand
* @return void
* @param Command $callingCommand
* @return Result
*/
private function publishVersions($name, $dir, $source, &$callingCommand = null)
{
Expand Down Expand Up @@ -149,12 +149,15 @@ private function publishVersions($name, $dir, $source, &$callingCommand = null)
if ($masterExists) {
$product = empty($product) ? new Product($productDir) : $product;
$product->publishAssets('master');
$tags = [];
// publish the different tags
$listTags = new Process("git tag -l", $masterDir);

try {
$listTags->mustRun();
$tags = array_map('trim', preg_split("/[\n\r]/", $listTags->getOutput()));
if ($splitTags = preg_split("/[\n\r]/", $listTags->getOutput())) {
$tags = array_map('trim', $splitTags);
}
$result->messages = [];

// publish each tag
Expand Down Expand Up @@ -202,8 +205,7 @@ private function publishVersions($name, $dir, $source, &$callingCommand = null)
* Update documentation for a particular product.
*
* @param string $name
* @param \Illuminate\Console\Command $callingCommand
*
* @param Command $callingCommand
* @return Result
*/
public function update($name, &$callingCommand = null)
Expand Down Expand Up @@ -272,7 +274,6 @@ public function updateAll(&$callingCommand = null)
*
* @param Product $product
* @param string $version Version to update.
*
* @return bool
*/
private function updateProductVersion($product, $version)
Expand All @@ -298,8 +299,8 @@ private function updateProductVersion($product, $version)
*
* @param string $name
* @param string $dir Product directory.
* @param \Illuminate\Console\Command $callingCommand
* @return void
* @param Command $callingCommand
* @return Result
*/
private function updateVersions($name, $dir, &$callingCommand = null)
{
Expand Down Expand Up @@ -342,7 +343,6 @@ private function updateVersions($name, $dir, &$callingCommand = null)
* Ensure documentation resource directory exists and is writable.
*
* @param string $dir
*
* @return bool
*/
private function readyResourceDir($dir = null)
Expand Down

0 comments on commit 0a2527e

Please sign in to comment.