Skip to content

Commit

Permalink
feat: Add Additional Information To Bookmarks Page (#17)
Browse files Browse the repository at this point in the history
Adding a localized date string to indicate when a bookmark was added to
an instance.

Adding an option to open a snapshot (if available).
  • Loading branch information
vkhitrin authored Dec 7, 2024
1 parent c7fd984 commit ce6e6b6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion i18n/en/cosmicding.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ no-bookmarks = No bookmarks
no-bookmarks-found-for-account = No bookmarks found for account {$acc}
notes = Notes
open-accounts-page = Open Accounts Page
open-instance = Open instance
open-instance = Open Instance
provided-url-is-not-valid = Provided URL is not valid
quit = Quit
refresh = Refresh
Expand All @@ -58,6 +58,7 @@ setting-managed-externally = This setting can only be managed from Linkding web
settings = Settings
shared = Shared
shared-disabled = Shared (Disabled)
snapshot = Snapshot
successful = successful
tags = Tags
tags-subtext = Enter any number of tags separated by space.
Expand Down
19 changes: 19 additions & 0 deletions src/pages/bookmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::app::Message;
use crate::fl;
use crate::models::account::Account;
use crate::models::bookmarks::Bookmark;
use chrono::{DateTime, Local};
use cosmic::iced::Length;
use cosmic::{
app::command::Task,
Expand Down Expand Up @@ -72,6 +73,8 @@ impl PageBookmarksView {
.iter()
.find(|&account| account.id == item.user_account_id)
.unwrap();
let date_added: DateTime<Local> =
item.date_added.clone().unwrap().parse().expect("");
let mut columns = Vec::new();
// Mandatory first row - title
columns.push(
Expand Down Expand Up @@ -168,6 +171,19 @@ impl PageBookmarksView {
.on_press(AppBookmarksMessage::ViewNotes(item.clone())),
);
}
if !item.web_archive_snapshot_url.is_empty() {
actions_row = actions_row.push(
widget::button::link(fl!("snapshot"))
.spacing(spacing.space_xxxs)
.trailing_icon(true)
.font_size(12)
.icon_size(11)
.tooltip(item.web_archive_snapshot_url.clone())
.on_press(AppBookmarksMessage::OpenExternalURL(
item.web_archive_snapshot_url.clone(),
)),
);
}
columns.push(
actions_row
.padding([
Expand All @@ -180,6 +196,9 @@ impl PageBookmarksView {
);
// Mandatory fifth row - details
let mut details_row = widget::row::with_capacity(1).spacing(spacing.space_xxs);
details_row = details_row
.push(widget::icon::from_name("accessories-clock-symbolic").size(12))
.push(widget::text(date_added.to_rfc2822()).size(12));
if item.is_archived {
details_row = details_row
.push(widget::icon::from_name("mail-archive-symbolic").size(12))
Expand Down

0 comments on commit ce6e6b6

Please sign in to comment.