feat: tag bookmarks and sites, and browse the library by tag
This commit is contained in:
parent
5cd053c8a9
commit
b0b86ef5b1
13 changed files with 445 additions and 21 deletions
|
|
@ -3,6 +3,7 @@ import '../../l10n/strings.dart';
|
|||
import '../../mews/document.dart';
|
||||
import 'mews_urls.dart';
|
||||
import 'page_blocks.dart';
|
||||
import 'tags_page.dart';
|
||||
|
||||
Future<MewsPage> buildBookmarksPage(
|
||||
Uri url, {
|
||||
|
|
@ -10,7 +11,10 @@ Future<MewsPage> buildBookmarksPage(
|
|||
required Strings strings,
|
||||
}) async {
|
||||
final query = url.queryParameters['q'] ?? '';
|
||||
final bookmarks = await db.bookmarksByDate(query: query);
|
||||
final tag = url.queryParameters['tag'];
|
||||
final bookmarks = await db.bookmarksByDate(query: query, tag: tag);
|
||||
final tags = await db.tagsOfMany(
|
||||
TagKind.bookmark, bookmarks.map((b) => b.url).toList());
|
||||
final title = strings.t('bookmarks-title');
|
||||
|
||||
return internalPage(
|
||||
|
|
@ -18,16 +22,30 @@ Future<MewsPage> buildBookmarksPage(
|
|||
title: title,
|
||||
body: [
|
||||
...chrome(title: title, current: url, strings: strings),
|
||||
searchForm(
|
||||
textForm(
|
||||
action: MewsUrls.bookmarks,
|
||||
label: strings.t('bookmarks-search-label'),
|
||||
submitLabel: strings.t('action-search'),
|
||||
query: query,
|
||||
field: 'q',
|
||||
value: query,
|
||||
),
|
||||
if (query.isNotEmpty)
|
||||
ParagraphBlock([
|
||||
ParagraphBlock([
|
||||
if (query.isNotEmpty) ...[
|
||||
MewsLink(MewsUrls.page(url, {'q': null}),
|
||||
[MewsText(strings.t('action-clear-search'))]),
|
||||
const MewsText(actionSeparator),
|
||||
],
|
||||
if (tag != null && tag.isNotEmpty) ...[
|
||||
MewsLink(MewsUrls.page(url, {'tag': null}),
|
||||
[MewsText(strings.t('bookmarks-show-all'))]),
|
||||
const MewsText(actionSeparator),
|
||||
],
|
||||
MewsLink(MewsUrls.tags, [MewsText(strings.t('nav-tags'))]),
|
||||
]),
|
||||
if (tag != null && tag.isNotEmpty)
|
||||
ParagraphBlock([
|
||||
MewsEmphasis(EmphasisStyle.emphasis,
|
||||
[MewsText(strings.t('bookmarks-tagged', {'tag': tag}))]),
|
||||
]),
|
||||
if (bookmarks.isEmpty)
|
||||
ParagraphBlock([
|
||||
|
|
@ -41,10 +59,16 @@ Future<MewsPage> buildBookmarksPage(
|
|||
href: bookmark.url,
|
||||
label: bookmark.title ?? bookmark.url,
|
||||
date: dayText(bookmark.createdAt),
|
||||
chips: [
|
||||
for (final tag in tags[bookmark.url] ?? const <String>[])
|
||||
action(MewsUrls.page(url, {'tag': tag, 'q': null}), tag),
|
||||
],
|
||||
actions: [
|
||||
action(
|
||||
MewsUrls.action('remove-bookmark', {'url': bookmark.url}),
|
||||
strings.t('action-remove-bookmark')),
|
||||
action(tagsOfItemUrl(TagKind.bookmark, bookmark.url),
|
||||
strings.t('action-edit-tags')),
|
||||
],
|
||||
),
|
||||
]),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue