Skip to content

Commit

Permalink
- Adjusted Blade Component Namespace & Adding missing start date rend…
Browse files Browse the repository at this point in the history
…ering option

Signed-off-by: Martin Niehoff <info@martin-niehoff.de>
  • Loading branch information
swatty007 committed Feb 22, 2021
1 parent 65bb532 commit aac0f16
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ It contains some optional configuration parameters and is fully documented.
## Usage
Simply add the following component to the desired location of your view:
```php
<x-versioning-helper::build-string></x-versioning-helper::build-string>
<x-versioning-helper-build-string></x-versioning-helper-build-string>
```
to display the full versioning information of your application, containing:
- Application Name
Expand All @@ -44,9 +44,9 @@ to display the full versioning information of your application, containing:
![Package Banner](./docs/blade-view.PNG "Package Banner")

Alternatively you can also the following components separately, to display only a part of those information:
- x-versioning-helper::application-name
- x-versioning-helper::copyright
- x-versioning-helper::version
- x-versioning-helper-application-name
- x-versioning-helper-copyright
- x-versioning-helper-version

You can simply specify the current version of your application through our config file,
or through a user definable Cache variable, which can be set/updated via our fully documented versioning artisan command.
Expand Down
6 changes: 3 additions & 3 deletions resources/views/components/build-string.blade.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<div>
<p {{ $attributes->merge(['class' => 'text-center text-xs text-80']) }}>

<x-versioning-helper-application-name :linkClasses="$linkClasses"></x-versioning-helper::application-name>
<x-versioning-helper-application-name :linkClasses="$linkClasses"></x-versioning-helper-application-name>

<span class="px-1">&middot;</span>
<x-versioning-helper-copyright :linkClasses="$linkClasses"></x-versioning-helper::copyright>
<x-versioning-helper-copyright :linkClasses="$linkClasses"></x-versioning-helper-copyright>

<span class="px-1">&middot;</span>
<x-versioning-helper-version :linkClasses="$linkClasses"></x-versioning-helper::version>
<x-versioning-helper-version :linkClasses="$linkClasses"></x-versioning-helper-version>

</p>
</div>
2 changes: 1 addition & 1 deletion resources/views/components/copyright.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<span>
&copy; {{ $startDate }} - {{ $endDate }} <a href="{{ $authorURL }}" target="_blank" class="{{ $linkClasses ?? 'text-primary dim no-underline' }}">{!! $author !!}</a>
&copy; {{ $dates }} <a href="{{ $authorURL }}" target="_blank" class="{{ $linkClasses ?? 'text-primary dim no-underline' }}">{!! $author !!}</a>
</span>
12 changes: 12 additions & 0 deletions src/Views/Components/Copyright.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ class Copyright extends Component
* @var string
*/
public string $endDate;
/**
* Defines the date string for our copyright notice
*
* @var string
*/
public string $dates;

/**
* Create a new component instance.
Expand All @@ -49,6 +55,12 @@ public function __construct($author = null, $url = null, $startDate = null, $end
$this->authorURL = $url ?? config('laravel-versioning-helper.author_url');
$this->startDate = $startDate ?? config('laravel-versioning-helper.creation_date');
$this->endDate = $endDate ?? date('Y');

if (config('laravel-versioning-helper.show_current_date')) {
$this->dates = "$this->startDate - $this->endDate";
} else {
$this->dates = $this->endDate;
}
}

/**
Expand Down
19 changes: 19 additions & 0 deletions tests/BladeComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Carbon\Carbon;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\View;
use Swatty007\LaravelVersioningHelper\LaravelVersioningHelperServiceProvider;
use Swatty007\LaravelVersioningHelper\Views\Components\ApplicationName;
Expand Down Expand Up @@ -117,6 +118,24 @@ public function copyright_does_render()
);
}

/** @test */
public function copyright_start_date_is_optional()
{
Config::set('laravel-versioning-helper.show_current_date', false);

$expected = <<<HTML
<span>
&copy; 2021 <a href="" target="_blank" class="text-primary dim no-underline">Developed with ❤</a>
</span>
HTML;
$compiled = $this->rendered(Copyright::class);

$this->assertSame(
preg_replace('/\s+/', '', $expected),
preg_replace('/\s+/', '', $compiled)
);
}

/** @test */
public function version_is_loaded()
{
Expand Down

0 comments on commit aac0f16

Please sign in to comment.