Skip to content

Commit

Permalink
Merge pull request #13 from joeriddles/6/more-settings
Browse files Browse the repository at this point in the history
#6: Add setting to use full filepath for label in generated TODO
  • Loading branch information
joeriddles authored Feb 27, 2024
2 parents ce54e72 + 9a4c304 commit 72af2fe
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Plugin, TFile, Vault } from 'obsidian';
import { DEFAULT_SETTINGS, ExtendedTaskListsSettingTab, ExtendedTaskListsSettings } from 'settings';
import TodoService, { Todo } from './findTodos';
import TodoService, { Todo } from './todoService';

export default class ExtendedTaskListsPlugin extends Plugin {
settings: ExtendedTaskListsSettings
Expand Down
12 changes: 12 additions & 0 deletions settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface ExtendedTaskListsSettings {
todoFilename: string;
excludeFilePattern: string;
excludeFolderFilename: string;
useFullFilepath: boolean;
includeNotStarted: boolean;
includeInProgress: boolean;
includeWontDo: boolean;
Expand All @@ -14,6 +15,7 @@ const DEFAULT_SETTINGS: ExtendedTaskListsSettings = {
todoFilename: "TODO.md",
excludeFilePattern: "<!-- exclude TODO -->",
excludeFolderFilename: ".exclude_todos",
useFullFilepath: false,
includeNotStarted: true,
includeInProgress: true,
includeWontDo: false,
Expand Down Expand Up @@ -83,6 +85,16 @@ class ExtendedTaskListsSettingTab extends PluginSettingTab {
await this.plugin.saveSettings()
}))

new Setting(containerEl)
.setName('Use full filepath')
.setDesc("If checked, the full Vault filepath is used for the label of grouped task items in the generated TODO file")
.addToggle(toggle => toggle
.setValue(this.plugin.settings.useFullFilepath)
.onChange(async (value) => {
this.plugin.settings.useFullFilepath = value
await this.plugin.saveSettings()
}))

new Setting(containerEl)
.setName('Include in progress tasks')
.addToggle(toggle => toggle
Expand Down
8 changes: 7 additions & 1 deletion findTodos.ts → todoService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ class TodoService {

todosByFile.forEach((todos, file) => {
const urlEncodedFilePath = encodeURI(file.path)
data += `- [${file.basename}](${urlEncodedFilePath})\n`

const heading = this.settings.useFullFilepath
? `- [${file.path}](${urlEncodedFilePath})\n`
: `- [${file.basename}](${urlEncodedFilePath})\n`

data += heading

todos.forEach(todo => {
data += ` - [${todo.task}] ${todo.text}\n`
})
Expand Down

0 comments on commit 72af2fe

Please sign in to comment.