├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .github └── workflows │ └── release.yml ├── .gitignore ├── .npmrc ├── .obsidian ├── app.json ├── appearance.json ├── core-plugins-migration.json ├── core-plugins.json └── workspace.json ├── .prettierrc ├── LICENSE.md ├── README.md ├── documents └── attachments │ ├── Pasted image 20240706113526.png │ ├── Pasted image 20240706165831.png │ ├── Pasted image 20240727125104.png │ ├── Pasted image 20240727131319.png │ ├── Pasted image 20240727131617.png │ ├── Pasted image 20240727131909.png │ ├── Pasted image 20240727154201.png │ ├── Pasted image 20240727154226.png │ ├── Pasted image 20240727154342.png │ ├── Pasted image 20240727154802.png │ ├── Pasted image 20240727162726.png │ ├── Pasted image 20240727164708.png │ ├── Pasted image 20240727164813.png │ ├── Pasted image 20240808152226.png │ ├── Pasted image 20240809094217.png │ ├── Pasted image 20240809101032.png │ └── Pasted image 20240809123010.png ├── esbuild.config.mjs ├── manifest.json ├── package-lock.json ├── package.json ├── src ├── data-access │ ├── folder-settings-resolver.ts │ ├── index.ts │ ├── journal-folder-settings-store.type.ts │ ├── journal-folder-settings.type.ts │ ├── journal-note.ts │ ├── link.type.ts │ ├── plugin-feature.ts │ └── string-utils.ts ├── features │ ├── journal-folder-settings │ │ ├── index.ts │ │ ├── journal-folder-settings-feature.ts │ │ └── journal-folder-settings-tab.ts │ └── journal-header │ │ ├── JournalHeader.svelte │ │ ├── index.ts │ │ ├── journal-header-feature.ts │ │ └── journal-header-info.ts ├── plugin │ ├── index.ts │ ├── journal-folder-plugin.ts │ └── plugin-feature-set.ts └── ui │ ├── ErrorMessage.svelte │ ├── NoteLink.svelte │ └── index.ts ├── styles.css ├── tsconfig.json ├── version-bump.mjs └── versions.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_style = tab 9 | indent_size = 4 10 | tab_width = 4 11 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | 3 | main.js 4 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "env": { "node": true }, 5 | "plugins": [ 6 | "@typescript-eslint" 7 | ], 8 | "extends": [ 9 | "eslint:recommended", 10 | "plugin:@typescript-eslint/eslint-recommended", 11 | "plugin:@typescript-eslint/recommended" 12 | ], 13 | "parserOptions": { 14 | "sourceType": "module" 15 | }, 16 | "rules": { 17 | "no-unused-vars": "off", 18 | "@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], 19 | "@typescript-eslint/ban-ts-comment": "off", 20 | "no-prototype-builtins": "off", 21 | "@typescript-eslint/no-empty-function": "off" 22 | } 23 | } -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release Obsidian plugin 2 | 3 | on: 4 | push: 5 | tags: 6 | - "*" 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v3 14 | 15 | - name: Use Node.js 16 | uses: actions/setup-node@v3 17 | with: 18 | node-version: "18.x" 19 | 20 | - name: Build plugin 21 | run: | 22 | npm install --force 23 | npm run build 24 | 25 | - name: Create release 26 | env: 27 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 28 | run: | 29 | tag="${GITHUB_REF#refs/tags/}" 30 | 31 | gh release create "$tag" \ 32 | --title="$tag" \ 33 | --draft \ 34 | main.js manifest.json styles.css 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # vscode 2 | .vscode 3 | 4 | # Intellij 5 | *.iml 6 | .idea 7 | 8 | # npm 9 | node_modules 10 | 11 | # Don't include the compiled main.js file in the repo. 12 | # They should be uploaded to GitHub releases instead. 13 | main.js 14 | 15 | # Exclude sourcemaps 16 | *.map 17 | 18 | # obsidian 19 | data.json 20 | 21 | # Exclude macOS Finder (System Explorer) View States 22 | .DS_Store 23 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | tag-version-prefix="" -------------------------------------------------------------------------------- /.obsidian/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "showInlineTitle": false, 3 | "attachmentFolderPath": "documents/attachments", 4 | "useMarkdownLinks": true, 5 | "newLinkFormat": "relative", 6 | "alwaysUpdateLinks": true, 7 | "promptDelete": false 8 | } -------------------------------------------------------------------------------- /.obsidian/appearance.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /.obsidian/core-plugins-migration.json: -------------------------------------------------------------------------------- 1 | { 2 | "file-explorer": true, 3 | "global-search": true, 4 | "switcher": true, 5 | "graph": true, 6 | "backlink": true, 7 | "canvas": true, 8 | "outgoing-link": true, 9 | "tag-pane": true, 10 | "properties": false, 11 | "page-preview": true, 12 | "daily-notes": true, 13 | "templates": true, 14 | "note-composer": true, 15 | "command-palette": true, 16 | "slash-command": false, 17 | "editor-status": true, 18 | "bookmarks": true, 19 | "markdown-importer": false, 20 | "zk-prefixer": false, 21 | "random-note": false, 22 | "outline": true, 23 | "word-count": true, 24 | "slides": false, 25 | "audio-recorder": false, 26 | "workspaces": false, 27 | "file-recovery": true, 28 | "publish": false, 29 | "sync": false 30 | } -------------------------------------------------------------------------------- /.obsidian/core-plugins.json: -------------------------------------------------------------------------------- 1 | [ 2 | "file-explorer", 3 | "global-search", 4 | "switcher", 5 | "graph", 6 | "backlink", 7 | "canvas", 8 | "outgoing-link", 9 | "tag-pane", 10 | "page-preview", 11 | "daily-notes", 12 | "templates", 13 | "note-composer", 14 | "command-palette", 15 | "editor-status", 16 | "bookmarks", 17 | "outline", 18 | "word-count", 19 | "file-recovery" 20 | ] -------------------------------------------------------------------------------- /.obsidian/workspace.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "id": "95603e326932b40d", 4 | "type": "split", 5 | "children": [ 6 | { 7 | "id": "33d3eba770cd8fd1", 8 | "type": "tabs", 9 | "children": [ 10 | { 11 | "id": "59e5009b86be4e9a", 12 | "type": "leaf", 13 | "state": { 14 | "type": "markdown", 15 | "state": { 16 | "file": "README.md", 17 | "mode": "source", 18 | "source": false 19 | } 20 | } 21 | } 22 | ] 23 | } 24 | ], 25 | "direction": "vertical" 26 | }, 27 | "left": { 28 | "id": "5e59c98b42e54607", 29 | "type": "split", 30 | "children": [ 31 | { 32 | "id": "8467754220e14823", 33 | "type": "tabs", 34 | "children": [ 35 | { 36 | "id": "852d379c67018bc2", 37 | "type": "leaf", 38 | "state": { 39 | "type": "file-explorer", 40 | "state": { 41 | "sortOrder": "alphabetical" 42 | } 43 | } 44 | }, 45 | { 46 | "id": "8dd41ff86c00dd3a", 47 | "type": "leaf", 48 | "state": { 49 | "type": "search", 50 | "state": { 51 | "query": "", 52 | "matchingCase": false, 53 | "explainSearch": false, 54 | "collapseAll": false, 55 | "extraContext": false, 56 | "sortOrder": "alphabetical" 57 | } 58 | } 59 | }, 60 | { 61 | "id": "e0dc653374add754", 62 | "type": "leaf", 63 | "state": { 64 | "type": "bookmarks", 65 | "state": {} 66 | } 67 | } 68 | ] 69 | } 70 | ], 71 | "direction": "horizontal", 72 | "width": 514.5026054382324 73 | }, 74 | "right": { 75 | "id": "a98a58275bc2afaa", 76 | "type": "split", 77 | "children": [ 78 | { 79 | "id": "61d9d9bec75aeaa3", 80 | "type": "tabs", 81 | "children": [ 82 | { 83 | "id": "e18b34a89491c27c", 84 | "type": "leaf", 85 | "state": { 86 | "type": "backlink", 87 | "state": { 88 | "file": "README.md", 89 | "collapseAll": false, 90 | "extraContext": false, 91 | "sortOrder": "alphabetical", 92 | "showSearch": false, 93 | "searchQuery": "", 94 | "backlinkCollapsed": false, 95 | "unlinkedCollapsed": true 96 | } 97 | } 98 | }, 99 | { 100 | "id": "2fadff8aaeb0d4be", 101 | "type": "leaf", 102 | "state": { 103 | "type": "outgoing-link", 104 | "state": { 105 | "file": "README.md", 106 | "linksCollapsed": false, 107 | "unlinkedCollapsed": true 108 | } 109 | } 110 | }, 111 | { 112 | "id": "1c4ea8f5d60086de", 113 | "type": "leaf", 114 | "state": { 115 | "type": "tag", 116 | "state": { 117 | "sortOrder": "frequency", 118 | "useHierarchy": true 119 | } 120 | } 121 | }, 122 | { 123 | "id": "c6e8b918fe54d7f9", 124 | "type": "leaf", 125 | "state": { 126 | "type": "outline", 127 | "state": { 128 | "file": "README.md" 129 | } 130 | } 131 | } 132 | ] 133 | } 134 | ], 135 | "direction": "horizontal", 136 | "width": 300 137 | }, 138 | "left-ribbon": { 139 | "hiddenItems": { 140 | "switcher:Open quick switcher": false, 141 | "graph:Open graph view": false, 142 | "canvas:Create new canvas": false, 143 | "daily-notes:Open today's daily note": false, 144 | "templates:Insert template": false, 145 | "command-palette:Open command palette": false 146 | } 147 | }, 148 | "active": "59e5009b86be4e9a", 149 | "lastOpenFiles": [ 150 | "documents/attachments/Pasted image 20240809101032.png", 151 | "documents/attachments/Pasted image 20240809123010.png", 152 | "documents/attachments/Pasted image 20240809114059.png", 153 | "documents/attachments/Pasted image 20240809114226.png", 154 | "documents/attachments/Pasted image 20240809121952.png", 155 | "README.md", 156 | "documents/attachments/Pasted image 20240809094217.png", 157 | "documents/attachments/Pasted image 20240808152226.png", 158 | "documents/attachments/Pasted image 20240727164813.png", 159 | "documents/attachments/Pasted image 20240727164708.png", 160 | "documents/attachments/Pasted image 20240727162726.png", 161 | "ORIGINAL README.md", 162 | "documents/attachments", 163 | "documents/images", 164 | "documents" 165 | ] 166 | } -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "tabWidth": 2, 4 | "printWidth": 80, 5 | "semi": false, 6 | "trailingComma": "es5", 7 | "useTabs": false 8 | } 9 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Journal Folder Plugin 2 | 3 | This plugin provides utilities for use with folder based journaling. The term _"folder based journaling"_ implies the ability to use any arbitrary folder within an _Obsidian_ vault as a journal. 4 | 5 | There's no special setup that need to be performed for this folder. Simply start creating notes using a pre-defined naming convention to indicate the journal note type and the date range represented by the note. All notes within this folder that adheres to the aforementioned naming convention will be seen and handled as part of the journal represented by the folder. 6 | 7 | _Folder based journaling_ enables the user to maintain multiple arbitrary journals within the same vault as opposed to the model where only one folder within the vault is allocated for journal entries of a specific type. This opens up a range of possibilities. As an example, a project worked on for a client can have it's own journal which can then be used for reporting to the client. 8 | 9 | It should be noted that, as with the initial releases of this plugin, while the date format used within files (for titles, links etc.) are configurable as per the user's preference, the file name format is fixed. 10 | 11 | The following journal note types are supported by the plugin: 12 | 13 | | **Note type** | **Filename Format** | Example filename | 14 | | ------------- | ------------------- | ---------------- | 15 | | Daily note | YYYY-MM-DD.md | 2024-07-23.md | 16 | | Weekly note | gggg-[W]ww.md | 2024-W30.md | 17 | | Monthly note | YYYY-MM | 2024-07.md | 18 | | Yearly note | YYYY | 2024.md | 19 | 20 | > [!CAUTION] 21 | > Please take note that, due to the way in which link resolution is handled in Obsidian, using the vault's root folder as a journal folder is not supported by this plugin. 22 | 23 | >[!note] 24 | > The usage of sub-folders is not currently supported by this plugin, nor are there plans to add support for it in the foreseeable future. 25 | 26 | The following is a list of features that have been, or are planned to be implemented in this plugin... 27 | 28 | --- 29 | ## Feature: Journal header 30 | 31 | The _journal header_ feature is a code block processor that renders an appropriate header in a journal file. 32 | 33 | ### Examples 34 | Examples of rendered headers for the different supported note types are as follows: 35 | 36 | Daily note 37 | ![](documents/attachments/Pasted%20image%2020240727154201.png) 38 | 39 | 40 | Weekly note 41 | ![](documents/attachments/Pasted%20image%2020240727154226.png) 42 | 43 | 44 | Monthly note 45 | ![](documents/attachments/Pasted%20image%2020240727154802.png) 46 | 47 | 48 | Yearly note 49 | ![](documents/attachments/Pasted%20image%2020240727154342.png) 50 | 51 | ### Using the Journal Header feature 52 | To render a header in your journal note, simply add the following to the top of your note... 53 | 54 | ![](documents/attachments/Pasted%20image%2020240808152226.png) 55 | 56 | Note that the header will render correctly without the `%% EDITING %%` in the first line. It is however recommended to include a comment line for the following reason... If the `journal-header` code block is placed on the first line, whenever you open a document in edit mode, the cursor (which defaults to the first line in the file) will start off on the code block. This results in the code block being rendered instead of the title until the user moves the cursor off it. This behaviour can be a bit distracting. 57 | 58 | By placing a comment on the first line, the cursor will fall on the comment when entering edit mode in stead of the header, providing a better user experience. However, when switching to _reading view_, the comment is omitted, resulting in the header being rendered right at the top of the document. 59 | 60 | As a personal preference, I like adding the word "EDITING" to the above comment as it also serves as an additional queue that the page is currently displayed in edit mode. 61 | 62 | It is recommended to use the templating functionality provided by the __Templater__ plugin (available in the _Obsidian_ plugin store) to automatically add the above code block to new journal files. _Templater_ can be configured to automatically add the code block to any new files created in the specified folders. 63 | 64 | ![](documents/attachments/Pasted%20image%2020240706113526.png) 65 | 66 | Alternatively the _Obsidian_ core _Templates_ plugin can be used. 67 | 68 | ### Composition of a Journal header 69 | #### Daily notes 70 | 71 | ![](documents/attachments/Pasted%20image%2020240727125104.png) 72 | 73 | ##### Folder title 74 | - Renders the folder title assigned to the current folder. If no title is assigned, this line is omitted. 75 | 76 | ##### Title 77 | - Renders the date represented by the journal note, using the specified date format for the note type. 78 | - The date format used for the title can be configured in the _Journal Note_ plugin configuration tab (see topic on _Configuration_ later in this document). 79 | 80 | ##### Backwards link 81 | - Renders a link to a daily note file for the closest date before the current note's date where either the note already exists, or the note's date is in the present or future. 82 | - If none of the above exist, this link is omitted. 83 | 84 | ##### Forwards link 85 | - Renders a link to a daily note file for the closest date after the current note's date where either the note already exists, or the note's date is in the future. 86 | - If the current note represents yesterday, a link to today's daily note will be rendered regardless of whether the note exists or not. 87 | - If no note can be found that meet the above criteria, this link is omitted. 88 | 89 | ##### Current year link 90 | - If a note exists for the current note's year component, or if the current note's year component represents the current or a future year, a link to the year note is rendered. 91 | - If the year component falls in the past and no note exists for the year component, this link is omitted. 92 | 93 | ##### Current month link 94 | - If a note exists for the current note's month component, or if the current note's month component represents the current or a future month, a link to the month note is rendered. 95 | - If the month component falls in the past and no note exists for the month component, this link is omitted. 96 | 97 | ##### Current week link 98 | - If a note exists for the current note's week component, or if the current note's week component represents the current or a future week, a link to the week note is rendered. 99 | - If the week component falls in the past and no note exists for the week component, this link is omitted. 100 | 101 | ##### Today link 102 | - Rendered if the current note represents a different date than the current date. 103 | 104 | #### Weekly notes 105 | 106 | ![](documents/attachments/Pasted%20image%2020240727131319.png) 107 | 108 | ##### Folder title 109 | - Renders the folder title assigned to the current folder. If no title is assigned, this line is omitted. 110 | 111 | ##### Title 112 | - Renders the week represented by the journal note, using the specified date format for the note type. 113 | - The date format used for the title can be configured in the _Journal Note_ plugin configuration tab (see topic on _Configuration_ later in this document). 114 | 115 | ##### Backwards link 116 | - Renders a link to a weekly note file for the closest week before the current note's week, where either the note already exists, or the note's week is in the present or future. 117 | - If none of the above exist, this link is omitted. 118 | 119 | ##### Forwards link 120 | - Renders a link to a weekly note file for the closest week after the current note's week, where either the note already exists, or the note's week is in the present or future. 121 | 122 | ##### Current year link 123 | - If a note exists for the current note's year component, or if the current note's year component represents the current or a future year, a link to the year note is rendered. 124 | - If the year component falls in the past and no note exists for the year component, this link is omitted. 125 | 126 | ##### Current month(s) link 127 | - If a note exists for the current note's month component, or if the current note's month component represents the current or a future month, a link to the month note is rendered. 128 | - If the month component falls in the past and no note exists for the month component, this link is omitted. 129 | - If the weekly note's week spans over 2 months, links to both months may be displayed depending on the above criteria. 130 | 131 | ##### Today link 132 | - Links to the daily note for the current date. 133 | - Always rendered for weekly notes. 134 | 135 | ##### Day links for week 136 | - Renders links or plain text labels for each day that falls in the current link's week. 137 | - If a link exists for the day, or the day falls in the present or future, a link to the daily note is rendered. Otherwise a plain text label is rendered. 138 | 139 | #### Monthly notes 140 | 141 | ![](documents/attachments/Pasted%20image%2020240727131617.png) 142 | 143 | ##### Folder title 144 | - Renders the folder title assigned to the current folder. If no title is assigned, this line is omitted. 145 | 146 | ##### Title 147 | - Renders the month represented by the journal note, using the specified date format for the note type. 148 | - The date format used for the title can be configured in the _Journal Note_ plugin configuration tab (see topic on _Configuration_ later in this document). 149 | 150 | ##### Backwards link 151 | - Renders a link to a monthly note file for the closest month before the current note's month, where either the note already exists, or the note's month is in the present or future. 152 | - If none of the above exist, this link is omitted. 153 | 154 | ##### Forwards link 155 | - Renders a link to a monthly note file for the closest month after the current note's month, where either the note already exists, or the note's month is in the present or future. 156 | 157 | ##### Current year link 158 | - If a note exists for the current note's year component, or if the current note's year component represents the current or a future year, a link to the year note is rendered. 159 | - If the year component falls in the past and no note exists for the year component, this link is omitted. 160 | 161 | ##### Today link 162 | - Links to the daily note for the current date. 163 | - Always rendered for monthly notes. 164 | 165 | ##### Week links for month 166 | - Renders links or plain text labels for each week that falls in the current link's month. 167 | - If a link exists for the week, or the week ends in the present or future, a link to the weekly note is rendered. Otherwise a plain text label is rendered. 168 | 169 | #### Yearly notes 170 | 171 | ![](documents/attachments/Pasted%20image%2020240727131909.png) 172 | 173 | ##### Folder title 174 | - Renders the folder title assigned to the current folder. If no title is assigned, this line is omitted. 175 | 176 | ##### Title 177 | - Renders the year represented by the journal note, using the specified date format for the note type. 178 | - The date format used for the title can be configured in the _Journal Note_ plugin configuration tab (see topic on _Configuration_ later in this document). 179 | 180 | ##### Backwards link 181 | - Renders a link to a yearly note file for the closest year before the current note's year, where either the note already exists, or the note's year is in the present or future. 182 | - If none of the above exist, this link is omitted. 183 | 184 | ##### Forwards link 185 | - Renders a link to a yearly note file for the closest year after the current note's year, where either the note already exists, or the note's year is in the present or future. 186 | 187 | ##### Today link 188 | - Links to the daily note for the current date. 189 | - Always rendered for yearly notes. 190 | 191 | ##### Month links for year 192 | - Renders links or plain text labels for each month that falls in the current link's year. 193 | - If a link exists for the month, or the month ends in the present or future, a link to the monthly note is rendered. Otherwise a plain text label is rendered. 194 | #### Journal header options 195 | All configuration settings used in rendering a journal header can be overridden on an individual header. This is accomplished by adding any config values that should be overridden as content to the code block. As an example, the following journal-header code block... 196 | 197 | ![](documents/attachments/Pasted%20image%2020240727164708.png) 198 | 199 | ...would render folder title and title... 200 | 201 | ![](documents/attachments/Pasted%20image%2020240727164813.png) 202 | 203 | Setting names can be delimited by either spaces, dashes, or underscores. Any uppercase/lowercase combination can be used. As an example, all of the following front-matter declarations for the folder title are valid: 204 | - journal-folder-title: My Awesome Project 205 | - journal_folder_title: My Awesome Project 206 | - JOURNAL_FOLDER_TITLE: My Awesome Project 207 | - Journal folder title: My Awesome Project 208 | 209 | For a list of settings that can be configured, please refer to the section on configurable settings later in this document. 210 | 211 | > [!CAUTION] 212 | > It should be noted that any settings configured in the code block will only apply to that code block. If for example the journal-folder-title property is configured within the code block, it will only effect the title rendered for that header and will not determine/override the actual title assigned to the folder. 213 | 214 | --- 215 | ### Configuration 216 | #### Vault level configuration 217 | The _Journal Folder_ plugin includes a configuration tab that is available in Obsidian's configuration screens. For each note type (daily, weekly, monthly, yearly), the the following is configurable.... 218 | - **Title pattern:** The date pattern used to render the title of the note. 219 | - Short title pattern: The pattern used as labels for links to the note. 220 | - Medium title pattern: The pattern used as labels for links to this note where the this note falls in a different year than the note where the link is situated. This pattern should typically be similar to the short title pattern, but should contain the year also to make the change in year explicit. 221 | 222 | > [!CAUTION] 223 | > As previously noted, the filename format for journal files isn't configurable in the first releases of this plugin. The filename format used for weekly note files is `gggg-[W]ww`. It is therefore important that, when setting up custom title patterns for weekly note titles and adding a year component, only 'gggg' or 'gg' should be used. Any other variant used (e.g. yyyy, YYYY, GGGG, GG etc.) will result in discrepancies between the date in the filename and the date displayed to the user. 224 | 225 | 226 | ![](documents/attachments/Pasted%20image%2020240706165831.png) 227 | 228 | #### Folder level configuration 229 | All configuration settings can be overridden at folder level. This is accomplished by creating a note named "journal-folder" in the folder to be configured, and then adding any config values that should be overridden as front matter. 230 | 231 | ![](documents/attachments/Pasted%20image%2020240727162726.png) 232 | 233 | Setting names can be delimited by either spaces, dashes, or underscores. Any uppercase/lowercase combination can be used. As an example, all of the following front-matter declarations for the folder title are valid: 234 | - journal-folder-title: My Awesome Project 235 | - journal_folder_title: My Awesome Project 236 | - JOURNAL_FOLDER_TITLE: My Awesome Project 237 | - Journal folder title: My Awesome Project 238 | 239 | For a list of settings that can be configured, please refer to the section configurable settings below. 240 | 241 | #### Configurable Settings 242 | 243 | | Setting | Description | 244 | | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 245 | | daily-note-title-pattern | The pattern used to render the title of a daily note. This pattern should not render any date/time elements shorter than a day (e.g. hour or minute). For instance, using a pattern of 'DD-HH' would not make sense as the hour component represents a fraction of the day. [pattern syntax] | 246 | | daily-noteShort-title-pattern | The pattern used to render links to daily notes. The user should aim to keep this pattern short as multiple links may be rendered next to each other. This pattern should not render any date/time elements shorter than a day (e.g. hour or minute). For instance, using a pattern of 'DD-HH' would not make sense as the hour component represents a fraction of the day. [pattern syntax] | 247 | | daily-noteMedium-title-pattern | The pattern used to render links to daily notes where the destination note falls in a different year then the current note. The user should aim to keep this pattern short as multiple links may be rendered next to each other. This pattern should not render any date/time elements shorter than a day (e.g. hour or minute). For instance, using a pattern of 'DD-HH' would not make sense as the hour component represents a fraction of the day. [pattern syntax] | 248 | | weekly-note-title-pattern | The pattern used to render the title of a weekly note. This pattern should not render any date/time elements shorter than a week (e.g. day or hour). For instance, using a pattern of 'WW-DD' would not make sense as the day component represents a fraction of the week. PLEASE NOTE: for weekly patterns 'gg' or 'gggg' should be used to reflect the year. [pattern syntax] | 249 | | weekly-note-short-title-pattern | The pattern used to render links to weekly notes. The user should aim to keep this pattern short as multiple links may be rendered next to each other. This pattern should not render any date/time elements shorter than a week (e.g. day or hour). For instance, using a pattern of 'WW-DD' would not make sense as the day component represents a fraction of the week. PLEASE NOTE: for weekly patterns 'gg' or 'gggg' should be used to reflect the year. [pattern syntax] | 250 | | weekly-note-medium-title-pattern | The pattern used to render links to weekly notes where the destination note falls in a different year then the current note. The user should aim to keep this pattern short as multiple links may be rendered next to each other. This pattern should not render any date/time elements shorter than a week (e.g. day or hour). For instance, using a pattern of 'WW-DD' would not make sense as the day component represents a fraction of the week. PLEASE NOTE: for weekly patterns 'gg' or 'gggg' should be used to reflect the year. [pattern syntax] | 251 | | monthly-note-title-pattern | The pattern used to render the title of a monthly note. This pattern should not render any date/time elements shorter than a month (e.g. week or day). For instance, using a pattern of 'MM-DD' would not make sense as the day component represents a fraction of the month. [pattern syntax] | 252 | | monthly-note-short-title-pattern | The pattern used to render links to monthly notes. The user should aim to keep this pattern short as multiple links may be rendered next to each other. This pattern should not render any date/time elements shorter than a month (e.g. week or day). For instance, using a pattern of 'MM-DD' would not make sense as the day component represents a fraction of the month. [pattern syntax] | 253 | | monthly-note-medium-title-pattern | The pattern used to render links to monthly notes where the destination note falls in a different year then the current note. The user should aim to keep this pattern short as multiple links may be rendered next to each other. This pattern should not render any date/time elements shorter than a month (e.g. week or day). For instance, using a pattern of 'MM-DD' would not make sense as the day component represents a fraction of the month. [pattern syntax] | 254 | | yearly-note-title-pattern | The pattern used to render the title of a yearly note. This pattern should not render any date/time elements shorter than a year (e.g. month, week or day). For instance, using a pattern of 'YYYY-MM' would not make sense as the month component represents a fraction of the year. [pattern syntax] | 255 | | yearly-note-short-title-pattern | The pattern used to render links to yearly notes. The user should aim to keep this pattern short as multiple links may be rendered next to each other. This pattern should not render any date/time elements shorter than a year (e.g. month, week or day). For instance, using a pattern of 'YYYY-MM' would not make sense as the month component represents a fraction of the year. [pattern syntax] | 256 | | user-folder-name-as-default-title | Indicates whether the folder name should be used as default title for the journal folder. Value can be either true or false. If true, and no journal-folder-title is configured at folder level, the folder name will be used as title. | 257 | | journal-folder-title | The journal folder title is used in the rendering of journal headers as well as to identify the folder in other views. The journal folder title should typically be configured at folder level (i.e. as a front-matter property in the `journal-folder` note in the applicable folder). | 258 | 259 | #### Journal folder title configuration 260 | A title can be assigned to a journal folder. This title will be displayed in the header, and will also be used as label for the folder in various other views. The title for a folder will be determined as follows: 261 | - If the title is configured at folder level (as described earlier in this document), that title will be used for the folder. 262 | - Otherwise, if the `user-folder-name-as-default-title` property is set to `true` ("Use folder name as default title" in global configuration), the folder name will be used as title. 263 | - Otherwise the value will be seen as `empty`. 264 | 265 | ![](documents/attachments/Pasted%20image%2020240809094217.png) 266 | 267 | --- 268 | ## Planned Feature: Journal Folder view 269 | This plugin view will provide a view context sensitive the note currently active in the editor. The following components will be provided by the view... 270 | - The calendar folder title assigned to the folder where the currently active note resides. If no title has been assigned, the folder path will be displayed in stead. 271 | - A calendar similar to the [calendar plugin](https://github.com/liamcain/obsidian-calendar-plugin) written by __Liam Cain__. The biggest difference from Liam's plugin will be that the folder of the currently active note will be used for rendering the calendar. 272 | - An option to configure the folder level settings for the folder of the currently active note. Selecting this feature will open a dialog where these settings can be update. Folder level settings are retrieved from and stored as front matter in a note named `journal-folder` within the folder of the currently active note. If the `journal-folder` note does not exist yet, it will be created on submission of the updated folder level settings. 273 | - A task view that will be rendered based on the currently active note. 274 | - Tasks will be limited to those defined in the folder of the currently active note. 275 | - The date range depicted by the note (year, month, week, day or n/a) will determine which tasks are rendered and how/where the individual task are rendered. 276 | 277 | ![](documents/attachments/Pasted%20image%2020240809123010.png) 278 | (Please note that the above image is just a rough estimate and by no means accurate reflection of the final artefact) -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240706113526.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240706113526.png -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240706165831.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240706165831.png -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240727125104.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240727125104.png -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240727131319.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240727131319.png -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240727131617.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240727131617.png -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240727131909.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240727131909.png -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240727154201.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240727154201.png -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240727154226.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240727154226.png -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240727154342.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240727154342.png -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240727154802.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240727154802.png -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240727162726.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240727162726.png -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240727164708.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240727164708.png -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240727164813.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240727164813.png -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240808152226.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240808152226.png -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240809094217.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240809094217.png -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240809101032.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240809101032.png -------------------------------------------------------------------------------- /documents/attachments/Pasted image 20240809123010.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chfourie/obsidian-journal-folder/663a8c990045f35c5a673a0f3681326e2dfa6106/documents/attachments/Pasted image 20240809123010.png -------------------------------------------------------------------------------- /esbuild.config.mjs: -------------------------------------------------------------------------------- 1 | import esbuild from "esbuild"; 2 | import process from "process"; 3 | import builtins from "builtin-modules"; 4 | import esbuildSvelte from "esbuild-svelte"; 5 | import { sveltePreprocess } from "svelte-preprocess"; 6 | 7 | const banner = 8 | `/* 9 | THIS IS A GENERATED/BUNDLED FILE BY ESBUILD 10 | if you want to view the source, please visit the github repository of this plugin 11 | */ 12 | `; 13 | 14 | const prod = (process.argv[2] === "production"); 15 | 16 | const context = await esbuild.context({ 17 | banner: { 18 | js: banner, 19 | }, 20 | entryPoints: ["src/plugin/journal-folder-plugin.ts"], 21 | bundle: true, 22 | external: [ 23 | "obsidian", 24 | "electron", 25 | "@codemirror/autocomplete", 26 | "@codemirror/collab", 27 | "@codemirror/commands", 28 | "@codemirror/language", 29 | "@codemirror/lint", 30 | "@codemirror/search", 31 | "@codemirror/state", 32 | "@codemirror/view", 33 | "@lezer/common", 34 | "@lezer/highlight", 35 | "@lezer/lr", 36 | ...builtins], 37 | format: "cjs", 38 | target: "es2018", 39 | logLevel: "info", 40 | sourcemap: prod ? false : "inline", 41 | treeShaking: true, 42 | plugins: [ 43 | esbuildSvelte({ 44 | compilerOptions: { css: "injected"}, 45 | preprocess: sveltePreprocess(), 46 | }), 47 | ], 48 | outfile: "main.js", 49 | }); 50 | 51 | if (prod) { 52 | await context.rebuild(); 53 | process.exit(0); 54 | } else { 55 | await context.watch(); 56 | } 57 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "journal-folder", 3 | "name": "Journal Folder", 4 | "version": "1.3.0", 5 | "minAppVersion": "0.15.0", 6 | "description": "Utilities for folder-based journaling", 7 | "author": "Charl Fourie", 8 | "authorUrl": "https://github.com/chfourie", 9 | "fundingUrl": { 10 | "Buy Me a Coffee": "https://buymeacoffee.com/chfourie", 11 | "Github Sponsor": "https://github.com/sponsors/chfourie" 12 | }, 13 | "isDesktopOnly": false 14 | } 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "obsidian-sample-plugin", 3 | "version": "1.0.0", 4 | "description": "This is a sample plugin for Obsidian (https://obsidian.md)", 5 | "main": "main.js", 6 | "scripts": { 7 | "dev": "node esbuild.config.mjs", 8 | "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", 9 | "version": "node version-bump.mjs && git add manifest.json versions.json" 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "MIT", 14 | "devDependencies": { 15 | "@tsconfig/svelte": "^5.0.4", 16 | "@types/node": "^16.11.6", 17 | "@typescript-eslint/eslint-plugin": "5.29.0", 18 | "@typescript-eslint/parser": "5.29.0", 19 | "builtin-modules": "3.3.0", 20 | "esbuild": "0.17.3", 21 | "esbuild-svelte": "^0.8.1", 22 | "obsidian": "latest", 23 | "prettier": "3.3.2", 24 | "svelte": "^5.0.0-next.166", 25 | "svelte-preprocess": "^6.0.1", 26 | "tslib": "2.4.0", 27 | "typescript": "^5.5.2" 28 | }, 29 | "resolutions": { 30 | "typescript": "5.5.2" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/data-access/folder-settings-resolver.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | import { TFile, type FrontMatterCache, type Plugin } from 'obsidian' 20 | import { type JournalFolderSettings } from './journal-folder-settings.type' 21 | import { camelCase } from './string-utils' 22 | 23 | export class FolderSettingsResolver { 24 | constructor(private plugin: Plugin) {} 25 | 26 | resolve( 27 | globalSettings: JournalFolderSettings, 28 | file: TFile | null = null, 29 | embeddedConfig = '' 30 | ): JournalFolderSettings { 31 | return { 32 | ...globalSettings, 33 | ...this.getFolderConfig(file), 34 | ...this.getEmbeddedConfig(embeddedConfig), 35 | } 36 | } 37 | 38 | private getFolderConfig(file: TFile | null): Partial { 39 | const config = {} 40 | const frontMatter = this.getFrontMatterCache(this.getFolderConfigFile(file)) 41 | 42 | Object.keys(frontMatter).forEach((key) => { 43 | const configKey = camelCase(key) 44 | // @ts-ignore 45 | config[configKey] = frontMatter[key] 46 | }) 47 | 48 | return config 49 | } 50 | 51 | private getFolderConfigFile(file: TFile | null) { 52 | if (!file) return null 53 | const dest = this.plugin.app.vault.getAbstractFileByPath( 54 | `${file.parent?.path}/journal-folder.md` 55 | ) 56 | return dest instanceof TFile ? dest : null 57 | } 58 | 59 | private getEmbeddedConfig(rawConfig: string): Partial { 60 | const config = {} 61 | rawConfig = rawConfig.trim() 62 | if (!rawConfig) return {} 63 | 64 | rawConfig 65 | .split('\n') 66 | .map((line) => this.keyValuePair(line)) 67 | .filter((item) => !!item) 68 | .forEach((item) => { 69 | // @ts-ignore 70 | config[item.key] = item.value 71 | }) 72 | 73 | return config 74 | } 75 | 76 | private getFrontMatterCache(file: TFile | null): FrontMatterCache { 77 | const frontMatter = 78 | file && this.plugin.app.metadataCache.getFileCache(file)?.frontmatter 79 | return frontMatter || {} 80 | } 81 | 82 | private keyValuePair( 83 | line: string 84 | ): { key: string; value: string } | undefined { 85 | line = line.trim() 86 | const separatorIndex = line.indexOf(':') 87 | 88 | if (separatorIndex > 0) { 89 | const key = camelCase(line.substring(0, separatorIndex).trim()) 90 | const value = line.substring(separatorIndex + 1).trim() 91 | return { key, value } 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/data-access/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | export * from './link.type' 20 | export * from './journal-folder-settings.type' 21 | export * from './plugin-feature' 22 | export * from './journal-note' 23 | export * from './folder-settings-resolver' 24 | export * from './string-utils' 25 | -------------------------------------------------------------------------------- /src/data-access/journal-folder-settings-store.type.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | import type { JournalFolderSettings } from './journal-folder-settings.type' 20 | 21 | export type JournalFolderSettingsStore = { 22 | saveToStorage: (settings: JournalFolderSettings) => Promise 23 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 24 | loadFromStorage: () => Promise 25 | } 26 | -------------------------------------------------------------------------------- /src/data-access/journal-folder-settings.type.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | export type JournalFolderSettings = { 20 | dailyNoteTitlePattern: string 21 | dailyNoteShortTitlePattern: string 22 | dailyNoteMediumTitlePattern: string 23 | weeklyNoteTitlePattern: string 24 | weeklyNoteShortTitlePattern: string 25 | weeklyNoteMediumTitlePattern: string 26 | monthlyNoteTitlePattern: string 27 | monthlyNoteShortTitlePattern: string 28 | monthlyNoteMediumTitlePattern: string 29 | yearlyNoteTitlePattern: string 30 | yearlyNoteShortTitlePattern: string 31 | yearlyNoteMediumTitlePattern: string 32 | journalFolderTitle: string 33 | useFolderNameAsDefaultTitle: boolean 34 | } 35 | 36 | export const DEFAULT_SETTINGS: JournalFolderSettings = { 37 | dailyNoteTitlePattern: 'dddd, DD MMMM YYYY', 38 | dailyNoteShortTitlePattern: 'ddd, D MMM', 39 | dailyNoteMediumTitlePattern: 'ddd, D MMM YY', 40 | weeklyNoteTitlePattern: 'gggg [Week] w', 41 | weeklyNoteShortTitlePattern: '[W]ww', 42 | weeklyNoteMediumTitlePattern: '[W]ww gg', 43 | monthlyNoteTitlePattern: 'MMMM YYYY', 44 | monthlyNoteShortTitlePattern: 'MMM', 45 | monthlyNoteMediumTitlePattern: 'MMM YY', 46 | yearlyNoteTitlePattern: 'YYYY', 47 | yearlyNoteShortTitlePattern: 'YYYY', 48 | yearlyNoteMediumTitlePattern: 'YYYY', 49 | journalFolderTitle: '', 50 | useFolderNameAsDefaultTitle: false, 51 | } 52 | -------------------------------------------------------------------------------- /src/data-access/journal-note.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | import { normalizePath, type TFile } from 'obsidian' 20 | import type { JournalFolderSettings, Link } from './index' 21 | import { moment } from 'obsidian' 22 | 23 | type JournalNoteStrategy = { 24 | fileRegex: RegExp 25 | filePattern: string 26 | titlePattern: string 27 | shortTitlePattern: string 28 | mediumTitlePattern: string 29 | yearPattern: string 30 | timeUnit: 'day' | 'week' | 'month' | 'year' 31 | } 32 | 33 | type JournalNoteStrategies = { 34 | DAILY_NOTE_STRATEGY: JournalNoteStrategy 35 | WEEKLY_NOTE_STRATEGY: JournalNoteStrategy 36 | MONTHLY_NOTE_STRATEGY: JournalNoteStrategy 37 | YEARLY_NOTE_STRATEGY: JournalNoteStrategy 38 | BY_DESCENDING_ORDER: JournalNoteStrategy[] 39 | } 40 | 41 | export type JournalNoteFactory = (file: TFile) => JournalNote 42 | 43 | function startOfInterval( 44 | sourceMoment: moment.Moment, 45 | pattern: string 46 | ): moment.Moment { 47 | // @ts-ignore 48 | return moment(sourceMoment.format(pattern), pattern) 49 | } 50 | 51 | export function journalNoteFactoryWithSettings( 52 | settings: JournalFolderSettings 53 | ): JournalNoteFactory { 54 | const DAILY_NOTE_STRATEGY: JournalNoteStrategy = { 55 | fileRegex: /^[12]\d{3}-((0[1-9])|(1[012]))-(([0-2][0-9])|(3[01]))$/, 56 | filePattern: 'YYYY-MM-DD', 57 | titlePattern: settings.dailyNoteTitlePattern, 58 | shortTitlePattern: settings.dailyNoteShortTitlePattern, 59 | mediumTitlePattern: settings.dailyNoteMediumTitlePattern, 60 | yearPattern: 'YYYY', 61 | timeUnit: 'day', 62 | } 63 | 64 | const WEEKLY_NOTE_STRATEGY: JournalNoteStrategy = { 65 | fileRegex: /^[12]\d{3}-W((0[1-9])|([1-4][0-9])|(5[0-3]))$/, 66 | filePattern: 'gggg-[W]ww', 67 | titlePattern: settings.weeklyNoteTitlePattern, 68 | shortTitlePattern: settings.weeklyNoteShortTitlePattern, 69 | mediumTitlePattern: settings.weeklyNoteMediumTitlePattern, 70 | yearPattern: 'gggg', 71 | timeUnit: 'week', 72 | } 73 | 74 | const MONTHLY_NOTE_STRATEGY: JournalNoteStrategy = { 75 | fileRegex: /^[12]\d{3}-((0[1-9])|(1[012]))$/, 76 | filePattern: 'YYYY-MM', 77 | titlePattern: settings.monthlyNoteTitlePattern, 78 | shortTitlePattern: settings.monthlyNoteShortTitlePattern, 79 | mediumTitlePattern: settings.monthlyNoteMediumTitlePattern, 80 | yearPattern: 'YYYY', 81 | timeUnit: 'month', 82 | } 83 | 84 | const YEARLY_NOTE_STRATEGY: JournalNoteStrategy = { 85 | fileRegex: /^[12]\d{3}$/, 86 | filePattern: 'YYYY', 87 | titlePattern: settings.yearlyNoteTitlePattern, 88 | shortTitlePattern: settings.yearlyNoteShortTitlePattern, 89 | mediumTitlePattern: settings.yearlyNoteMediumTitlePattern, 90 | yearPattern: 'YYYY', 91 | timeUnit: 'year', 92 | } 93 | 94 | const strategies: JournalNoteStrategies = { 95 | DAILY_NOTE_STRATEGY, 96 | WEEKLY_NOTE_STRATEGY, 97 | MONTHLY_NOTE_STRATEGY, 98 | YEARLY_NOTE_STRATEGY, 99 | BY_DESCENDING_ORDER: [ 100 | YEARLY_NOTE_STRATEGY, 101 | MONTHLY_NOTE_STRATEGY, 102 | WEEKLY_NOTE_STRATEGY, 103 | DAILY_NOTE_STRATEGY, 104 | ], 105 | } 106 | 107 | function getNoteStrategy(file: TFile): JournalNoteStrategy { 108 | const buildStrategy = strategies.BY_DESCENDING_ORDER.filter((s) => 109 | s.fileRegex.test(file.basename) 110 | ).first() 111 | 112 | if (!buildStrategy) 113 | throw new Error( 114 | `File name does not represent a valid journal file - ${file.basename}` 115 | ) 116 | 117 | return buildStrategy 118 | } 119 | 120 | return function journalNote(file: TFile): JournalNote { 121 | const strategy = getNoteStrategy(file) 122 | // @ts-ignore 123 | const today = moment().startOf('day') 124 | const noteNames = (file.parent?.children || []).map((f) => 125 | f.name.replace(/\.md$/, '') 126 | ) 127 | 128 | return new JournalNote( 129 | strategies, 130 | file.parent?.name, 131 | file.parent?.path || '', 132 | noteNames, 133 | strategy, 134 | // @ts-ignore 135 | moment(file.basename, strategy.filePattern), 136 | startOfInterval(today, strategy.filePattern), 137 | today 138 | ) 139 | } 140 | } 141 | 142 | export class JournalNote { 143 | private readonly name: string 144 | private readonly lastDay: moment.Moment 145 | 146 | constructor( 147 | private strategies: JournalNoteStrategies, 148 | private folderName: string | undefined, 149 | private path: string, 150 | private noteNames: string[], 151 | private strategy: JournalNoteStrategy, 152 | private fileMoment: moment.Moment, 153 | private present: moment.Moment, 154 | private today: moment.Moment 155 | ) { 156 | this.name = fileMoment.format(this.strategy.filePattern) 157 | this.lastDay = fileMoment 158 | .clone() 159 | .add(1, strategy.timeUnit) 160 | .subtract(1, 'day') 161 | } 162 | 163 | getTitle(): string { 164 | return this.fileMoment.format(this.strategy.titlePattern) 165 | } 166 | 167 | forwardInTime(): JournalNote { 168 | const moment = this.fileMoment.clone().add(1, this.strategy.timeUnit) 169 | return this.createNoteOfSameTimeUnit(moment) 170 | } 171 | 172 | backInTime(): JournalNote { 173 | const moment = this.fileMoment.clone().subtract(1, this.strategy.timeUnit) 174 | return this.createNoteOfSameTimeUnit(moment) 175 | } 176 | 177 | // noinspection JSUnusedGlobalSymbols 178 | presentNote(): JournalNote { 179 | return this.createNoteOfSameTimeUnit(this.present) 180 | } 181 | 182 | dailyNoteToday(): JournalNote { 183 | return this.createNote(this.strategies.DAILY_NOTE_STRATEGY, this.today) 184 | } 185 | 186 | // noinspection JSUnusedGlobalSymbols 187 | isFuture(): boolean { 188 | return this.fileMoment.isAfter(this.present) 189 | } 190 | 191 | // noinspection JSUnusedGlobalSymbols 192 | isPast(): boolean { 193 | return this.fileMoment.isBefore(this.present, this.strategy.timeUnit) 194 | } 195 | 196 | isPresentTime(): boolean { 197 | return this.fileMoment.isSame(this.present, this.strategy.timeUnit) 198 | } 199 | 200 | isPresentOrFuture(): boolean { 201 | return this.fileMoment.isSameOrAfter(this.present, this.strategy.timeUnit) 202 | } 203 | 204 | isExistingNote(): boolean { 205 | return this.noteNames.some((name) => name === this.name) 206 | } 207 | 208 | isToday(): boolean { 209 | return this.strategy.timeUnit === 'day' && this.isPresentTime() 210 | } 211 | 212 | // noinspection JSUnusedGlobalSymbols 213 | isMissingNote(): boolean { 214 | return !this.isExistingNote() 215 | } 216 | 217 | getHigherOrderNotes(): JournalNote[] { 218 | const notes: JournalNote[] = [] 219 | 220 | for (const strategy of this.strategies.BY_DESCENDING_ORDER) { 221 | if (this.strategy === strategy) break 222 | const note = this.createNote(strategy) 223 | notes.push(note) 224 | const note2 = this.createNote(strategy, this.lastDay) 225 | if (!note2.sameNoteAs(note)) notes.push(note2) 226 | } 227 | 228 | return notes 229 | } 230 | 231 | private sameNoteAs(note: JournalNote): boolean { 232 | return ( 233 | note.strategy === this.strategy && 234 | note.fileMoment.isSame(this.fileMoment, 'day') 235 | ) 236 | } 237 | 238 | getLowerOrderNotes(): JournalNote[] { 239 | const notes: JournalNote[] = [] 240 | const lowerOrderStrategy = this.getLowerOrderStrategy() 241 | 242 | if (lowerOrderStrategy) { 243 | const moment = this.fileMoment.clone() 244 | 245 | while (this.name === moment.format(this.strategy.filePattern)) { 246 | notes.push(this.createNote(lowerOrderStrategy, moment)) 247 | moment.add(1, lowerOrderStrategy.timeUnit) 248 | } 249 | } 250 | 251 | return notes 252 | } 253 | 254 | getFolderName(): string | undefined { 255 | return this.folderName 256 | } 257 | 258 | shortLinkFrom(note: JournalNote, inactive = false): Link { 259 | const pattern = 260 | note.formattedYear() === this.formattedYear(note.strategy.yearPattern) 261 | ? this.strategy.shortTitlePattern 262 | : this.strategy.mediumTitlePattern 263 | return this.linkWithTitlePattern(pattern, inactive) 264 | } 265 | 266 | link(titlePattern: 'regular' | 'short' = 'short', inactive = false): Link { 267 | const pattern = 268 | titlePattern === 'regular' 269 | ? this.strategy.titlePattern 270 | : this.strategy.shortTitlePattern 271 | return this.linkWithTitlePattern(pattern, inactive) 272 | } 273 | 274 | linkWithTitlePattern(pattern: string, inactive = false): Link { 275 | return this.createJournalNoteLink( 276 | pattern, 277 | this.strategy.filePattern, 278 | this.fileMoment, 279 | inactive 280 | ) 281 | } 282 | 283 | closestSibling(beforeOrAfter: 'before' | 'after'): JournalNote | undefined { 284 | const multiplier = beforeOrAfter === 'before' ? -1 : 1 285 | const adjacentFileName = this.noteNames.reduce( 286 | (prev, curr) => { 287 | if (!this.strategy.fileRegex.test(curr)) return prev 288 | if (curr.localeCompare(this.name) * multiplier <= 0) return prev 289 | if (prev == null) return curr 290 | return curr.localeCompare(prev) * multiplier < 0 ? curr : prev 291 | }, 292 | null 293 | ) 294 | 295 | if (adjacentFileName) { 296 | return this.createNoteOfSameTimeUnit( 297 | // @ts-ignore 298 | moment(adjacentFileName, this.strategy.filePattern) 299 | ) 300 | } 301 | } 302 | 303 | private formattedYear(yearPattern = this.strategy.yearPattern): string { 304 | return this.fileMoment.format(yearPattern) 305 | } 306 | 307 | private getLowerOrderStrategy(): JournalNoteStrategy | undefined { 308 | let currentStrategyFound = false 309 | 310 | for (const strategy of this.strategies.BY_DESCENDING_ORDER) { 311 | if (currentStrategyFound) return strategy 312 | currentStrategyFound = this.strategy === strategy 313 | } 314 | } 315 | 316 | private createJournalNoteLink( 317 | titlePattern: string, 318 | fileNamePattern: string, 319 | targetMoment: moment.Moment = this.fileMoment, 320 | inactive = false 321 | ): Link { 322 | return { 323 | title: targetMoment.format(titlePattern), 324 | url: this.fullPath(targetMoment.format(fileNamePattern)), 325 | inactive, 326 | } 327 | } 328 | 329 | private createNoteOfSameTimeUnit(moment: moment.Moment): JournalNote { 330 | return new JournalNote( 331 | this.strategies, 332 | this.folderName, 333 | this.path, 334 | this.noteNames, 335 | this.strategy, 336 | moment, 337 | this.present, 338 | this.today 339 | ) 340 | } 341 | 342 | private createNote( 343 | strategy: JournalNoteStrategy, 344 | moment: moment.Moment = this.fileMoment 345 | ): JournalNote { 346 | return new JournalNote( 347 | this.strategies, 348 | this.folderName, 349 | this.path, 350 | this.noteNames, 351 | strategy, 352 | startOfInterval(moment, strategy.filePattern), 353 | startOfInterval(this.today, strategy.filePattern), 354 | this.today 355 | ) 356 | } 357 | 358 | private fullPath(fileName: string): string { 359 | return normalizePath(this.path ? `${this.path}/${fileName}` : fileName) 360 | } 361 | } 362 | -------------------------------------------------------------------------------- /src/data-access/link.type.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | export type Link = { 20 | title: string 21 | url: string 22 | inactive?: boolean 23 | } 24 | -------------------------------------------------------------------------------- /src/data-access/plugin-feature.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | import { 20 | DEFAULT_SETTINGS, 21 | type JournalFolderSettings, 22 | } from './journal-folder-settings.type' 23 | import type { Plugin, TFile } from 'obsidian' 24 | import { FolderSettingsResolver } from './folder-settings-resolver' 25 | 26 | // noinspection JSUnusedLocalSymbols 27 | export abstract class PluginFeature { 28 | #settingsResolver: FolderSettingsResolver 29 | #settings = DEFAULT_SETTINGS 30 | 31 | protected constructor(protected plugin: Plugin) { 32 | this.#settingsResolver = new FolderSettingsResolver(plugin) 33 | } 34 | 35 | protected get globalSettings(): JournalFolderSettings { 36 | return this.#settings 37 | } 38 | 39 | protected getSettings( 40 | file: TFile | null = null, 41 | embeddedConfig = '' 42 | ): JournalFolderSettings { 43 | return this.#settingsResolver.resolve(this.#settings, file, embeddedConfig) 44 | } 45 | 46 | async load(): Promise {} 47 | 48 | unload(): void {} 49 | 50 | onExternalSettingsChange(): void {} 51 | 52 | useSettings(settings: JournalFolderSettings): void { 53 | this.#settings = settings 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/data-access/string-utils.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | export function camelCase(str: string): string { 20 | return str 21 | .toLowerCase() 22 | .trim() 23 | .split(/[ _-]/) 24 | .reduce((s, c) => s + c.charAt(0).toUpperCase() + c.slice(1)) 25 | } 26 | -------------------------------------------------------------------------------- /src/features/journal-folder-settings/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | export * from './journal-folder-settings-feature' 20 | -------------------------------------------------------------------------------- /src/features/journal-folder-settings/journal-folder-settings-feature.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | import { 20 | DEFAULT_SETTINGS, 21 | type JournalFolderSettings, 22 | PluginFeature, 23 | } from '../../data-access' 24 | import type { Plugin } from 'obsidian' 25 | import { JournalFolderSettingsTab } from './journal-folder-settings-tab' 26 | 27 | export class JournalFolderSettingsFeature extends PluginFeature { 28 | constructor( 29 | plugin: Plugin, 30 | private propagateSettings: (settings: JournalFolderSettings) => void 31 | ) { 32 | super(plugin) 33 | this.useSettings(DEFAULT_SETTINGS) 34 | } 35 | 36 | async load(): Promise { 37 | await this.updateSettingsFromStorage() 38 | 39 | this.plugin.addSettingTab( 40 | new JournalFolderSettingsTab( 41 | this.plugin, 42 | () => this.globalSettings, 43 | this.saveSettings 44 | ) 45 | ) 46 | } 47 | 48 | private readonly saveSettings = async ( 49 | settings: JournalFolderSettings 50 | ): Promise => { 51 | await this.plugin.saveData(settings) 52 | this.propagateSettings(settings) 53 | } 54 | 55 | readonly updateSettingsFromStorage = async (): Promise => { 56 | const settings = { 57 | ...this.globalSettings, 58 | ...(await this.plugin.loadData()), 59 | } 60 | await this.saveSettings(settings) 61 | } 62 | 63 | readonly onExternalSettingsChange = this.updateSettingsFromStorage 64 | } 65 | -------------------------------------------------------------------------------- /src/features/journal-folder-settings/journal-folder-settings-tab.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | import { 20 | debounce, 21 | MomentFormatComponent, 22 | type Plugin, 23 | PluginSettingTab, 24 | Setting, 25 | TextComponent, 26 | ToggleComponent, 27 | } from 'obsidian' 28 | import { DEFAULT_SETTINGS, type JournalFolderSettings } from '../../data-access' 29 | 30 | type SettingsStringFieldName = 31 | | 'dailyNoteTitlePattern' 32 | | 'dailyNoteShortTitlePattern' 33 | | 'weeklyNoteTitlePattern' 34 | | 'weeklyNoteShortTitlePattern' 35 | | 'monthlyNoteTitlePattern' 36 | | 'monthlyNoteShortTitlePattern' 37 | | 'yearlyNoteTitlePattern' 38 | | 'yearlyNoteShortTitlePattern' 39 | | 'dailyNoteMediumTitlePattern' 40 | | 'weeklyNoteMediumTitlePattern' 41 | | 'monthlyNoteMediumTitlePattern' 42 | | 'yearlyNoteMediumTitlePattern' 43 | | 'journalFolderTitle' 44 | 45 | /*************************************************************************************************** 46 | ** NOTE: This class has been slapped together in order to get the plugin released into the wild. ** 47 | ** It does the job, but will be replaced with a more refined version somewhere in the future. ** 48 | ** ************************************************************************************************/ 49 | export class JournalFolderSettingsTab extends PluginSettingTab { 50 | constructor( 51 | private plugin: Plugin, 52 | private getCurrentSettings: () => JournalFolderSettings, 53 | private saveSettings: (settings: JournalFolderSettings) => Promise 54 | ) { 55 | super(plugin.app, plugin) 56 | } 57 | 58 | display() { 59 | this.containerEl.empty() 60 | const settings = { ...this.getCurrentSettings() } 61 | 62 | this.createMomentSetting( 63 | settings, 64 | 'dailyNoteTitlePattern', 65 | 'Daily note title pattern' 66 | ).setDesc( 67 | 'The pattern used to render the title of a daily note. ' + 68 | 'This pattern should not render any date/time elements shorter than a day (e.g. hour or minute). ' + 69 | "For instance, using a pattern of 'DD-HH' would not make sense " + 70 | 'as the hour component represents a fraction of the day. ' + 71 | 'For help on the pattern syntax, refer to the link below.' 72 | ) 73 | 74 | this.createMomentSetting( 75 | settings, 76 | 'dailyNoteShortTitlePattern', 77 | 'Daily note short title pattern' 78 | ).setDesc( 79 | 'The pattern used to render links to daily notes. The user should aim to keep this pattern short ' + 80 | 'as multiple links may be rendered next to each other. ' + 81 | 'This pattern should not render any date/time elements shorter than a day (e.g. hour or minute). ' + 82 | "For instance, using a pattern of 'DD-HH' would not make sense " + 83 | 'as the hour component represents a fraction of the day. ' + 84 | 'For help on the pattern syntax, refer to the link below.' 85 | ) 86 | 87 | this.createMomentSetting( 88 | settings, 89 | 'dailyNoteMediumTitlePattern', 90 | 'Daily note medium title pattern' 91 | ).setDesc( 92 | 'The pattern used to render links to daily notes where the destination note falls in a different ' + 93 | 'year then the current note. The user should aim to keep this pattern short ' + 94 | 'as multiple links may be rendered next to each other. ' + 95 | 'This pattern should not render any date/time elements shorter than a day (e.g. hour or minute). ' + 96 | "For instance, using a pattern of 'DD-HH' would not make sense " + 97 | 'as the hour component represents a fraction of the day. ' + 98 | 'For help on the pattern syntax, refer to the link below.' 99 | ) 100 | 101 | this.createMomentSetting( 102 | settings, 103 | 'weeklyNoteTitlePattern', 104 | 'Weekly note title pattern' 105 | ).setDesc( 106 | 'The pattern used to render the title of a weekly note. ' + 107 | 'This pattern should not render any date/time elements shorter than a week (e.g. day or hour). ' + 108 | "For instance, using a pattern of 'WW-DD' would not make sense " + 109 | 'as the day component represents a fraction of the week. ' + 110 | "PLEASE NOTE: for weekly patterns 'gg' or 'gggg' should be used to reflect the year. " + 111 | 'For help on the pattern syntax, refer to the link below.' 112 | ) 113 | 114 | this.createMomentSetting( 115 | settings, 116 | 'weeklyNoteShortTitlePattern', 117 | 'Weekly note short title pattern' 118 | ).setDesc( 119 | 'The pattern used to render links to weekly notes. The user should aim to keep this pattern short ' + 120 | 'as multiple links may be rendered next to each other. ' + 121 | 'This pattern should not render any date/time elements shorter than a week (e.g. day or hour). ' + 122 | "For instance, using a pattern of 'WW-DD' would not make sense " + 123 | 'as the day component represents a fraction of the week. ' + 124 | "PLEASE NOTE: for weekly patterns 'gg' or 'gggg' should be used to reflect the year. " + 125 | 'For help on the pattern syntax, refer to the link below.' 126 | ) 127 | 128 | this.createMomentSetting( 129 | settings, 130 | 'weeklyNoteMediumTitlePattern', 131 | 'Weekly note medium title pattern' 132 | ).setDesc( 133 | 'The pattern used to render links to weekly notes where the destination note falls in a different ' + 134 | 'year then the current note. The user should aim to keep this pattern short ' + 135 | 'as multiple links may be rendered next to each other. ' + 136 | 'This pattern should not render any date/time elements shorter than a week (e.g. day or hour). ' + 137 | "For instance, using a pattern of 'WW-DD' would not make sense " + 138 | 'as the day component represents a fraction of the week. ' + 139 | "PLEASE NOTE: for weekly patterns 'gg' or 'gggg' should be used to reflect the year. " + 140 | 'For help on the pattern syntax, refer to the link below.' 141 | ) 142 | 143 | this.createMomentSetting( 144 | settings, 145 | 'monthlyNoteTitlePattern', 146 | 'Monthly note title pattern' 147 | ).setDesc( 148 | 'The pattern used to render the title of a monthly note. ' + 149 | 'This pattern should not render any date/time elements shorter than a month (e.g. week or day). ' + 150 | "For instance, using a pattern of 'MM-DD' would not make sense " + 151 | 'as the day component represents a fraction of the month. ' + 152 | 'For help on the pattern syntax, refer to the link below.' 153 | ) 154 | 155 | this.createMomentSetting( 156 | settings, 157 | 'monthlyNoteShortTitlePattern', 158 | 'Monthly note short title pattern' 159 | ).setDesc( 160 | 'The pattern used to render links to monthly notes. The user should aim to keep this pattern short ' + 161 | 'as multiple links may be rendered next to each other. ' + 162 | 'This pattern should not render any date/time elements shorter than a month (e.g. week or day). ' + 163 | "For instance, using a pattern of 'MM-DD' would not make sense " + 164 | 'as the day component represents a fraction of the month. ' + 165 | 'For help on the pattern syntax, refer to the link below.' 166 | ) 167 | 168 | this.createMomentSetting( 169 | settings, 170 | 'monthlyNoteMediumTitlePattern', 171 | 'Monthly note medium title pattern' 172 | ).setDesc( 173 | 'The pattern used to render links to monthly notes where the destination note falls in a different ' + 174 | 'year then the current note. The user should aim to keep this pattern short ' + 175 | 'as multiple links may be rendered next to each other. ' + 176 | 'This pattern should not render any date/time elements shorter than a month (e.g. week or day). ' + 177 | "For instance, using a pattern of 'MM-DD' would not make sense " + 178 | 'as the day component represents a fraction of the month. ' + 179 | 'For help on the pattern syntax, refer to the link below.' 180 | ) 181 | 182 | this.createMomentSetting( 183 | settings, 184 | 'yearlyNoteTitlePattern', 185 | 'Yearly note title pattern' 186 | ).setDesc( 187 | 'The pattern used to render the title of a yearly note. ' + 188 | 'This pattern should not render any date/time elements shorter than a year (e.g. month, week or day). ' + 189 | "For instance, using a pattern of 'YYYY-MM' would not make sense " + 190 | 'as the month component represents a fraction of the year. ' + 191 | 'For help on the pattern syntax, refer to the link below.' 192 | ) 193 | 194 | this.createMomentSetting( 195 | settings, 196 | 'yearlyNoteShortTitlePattern', 197 | 'Yearly note short title pattern' 198 | ).setDesc( 199 | 'The pattern used to render links to yearly notes. The user should aim to keep this pattern short ' + 200 | 'as multiple links may be rendered next to each other. ' + 201 | 'This pattern should not render any date/time elements shorter than a year (e.g. month, week or day). ' + 202 | "For instance, using a pattern of 'YYYY-MM' would not make sense " + 203 | 'as the month component represents a fraction of the year. ' + 204 | 'For help on the pattern syntax, refer to the link below.' 205 | ) 206 | 207 | this.createUseFolderNameAsDefaultTitleSetting(settings) 208 | 209 | if (!settings.useFolderNameAsDefaultTitle) { 210 | this.createTextSetting( 211 | settings, 212 | 'journalFolderTitle', 213 | 'Default journal folder title' 214 | ).setDesc( 215 | 'The default title assigned to journal folders. The journal folder title ' + 216 | 'is used in the rendering of journal headers as well as to identify the ' + 217 | 'folder in other views. The journal folder title should typically be ' + 218 | 'configured at folder level as it would typically be unique to that ' + 219 | 'folder. The user is however provided the option to assign a default ' + 220 | 'value here. For most users it would make most sense, and it is ' + 221 | 'highly recommended to leave this value blank.' 222 | ) 223 | } 224 | 225 | new Setting(this.containerEl) 226 | .setName('Reset all to default values') 227 | .addButton((btn) => { 228 | btn 229 | .setIcon('reset') 230 | .setWarning() 231 | .onClick(() => { 232 | // noinspection JSIgnoredPromiseFromCall 233 | this.saveSettings(DEFAULT_SETTINGS).then(() => this.display()) 234 | }) 235 | }) 236 | } 237 | 238 | createMomentSetting( 239 | settings: JournalFolderSettings, 240 | fieldName: SettingsStringFieldName, 241 | name: string 242 | ): Setting { 243 | let component: MomentFormatComponent 244 | const sampleValueEl = document.createElement('div') 245 | sampleValueEl.addClass('journal-folder-config-sample-value') 246 | 247 | const setting = new Setting(this.containerEl) 248 | .setName(name) 249 | .addMomentFormat((text) => { 250 | component = text 251 | const onChange = debounce( 252 | (value: string) => { 253 | settings[fieldName] = value 254 | // noinspection JSIgnoredPromiseFromCall 255 | this.saveSettings(settings) 256 | }, 257 | 250, 258 | true 259 | ) 260 | 261 | text.setDefaultFormat(DEFAULT_SETTINGS[fieldName]) 262 | text.setValue(settings[fieldName]).onChange(onChange) 263 | text.setSampleEl(sampleValueEl) 264 | }) 265 | .addExtraButton((btn) => { 266 | btn 267 | .setIcon('reset') 268 | .setTooltip('Reset to default value') 269 | .onClick(() => { 270 | component.setValue(DEFAULT_SETTINGS[fieldName]) 271 | component.onChanged() 272 | }) 273 | }) 274 | 275 | const sampleEl = document.createElement('div') 276 | sampleEl.addClass('journal-folder-config-hints-row') 277 | 278 | const helpLinkEl = document.createElement('a') 279 | helpLinkEl.setAttribute( 280 | 'href', 281 | 'https://momentjs.com/docs/#/displaying/format/' 282 | ) 283 | helpLinkEl.innerText = 'Pattern syntax reference' 284 | helpLinkEl.addClass('journal-folder-config-syntax-reference-link') 285 | 286 | const sampleLabelEl = document.createElement('div') 287 | sampleLabelEl.addClass('journal-folder-config-sample-label') 288 | sampleLabelEl.setText('Sample value:') 289 | 290 | sampleEl.appendChild(helpLinkEl) 291 | sampleEl.appendChild(sampleLabelEl) 292 | sampleEl.appendChild(sampleValueEl) 293 | this.containerEl.appendChild(sampleEl) 294 | return setting 295 | } 296 | 297 | createTextSetting( 298 | settings: JournalFolderSettings, 299 | fieldName: SettingsStringFieldName, 300 | name: string 301 | ): Setting { 302 | const setting = new Setting(this.containerEl) 303 | let component: TextComponent 304 | 305 | return setting 306 | .setName(name) 307 | .addText((text) => { 308 | component = text 309 | const onChange = debounce( 310 | (value: string) => { 311 | settings[fieldName] = value 312 | // noinspection JSIgnoredPromiseFromCall 313 | this.saveSettings(settings) 314 | }, 315 | 250, 316 | true 317 | ) 318 | 319 | text.setValue(settings[fieldName]).onChange(onChange) 320 | }) 321 | .addExtraButton((btn) => { 322 | btn 323 | .setIcon('reset') 324 | .setTooltip('Reset to default value') 325 | .onClick(() => { 326 | component.setValue(DEFAULT_SETTINGS[fieldName]) 327 | component.onChanged() 328 | }) 329 | }) 330 | } 331 | 332 | createUseFolderNameAsDefaultTitleSetting( 333 | settings: JournalFolderSettings 334 | ): Setting { 335 | const name = 'Use folder name as default folder title' 336 | let component: ToggleComponent 337 | 338 | const onChange = (value: boolean) => { 339 | settings.useFolderNameAsDefaultTitle = value 340 | if (value) settings.journalFolderTitle = '' 341 | // noinspection JSIgnoredPromiseFromCall 342 | this.saveSettings(settings).then(() => this.display()) 343 | } 344 | 345 | return new Setting(this.containerEl) 346 | .setName(name) 347 | .addToggle((toggle) => { 348 | component = toggle 349 | toggle.setValue(settings.useFolderNameAsDefaultTitle).onChange(onChange) 350 | }) 351 | .addExtraButton((btn) => { 352 | btn 353 | .setIcon('reset') 354 | .setTooltip('Reset to default value') 355 | .onClick(() => { 356 | component.setValue(DEFAULT_SETTINGS.useFolderNameAsDefaultTitle) 357 | onChange(DEFAULT_SETTINGS.useFolderNameAsDefaultTitle) 358 | }) 359 | }) 360 | .setDesc( 361 | 'If this option is checked, and a journal folder title is not configured at ' + 362 | 'folder level, the folder name will be used as title for the journal folder.' 363 | ) 364 | } 365 | } 366 | -------------------------------------------------------------------------------- /src/features/journal-header/JournalHeader.svelte: -------------------------------------------------------------------------------- 1 | 18 | 19 | 27 | 28 |
29 | {#if info.journalFolderTitle} 30 |
{info.journalFolderTitle}
31 | {/if} 32 | 33 |

{info.title}

34 | 35 |
36 | 49 | 50 | {#if info.secondaryLinks.length > 0} 51 | 59 | {/if} 60 |
61 |
62 | -------------------------------------------------------------------------------- /src/features/journal-header/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | export * from './journal-header-feature' 20 | -------------------------------------------------------------------------------- /src/features/journal-header/journal-header-feature.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | import { mount } from 'svelte' 20 | import { 21 | type JournalFolderSettings, 22 | JournalNote, 23 | journalNoteFactoryWithSettings, 24 | PluginFeature, 25 | } from 'src/data-access' 26 | import { ErrorMessage } from 'src/ui' 27 | import JournalHeader from './JournalHeader.svelte' 28 | import { 29 | buildJournalHeaderInfo, 30 | type JournalHeaderInfo, 31 | } from './journal-header-info' 32 | import { TFile, type Plugin } from 'obsidian' 33 | 34 | export class JournalHeaderFeature extends PluginFeature { 35 | constructor(plugin: Plugin) { 36 | super(plugin) 37 | } 38 | 39 | async load() { 40 | this.plugin.registerMarkdownCodeBlockProcessor( 41 | 'journal-header', 42 | (source, el, ctx) => { 43 | try { 44 | const currentFile = this.plugin.app.vault.getAbstractFileByPath( 45 | ctx.sourcePath 46 | ) 47 | 48 | if (currentFile instanceof TFile) { 49 | const settings: JournalFolderSettings = this.getSettings( 50 | currentFile, 51 | source 52 | ) 53 | const note: JournalNote = 54 | journalNoteFactoryWithSettings(settings)(currentFile) 55 | const info: JournalHeaderInfo = buildJournalHeaderInfo( 56 | settings, 57 | note 58 | ) 59 | // @ts-ignore 60 | mount(JournalHeader, { target: el, props: { info } }) 61 | } else { 62 | this.mountError(el, `No current file present (${ctx.sourcePath})`) 63 | } 64 | } catch (error) { 65 | this.mountError(el, `${error}`) 66 | } 67 | } 68 | ) 69 | } 70 | 71 | private mountError(el: HTMLElement, error: string): void { 72 | mount(ErrorMessage, { target: el, props: { error: `${error}` } }) 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/features/journal-header/journal-header-info.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | import { 20 | type JournalFolderSettings, 21 | JournalNote, 22 | type Link, 23 | } from '../../data-access' 24 | 25 | export type JournalHeaderInfo = { 26 | title: string 27 | centerLinks: Link[] 28 | backwardLink: Link | undefined 29 | forwardLink: Link | undefined 30 | secondaryLinks: Link[] 31 | journalFolderTitle?: string 32 | } 33 | 34 | export function buildJournalHeaderInfo( 35 | settings: JournalFolderSettings, 36 | note: JournalNote 37 | ): JournalHeaderInfo { 38 | return { 39 | title: note.getTitle(), 40 | centerLinks: buildCenterLinks(), 41 | backwardLink: createBackwardLink(), 42 | forwardLink: createForwardLink(), 43 | secondaryLinks: buildSecondaryLinks(), 44 | journalFolderTitle: buildJournalFolderTitle(), 45 | } 46 | 47 | function buildJournalFolderTitle(): string | undefined { 48 | if (settings.journalFolderTitle) { 49 | return settings.journalFolderTitle 50 | } else if (settings.useFolderNameAsDefaultTitle) { 51 | return note.getFolderName() 52 | } 53 | } 54 | 55 | function buildCenterLinks(): Link[] { 56 | const links = note 57 | .getHigherOrderNotes() 58 | .filter((n) => n.isExistingNote() || n.isPresentOrFuture()) 59 | .map((n) => n.shortLinkFrom(note)) 60 | 61 | if (!note.isToday()) { 62 | links.push(note.dailyNoteToday().linkWithTitlePattern('[Today]')) 63 | } 64 | 65 | return links 66 | } 67 | 68 | function createForwardLink(): Link | undefined { 69 | const directSibling = note.forwardInTime() 70 | 71 | if (directSibling.isExistingNote() || directSibling.isPresentOrFuture()) { 72 | return directSibling.shortLinkFrom(note) 73 | } 74 | 75 | const closestSibling = note.closestSibling('after') 76 | 77 | if (closestSibling) { 78 | return closestSibling.shortLinkFrom(note) 79 | } 80 | } 81 | 82 | function createBackwardLink(): Link | undefined { 83 | const directSibling = note.backInTime() 84 | 85 | if (directSibling.isExistingNote() || directSibling.isPresentOrFuture()) { 86 | return directSibling.shortLinkFrom(note) 87 | } 88 | 89 | return note.closestSibling('before')?.shortLinkFrom(note) 90 | } 91 | 92 | function buildSecondaryLinks(): Link[] { 93 | return note 94 | .getLowerOrderNotes() 95 | .map((n) => n.link('short', n.isMissingNote() && n.isPast())) 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/plugin/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | import JournalFolderPlugin from './journal-folder-plugin' 20 | 21 | export default JournalFolderPlugin 22 | -------------------------------------------------------------------------------- /src/plugin/journal-folder-plugin.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | import { App, Plugin, type PluginManifest } from 'obsidian' 20 | import { PluginFeatureSet } from './plugin-feature-set' 21 | import { JournalHeaderFeature } from '../features/journal-header' 22 | import { JournalFolderSettingsFeature } from '../features/journal-folder-settings' 23 | 24 | export default class JournalFolderPlugin extends Plugin { 25 | readonly #features: PluginFeatureSet = new PluginFeatureSet() 26 | 27 | constructor(app: App, manifest: PluginManifest) { 28 | super(app, manifest) 29 | 30 | this.#features 31 | .addFeature( 32 | new JournalFolderSettingsFeature(this, this.#features.useSettings) 33 | ) 34 | .addFeature(new JournalHeaderFeature(this)) 35 | } 36 | 37 | readonly onExternalSettingsChange = this.#features.onExternalSettingsChange 38 | readonly onload = this.#features.load 39 | readonly unload = this.#features.unload 40 | } 41 | -------------------------------------------------------------------------------- /src/plugin/plugin-feature-set.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | import type { JournalFolderSettings, PluginFeature } from '../data-access' 20 | 21 | export class PluginFeatureSet { 22 | readonly #pluginFeatures: PluginFeature[] = [] 23 | 24 | readonly addFeature = (feature: PluginFeature): PluginFeatureSet => { 25 | this.#pluginFeatures.push(feature) 26 | return this 27 | } 28 | 29 | readonly load = async (): Promise => { 30 | for (const feature of this.#pluginFeatures) { 31 | try { 32 | await feature.load() 33 | } catch (e) { 34 | console.error(e) 35 | } 36 | } 37 | } 38 | 39 | readonly unload = (): void => { 40 | this.#pluginFeatures.forEach((feature) => { 41 | try { 42 | feature.unload() 43 | } catch (e) { 44 | console.error(e) 45 | } 46 | }) 47 | } 48 | 49 | readonly useSettings = (settings: JournalFolderSettings): void => { 50 | this.#pluginFeatures.forEach((feature) => { 51 | try { 52 | feature.useSettings({ ...settings }) 53 | } catch (e) { 54 | console.error(e) 55 | } 56 | }) 57 | } 58 | 59 | readonly onExternalSettingsChange = (): void => { 60 | this.#pluginFeatures.forEach((feature) => { 61 | try { 62 | feature.onExternalSettingsChange() 63 | } catch (e) { 64 | console.error(e) 65 | } 66 | }) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/ui/ErrorMessage.svelte: -------------------------------------------------------------------------------- 1 | 18 | 19 | 22 | 23 |
{error}
24 | -------------------------------------------------------------------------------- /src/ui/NoteLink.svelte: -------------------------------------------------------------------------------- 1 | 18 | 19 | 25 | 26 | {#if inactive} 27 | {title} 28 | {:else} 29 | {title} 30 | {/if} 31 | -------------------------------------------------------------------------------- /src/ui/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Obsidian Journal Folder - Utilities for folder-based journaling in Obsidian 3 | Copyright (C) 2024 Charl Fourie 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | export { default as ErrorMessage } from './ErrorMessage.svelte' 20 | export { default as NoteLink } from './NoteLink.svelte' 21 | -------------------------------------------------------------------------------- /styles.css: -------------------------------------------------------------------------------- 1 | /*No global styles to declare*/ 2 | 3 | .journal-folder-header { 4 | position: sticky; 5 | top: 0; 6 | z-index: 10000000; 7 | align-self: start; 8 | justify-self: start; 9 | width: 100% 10 | } 11 | 12 | .journal-folder-header-folder-title { 13 | width: fit-content; 14 | margin-inline: auto; 15 | font-size: 1.2rem; 16 | opacity: 50%; 17 | margin-bottom: 0.4rem; 18 | cursor: default; 19 | } 20 | 21 | .journal-folder-header-title { 22 | width: fit-content; 23 | margin-inline: auto; 24 | margin-block: .4rem !important; 25 | cursor: default; 26 | } 27 | 28 | .journal-folder-header-options { 29 | font-size: .9rem; 30 | padding: .3rem 0; 31 | gap: .2rem; 32 | border-block: solid var(--border-width) var(--hr-color); 33 | display: flex; 34 | flex-direction: column; 35 | margin-bottom: 1rem; 36 | } 37 | 38 | .journal-folder-header-links { 39 | display: flex; 40 | gap: .2rem .3rem; 41 | justify-content: center; 42 | align-items: center; 43 | flex-wrap: wrap; 44 | } 45 | 46 | .journal-folder-header-links > * { 47 | margin: 0; 48 | } 49 | 50 | .journal-folder-note-link.chip { 51 | border: solid thin; 52 | display: block; 53 | line-height: 1rem; 54 | border-radius: .5rem; 55 | padding-inline: .5rem; 56 | height: fit-content; 57 | text-decoration: none; 58 | 59 | &:link, &:visited, &:hover, &:active { 60 | text-decoration: none !important; 61 | } 62 | 63 | &:hover { 64 | background: hsla(var(--accent-h), var(--accent-s), var(--accent-l), 0.2); 65 | } 66 | 67 | &:active { 68 | color: var(--background-primary); 69 | background: hsl(var(--accent-h), var(--accent-s), var(--accent-l)); 70 | } 71 | } 72 | 73 | .journal-folder-note-link.no-link { 74 | color: var(--text-faint); 75 | } 76 | 77 | .journal-folder-error-message { 78 | color: var(--color-red); 79 | } 80 | 81 | .journal-folder-config-sample-label { 82 | opacity: 50%; 83 | } 84 | 85 | .journal-folder-config-sample-value { 86 | opacity: 75%; 87 | } 88 | 89 | .journal-folder-config-hints-row { 90 | display: flex; 91 | gap: 1em; 92 | margin-bottom: .25em; 93 | } 94 | 95 | .journal-folder-config-syntax-reference-link { 96 | margin-right: auto; 97 | } 98 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/svelte/tsconfig.json", 3 | "compilerOptions": { 4 | "types": ["svelte", "node"], 5 | "baseUrl": ".", 6 | "inlineSources": true, 7 | "module": "ESNext", 8 | "target": "ES2020", 9 | "allowJs": true, 10 | "noImplicitAny": true, 11 | "moduleResolution": "node", 12 | "importHelpers": true, 13 | "isolatedModules": true, 14 | "strictNullChecks": true, 15 | "lib": [ 16 | "DOM", 17 | "ES2020" 18 | ], 19 | }, 20 | "include": [ 21 | "**/*.ts" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /version-bump.mjs: -------------------------------------------------------------------------------- 1 | import { readFileSync, writeFileSync } from "fs"; 2 | 3 | const targetVersion = process.env.npm_package_version; 4 | 5 | // read minAppVersion from manifest.json and bump version to target version 6 | let manifest = JSON.parse(readFileSync("manifest.json", "utf8")); 7 | const { minAppVersion } = manifest; 8 | manifest.version = targetVersion; 9 | writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t")); 10 | 11 | // update versions.json with target version and minAppVersion from manifest.json 12 | let versions = JSON.parse(readFileSync("versions.json", "utf8")); 13 | versions[targetVersion] = minAppVersion; 14 | writeFileSync("versions.json", JSON.stringify(versions, null, "\t")); 15 | -------------------------------------------------------------------------------- /versions.json: -------------------------------------------------------------------------------- 1 | { 2 | "1.0.0": "0.15.0" 3 | } --------------------------------------------------------------------------------