Skip to content

Commit

Permalink
feat: reminders implemented (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
akosbalasko authored Jan 22, 2022
1 parent f1afe20 commit 4002952
Show file tree
Hide file tree
Showing 25 changed files with 244 additions and 8 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
![logo](screens/yarle-logo.png)

![Last Commit](https://img.shields.io/github/last-commit/akosbalasko/yarle?style=for-the-badge)
![Version](https://img.shields.io/badge/version-4.5.4-blue?style=for-the-badge)
![Version](https://img.shields.io/badge/version-4.8.0-blue?style=for-the-badge)
[![Documentation](https://img.shields.io/badge/documentation-yes-brightgreen?style=for-the-badge)](https://github.com/akosbalasko/yarle#readme)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green?style=for-the-badge)](https://github.com/akosbalasko/yarle/graphs/commit-activity)
[![License: MIT](https://img.shields.io/github/license/akosbalasko/yarle?style=for-the-badge)](https://github.com/akosbalasko/yarle/blob/master/LICENSE)
Expand Down Expand Up @@ -40,13 +40,13 @@ Yarle is the ultimate converter of Evernote notes to Markdown.

## Binaries:

[Windows](https://github.com/akosbalasko/yarle/releases/download/v4.7.2/yarle-evernote-to-md-4.7.2.Setup.exe)
[Windows](https://github.com/akosbalasko/yarle/releases/download/v4.8.0/yarle-evernote-to-md-4.8.0.Setup.exe)

[Linux (.rpm)](https://github.com/akosbalasko/yarle/releases/download/v4.7.2/yarle-evernote-to-md-4.7.2-1.x86_64.rpm)
[Linux (.rpm)](https://github.com/akosbalasko/yarle/releases/download/v4.8.0/yarle-evernote-to-md-4.8.0-1.x86_64.rpm)

[Debian (.deb)](https://github.com/akosbalasko/yarle/releases/download/v4.7.2/yarle-evernote-to-md_4.7.2_amd64.deb)
[Debian (.deb)](https://github.com/akosbalasko/yarle/releases/download/v4.8.0/yarle-evernote-to-md_4.8.0_amd64.deb)

[Mac](https://github.com/akosbalasko/yarle/releases/download/v4.7.2/yarle-evernote-to-md-darwin-x64-4.7.2.zip)
[Mac](https://github.com/akosbalasko/yarle/releases/download/v4.8.0/yarle-evernote-to-md-darwin-x64-4.8.0.zip)

## Feedback, Appreciation, Donation:
If you have an idea on how to improve the tool or face any problems, feel free to raise an issue, or even contribute!
Expand Down
3 changes: 3 additions & 0 deletions Templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ A custom template file can have any file name and extension.
| Tags | `{tags-block}{tags}{end-tags-block}` | Note tags |
| Content | `{content-block}{content}{end-content-block}` | Note content |
| Date of creation | `{created-at-block}{created-at}{end-created-at-block}` | Creation date of the note |
| Reminder Time | `{reminder-time-block}{reminder-time}{end-reminder-time-block}` | Reminder time of the note |
| Reminder Done Time | `{reminder-done-time-block}{reminder-done-time}{end-reminder-done-time-block}` | Reminder done time of the note |
| Reminder Order | `{reminder-order-block}{reminder-order}{end-reminder-order-block}` | Reminder order of the note |
| Last update | `{updated-at-block}{updated-at}{end-updated-at-block}` | Last updated date of the note |
| Source URL | `{source-url-block}{source-url}{end-source-url-block}` | Source URL from the EN metadata|
| Original Notebook Name | `{notebook-block}{notebook}{end-notebook-block}` | Name of the EN notebook where the note is stored |
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yarle-evernote-to-md",
"version": "4.7.2",
"version": "4.8.0",
"description": "Yet Another Rope Ladder from Evernote",
"keywords": [
"evernote",
Expand Down
3 changes: 3 additions & 0 deletions src/YarleOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export interface YarleOptions {
skipUpdateTime?: boolean;
skipSourceUrl?: boolean;
skipWebClips?: boolean;
skipReminderTime?: boolean;
skipReminderOrder?: boolean;
skipReminderDoneTime?: boolean;
skipTags?: boolean;
useHashTags?: boolean;
outputFormat?: OutputFormat;
Expand Down
3 changes: 3 additions & 0 deletions src/models/MetaData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ export interface MetaData {
location?: string;
linkToOriginal?: string;
notebookName?: string;
reminderTime?: string;
reminderOrder?: string;
reminderDoneTime?: string;
}
3 changes: 3 additions & 0 deletions src/models/NoteData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ export interface NoteData {
linkToOriginal?: string;
notebookName?: string;
internalLinks?: Array<InternalLink>;
reminderTime?: string;
reminderDoneTime?: string;
reminderOrder?: string;
}
30 changes: 29 additions & 1 deletion src/utils/content-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { utimes } from 'utimes';

import { yarleOptions } from './../yarle';
import { MetaData } from './../models/MetaData';
import { NoteData, TagSeparatorReplaceOptions } from './../models';
import { NoteData } from './../models';
import { getHtmlFileLink } from './folder-utils';

export const getMetadata = (note: any, notebookName: string): MetaData => {
Expand All @@ -15,6 +15,9 @@ export const getMetadata = (note: any, notebookName: string): MetaData => {
sourceUrl: getSourceUrl(note),
location: getLatLong(note),
linkToOriginal: getLinkToOriginal(note),
reminderTime: getReminderTime(note),
reminderOrder: getReminderOrder(note),
reminderDoneTime: getReminderDoneTime(note),
notebookName,
};
};
Expand Down Expand Up @@ -54,6 +57,31 @@ export const getLatLong = (note: any): string => {
? `${note['note-attributes'].latitude},${note['note-attributes'].longitude}`
: undefined;
};
export const getReminderTime = (note: any): string => {
return !yarleOptions.skipReminderTime &&
note['note-attributes'] &&
note['note-attributes']['reminder-time']
? Moment(note['note-attributes']['reminder-time']).format(yarleOptions.dateFormat)
: undefined;
};
export const getReminderOrder = (note: any): string => {
return !yarleOptions.skipReminderOrder &&
note['note-attributes'] &&
note['note-attributes']['reminder-order']
? note['note-attributes']['reminder-order']
: undefined;
};
export const getReminderDoneTime = (note: any): string => {
return !yarleOptions.skipReminderDoneTime &&
note['note-attributes'] &&
note['note-attributes']['reminder-done-time']
? Moment(note['note-attributes']['reminder-done-time']).format(yarleOptions.dateFormat)
: undefined;
};
/*
<reminder-order>
<reminder-time>
<reminder-done-time> */
export const getTags = (note: any): NoteData => {
return {tags: logTags(note)};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { NoteData } from '../../../models/NoteData';
import * as P from '../placeholders/reminderdonetime-placeholders';

import { applyConditionalTemplate } from './apply-conditional-template';

export const applyReminderDoneTimeTemplate = (noteData: NoteData, text: string): string => {
return applyConditionalTemplate(text, P, noteData.reminderDoneTime);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { NoteData } from '../../../models/NoteData';
import * as P from '../placeholders/reminderorder-placeholders';

import { applyConditionalTemplate } from './apply-conditional-template';

export const applyReminderOrderTemplate = (noteData: NoteData, text: string): string => {
return applyConditionalTemplate(text, P, noteData.reminderOrder);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { NoteData } from '../../../models/NoteData';
import * as P from '../placeholders/remindertime-placeholders';

import { applyConditionalTemplate } from './apply-conditional-template';

export const applyReminderTimeTemplate = (noteData: NoteData, text: string): string => {
return applyConditionalTemplate(text, P, noteData.reminderTime);
};
3 changes: 3 additions & 0 deletions src/utils/templates/apply-functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ export * from './apply-sourceurl-template';
export * from './apply-location-template';
export * from './apply-original-template';
export * from './apply-notebook-template';
export * from './apply-remindertime-template';
export * from './apply-reminderorder-template';
export * from './apply-reminderdonetime-template';
14 changes: 14 additions & 0 deletions src/utils/templates/checker-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,25 @@ import * as SOURCEURL from './placeholders/sourceurl-placeholders';
import * as TAGS from './placeholders/tags-placeholders';
import * as METADATA from './placeholders/metadata-placeholders';
import * as UPDATETIME from './placeholders/updatedat-placeholders';
import * as REMINDERTIME from './placeholders/remindertime-placeholders';
import * as REMINDERDONETIME from './placeholders/reminderdonetime-placeholders';
import * as REMINDERORDER from './placeholders/reminderorder-placeholders';

export const hasCreationTimeInTemplate = (templateContent: string): boolean => {
return hasItemInTemplate(CREATIONTIME, templateContent);
};

export const hasReminderTimeInTemplate = (templateContent: string): boolean => {
return hasItemInTemplate(REMINDERTIME, templateContent);
};
export const hasReminderDoneTimeInTemplate = (templateContent: string): boolean => {
return hasItemInTemplate(REMINDERDONETIME, templateContent);

};
export const hasReminderOrderInTemplate = (templateContent: string): boolean => {
return hasItemInTemplate(REMINDERORDER, templateContent);
};

export const hasLocationInTemplate = (templateContent: string): boolean => {
return hasItemInTemplate(LOCATION, templateContent);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const CONTENT_PLACEHOLDER = '{reminder-done-time}';
export const START_BLOCK = '{reminder-done-time-block}';
export const END_BLOCK = '{end-reminder-done-time-block}';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const CONTENT_PLACEHOLDER = '{reminder-order}';
export const START_BLOCK = '{reminder-order-block}';
export const END_BLOCK = '{end-reminder-order-block}';
3 changes: 3 additions & 0 deletions src/utils/templates/placeholders/remindertime-placeholders.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const CONTENT_PLACEHOLDER = '{reminder-time}';
export const START_BLOCK = '{reminder-time-block}';
export const END_BLOCK = '{end-reminder-time-block}';
3 changes: 3 additions & 0 deletions src/utils/templates/remove-functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ export * from './remove-notebook-placeholder';
export * from './remove-metadataBlock-placeholder';
export * from './remove-location-placeholder';
export * from './remove-link-to-original-placeholder';
export * from './remove-remindertime-placeholder';
export * from './remove-reminderdonetime-placeholder';
export * from './remove-reminderorder-placeholder';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { EOL } from 'os';

import * as T from '../placeholders/reminderdonetime-placeholders';

import { removePlaceholder } from './remove-placeholder';

export const removeReminderDoneTimePlaceholder = (text: string): string => {
return removePlaceholder(text, T);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { EOL } from 'os';

import * as T from '../placeholders/reminderorder-placeholders';

import { removePlaceholder } from './remove-placeholder';

export const removeReminderOrderPlaceholder = (text: string): string => {
return removePlaceholder(text, T);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { EOL } from 'os';

import * as T from '../placeholders/remindertime-placeholders';

import { removePlaceholder } from './remove-placeholder';

export const removeReminderTimePlaceholder = (text: string): string => {
return removePlaceholder(text, T);
};
18 changes: 18 additions & 0 deletions src/utils/templates/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
applyLinkToOriginalTemplate,
applyLocationTemplate,
applyNotebookTemplate,
applyReminderDoneTimeTemplate,
applyReminderOrderTemplate,
applyReminderTimeTemplate,
applySourceUrlTemplate,
applyTagsTemplate,
applyTitleTemplate,
Expand All @@ -23,6 +26,9 @@ import {
removeLocationPlaceholder,
removeMetadataBlockPlaceholder,
removeNotebookPlaceholder,
removeReminderDoneTimePlaceholder,
removeReminderOrderPlaceholder,
removeReminderTimePlaceholder,
removeSourceUrlPlaceholder,
removeUpdatedAtPlaceholder,
} from './remove-functions';
Expand Down Expand Up @@ -59,6 +65,18 @@ export const applyTemplate = (noteData: NoteData, yarleOptions: YarleOptions) =>
? applyNotebookTemplate(noteData, result)
: removeNotebookPlaceholder(result);

result = (!yarleOptions.skipReminderTime && noteData.reminderTime)
? applyReminderTimeTemplate(noteData, result)
: removeReminderTimePlaceholder(result);

result = (!yarleOptions.skipReminderOrder && noteData.reminderOrder)
? applyReminderOrderTemplate(noteData, result)
: removeReminderOrderPlaceholder(result);

result = (!yarleOptions.skipReminderDoneTime && noteData.reminderDoneTime)
? applyReminderDoneTimeTemplate(noteData, result)
: removeReminderDoneTimePlaceholder(result);

result = result.replace(T.START_BLOCK, '')
.replace(T.END_BLOCK, '');

Expand Down
13 changes: 13 additions & 0 deletions test/data/reminder_template.templ
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{title-block}# {title}{end-title-block}
{tags-block}
---
Tag(s): {tags}

---
{end-tags-block}
{content-block}{content}{end-content-block}


{reminder-time-block} Reminder: {reminder-time}{end-reminder-time-block}
{reminder-done-time-block} Reminder Done: {reminder-done-time}{end-reminder-done-time-block}
{reminder-order-block} Reminder Order: {reminder-order}{end-reminder-order-block}
8 changes: 8 additions & 0 deletions test/data/test - reminders title.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# reminders title




Reminder: 2022-01-20T07:00:00+00:00
Reminder Done: 2022-01-19T20:01:23+00:00
Reminder Order: 1642621213000
48 changes: 48 additions & 0 deletions test/data/test-reminder.enex
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export3.dtd">
<en-export export-date="20220119T200151Z" application="Evernote" version="Evernote Mac 7.14 (458244)">
<note>
<title>
reminders title
</title>
<content>
<![CDATA[
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
<en-note/>
]]>
</content>
<created>
20220119T193959Z
</created>
<updated>
20220119T194008Z
</updated>
<note-attributes>
<latitude>
47.625
</latitude>
<longitude>
19.1387093306179
</longitude>
<altitude>
126.2126541137695
</altitude>
<author>
akos
</author>
<source>
desktop.mac
</source>
<reminder-order>
1642621213000
</reminder-order>
<reminder-time>
20220120T070000Z
</reminder-time>
<reminder-done-time>
20220119T200123Z
</reminder-done-time>
</note-attributes>
</note>
</en-export>
29 changes: 29 additions & 0 deletions test/yarle-special-cases.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,35 @@ describe('Yarle special cases', async () => {
true,
);
});

it('Enex file with reminder', async () => {
const options: YarleOptions = {
enexSources: [ `${testDataFolder}test-reminder.enex` ],
outputDir: 'out',
isMetadataNeeded: true,
plainTextNotesOnly: false,
skipReminderTime: false,
skipReminderOrder: false,
skipReminderDoneTime: false,
templateFile: `${testDataFolder}reminder_template.templ`,

};
await yarle.dropTheRope(options);

assert.equal(
fs.existsSync(
`${__dirname}/../out/notes/test-reminder/reminders title.md`,
),
true,
);
assert.equal(
eol.auto(fs.readFileSync(
`${__dirname}/../out/notes/test-reminder/reminders title.md`,
'utf8',
)),
fs.readFileSync(`${__dirname}/data/test - reminders title.md`, 'utf8'),
);
});
it('Enex file obsidian style', async () => {
const options: YarleOptions = {
enexSources: [ `${testDataFolder}test-twoNotes.enex` ],
Expand Down

0 comments on commit 4002952

Please sign in to comment.