6 Commits
1.0.2 ... 1.0.3

Author SHA1 Message Date
ad5b5e81bb Updated README.md 2025-11-22 17:10:27 +01:00
951e9c5406 Added Feature - Daily note summary 2025-11-22 17:01:41 +01:00
6dc4d2952d Added Feature - Daily note summary 2025-11-22 17:01:12 +01:00
8e10724206 Updated Version 2025-11-22 16:57:32 +01:00
d661466c81 Added Feature - Daily note summary 2025-11-22 16:56:25 +01:00
f634993637 Updated README.md 2025-11-22 16:54:14 +01:00
7 changed files with 254 additions and 16 deletions

View File

@@ -4,7 +4,7 @@ A powerful task management and focus timer plugin for [Obsidian](https://obsidia
![Focus Task Banner](https://img.shields.io/badge/Obsidian-Plugin-7c3aed?style=for-the-badge&logo=obsidian&logoColor=white) ![Focus Task Banner](https://img.shields.io/badge/Obsidian-Plugin-7c3aed?style=for-the-badge&logo=obsidian&logoColor=white)
![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge) ![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)
![Version](https://img.shields.io/badge/Version-1.0.2-blue?style=for-the-badge) ![Version](https://img.shields.io/badge/Version-1.0.3-blue?style=for-the-badge)
## 🎯 Overview ## 🎯 Overview
@@ -224,17 +224,6 @@ npm run dev
ln -s $(pwd) /path/to/vault/.obsidian/plugins/focus-task ln -s $(pwd) /path/to/vault/.obsidian/plugins/focus-task
``` ```
## 📝 Roadmap
- [ ] Integration with Obsidian Tasks plugin
- [ ] Calendar view for scheduled tasks
- [ ] Weekly/Monthly reports
- [ ] Task templates
- [ ] Sync with external task managers
- [ ] Mobile optimizations
- [ ] Task dependencies
- [ ] Time blocking in daily notes
## 📜 License ## 📜 License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

96
main.js
View File

@@ -44,7 +44,11 @@ var DEFAULT_SETTINGS = {
{ id: "learning", name: "Learning", color: "#f59e0b", icon: "\u{1F4DA}" } { id: "learning", name: "Learning", color: "#f59e0b", icon: "\u{1F4DA}" }
], ],
autoStartBreak: false, autoStartBreak: false,
tickSoundEnabled: false tickSoundEnabled: false,
// Daily note logging
logToDaily: false,
dailyNoteFormat: "YYYY-MM-DD",
dailyNoteHeading: "## \u26A1 Completed Tasks"
}; };
var DEFAULT_DATA = { var DEFAULT_DATA = {
tasks: [], tasks: [],
@@ -640,6 +644,9 @@ var FocusTaskPlugin = class extends import_obsidian3.Plugin {
if (this.settings.enableSounds) { if (this.settings.enableSounds) {
this.playCompletionSound(); this.playCompletionSound();
} }
if (this.settings.logToDaily) {
this.logTaskToDailyNote(task);
}
if (this.activeTaskId === taskId) { if (this.activeTaskId === taskId) {
this.stopTimer(); this.stopTimer();
this.activeTaskId = null; this.activeTaskId = null;
@@ -878,6 +885,80 @@ var FocusTaskPlugin = class extends import_obsidian3.Plugin {
console.log("Audio not available"); console.log("Audio not available");
} }
} }
// ============ Daily Note Logging ============
async logTaskToDailyNote(task) {
try {
const dailyNotePath = this.getDailyNotePath();
const list = this.settings.lists.find((l) => l.id === task.list);
const timeDiff = task.actualMinutes - task.estimatedMinutes;
let timeComparison = "";
if (timeDiff < 0) {
timeComparison = `${Math.abs(timeDiff)}min under estimate \u2728`;
} else if (timeDiff > 0) {
timeComparison = `${timeDiff}min over estimate`;
} else {
timeComparison = `exactly on target \u{1F3AF}`;
}
const completedTime = new Date(task.completedAt || Date.now()).toLocaleTimeString("en-US", {
hour: "2-digit",
minute: "2-digit",
hour12: false
});
const taskEntry = `- [x] ${task.text} | ${(list == null ? void 0 : list.icon) || "\u{1F4CB}"} ${(list == null ? void 0 : list.name) || "Task"} | \u23F1\uFE0F ${this.formatTimeHuman(task.actualMinutes)} / ${this.formatTimeHuman(task.estimatedMinutes)} (${timeComparison}) | \u2705 ${completedTime}`;
await this.appendToDailyNote(dailyNotePath, taskEntry);
} catch (e) {
console.error("Failed to log task to daily note:", e);
new import_obsidian3.Notice("Failed to log task to daily note");
}
}
getDailyNotePath() {
const now = new Date();
const format = this.settings.dailyNoteFormat;
const year = now.getFullYear();
const month = (now.getMonth() + 1).toString().padStart(2, "0");
const day = now.getDate().toString().padStart(2, "0");
let filename = format.replace("YYYY", year.toString()).replace("MM", month).replace("DD", day);
return `${filename}.md`;
}
async appendToDailyNote(path, content) {
const { vault } = this.app;
const heading = this.settings.dailyNoteHeading;
let file = vault.getAbstractFileByPath(path);
if (!file) {
await vault.create(path, `# ${new Date().toLocaleDateString("en-US", { weekday: "long", year: "numeric", month: "long", day: "numeric" })}
${heading}
${content}
`);
new import_obsidian3.Notice("\u{1F4DD} Task logged to new daily note");
return;
}
if (!(file instanceof import_obsidian3.TFile)) {
new import_obsidian3.Notice("Daily note path is not a file");
return;
}
let existingContent = await vault.read(file);
if (existingContent.includes(heading)) {
const headingIndex = existingContent.indexOf(heading);
const afterHeading = headingIndex + heading.length;
const nextHeadingMatch = existingContent.slice(afterHeading).match(/\n##? /);
let insertPosition;
if (nextHeadingMatch && nextHeadingMatch.index !== void 0) {
insertPosition = afterHeading + nextHeadingMatch.index;
} else {
insertPosition = existingContent.length;
}
const before = existingContent.slice(0, insertPosition);
const after = existingContent.slice(insertPosition);
const newContent = before.trimEnd() + "\n" + content + "\n" + after.trimStart();
await vault.modify(file, newContent);
} else {
const newContent = existingContent.trimEnd() + "\n\n" + heading + "\n\n" + content + "\n";
await vault.modify(file, newContent);
}
new import_obsidian3.Notice("\u{1F4DD} Task logged to daily note");
}
// ============ Utilities ============ // ============ Utilities ============
formatTime(seconds) { formatTime(seconds) {
const absSeconds = Math.abs(seconds); const absSeconds = Math.abs(seconds);
@@ -985,6 +1066,19 @@ var FocusTaskSettingTab = class extends import_obsidian3.PluginSettingTab {
this.plugin.settings.enableCelebrations = value; this.plugin.settings.enableCelebrations = value;
await this.plugin.saveAllData(); await this.plugin.saveAllData();
})); }));
containerEl.createEl("h2", { text: "\u{1F4DD} Daily Note Integration" });
new import_obsidian3.Setting(containerEl).setName("Log completed tasks to daily note").setDesc("When you complete a task, add an entry to your daily note").addToggle((toggle) => toggle.setValue(this.plugin.settings.logToDaily).onChange(async (value) => {
this.plugin.settings.logToDaily = value;
await this.plugin.saveAllData();
}));
new import_obsidian3.Setting(containerEl).setName("Daily note filename format").setDesc("Format for daily note filename (YYYY = year, MM = month, DD = day)").addText((text) => text.setPlaceholder("YYYY-MM-DD").setValue(this.plugin.settings.dailyNoteFormat).onChange(async (value) => {
this.plugin.settings.dailyNoteFormat = value || "YYYY-MM-DD";
await this.plugin.saveAllData();
}));
new import_obsidian3.Setting(containerEl).setName("Section heading").setDesc("Heading under which completed tasks will be logged").addText((text) => text.setPlaceholder("## \u26A1 Completed Tasks").setValue(this.plugin.settings.dailyNoteHeading).onChange(async (value) => {
this.plugin.settings.dailyNoteHeading = value || "## \u26A1 Completed Tasks";
await this.plugin.saveAllData();
}));
containerEl.createEl("h2", { text: "\u{1F4CB} Lists" }); containerEl.createEl("h2", { text: "\u{1F4CB} Lists" });
this.plugin.settings.lists.forEach((list, index) => { this.plugin.settings.lists.forEach((list, index) => {
new import_obsidian3.Setting(containerEl).setName(`${list.icon} ${list.name}`).addText((text) => text.setValue(list.name).setPlaceholder("List name").onChange(async (value) => { new import_obsidian3.Setting(containerEl).setName(`${list.icon} ${list.name}`).addText((text) => text.setValue(list.name).setPlaceholder("List name").onChange(async (value) => {

View File

@@ -1,7 +1,7 @@
{ {
"id": "focus-task", "id": "focus-task",
"name": "Focus Task", "name": "Focus Task",
"version": "1.0.2", "version": "1.0.3",
"minAppVersion": "0.15.0", "minAppVersion": "0.15.0",
"description": "A Blitzit-inspired task management and focus timer plugin. Plan your day, track time with Pomodoro technique, and crush your tasks with satisfying checkoffs.", "description": "A Blitzit-inspired task management and focus timer plugin. Plan your day, track time with Pomodoro technique, and crush your tasks with satisfying checkoffs.",
"author": "Crib", "author": "Crib",

View File

@@ -1,6 +1,6 @@
{ {
"name": "focus-task", "name": "focus-task",
"version": "1.0.2", "version": "1.0.3",
"description": "A Blitzit-inspired task management and focus timer plugin for Obsidian", "description": "A Blitzit-inspired task management and focus timer plugin for Obsidian",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {

View File

@@ -4,6 +4,7 @@ import {
Plugin, Plugin,
PluginSettingTab, PluginSettingTab,
Setting, Setting,
TFile,
WorkspaceLeaf, WorkspaceLeaf,
} from 'obsidian'; } from 'obsidian';
@@ -224,6 +225,11 @@ export default class FocusTaskPlugin extends Plugin {
this.playCompletionSound(); this.playCompletionSound();
} }
// Log to daily note
if (this.settings.logToDaily) {
this.logTaskToDailyNote(task);
}
if (this.activeTaskId === taskId) { if (this.activeTaskId === taskId) {
this.stopTimer(); this.stopTimer();
this.activeTaskId = null; this.activeTaskId = null;
@@ -541,6 +547,112 @@ export default class FocusTaskPlugin extends Plugin {
} }
} }
// ============ Daily Note Logging ============
async logTaskToDailyNote(task: FocusTask) {
try {
const dailyNotePath = this.getDailyNotePath();
const list = this.settings.lists.find(l => l.id === task.list);
// Format the task entry
const timeDiff = task.actualMinutes - task.estimatedMinutes;
let timeComparison = '';
if (timeDiff < 0) {
timeComparison = `${Math.abs(timeDiff)}min under estimate ✨`;
} else if (timeDiff > 0) {
timeComparison = `${timeDiff}min over estimate`;
} else {
timeComparison = `exactly on target 🎯`;
}
const completedTime = new Date(task.completedAt || Date.now()).toLocaleTimeString('en-US', {
hour: '2-digit',
minute: '2-digit',
hour12: false
});
const taskEntry = `- [x] ${task.text} | ${list?.icon || '📋'} ${list?.name || 'Task'} | ⏱️ ${this.formatTimeHuman(task.actualMinutes)} / ${this.formatTimeHuman(task.estimatedMinutes)} (${timeComparison}) | ✅ ${completedTime}`;
await this.appendToDailyNote(dailyNotePath, taskEntry);
} catch (e) {
console.error('Failed to log task to daily note:', e);
new Notice('Failed to log task to daily note');
}
}
getDailyNotePath(): string {
const now = new Date();
const format = this.settings.dailyNoteFormat;
// Simple date formatting
const year = now.getFullYear();
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const day = now.getDate().toString().padStart(2, '0');
let filename = format
.replace('YYYY', year.toString())
.replace('MM', month)
.replace('DD', day);
return `${filename}.md`;
}
async appendToDailyNote(path: string, content: string) {
const { vault } = this.app;
const heading = this.settings.dailyNoteHeading;
let file = vault.getAbstractFileByPath(path);
if (!file) {
// Create the daily note if it doesn't exist
await vault.create(path, `# ${new Date().toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })}\n\n${heading}\n\n${content}\n`);
new Notice('📝 Task logged to new daily note');
return;
}
if (!(file instanceof TFile)) {
new Notice('Daily note path is not a file');
return;
}
// Read existing content
let existingContent = await vault.read(file);
// Check if heading exists
if (existingContent.includes(heading)) {
// Find the heading and append after it
const headingIndex = existingContent.indexOf(heading);
const afterHeading = headingIndex + heading.length;
// Find the next heading or end of file
const nextHeadingMatch = existingContent.slice(afterHeading).match(/\n##? /);
let insertPosition: number;
if (nextHeadingMatch && nextHeadingMatch.index !== undefined) {
// Insert before the next heading
insertPosition = afterHeading + nextHeadingMatch.index;
} else {
// Append to end of file
insertPosition = existingContent.length;
}
// Insert the new task entry
const before = existingContent.slice(0, insertPosition);
const after = existingContent.slice(insertPosition);
// Make sure there's a newline before our content
const newContent = before.trimEnd() + '\n' + content + '\n' + after.trimStart();
await vault.modify(file, newContent);
} else {
// Add the heading and content at the end
const newContent = existingContent.trimEnd() + '\n\n' + heading + '\n\n' + content + '\n';
await vault.modify(file, newContent);
}
new Notice('📝 Task logged to daily note');
}
// ============ Utilities ============ // ============ Utilities ============
formatTime(seconds: number): string { formatTime(seconds: number): string {
@@ -726,6 +838,41 @@ class FocusTaskSettingTab extends PluginSettingTab {
await this.plugin.saveAllData(); await this.plugin.saveAllData();
})); }));
// Daily Note Integration
containerEl.createEl('h2', { text: '📝 Daily Note Integration' });
new Setting(containerEl)
.setName('Log completed tasks to daily note')
.setDesc('When you complete a task, add an entry to your daily note')
.addToggle(toggle => toggle
.setValue(this.plugin.settings.logToDaily)
.onChange(async value => {
this.plugin.settings.logToDaily = value;
await this.plugin.saveAllData();
}));
new Setting(containerEl)
.setName('Daily note filename format')
.setDesc('Format for daily note filename (YYYY = year, MM = month, DD = day)')
.addText(text => text
.setPlaceholder('YYYY-MM-DD')
.setValue(this.plugin.settings.dailyNoteFormat)
.onChange(async value => {
this.plugin.settings.dailyNoteFormat = value || 'YYYY-MM-DD';
await this.plugin.saveAllData();
}));
new Setting(containerEl)
.setName('Section heading')
.setDesc('Heading under which completed tasks will be logged')
.addText(text => text
.setPlaceholder('## ⚡ Completed Tasks')
.setValue(this.plugin.settings.dailyNoteHeading)
.onChange(async value => {
this.plugin.settings.dailyNoteHeading = value || '## ⚡ Completed Tasks';
await this.plugin.saveAllData();
}));
// Lists Management // Lists Management
containerEl.createEl('h2', { text: '📋 Lists' }); containerEl.createEl('h2', { text: '📋 Lists' });

View File

@@ -32,6 +32,10 @@ export interface FocusTaskSettings {
lists: TaskList[]; lists: TaskList[];
autoStartBreak: boolean; autoStartBreak: boolean;
tickSoundEnabled: boolean; tickSoundEnabled: boolean;
// Daily note logging
logToDaily: boolean;
dailyNoteFormat: string;
dailyNoteHeading: string;
} }
export interface FocusTaskData { export interface FocusTaskData {
@@ -58,6 +62,10 @@ export const DEFAULT_SETTINGS: FocusTaskSettings = {
], ],
autoStartBreak: false, autoStartBreak: false,
tickSoundEnabled: false, tickSoundEnabled: false,
// Daily note logging
logToDaily: false,
dailyNoteFormat: 'YYYY-MM-DD',
dailyNoteHeading: '## ⚡ Completed Tasks',
}; };
export const DEFAULT_DATA: FocusTaskData = { export const DEFAULT_DATA: FocusTaskData = {

View File

@@ -1,3 +1,3 @@
{ {
"1.0.2": "0.15.0" "1.0.3": "0.15.0"
} }