Skip to content

Commit

Permalink
Added function to shorten links longer than 40 characters. Added proo…
Browse files Browse the repository at this point in the history
…f of concept for human friendly dates in the UI (#609). Added a setting, which helps to hide todos by prepending a prefix to the beginning of the line (#660).
  • Loading branch information
ransome1 committed Feb 11, 2024
1 parent e98cd7e commit df5f663
Show file tree
Hide file tree
Showing 29 changed files with 94 additions and 49 deletions.
4 changes: 1 addition & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ labels: 'feature request'
## Feature Request

### Important ###
Please follow this template strictly when requesting features.

Reports that do not adhere to this template will not be addressed and will be closed.
Requests that do not adhere to this template will not be addressed and will be closed.

If your feature request is more of a **loose idea** and you are **unsure about its implementation or potential impact**, please discuss it first in the [GitHub Discussions section](https://github.com/ransome1/sleek/discussions).

Expand Down
2 changes: 0 additions & 2 deletions assets/mas/entitlements.mas.plist
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
</array>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.files.bookmarks.document-scope</key>
Expand Down
2 changes: 1 addition & 1 deletion flatpak/com.github.ransome1.sleek.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<developer_name>Robin Ahle</developer_name>
<content_rating type="oars-1.1"/>
<releases>
<release version="2.0.9" date="2024-02-09"/>
<release version="2.0.10-rc.1" date="2024-02-11"/>
</releases>
<url type="homepage">https://github.com/ransome1/sleek</url>
<url type="contact">https://github.com/ransome1/sleek/issues</url>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sleek",
"version": "2.0.9",
"version": "2.0.10-rc.1",
"main": "./src/main/main.tsx",
"scripts": {
"build": "concurrently \"yarn run peggy\" \"yarn run build:main\" \"yarn run build:renderer\"",
Expand Down Expand Up @@ -147,7 +147,7 @@
"webpack-merge": "^5.9.0"
},
"build": {
"buildVersion": "38",
"buildVersion": "39",
"asar": true,
"asarUnpack": "**\\*.{node,dll}",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sleek",
"version": "2.0.9",
"version": "2.0.10-rc.1",
"description": "todo.txt manager for Linux, Windows and MacOS, free and open-source (FOSS)",
"synopsis": "todo.txt manager for Linux, Windows and MacOS, free and open-source (FOSS)",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: sleek
base: core20
version: "2.0.9"
version: "2.0.10-rc.1"
summary: todo.txt manager for Linux, free and open-source (FOSS)
description: |
sleek is an open-source (FOSS) todo manager based on the todo.txt syntax. Stripped down to only the most necessary features, and with a clean and simple interface, sleek aims to help you focus on getting things done.
Expand Down
28 changes: 14 additions & 14 deletions src/__tests__/__mock__/recurrence.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

2024-02-09 Line 1 rec:1d due:2024-02-10
2024-02-09 Line 1 rec:w due:2024-02-16
2024-02-09 Line 1 rec:2m due:2024-04-09
2024-02-09 Line 1 rec:+1d due:2024-02-11
2024-02-09 Line 1 rec:7w due:2024-03-29
2024-02-09 Line 1 due:2023-07-24 rec:+1b
2024-02-09 taxes are due in one year t:2022-03-30 due:2022-04-30 rec:+1y
2024-02-09 Water plants @home +quick due:2024-02-16 t:2024-02-06 rec:1w
2024-02-09 Line 1 rec:+1d t:2023-09-20
2024-02-09 Line 1 rec:1d pri:A due:2024-02-10
2024-02-09 (A) Do something rec:d t:2024-02-10 @SomeContext
2024-02-09 Do something rec:0d
2024-02-09 Do something rec:0d due:2024-02-09
2024-02-09 Do something rec:0d due:2024-02-09 t:2024-02-09
2024-02-11 Line 1 rec:1d due:2024-02-12
2024-02-11 Line 1 rec:w due:2024-02-18
2024-02-11 Line 1 rec:2m due:2024-04-11
2024-02-11 Line 1 rec:+1d due:2024-02-13
2024-02-11 Line 1 rec:7w due:2024-03-31
2024-02-11 Line 1 due:2023-07-24 rec:+1b
2024-02-11 taxes are due in one year t:2022-03-30 due:2022-04-30 rec:+1y
2024-02-11 Water plants @home +quick due:2024-02-18 t:2024-02-08 rec:1w
2024-02-11 Line 1 rec:+1d t:2023-09-20
2024-02-11 Line 1 rec:1d pri:A due:2024-02-12
2024-02-11 (A) Do something rec:d t:2024-02-12 @SomeContext
2024-02-11 Do something rec:0d
2024-02-11 Do something rec:0d due:2024-02-11
2024-02-11 Do something rec:0d due:2024-02-11 t:2024-02-11
1 change: 1 addition & 0 deletions src/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"settings.matomo": "Povolit analýzu Matomo",
"settings.zoom": "Přiblížení",
"settings.disableAnimations": "Vypnout animace",
"settings.useHumanFriendlyDates": "Používat lidsky přívětivá data",
"drawer.tabs.attributes": "Atributy",
"drawer.tabs.filters": "Filtry",
"drawer.tabs.sorting": "Řazení",
Expand Down
1 change: 1 addition & 0 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"settings.matomo": "Matomo-Analyse zulassen",
"settings.zoom": "Vergrößerung",
"settings.disableAnimations": "Animationen deaktivieren",
"settings.useHumanFriendlyDates": "Benutze benutzerfreundliche Datumsangaben",
"drawer.tabs.attributes": "Attribute",
"drawer.tabs.filters": "Filter",
"drawer.tabs.sorting": "Sortierung",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en-gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"settings.matomo": "Allow Matomo analytics",
"settings.zoom": "Zoom",
"settings.disableAnimations": "Disable animations",
"settings.useHumanFriendlyDates": "Use human friendly dates",
"drawer.tabs.attributes": "Attributes",
"drawer.tabs.filters": "Filters",
"drawer.tabs.sorting": "Sorting",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"settings.matomo": "Allow Matomo analytics",
"settings.zoom": "Zoom",
"settings.disableAnimations": "Disable animations",
"settings.useHumanFriendlyDates": "Use human friendly dates",
"drawer.tabs.attributes": "Attributes",
"drawer.tabs.filters": "Filters",
"drawer.tabs.sorting": "Sorting",
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"settings.matomo": "Autoriser l'analyse Matomo",
"settings.zoom": "Zoom",
"settings.disableAnimations": "Désactiver les animations",
"settings.useHumanFriendlyDates": "Utiliser des dates conviviales",
"drawer.tabs.attributes": "Attributs",
"drawer.tabs.filters": "Filtres",
"drawer.tabs.sorting": "Tri",
Expand Down
1 change: 1 addition & 0 deletions src/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"settings.matomo": "मैटोमो विश्लेषण की अनुमति दें",
"settings.zoom": "ज़ूम",
"settings.disableAnimations": "एनिमेशन अक्षम करें",
"settings.useHumanFriendlyDates": "मानव-मित्रता योग्य तिथियाँ उपयोग करें",
"drawer.tabs.attributes": "गुण",
"drawer.tabs.filters": "फ़िल्टर",
"drawer.tabs.sorting": "क्रमबद्ध करना",
Expand Down
1 change: 1 addition & 0 deletions src/locales/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"settings.matomo": "Matomo analitika engedélyezése",
"settings.zoom": "Nagyítás",
"settings.disableAnimations": "Animációk kikapcsolása",
"settings.useHumanFriendlyDates": "Használjon emberbarát dátumokat",
"drawer.tabs.attributes": "Tulajdonságok",
"drawer.tabs.filters": "Szűrők",
"drawer.tabs.sorting": "Rendezés",
Expand Down
1 change: 1 addition & 0 deletions src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"settings.matomo": "Consenti analisi Matomo",
"settings.zoom": "Zoom",
"settings.disableAnimations": "Disattiva animazioni",
"settings.useHumanFriendlyDates": "Usa date user-friendly",
"drawer.tabs.attributes": "Attributi",
"drawer.tabs.filters": "Filtri",
"drawer.tabs.sorting": "Ordinamento",
Expand Down
1 change: 1 addition & 0 deletions src/locales/jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"settings.matomo": "Matomoアナリティクスを許可する",
"settings.zoom": "ズーム",
"settings.disableAnimations": "アニメーションを無効にする",
"settings.useHumanFriendlyDates": "使いやすい日付を使用する",
"drawer.tabs.attributes": "属性",
"drawer.tabs.filters": "フィルター",
"drawer.tabs.sorting": "ソート",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"settings.matomo": "Matomo 분석 허용",
"settings.zoom": "",
"settings.disableAnimations": "애니메이션 비활성화",
"settings.useHumanFriendlyDates": "사용자 친화적인 날짜 사용",
"drawer.tabs.attributes": "속성",
"drawer.tabs.filters": "필터",
"drawer.tabs.sorting": "정렬",
Expand Down
1 change: 1 addition & 0 deletions src/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"settings.matomo": "Zezwalaj na analizy Matomo",
"settings.zoom": "Powiększenie",
"settings.disableAnimations": "Wyłącz animacje",
"settings.useHumanFriendlyDates": "Używaj przyjaznych dla użytkownika dat",
"drawer.tabs.attributes": "Atrybuty",
"drawer.tabs.filters": "Filtry",
"drawer.tabs.sorting": "Sortowanie",
Expand Down
1 change: 1 addition & 0 deletions src/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"settings.matomo": "Permitir análise do Matomo",
"settings.zoom": "Zoom",
"settings.disableAnimations": "Desativar animações",
"settings.useHumanFriendlyDates": "Usar datas amigáveis",
"drawer.tabs.attributes": "Atributos",
"drawer.tabs.filters": "Filtros",
"drawer.tabs.sorting": "Ordenação",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"settings.matomo": "Разрешить аналитику Matomo",
"settings.zoom": "Масштаб",
"settings.disableAnimations": "Отключить анимации",
"settings.useHumanFriendlyDates": "Использовать удобочитаемые даты",
"drawer.tabs.attributes": "Атрибуты",
"drawer.tabs.filters": "Фильтры",
"drawer.tabs.sorting": "Сортировка",
Expand Down
1 change: 1 addition & 0 deletions src/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"settings.matomo": "Matomo analitiğine izin ver",
"settings.zoom": "Yakınlaştırma",
"settings.disableAnimations": "Animasyonları devre dışı bırak",
"settings.useHumanFriendlyDates": "İnsan dostu tarihleri kullan",
"drawer.tabs.attributes": "Özellikler",
"drawer.tabs.filters": "Filtreler",
"drawer.tabs.sorting": "Sıralama",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"settings.matomo": "允许Matomo分析",
"settings.zoom": "缩放",
"settings.disableAnimations": "禁用动画",
"settings.useHumanFriendlyDates": "使用人性化日期",
"drawer.tabs.attributes": "属性",
"drawer.tabs.filters": "过滤器",
"drawer.tabs.sorting": "排序",
Expand Down
13 changes: 5 additions & 8 deletions src/main/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ const config: Store<Settings> = new Store<Settings>({
store.set('bulkTodoCreation', false);
store.set('disableAnimations', false);
},
'2.0.10': store => {
console.log('Migrating from 2.0.4 → 2.0.10');
store.set('useHumanFriendlyDates', false);
store.set('excludeLinesWithPrefix', null);
},
}
});

Expand Down Expand Up @@ -118,14 +123,6 @@ filter.onDidChange('attributes', async () => {
}
});

// filter.onDidChange('search', async () => {
// try {
// await processDataRequest(searchString);
// } catch(error: any) {
// console.error(error);
// }
// });

config.onDidAnyChange(async(settings) => {
try {
await processDataRequest(searchString);
Expand Down
17 changes: 13 additions & 4 deletions src/main/modules/ProcessDataRequest/CreateTodoObjects.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { app } from 'electron';
import { Item } from 'jstodotxt';
import { config } from '../../config';
import { handleNotification } from '../Notifications';
import { extractSpeakingDates } from '../Date';
import dayjs from 'dayjs';
Expand Down Expand Up @@ -72,13 +73,21 @@ async function createTodoObjects(fileContent: string | null): Promise<TodoObject
badge.count = 0;
lines = fileContent.split(/[\r\n]+/).filter(line => line.trim() !== '');

const todoObjects: TodoObject[] = await Promise.all(lines.map((line, i) => {
const todoObject: TodoObject = createTodoObject(i, line);
if(todoObject.body && !todoObject.complete) {
const todoObjects: TodoObject[] = await Promise.all(lines.map(async (line, i) => {

const excludeLinesWithPrefix: string = config.get('excludeLinesWithPrefix');
if (line.startsWith(excludeLinesWithPrefix)) {
return null;
}

const todoObject: TodoObject = await createTodoObject(i, line);

if (todoObject.body && !todoObject.complete) {
handleNotification(todoObject.due, todoObject.body, badge);
}

return todoObject;
}));
})).then((objects) => objects.filter(Boolean) as TodoObject[]);

app.setBadgeCount(badge.count);

Expand Down
13 changes: 11 additions & 2 deletions src/renderer/Drawer/Attributes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import AirIcon from '@mui/icons-material/Air';
import { handleFilterSelect } from '../Shared';
import { withTranslation, WithTranslation } from 'react-i18next';
import { i18n } from '../Settings/LanguageSelector';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import duration from 'dayjs/plugin/duration';
import './Attributes.scss';

const { store } = window.api;
Expand All @@ -33,6 +36,12 @@ const DrawerAttributes: React.FC<DrawerAttributesProps> = memo(({
const firstTabbableElementRef = useRef<HTMLDivElement | null>(null);
const [hovered, setHovered] = useState<string | null>(null);

if(settings.useHumanFriendlyDates) {
dayjs.locale(settings.language);
dayjs.extend(relativeTime);
dayjs.extend(duration);
}

const isAttributesEmpty = (attributes: Attributes | null) => {
return !attributes || Object.values(attributes).every((attribute) => !Object.keys(attribute).length);
};
Expand Down Expand Up @@ -77,6 +86,7 @@ const DrawerAttributes: React.FC<DrawerAttributesProps> = memo(({
const selected = filters && filters[key]?.some((filter: any) => filter.value === value);
const disabled = attributes[key][value].count === 0 || !attributes[key][value].visible;
const notify = (key === 'due') ? attributes[key][value].notify : false;
const friendlyDate = settings.useHumanFriendlyDates && dayjs(value).isValid() ? dayjs(value).fromNow() : null;

return (
<div
Expand Down Expand Up @@ -115,7 +125,7 @@ const DrawerAttributes: React.FC<DrawerAttributesProps> = memo(({
}
disabled={disabled}
>
{value}
{(friendlyDate) ? friendlyDate : value}
</Button>
</Badge>
{(excluded) && (
Expand All @@ -132,7 +142,6 @@ const DrawerAttributes: React.FC<DrawerAttributesProps> = memo(({
</div>
);
})}

</AccordionDetails>
</Accordion>
) : null
Expand Down
11 changes: 10 additions & 1 deletion src/renderer/Grid/DatePickerInline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Chip from '@mui/material/Chip';
import Badge from '@mui/material/Badge';
import { handleFilterSelect } from '../Shared';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import duration from 'dayjs/plugin/duration';

const { ipcRenderer } = window.api;

Expand All @@ -27,6 +29,12 @@ const DatePickerInline: React.FC<Props> = ({
const [open, setOpen] = useState(false);
const chipText = type === 'due' ? "due:" : type === 't' ? "t:" : null;

if(settings.useHumanFriendlyDates) {
dayjs.locale(settings.language);
dayjs.extend(relativeTime);
dayjs.extend(duration);
}

const handleChange = (date: dayjs.Dayjs | null) => {
try {
ipcRenderer.send('writeTodoToFile', todoObject.id, todoObject.string, false, type, dayjs(date).format('YYYY-MM-DD'));
Expand All @@ -51,6 +59,7 @@ const DatePickerInline: React.FC<Props> = ({
const ButtonField = ({ ...props }) => {
const { disabled, InputProps: { ref } = {}, inputProps: { 'aria-label': ariaLabel } = {} } = props;
const mustNotify = (type === 'due') ? !todoObject?.notify : true;
const friendlyDate = settings.useHumanFriendlyDates ? dayjs(date).fromNow() : null;
return (
<Button id={props.id} disabled={disabled} ref={ref} aria-label={ariaLabel} tabIndex={-1}>
<Badge variant="dot" invisible={mustNotify}>
Expand All @@ -66,7 +75,7 @@ const DatePickerInline: React.FC<Props> = ({
data-testid={`datagrid-picker-date-${type}`}
tabIndex={0}
>
{date}
{(friendlyDate) ? friendlyDate : date}
</div>
</Badge>
</Button>
Expand Down
25 changes: 16 additions & 9 deletions src/renderer/Grid/Renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm'
import Button from '@mui/material/Button';
import Chip from '@mui/material/Chip';
import Tooltip from '@mui/material/Tooltip';
import { ReactComponent as TomatoIconDuo } from '../../../assets/icons/tomato-duo.svg';
import DatePickerInline from './DatePickerInline';
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
Expand Down Expand Up @@ -90,15 +91,21 @@ const RendererComponent = ({ todoObject, filters, settings, handleButtonClick })
return modifiedChildren;
},
a: ({ children, href }) => {
const match = /([a-zA-Z]+:\/\/\S+)/g.exec(children);
if (match) {
return (
<a onClick={(event) => handleLinkClick(event, children)}>
{children}<OpenInNewIcon />
</a>
);
}
return <a onClick={(event) => handleLinkClick(event, href)}>{children}<OpenInNewIcon /></a>;
const match = /([a-zA-Z]+:\/\/\S+)/g.exec(children);
const maxChars = 40;
const truncatedChildren = children.length > maxChars ? children.slice(0, maxChars) + '...' : children;

const link = (
<a onClick={(event) => handleLinkClick(event, match ? children : href)}>
{truncatedChildren}<OpenInNewIcon />
</a>
);

return children.length > maxChars ? (
<Tooltip title={children} arrow>
{link}
</Tooltip>
) : link;
},
};

Expand Down

0 comments on commit df5f663

Please sign in to comment.