Skip to content
This repository has been archived by the owner on Oct 10, 2018. It is now read-only.

Commit

Permalink
Merge pull request #12 from kontenta/sections
Browse files Browse the repository at this point in the history
Sections
  • Loading branch information
bjuppa authored Sep 24, 2018
2 parents b738871 + 3daacc9 commit 1513873
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
10 changes: 4 additions & 6 deletions resources/views/layouts/master.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@
<button type="submit">Logout</button>
</form>
</header>
<nav>
<nav data-kontour-section="{{ $view_manager->navSection() }}">
@foreach($widget_manager->getWidgetsForSection($view_manager->navSection()) as $widget)
{{ $widget }}
@endforeach
</nav>
<main>
<!-- Section {{ $view_manager->mainSection() }} -->
<main data-kontour-section="{{ $view_manager->mainSection() }}">
@yield($view_manager->mainSection())
<!-- End section {{ $view_manager->mainSection() }} -->
</main>
<aside>
<section data-kontour-section="{{ $view_manager->widgetSection() }}">
@section($view_manager->widgetSection())
@foreach($widget_manager->getWidgetsForSection($view_manager->widgetSection()) as $widget)
{{ $widget }}
@endforeach
@show
</aside>
</section>
@endsection

@push('styles')
Expand Down
4 changes: 2 additions & 2 deletions src/PersonalRecentVisitsWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public function __construct(RecentVisitsRepository $repository)

public function toHtml()
{
return '<ul>' . $this->getVisits()->map(function ($visit) {
return '<aside data-kontour-widget="PersonalRecentVisitsWidget"><header>Recent</header><ul>' . $this->getVisits()->map(function ($visit) {
return '<li data-kontour-visit-type="' . $visit->getType() . '">' . $visit->getLink()->toHtml() . '</li>';
})->implode("\n") . '</ul>';
})->implode("\n") . '</ul></aside>';
}

public function isAuthorized(Authorizable $user = null): bool
Expand Down
4 changes: 2 additions & 2 deletions src/TeamRecentVisitsWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public function __construct(RecentVisitsRepository $repository)

public function toHtml()
{
return '<ul>' . $this->getVisits()->map(function ($visit) {
return '<aside data-kontour-widget="TeamRecentVisitsWidget"><header>Team Recent</header><ul>' . $this->getVisits()->map(function ($visit) {
return '<li data-kontour-visit-type="' . $visit->getType() . '" data-kontour-username="' . $visit->getUser()->getDisplayName() . '">' . $visit->getLink()->toHtml() . '</li>';
})->implode("\n") . '</ul>';
})->implode("\n") . '</ul></aside>';
}

public function isAuthorized(Authorizable $user = null): bool
Expand Down
6 changes: 6 additions & 0 deletions tests/Feature/UserlandControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,19 @@ public function test_recent_visits_widgets()
$response->assertOk();

// Check personal links
$response->assertSee('<aside data-kontour-widget="PersonalRecentVisitsWidget">');
$response->assertSee('<header>Recent</header>');

$numberOfMatches = substr_count($response->content(), '<li data-kontour-visit-type="show"><a href="' . route('userland.index') . '">Recent Userland Tool</a>');
$this->assertEquals(1, $numberOfMatches);

$numberOfMatches = substr_count($response->content(), '<li data-kontour-visit-type="edit"><a href="' . route('userland.edit') . '">Recent Userland Tool</a>');
$this->assertEquals(1, $numberOfMatches);

// Check team links
$response->assertSee('<aside data-kontour-widget="TeamRecentVisitsWidget">');
$response->assertSee('<header>Team Recent</header>');

$numberOfMatches = substr_count($response->content(), '<li data-kontour-visit-type="edit" data-kontour-username="' . $otherUser->getDisplayName() . '"><a href="' . route('userland.edit') . '">Other Recent Userland Tool</a>');
$this->assertEquals(1, $numberOfMatches);

Expand Down

0 comments on commit 1513873

Please sign in to comment.