Skip to content

Commit 5b96e4f

Browse files
authored
Add quarterly and yearly notes (#67)
* Add quarterly and yearly notes * Fix icons * bump manifest version
1 parent cd8eb97 commit 5b96e4f

9 files changed

+97
-27
lines changed

manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "periodic-notes",
33
"name": "Periodic Notes",
44
"description": "Create/manage your daily, weekly, and monthly notes",
5-
"version": "0.0.16",
5+
"version": "0.0.17",
66
"author": "Liam Cain",
77
"authorUrl": "https://github.com/liamcain/",
88
"isDesktopOnly": false,

package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-periodic-notes",
3-
"version": "0.0.16",
3+
"version": "0.0.17",
44
"description": "Create/manage daily, weekly, and monthly notes",
55
"author": "liamcain",
66
"main": "main.js",
@@ -13,8 +13,8 @@
1313
},
1414
"dependencies": {
1515
"@popperjs/core": "2.9.1",
16-
"obsidian": "obsidianmd/obsidian-api#master",
17-
"obsidian-daily-notes-interface": "0.9.1",
16+
"obsidian": "0.12.16",
17+
"obsidian-daily-notes-interface": "0.9.4",
1818
"svelte": "3.35.0",
1919
"tslib": "2.1.0"
2020
},
@@ -39,6 +39,9 @@
3939
"ts-jest": "26.5.3",
4040
"typescript": "4.2.3"
4141
},
42+
"resolutions": {
43+
"obsidian": "0.12.16"
44+
},
4245
"jest": {
4346
"moduleNameMapper": {
4447
"src/(.*)": "<rootDir>/src/$1"

src/commands.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@ import { Command, MarkdownView, Notice, TFile } from "obsidian";
33
import {
44
createDailyNote,
55
createMonthlyNote,
6+
createQuarterlyNote,
67
createWeeklyNote,
8+
createYearlyNote,
79
getAllDailyNotes,
810
getAllMonthlyNotes,
11+
getAllQuarterlyNotes,
912
getAllWeeklyNotes,
13+
getAllYearlyNotes,
1014
getDailyNote,
1115
getDateFromFile,
1216
getMonthlyNote,
17+
getQuarterlyNote,
1318
getWeeklyNote,
19+
getYearlyNote,
1420
} from "obsidian-daily-notes-interface";
1521

1622
import type { IPeriodicity } from "src/settings";
1723
import { orderedValues } from "src/utils";
1824

1925
interface IPeriodConfig {
20-
unitOfTime: "day" | "week" | "month";
26+
unitOfTime: "day" | "week" | "month" | "quarter" | "year";
2127
relativeUnit: string;
2228
createNote: (date: Moment) => Promise<TFile>;
2329
getNote: (date: Moment, allFiles: Record<string, TFile>) => TFile;
@@ -46,6 +52,20 @@ export const periodConfigs: Record<IPeriodicity, IPeriodConfig> = {
4652
getNote: getMonthlyNote,
4753
getAllNotes: getAllMonthlyNotes,
4854
},
55+
quarterly: {
56+
unitOfTime: "quarter",
57+
relativeUnit: "this quarter",
58+
createNote: createQuarterlyNote,
59+
getNote: getQuarterlyNote,
60+
getAllNotes: getAllQuarterlyNotes,
61+
},
62+
yearly: {
63+
unitOfTime: "year",
64+
relativeUnit: "this year",
65+
createNote: createYearlyNote,
66+
getNote: getYearlyNote,
67+
getAllNotes: getAllYearlyNotes,
68+
},
4969
};
5070

5171
export async function openPeriodicNote(

src/icons.ts

+14
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,17 @@ export const calendarMonthIcon = `
1919
<path d="M69.6199 77.9516H64.382V56.9112C64.382 54.4 64.4415 52.4089 64.5603 50.9378C64.2186 51.2944 63.7951 51.6882 63.2899 52.1191C62.7995 52.55 61.1353 53.9171 58.2972 56.2202L55.6672 52.8992L65.2513 45.3657H69.6199V77.9516Z" fill="currentColor"/>
2020
</g>
2121
`;
22+
23+
export const calendarQuarterIcon = `
24+
<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
25+
<path d="M24.768 3C22.634 3 20.888 4.746 20.888 6.88V10.76H9.24804C7.21104 10.76 5.36804 12.312 5.36804 14.543V92.628C5.36804 93.695 6.04704 94.859 6.82304 95.344C7.59904 95.926 8.37504 96.12 9.24804 96.12H90.728C91.601 96.12 92.377 95.926 93.153 95.344C93.929 94.762 94.608 93.695 94.608 92.628V14.543C94.608 12.506 92.959 10.76 90.922 10.76H79.088V6.88C79.088 4.746 77.342 3 75.208 3H71.328C69.194 3 67.448 4.746 67.448 6.88V10.76H32.528V6.88C32.528 4.746 30.782 3 28.648 3H24.768ZM24.768 6.88H28.648V18.52H24.768V6.88ZM71.328 6.88H75.208V18.52H71.328V6.88ZM9.24804 14.64H20.888V18.52C20.888 20.654 22.634 22.4 24.768 22.4H28.648C30.782 22.4 32.528 20.654 32.528 18.52V14.64H67.448V18.52C67.448 20.654 69.194 22.4 71.328 22.4H75.208C77.342 22.4 79.088 20.654 79.088 18.52V14.64H90.728V28.22H9.24804V14.64ZM9.24804 32.1H90.728V92.24H9.24804V32.1Z" fill="currentColor" stroke="currentColor" stroke-width="0.17"/>
26+
<path d="M63.2498 61.614C63.2498 65.5665 62.492 68.8949 60.9764 71.5993C59.4756 74.3036 57.2839 76.2056 54.4012 77.3052L62.2022 85.708H55.0253L48.8737 78.3973H48.0044C43.086 78.3973 39.3044 76.9411 36.6595 74.0287C34.0294 71.1015 32.7144 66.9484 32.7144 61.5694C32.7144 56.1904 34.0369 52.0596 36.6818 49.1769C39.3416 46.2943 43.1306 44.853 48.049 44.853C52.893 44.853 56.6375 46.3166 59.2824 49.2438C61.9273 52.171 63.2498 56.2944 63.2498 61.614ZM38.3757 61.614C38.3757 65.6259 39.1855 68.672 40.8052 70.7523C42.4248 72.8177 44.8246 73.8504 48.0044 73.8504C51.1694 73.8504 53.5543 72.8251 55.159 70.7746C56.7787 68.724 57.5885 65.6705 57.5885 61.614C57.5885 57.6169 56.7861 54.5856 55.1813 52.5202C53.5914 50.4548 51.214 49.4221 48.049 49.4221C44.8543 49.4221 42.4397 50.4548 40.8052 52.5202C39.1855 54.5856 38.3757 57.6169 38.3757 61.614Z" fill="currentColor"/>
27+
</svg>
28+
`;
29+
30+
export const calendarYearIcon = `
31+
<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
32+
<path d="M24.768 3C22.634 3 20.888 4.746 20.888 6.88V10.76H9.24804C7.21104 10.76 5.36804 12.312 5.36804 14.543V92.628C5.36804 93.695 6.04704 94.859 6.82304 95.344C7.59904 95.926 8.37504 96.12 9.24804 96.12H90.728C91.601 96.12 92.377 95.926 93.153 95.344C93.929 94.762 94.608 93.695 94.608 92.628V14.543C94.608 12.506 92.959 10.76 90.922 10.76H79.088V6.88C79.088 4.746 77.342 3 75.208 3H71.328C69.194 3 67.448 4.746 67.448 6.88V10.76H32.528V6.88C32.528 4.746 30.782 3 28.648 3H24.768ZM24.768 6.88H28.648V18.52H24.768V6.88ZM71.328 6.88H75.208V18.52H71.328V6.88ZM9.24804 14.64H20.888V18.52C20.888 20.654 22.634 22.4 24.768 22.4H28.648C30.782 22.4 32.528 20.654 32.528 18.52V14.64H67.448V18.52C67.448 20.654 69.194 22.4 71.328 22.4H75.208C77.342 22.4 79.088 20.654 79.088 18.52V14.64H90.728V28.22H9.24804V14.64ZM9.24804 32.1H90.728V92.24H9.24804V32.1Z" fill="currentColor" stroke="currentColor" stroke-width="0.17"/>
33+
<path d="M49.2303 60.2321L56.9421 45.3656H62.7371L51.8826 65.3139V77.9515H46.5333V65.4922L35.7234 45.3656H41.5184L49.2303 60.2321Z" fill="currentColor"/>
34+
</svg>
35+
`;

src/index.ts

+20-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import { addIcon, App, Plugin } from "obsidian";
33

44
import { getCommands, openPeriodicNote, periodConfigs } from "./commands";
55
import { SETTINGS_UPDATED } from "./events";
6-
import { calendarDayIcon, calendarMonthIcon, calendarWeekIcon } from "./icons";
6+
import {
7+
calendarDayIcon,
8+
calendarMonthIcon,
9+
calendarWeekIcon,
10+
calendarQuarterIcon,
11+
calendarYearIcon,
12+
} from "./icons";
713
import { showFileMenu } from "./modal";
814
import {
915
DEFAULT_SETTINGS,
@@ -43,6 +49,8 @@ export default class PeriodicNotesPlugin extends Plugin {
4349
addIcon("calendar-day", calendarDayIcon);
4450
addIcon("calendar-week", calendarWeekIcon);
4551
addIcon("calendar-month", calendarMonthIcon);
52+
addIcon("calendar-quarter", calendarQuarterIcon);
53+
addIcon("calendar-year", calendarYearIcon);
4654
}
4755

4856
onLayoutReady(): void {
@@ -71,9 +79,13 @@ export default class PeriodicNotesPlugin extends Plugin {
7179
private configureRibbonIcons() {
7280
this.ribbonEl?.detach();
7381

74-
const configuredPeriodicities = ["daily", "weekly", "monthly"].filter(
75-
(periodicity) => this.settings[periodicity].enabled
76-
);
82+
const configuredPeriodicities = [
83+
"daily",
84+
"weekly",
85+
"monthly",
86+
"quarterly",
87+
"yearly",
88+
].filter((periodicity) => this.settings[periodicity].enabled);
7789

7890
if (configuredPeriodicities.length) {
7991
const periodicity = configuredPeriodicities[0] as IPeriodicity;
@@ -96,7 +108,7 @@ export default class PeriodicNotesPlugin extends Plugin {
96108

97109
private configureCommands() {
98110
// Remove disabled commands
99-
["daily", "weekly", "monthly"]
111+
["daily", "weekly", "monthly", "quarterly", "yearly"]
100112
.filter((periodicity) => !this.settings[periodicity].enabled)
101113
.forEach((periodicity: IPeriodicity) => {
102114
getCommands(periodicity).forEach((command) =>
@@ -108,7 +120,7 @@ export default class PeriodicNotesPlugin extends Plugin {
108120
});
109121

110122
// register enabled commands
111-
["daily", "weekly", "monthly"]
123+
["daily", "weekly", "monthly", "quarterly", "yearly"]
112124
.filter((periodicity) => this.settings[periodicity].enabled)
113125
.forEach((periodicity: IPeriodicity) => {
114126
getCommands(periodicity).forEach(this.addCommand.bind(this));
@@ -132,6 +144,8 @@ export default class PeriodicNotesPlugin extends Plugin {
132144
daily: { ...DEFAULT_SETTINGS },
133145
weekly: { ...DEFAULT_SETTINGS },
134146
monthly: { ...DEFAULT_SETTINGS },
147+
quarterly: { ...DEFAULT_SETTINGS },
148+
yearly: { ...DEFAULT_SETTINGS },
135149
},
136150
settings || {}
137151
);

src/settings/NoteFormatSetting.svelte

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
DEFAULT_DAILY_NOTE_FORMAT,
44
DEFAULT_MONTHLY_NOTE_FORMAT,
55
DEFAULT_WEEKLY_NOTE_FORMAT,
6+
DEFAULT_QUARTERLY_NOTE_FORMAT,
7+
DEFAULT_YEARLY_NOTE_FORMAT,
68
} from "obsidian-daily-notes-interface";
79
import { onMount } from "svelte";
810
import type { Writable } from "svelte/store";
@@ -18,6 +20,8 @@
1820
daily: DEFAULT_DAILY_NOTE_FORMAT,
1921
weekly: DEFAULT_WEEKLY_NOTE_FORMAT,
2022
monthly: DEFAULT_MONTHLY_NOTE_FORMAT,
23+
quarterly: DEFAULT_QUARTERLY_NOTE_FORMAT,
24+
yearly: DEFAULT_YEARLY_NOTE_FORMAT,
2125
};
2226
const defaultFormat = DEFAULT_FORMATS[periodicity];
2327

src/settings/SettingsTab.svelte

+9-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@
2929
}));
3030
}
3131
32-
const periodicities: IPeriodicity[] = ["daily", "weekly", "monthly"];
32+
const periodicities: IPeriodicity[] = [
33+
"daily",
34+
"weekly",
35+
"monthly",
36+
"quarterly",
37+
"yearly",
38+
];
3339
3440
onDestroy(() => {
3541
unsubscribeFromSettings();
@@ -59,8 +65,8 @@
5965
class="checkbox-container"
6066
class:is-enabled={$settingsStore[periodicity].enabled}
6167
on:click={() => {
62-
$settingsStore[periodicity].enabled = !$settingsStore[periodicity]
63-
.enabled;
68+
$settingsStore[periodicity].enabled =
69+
!$settingsStore[periodicity].enabled;
6470
}}
6571
/>
6672
</div>

src/settings/index.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import type { SvelteComponent } from "svelte";
55
import type WeeklyNotesPlugin from "../index";
66
import SettingsTab from "./SettingsTab.svelte";
77

8-
export type IPeriodicity = "daily" | "weekly" | "monthly";
8+
export type IPeriodicity =
9+
| "daily"
10+
| "weekly"
11+
| "monthly"
12+
| "quarterly"
13+
| "yearly";
914

1015
interface IPerioditySettings extends IPeriodicNoteSettings {
1116
enabled: boolean;
@@ -19,6 +24,8 @@ export interface ISettings {
1924
daily: IPerioditySettings;
2025
weekly: IPerioditySettings;
2126
monthly: IPerioditySettings;
27+
quarterly: IPerioditySettings;
28+
yearly: IPerioditySettings;
2229
}
2330

2431
export const DEFAULT_SETTINGS = Object.freeze({

yarn.lock

+14-12
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,10 @@
629629
dependencies:
630630
"@babel/types" "^7.3.0"
631631

632-
"@types/[email protected].98":
633-
version "0.0.98"
634-
resolved "https://registry.yarnpkg.com/@types/codemirror/-/codemirror-0.0.98.tgz#b35c7a4ab1fc1684b08a4e3eb65240020556ebfb"
635-
integrity sha512-cbty5LPayy2vNSeuUdjNA9tggG+go5vAxmnLDRWpiZI5a+RDBi9dlozy4/jW/7P/gletbBWbQREEa7A81YxstA==
632+
"@types/[email protected].108":
633+
version "0.0.108"
634+
resolved "https://registry.yarnpkg.com/@types/codemirror/-/codemirror-0.0.108.tgz#e640422b666bf49251b384c390cdeb2362585bde"
635+
integrity sha512-3FGFcus0P7C2UOGCNUVENqObEb4SFk+S8Dnxq7K6aIsLVs/vDtlangl3PEO0ykaKXyK56swVF6Nho7VsA44uhw==
636636
dependencies:
637637
"@types/tern" "*"
638638

@@ -3272,19 +3272,21 @@ object.pick@^1.3.0:
32723272
dependencies:
32733273
isobject "^3.0.1"
32743274

3275-
3276-
version "0.9.1"
3277-
resolved "https://registry.yarnpkg.com/obsidian-daily-notes-interface/-/obsidian-daily-notes-interface-0.9.1.tgz#5eeff88f4132b868b3f37f264aa5f7e595aa3c94"
3278-
integrity sha512-XllmaPTt3vIvTXkgM9YpR88/7IUHzOYJ8XiIOS5oTbFg9g7dFo26Xe/P+qR+8YVTTcC7UTHDnoxVRiGhbcTqyw==
3275+
3276+
version "0.9.4"
3277+
resolved "https://registry.yarnpkg.com/obsidian-daily-notes-interface/-/obsidian-daily-notes-interface-0.9.4.tgz#df085c5aa4c8c2b2b810185d4d9dc24344cb7604"
3278+
integrity sha512-PILoRtZUB5wEeGnDQAPMlkVlXwDYoxkLR8Wl4STU2zLNwhcq9kKvQexiXi7sfjGlpTnL+LeAOfEVWyeVndneKg==
32793279
dependencies:
32803280
obsidian obsidianmd/obsidian-api#master
32813281
tslib "2.1.0"
32823282

3283-
obsidian@obsidianmd/obsidian-api#master:
3284-
version "0.11.7"
3285-
resolved "https://codeload.github.com/obsidianmd/obsidian-api/tar.gz/55946e5a6259a28c416d2d6e600a7964a86a01dd"
3283+
[email protected], obsidian@obsidianmd/obsidian-api#master:
3284+
version "0.12.16"
3285+
resolved "https://registry.yarnpkg.com/obsidian/-/obsidian-0.12.16.tgz#5745ad2892bcb26b562025f29fac2ca0dd9959c7"
3286+
integrity sha512-YwwhYrmlv71A/ntTiGOyGaqr9ONhKPE1OKN1tcHovLJC0N/BRZ7XlGpzaN1T3BnAE5H8DmYLsAI3h67u6eJPGQ==
32863287
dependencies:
3287-
"@types/codemirror" "0.0.98"
3288+
"@types/codemirror" "0.0.108"
3289+
moment "2.29.1"
32883290

32893291
once@^1.3.0, once@^1.3.1, once@^1.4.0:
32903292
version "1.4.0"

0 commit comments

Comments
 (0)