Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin-Arnold committed Jul 26, 2024
2 parents f4ed5db + ef28b35 commit c07e6e4
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 11 deletions.
42 changes: 39 additions & 3 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default class JournalystPlugin extends Plugin {
this.activateView();
});


this.app.workspace.onLayoutReady(() => {
const rootFolder = this.app.vault.getAbstractFileByPath(this.settings.rootDirectory);

Expand Down Expand Up @@ -54,11 +53,48 @@ export default class JournalystPlugin extends Plugin {
(leaf) => new SideBarView(leaf, this)
);
})

this.registerEvent(
this.app.vault.on('create', (item) => this.onItemChange())
);
this.registerEvent(
this.app.vault.on('delete', (item) => this.onItemChange())
);
this.registerEvent(
this.app.vault.on('rename', (item) => this.onItemChange())
);
};

onunload() {
onunload() {}

}
private onItemChange() {
const rootFolder = this.app.vault.getAbstractFileByPath(this.settings.rootDirectory);

if (rootFolder instanceof TFolder === false) {
return;
}

this.journals = []

rootFolder.children.forEach(child => {
if (child instanceof TFolder === false) {
return;
}

this.journals.push(child);

this.addCommand({
id: 'create-journal-' + child.name,
name: 'Create new journal in ' + child.name,
callback: () => {
const todaysDate = moment().format('YYYY-MM-DD');
const newFileName = todaysDate + '.md';
const fullPath = normalizePath(child.path + '/' + newFileName);
this.app.vault.create(fullPath, '---\ntitle: ' + todaysDate + '\n---\n')
}
})
})
}

async activateView() {
const { workspace } = this.app;
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "journalyst",
"name": "Journalyst",
"version": "1.0.2",
"version": "1.1.0",
"minAppVersion": "1.0.0",
"description": "Journalyst enables easy creation of topic-specific journals. Organize your life into categories like sleep, routines, or work, with daily or recurring entries for effortless tracking and reflection.",
"author": "Justin Arnold",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "journalyst",
"version": "1.0.2",
"version": "1.1.0",
"description": "This is a plugin for Obsidian that allows you to create a grouped journal entries for each day.",
"main": "main.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"1.0.0": "1.0.0",
"1.0.1": "1.0.0",
"1.0.2": "1.0.0"
"1.0.2": "1.0.0",
"1.1.0": "1.0.0"
}
31 changes: 26 additions & 5 deletions views/SideBar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ItemView, WorkspaceLeaf, TFolder, moment } from "obsidian";
import { ItemView, WorkspaceLeaf, TFolder, moment, TAbstractFile } from "obsidian";
import JournalystPlugin from "../main";


Expand All @@ -22,10 +22,31 @@ export class SideBarView extends ItemView {
}

async onOpen() {
this.rootContainer = this.containerEl.children[1];
this.rootContainer.empty();
this.addHeader();
this.addJournalSections();
this.rootContainer = this.containerEl.children[1];
this.rootContainer.empty();
this.addHeader();
this.addJournalSections();

// Register file system event listeners
this.registerEvent(
this.app.vault.on('create', () => this.onFileChanged())
);
this.registerEvent(
this.app.vault.on('delete', () => this.onFileChanged())
);
this.registerEvent(
this.app.vault.on('modify', () => this.onFileChanged())
);
this.registerEvent(
this.app.vault.on('rename', (item) => this.onFileChanged())
);
}

private onFileChanged() {
this.rootContainer = this.containerEl.children[1];
this.rootContainer.empty();
this.addHeader();
this.addJournalSections();
}

async onClose() {
Expand Down

0 comments on commit c07e6e4

Please sign in to comment.