Skip to content

Commit

Permalink
Use generic calendar UI
Browse files Browse the repository at this point in the history
bump version of calendar-ui

filemenu

apply gggg patch for weekly notes

add issue template

bug fixes

- no longer has multiple days selected at once
- deselects day when navigating to non-daily note
- no longer resets displayedMonth on tick()
- now supports any day of the week (monday, tuesday, wednesday, thursday, friday, saturday, sunday)

Fastforward settings improvements

Fix locale config

Move localization code from plugin into ui lib

Fix update on settings change

use 0.2.0 of the cal-ui
  • Loading branch information
liamcain committed Jan 17, 2021
1 parent 4c32c8f commit 8bf80fb
Show file tree
Hide file tree
Showing 26 changed files with 723 additions and 607 deletions.
41 changes: 41 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: Bug report
about: Create a report to help us improve
title: ""
labels: bug, needs-review
assignees: ""
---

> **Before Submitting:** Double-check that you are running the latest version of the plugin. The bug might have already been fixed 😄
### Describe the bug

_A clear and concise description of what the bug is._

### Steps to reproduce

1. Go to '...'
2. Click on '....'
3. See error

### Expected behavior

_A clear and concise description of what you expected to happen_.

### Screenshots

_If applicable, add screenshots to help explain your problem._

### Environment (please specify)

#### OS

[e.g. macOS]

#### Obsidian Version (e.g. v0.10.6)

`(Settings → About → Current Version)`

### Additional context

_Add any other context about the problem here._
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Feature request
about: Suggest an idea for this project
title: ""
labels: enhancement
assignees: ""
---

> **Before Submitting:** Double-check that you are running the latest version of the plugin. The feature might have already been included 😄
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
File renamed without changes.
14 changes: 14 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: CI
on:
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install modules
run: yarn
- name: Run tests
run: yarn test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules/
dist/
data.json
main.js
.vscode/
*.code-workspace
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ From the Settings menu, you can toggle "Start week on Monday".

### How do I include "unformatted" words in my weekly note filenames?

If you want the weekly note format to include a word (e.g. "Week 21 of Year 2020") you can do so by surrounding the words with `[]` brackets. This tells [moment](https://momentjs.com/docs/#/displaying/format/) to ignore the words. So for the example above, you would set your format to `[Week] ww [of Year] YYYY`.
If you want the weekly note format to include a word (e.g. "Week 21 of Year 2020") you can do so by surrounding the words with `[]` brackets. This tells [moment](https://momentjs.com/docs/#/displaying/format/) to ignore the words. So for the example above, you would set your format to `[Week] ww [of Year] gggg`.

### I don't like showing the week numbers but I still want to use weekly notes. Can I still use them?

Expand Down Expand Up @@ -171,9 +171,9 @@ You can open **weekly notes** in 2 ways: searching `Calendar: open weekly note`

| Tag | Description |
| -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `sunday`, `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `saturday`, `sunday` | Because weekly tags refer to main days, you can refer to individual days like this `{{sunday:YYYY-MM-DD}}` to automatically insert the date for that particular day. Note, you must specify the date format! |
| `sunday`, `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `saturday`, `sunday` | Because weekly tags refer to main days, you can refer to individual days like this `{{sunday:gggg-MM-DD}}` to automatically insert the date for that particular day. Note, you must specify the date format! |
| `title` | Works the same as the daily note `{{title}}`. It will insert the title of the note |
| `date`, `time` | Works the same as the daily note `{{date}}` and `{{time}}`. It will insert the date and time of the first day of the week. Useful for creating a heading (e.g. `# # {{date:YYYY [Week] ww}}`). |
| `date`, `time` | Works the same as the daily note `{{date}}` and `{{time}}`. It will insert the date and time of the first day of the week. Useful for creating a heading (e.g. `# # {{date:gggg [Week] ww}}`). |

## Say Thanks 🙏

Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@
},
"dependencies": {
"obsidian": "obsidianmd/obsidian-api#master",
"obsidian-calendar-ui": "0.0.2",
"obsidian-daily-notes-interface": "0.4.0",
"obsidian-calendar-ui": "0.2.0",
"obsidian-daily-notes-interface": "0.5.1",
"svelte": "3.31.0",
"tslib": "2.0.3"
},
"devDependencies": {
"@rollup/plugin-commonjs": "17.0.0",
"@rollup/plugin-node-resolve": "11.0.0",
"@rollup/plugin-typescript": "8.0.0",
"@testing-library/jest-dom": "5.11.6",
"@testing-library/svelte": "3.0.0",
"@rollup/plugin-typescript": "8.1.0",
"@testing-library/jest-dom": "5.11.9",
"@testing-library/svelte": "3.0.3",
"@tsconfig/svelte": "1.0.10",
"@types/jest": "26.0.19",
"@types/jest": "26.0.20",
"@types/moment": "2.13.0",
"@types/node": "14.14.13",
"@typescript-eslint/eslint-plugin": "4.9.1",
"@typescript-eslint/parser": "4.9.1",
"eslint": "7.15.0",
"@types/node": "14.14.21",
"@typescript-eslint/eslint-plugin": "4.13.0",
"@typescript-eslint/parser": "4.13.0",
"eslint": "7.18.0",
"jest": "26.6.3",
"moment": "2.29.1",
"rollup": "2.34.2",
Expand Down
2 changes: 1 addition & 1 deletion src/io/weeklyNotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export async function tryToCreateWeeklyNote(
cta: "Create",
onAccept: createFile,
text: `File ${filename} does not exist. Would you like to create it?`,
title: "New Daily Note",
title: "New Weekly Note",
});
} else {
await createFile();
Expand Down
46 changes: 0 additions & 46 deletions src/localization.ts

This file was deleted.

24 changes: 3 additions & 21 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import type { Moment, WeekSpec } from "moment";
import { App, Plugin, WorkspaceLeaf } from "obsidian";

import { configureMomentLocale } from "src/localization";

import { VIEW_TYPE_CALENDAR } from "./constants";
import { settings } from "./ui/stores";
import {
CalendarSettingsTab,
ISettings,
syncMomentLocaleWithSettings,
} from "./settings";
import { CalendarSettingsTab, ISettings } from "./settings";
import CalendarView from "./view";

declare global {
Expand All @@ -34,14 +28,13 @@ export default class CalendarPlugin extends Plugin {
this.register(
settings.subscribe((value) => {
this.options = value;
configureMomentLocale(this.options);
// TODO pass new weekStart and localeOverride to Calendar
})
);

this.registerView(
VIEW_TYPE_CALENDAR,
(leaf: WorkspaceLeaf) =>
(this.view = new CalendarView(leaf, this.options))
(leaf: WorkspaceLeaf) => (this.view = new CalendarView(leaf))
);

this.addCommand({
Expand All @@ -63,12 +56,6 @@ export default class CalendarPlugin extends Plugin {
callback: () => this.view.openOrCreateWeeklyNote(window.moment(), false),
});

// this.addCommand({
// id: "reload-calendar-view",
// name: "Reload daily note settings",
// callback: () => {},
// });

this.addCommand({
id: "reveal-active-note",
name: "Reveal active note",
Expand All @@ -77,10 +64,6 @@ export default class CalendarPlugin extends Plugin {

await this.loadOptions();

// After we retrieve the settings, override window.moment to
// reflect 'start week on monday' setting
syncMomentLocaleWithSettings(this.options);

this.addSettingTab(new CalendarSettingsTab(this.app, this));

if (this.app.workspace.layoutReady) {
Expand Down Expand Up @@ -117,7 +100,6 @@ export default class CalendarPlugin extends Plugin {
changeOpts: (settings: ISettings) => Partial<ISettings>
): Promise<void> {
settings.update((old) => ({ ...old, ...changeOpts(old) }));
syncMomentLocaleWithSettings(this.options);
await this.saveData(this.options);
}
}
Loading

0 comments on commit 8bf80fb

Please sign in to comment.