Merge pull request #365 from jonnybarnes/develop
MTM Add tagged bookmarks page
This commit is contained in:
commit
14a10472a6
3 changed files with 63 additions and 0 deletions
|
@ -33,4 +33,19 @@ class BookmarksController extends Controller
|
||||||
|
|
||||||
return view('bookmarks.show', compact('bookmark'));
|
return view('bookmarks.show', compact('bookmark'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show bookmakrs tagged with a specific tag.
|
||||||
|
*
|
||||||
|
* @param string $tag
|
||||||
|
* @return View
|
||||||
|
*/
|
||||||
|
public function tagged(string $tag): View
|
||||||
|
{
|
||||||
|
$bookmarks = Bookmark::whereHas('tags', function ($query) use ($tag) {
|
||||||
|
$query->where('tag', $tag);
|
||||||
|
})->latest()->with('tags')->withCount('tags')->paginate(10);
|
||||||
|
|
||||||
|
return view('bookmarks.tagged', compact('bookmarks', 'tag'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
47
resources/views/bookmarks/tagged.blade.php
Normal file
47
resources/views/bookmarks/tagged.blade.php
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
@extends('master')
|
||||||
|
|
||||||
|
@section('title')Bookmarks « @stop
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="h-feed">
|
||||||
|
<h1>Bookmarks tagged with {{ $tag }}</h1>
|
||||||
|
@foreach($bookmarks as $bookmark)
|
||||||
|
<div class="h-entry">
|
||||||
|
<div class="bookmark-link">
|
||||||
|
<a class="u-bookmark-of<?php if ($bookmark->name !== null) { echo ' h-cite'; } ?>" href="{{ $bookmark->url }}">
|
||||||
|
@isset($bookmark->name)
|
||||||
|
{{ $bookmark->name }}
|
||||||
|
@endisset
|
||||||
|
|
||||||
|
@empty($bookmark->name)
|
||||||
|
{{ $bookmark->url }}
|
||||||
|
@endempty
|
||||||
|
</a> <a href="{{ $bookmark->longurl }}">🔗</a>
|
||||||
|
</div>
|
||||||
|
@isset($bookmark->content)
|
||||||
|
<p>{{ $bookmark->content }}</p>
|
||||||
|
@endisset
|
||||||
|
|
||||||
|
@isset($bookmark->screenshot)
|
||||||
|
<img class="screenshot" src="/assets/img/bookmarks/{{ $bookmark->screenshot }}.png">
|
||||||
|
@endisset
|
||||||
|
|
||||||
|
@isset($bookmark->archive)
|
||||||
|
<p><a href="https://web.archive.org{{ $bookmark->archive }}">Internet Archive backup</a></p>
|
||||||
|
@endisset
|
||||||
|
|
||||||
|
@if($bookmark->tags_count > 0)
|
||||||
|
<ul class="tags">
|
||||||
|
@foreach($bookmark->tags as $tag)
|
||||||
|
<li>
|
||||||
|
<a href="/bookmarks/tagged/{{ $tag->tag }}" class="tag">{{ $tag->tag }}</a>
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{ $bookmarks->links() }}
|
||||||
|
@stop
|
|
@ -158,6 +158,7 @@ Route::group(['domain' => config('url.longurl')], function () {
|
||||||
Route::group(['prefix' => 'bookmarks'], function () {
|
Route::group(['prefix' => 'bookmarks'], function () {
|
||||||
Route::get('/', [BookmarksController::class, 'index']);
|
Route::get('/', [BookmarksController::class, 'index']);
|
||||||
Route::get('/{bookmark}', [BookmarksController::class, 'show']);
|
Route::get('/{bookmark}', [BookmarksController::class, 'show']);
|
||||||
|
Route::get('/tagged/{tag}', [BookmarksController::class, 'tagged']);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Token Endpoint
|
// Token Endpoint
|
||||||
|
|
Loading…
Add table
Reference in a new issue