* fixing some unmatched links, daily-note path note, start graphviz/tags/properties clarification
fixed links that didn't actually link to their target, add discussion about creating daily-notes in path based off date, then clarifying notes about styling graph viz and tags while enhancing the note properties descriptions by describing how properties are described and which properties are custom, which are foam-specific, and which are foam-template-specific
* add filter view, default variables to graphviz, and viewing tags in graphviz
graphviz: discuss filter view, add all changeable variables to graph style example, tags: describe viewing tags in the graphviz
* add small note about learning yaml
* last push fixing up some todos
* making recommended changes from PR request
* Added path util to resolve absolute path from multiple base directories
* Better support for multiple roots in include/ignore globs
* URI.asAbsolutePath to use path utils
* Lint
* Add a hover tooltip to placeholder links offering to create a new note from template
* Clicking the placeholder tooltip asks for template for new note
* Create new note from template using `CREATE_NOTE` command
* Update tests
* Added create-note command and refactored some template code
* Added tests
* Added uri resolution logic across multiple folders
* Deprecating create-note-from-default-template command, it is now replaced by the new and more flexible create-note command (which still has the same defaults)
* Reorganize docs folder; isolate dev docs and user docs; integrate foam-template docs
* Rename how-to to getting-started
* Fixup all references
* Fix contribution-guide.md
* Fix asset references
* Fix user/index.md
* Spelling is good.
Thanks @DrakeWhu
* Add note about how to wite docs for foam
Removed resource.source property:
* removed usage of resource.source.text
* removed usage of resource.source.eol
* removed usage of resource.source.contentStart
* removed usage of resource.source.end
* removed resource.source
Small change in provider set up:
* added IWatcher interface
* changed fs watcher set up
Commands refactoring:
* moved commands in own directory
* split one command per file
* added "update graph" command
* renamed date-snippet file (before it included a combination of commands and snippet completion)
Also some test cleanup:
* made tests about note renaming/sync more reliable
* improved clean up between tests
* improved reporting in test runs
* fixed exit on failure behavior to surface exit code to CI
* Added attachment provider
* distinguish attachment and image types
* Added support for embeding images/attachments
* Added setting to decide whether to show notes in container in preview panel
Remove references that are wiki links, they are not needed (because Foam will take care of the routing in the preview) and they cause the rendering of wiki links to be surrounded by square brackets.
* basic implementation of file rename support
* tweaks to various tests
* make lint happy again
* Improved reporting
* added setting related to file sync
* added documentation in readme
There was an issue with navigation that would cause multiple text editors to be opened for the same file.
Turns out the issue was related to the use of URIs that included the fragment component, as well as the interaction between the link provider and the definition provider.
This commit fixes the issue.
Fixes#941
Unfortunately there is no way to see which errors are being skipped, but at the same time it makes sense to not be strict and have a single file block a whole scan (especially because it could be a file Foam is not even interested in).
* create slugified title variable available in templates
* add test
* add FOAM_SLUG to documentation
* add github-slugger dependency
Co-authored-by: Brian DeVries <brian@brianjdevries.com>
* Add the snippet parsing code from VSCode
From 95be30b3ac
* Remove `override` keyword
This is a TypeScript 4.3 feature, but Foam is not there yet
* Use `SnippetParser` to find Foam variables
* Return `Variable` objects from `findFoamVariables`
* Make `SnippetParser` resolve async
* Implement a `VariableResolver`
* Add start/end positions to `Variable`s
* Substitute based on indices, not regex
* Remove limitation warning from docs
* Merge `FoamVariableResolver` and `Resolver`
* Remove `extraVariablesToResolve`
It was no longer being used for `FOAM_TITLE`, and `FOAM_SELECTED_TEXT` didn't need to have it set either, so long as it appeared in `givenValues`, which it does.
* Add name filter to `resolveVariables`
You cannot call `resolve` on a `Variable` without modifying it, even if your `VariableResolver` doesn't know how to resolve the `Variable`.
For example, a `Transform` with a default value will modify the `Varible`'s `children`, even if the `VariableResolver` does not resolve a value.
Instead, we add a name filter, so that we don't resolve any `Variable`s that aren't Foam variables.
* Return `undefined` when the `VariableResolver` cannot resolve a `Variable`
This is how a `VariableResolver` is supposed to behave in these cases.
* Move variable substitution into `TextmateSnippet`
That way, the Foam `VariableResolver` code doesn't need to keep track of the text, nor interact with the `Variable` `pos`/`endPos`.
* Added support for sections/subsections in `Resource`
* Added support for sections in navigation and definitions
* Section completion
* Diagnostics and quick actions for sections
* Added support for section embeds in preview
* Added reference to sections support in readme file
* Add support for sections in direct links
* Added support for sections in identifier computation
* Support for section wikilinks within same file
* Tweaks
* using different approach to store/look-up references in FoamWorkspace that also supports better wikilink matching
* added documentation for Foam wikilinks
* added changelog
* refactored note templates code
* more tests for "Create from template" commands
* inject resolver
* implemented feedback from PR #827 (Authored by @l2dy)
- introduce definition and references support
- changes links to only be used for placeholders
- simplifies configuration
Co-authored-by: Jonas Sprenger <sprengerjo@gmail.com>
* always convert vscode.Uri to foam.URI
* Improve handling on Windows paths in URI
- convert to upper case drive letter
- normalize use of Windows conversion in URI
- added more test cases
* Fixed tests
* added support for target date variables in daily note template
* added FOAM_DATE_* variables to resolver
* Document `FOAM_DATE_*` template variables
* Add CHANGELOG entry
Co-authored-by: Michael Overmeyer <michael.overmeyer@shopify.com>
* moved `foam-core` inside `foam-vscode`
* updated contribution guide to reflect new modules setup
* improved testing
* consolidate to root yarn.lock files
* tweaking CI workflow && using github secrets to force cache refresh
* improved linting configuration. `core` module cannot depend on other parts of the `foam-vscode` package
* Add the functionality to include notes in a note
* Add proposal of embedding
* Add tests for including notes
* Add documentation for inclusion feature
* Removes escape character of an alias when setting WikiLink target
* Alter tearDown of document-link-provider test
* Disable link reference defintion generation for all tests
* be more conservative in removing link definitions
* Update packages/foam-vscode/src/features/preview-navigation.ts
Co-authored-by: Riccardo <code@riccardoferretti.com>
Co-authored-by: Riccardo <code@riccardoferretti.com>
* Add docs to `createDailyNoteDirectoryIfNotExists`
* Add docs to `createDailyNoteIfNotExists`
* Capitalize doc strings
* Add docs to `getDailyNoteFileName`
* Update the @configuration parameter docs
* Add docs to `getDailyNotePath`
* Add docs to `openDailyNoteFor`
* Update packages/foam-vscode/src/dated-notes.ts
Co-authored-by: Michael Overmeyer <michael.overmeyer@shopify.com>
* Update packages/foam-vscode/src/dated-notes.ts
Co-authored-by: Michael Overmeyer <michael.overmeyer@shopify.com>
* Polish some of the comments
Co-authored-by: José Duarte <jmg.duarte@campus.fct.unl.pt!>
Co-authored-by: Michael Overmeyer <michael.overmeyer@shopify.com>
* Add support for basic link aliases
* Refactor to future link model
* Refactor preview behavior for aliases
* Refactore use of NoteSource
* Remove references from ref block before processing links
Co-authored-by: Jani Eväkallio <jani.evakallio@gmail.com>
* Add a frontmatter metadata parser
* Use the template metadata to determine the filepath to use
* Document template metadata
* Add name and description template metadata attributes
These are displayed in the template picker
* Document name and description template metadata attributes
* Fix snake_case to camelCase
* Always ask for the note title when creating from the default template
In the future, we'll make this conditional on whether the template provides the filepath to use in its metadata block
we wait to create the graph, as changes to the workspace will cause it to be recomputed.
so, first load all resources from the initial providers, then compute the graph.
* Add new `Create New Note` command
It is the streamlined counterpart to `Create New Note From Template`
* Simplify the variable Regex
\W is equivalent to [^A-Za-z0-9_]
* extracted graph from workspace
* refactored datastore
* dataviz to use URI for placeholder detection
* graph uses uris, not resources
* adding placeholder in graph
* link completion to use graph
* API v1 - Resource refactoring (#595)
* aside: tweaked jest extension configuration
* added provider for markdown
* removed file check in URI
the problem is that it makes the URI dependent on the disk, which makes testing harder.
The change was originally introduced to prevent Foam from treating directories ending in .md as markdown files, but the check needs to probably happen somewhere else, e.g. in `FileDataStore.list` - or directories should be expressed with a trailing slash (to check whether that breaks the URI convention)
* Various changes
- `resolveLink` now delegates to providers
- added `read` method in providers and `FoamWorkspace`
- improved `Matcher` API
- updated tests to use workspace with providers
- delegating more to workspace now it can read files (simplifies wiring and exposed API surface)
- provider init returns a promise, so it can be awaited on
- `IDataStore` now has `list` method, to encapsulate all access to FS
* improved windows support in URI and matcher
* improved grouped resources interface
* added readAsMarkdown in provider, useful for tooltip generation with preview in vscode
* Fix: Right links and formatting
* Docs: Run markdownlint to automatically fix minor formatting errors
* Style: Format with markdownlint and not prettier
* when calling URI.file more than two time on windows
* a extra slash('/') at path's beginning may cause some problems
* so add a condition to solve it
* placeholders are updated when creating connection, not when resolving link
* feature: link completion
* added tests
Co-authored-by: Jani Eväkallio <jani.evakallio@gmail.com>
* refactored URI to be less dependent on VS Code implementation
* moved uri tests in own file, and added test case from #507
* added license info for VS Code inspired code
* moved URI utility methods in abstract class for namespacing
* better names for some methods
Co-authored-by: Jonathan <jonny@mondago.com>
* added uri utility method, and exposing uri module
* added utility methods
* renamed and enhanced open-placeholder-note command to support all resources
* support for links via document link provider and decorator
* use open resource command in tree data provider
* make open resource command unavailable in command palette
* using snippet for better UX when creating note from placeholder
* exposing parser as a Foam service
* consolidated "open resource" command code
* added tests for document links provider
* added caching of VS Code also for lint
Even if linting doesn't require the vscode part of the cache, we are not separating the two cases so that we only have one cache to maintain, and linting being a faster task (and a task that should fail less than tests) will update the cache more often, speeding up the run of the tests afterwards
* `FoamWorkspace.find` to return `null` when no reference is provided for relative path
* turning wikilinks into browsable links in markdown preview
* moved preview styles in css file and reorganized code in static folder
Static was previous used only for the dataviz graph. Now we have 2 subdirectories: dataviz for the graph, and preview for the markdown preview.
For now the css style is a bit of an overkill, but sets up the right foundation for further customization down the line.
* chore: explicitly disabling gitdoc extension, removing unnecessary async keyword
* fix: fixed test utility fn (and linter warning)
* test: added tests for preview link generation
* changed launch configuration to support both foam-core and foam-vscode packages
* Use URI throughout dated-notes
* Fix typos in comments
* Allow absolute paths in `openDailyNote.directory`
This allows users to press the `alt-d` shortcut to open the daily note
from any instance of VSCode, not just within the `foam-template` repo.
The even listener is called with `this` bound to undefined, which causes the refresh function in fail when it accesses the object methods/fields. wrapping it into an arrow function avoids the problem
* Create Blank Note Explorer View
Creates a new "Blank Note" explorer view which displays all notes that
contain only a title. When note.source.text.trim().split('\n').length
is equal to 1, a note is considered blank. This should mean that the
note contains only a title.
The UX experience is identical to that of the Orphan view. A user can
toggle between both the flat view and a nested view grouped by
directory.
* Cleaned up views and made them much more dynamic.
Instead of just copy and pasting the orphans view into blank notes,
I created a filtered notes provider, which behaves identically to the
old orphan/blank notes providers, but allows the caller to pass in the
"filter function" which will narrow down the list of notes in the view.
This also allows us to more easily unit test the filtering logic, and
only test the flatten / nested logic in one place. It also makes it so
that when we refactor the way one of these views works (e.g. adding the
markdown preview), we don't have to make changes to the other view.
* Fixed unit test that was failing in Windows.
* Combined placeholders and blank notes.
* Removed workspacesFsPaths and replaced with workspacesURIs
Co-authored-by: J.T. James <joel.james@myfuelmaster.com>
* improved resolution for direct links and wikilink with definition
* if the definition of a wikilink points to a non-existing file, create a placeholder for the full path instead
* if a link doesn't point to a valid resource, create a placeholder for the full path instead
* commented out test-data.js import in dataviz.html
* moved test to more appropriate group
* Combine steps
* Cancel if escape pressed in any step
* New template command
* Execute "create new template" when no templates found
* Provide inline documentation
* Add tests
* Add docs for the feature
Co-authored-by: Jonathan <jonny@mondago.com>
* improved delta logic in graph.js
fixes a bug that was due to using object.splice inside a forEach loop (sometimes stackoverflow is wrong - removing the element inside the loop will actually reduce the iterations and not all elements in the array will be visited!)
* various fixes to live update of workspace model + tests
* added tab size option in settings.json
* added workspace WIP
* workspace supports resources
* uri check more lenient (was causing bug by not recognizing some objects)
* added placeholder resource type
* consolidated code in FoamWorkspace and added more tests
* updated all modules to use FoamWorkspace
* fixed FoamWorkspace.getConnections function
when links or backlinks are not present it no longer adds `undefined` to the connection list
* fix in workspace handling of direct links
* consolidated id/name generation functions
* added test for wikilink resolution when several notes have same filename
* removed reference to graphMiddleware in foam-local-plugins doc
graph middleware won't be supported with the `FoamWorkspace`. Support for the markdown provider remains
* removed support for graph middleware, graphlib dependency, and old note-graph implementation
Running the tests with vscode 1.53.0 is causing issues in `suite.ts:23`, which is causing a stack overflow, possibly due to a recursive callback. Also see https://github.com/foambubble/foam/pull/479#issuecomment-774167127 .
It's unclear what's causing the issue, but forcing the version to 1.52.0 solves the problem.
To review, further investigate, and roll back this workaround.
* fix#442 - link to known-issues replaced
* formatted settings + enable format on save + improved jest config
* removed editorconfig in foam-cli
* formatted foam-vscode
* removed author in package.json files
* minor changes to readme files
* fixed husky pre-commit hook
* Add graph style to VSCode settings
* Update default to an empty object
* Add function to retrieve the graph style from the settings
* Implement the graph custom styling setting
The implementation makes use of the webview communication mechanism to
switch messages between the webview and the graph.
It works as follows:
- When the webview is loaded, it now sends a single request to VSCode,
the request asks VSCode for the graph style
- When VSCode answers with the style, the graph style is updated and
the webview loading process continues as normal.
The style change does not modify the API, in fact it makes use of the
shadiest programming tatic ever, *global variables* to remain
compatible.
The style object *currently* supports four base fields:
- background: string
- fontSize: int
- highlightedForeground: string
- node: object
- note: string
- nonExistingNote: string
- unknown: string
* Simplify null handling logic
* Remove debug logs
* Rename style setting
* Rename message style type
* Remove forgotten debug log
* Refactor the code to match model & action
* Add missing break
* Allow for dynamic style updates
* Fix the window loading bug
* Implement a permanent fix to the bug
* Replace `nonExistingNote` with `placeholder`
* Include the new graph style feature in the docs
* Remove unnecessary async
* Remove unused case
* support direct links
* added support for labels with formatting
* added documentation and removed lint warning
* ignore external links
* improved uri parsing
* filter links pointing to same note (e.g. sections within the note)
* check that note exists before navigating to it
* fixed compilation error
* added support for e2e vscode tests
* using github action that supports headless test run
* loading vscode test instance in empty dir to speed up bootstrap
* add windows-2019 to CI os matrix
* use actual URI object instead of strings to represent paths/uris
* added datastore tests
* chore: make Foam IDisposable
* fix(graph): Don't delete node for note on update
Doing so causes graphlib to delete the inbound links from other nodes so when this node is re-created it will be adrift by itself.
* Clear graph node's forward links on note update so they can be accurately rebuilt
* test(dataviz): Ensure updating a note does not clear its backlinks (tests #393)
* fix(dataviz): On note delete, set node to "no file" state if it is referenced by other notes
* test(dataviz): Ensure graph updates properly from note deletions
* reorganized and updated foam docs
* minor changes to vscode extension readme
* added 404 page and minor changes
Co-authored-by: Joe Previte <jjprevite@gmail.com>
Added API and events around note deletion
Improved github workflows, added logic to avoid duplicate runs in CI and merged build + test jobs
Added support for running workflows in multiple environments, commented window-2019 as test don't pass, but they will be fixed in another PR to avoid scope creep here.
* Improved logging
- using classes instead of functions (feels like it fits better the use case)
- using singleton global to not pass logging service around
* Added vscode logger, command to change level, and settings
* improved bootstrap logging
* build foam-core before running tests in github workflows
* added common code from vscode repo
lots of good utility functions and objects, especially around lifecycle and event management
* added datastore and logger services
* refactored bootstrap to consolidate behavior in foam-core
* tags treeview now updates when files are saved
* updated node engine version to match vscode's
* using new event model for foam graph events
* Initial work to create new note from template
* Treat template as snippet string
* Small refactor
* Improve semantics of focusNote
* Ask for filename, not title
Authored-by: Jonathan Ingall <jonny@mondago.com>
* Add documentation to the settings getters
* Reduce code noise in the bootstrap method
Files are now all processed in one method,
without `filter`s or `map`s to avoid reallocating arrays.
`addFile` is now inlined, as its function was mostly noise and became
unused.
`isLocalMarkdown` is now done right after listing all workspace files,
before applying the ignore globs.
`registerFiles` merely deals with registering several files,
instead of requiring a loop each time several files are to be
registered.
* Add documentation and type annotations
* Rephrase filterAndRegister docstring
* added test with d3 and g6
* spiked on three graph libraries
* removed unnecessary deps
* small clean up
* picked implementation, cleaned code and added selection
* use title as graph node name instead of note basename
* reloading graph when adding/removing notes
* fixed graph construction to remove node duplicates
* using file name for notes that don't have an h1 title
* added utility functions
* fixed link highlighting bug
* fixed various checks and lint errors
* Start working on date snippets
* Refactor logic to share across date features
* Start providing computed values
This may need to be changed to a Thenable
* Make calculated snippets functional
* Add support for any number
* Comment the code
These comments should be removed later
* Make "+" in snippet work
* Refactor changes
* Remove unused imports
* Add days of week snippets
* Add a shortcut for yesterday's note
* Rename focusDailyNote function
* Move pathExists to utils
* Make navigation on snippet selection configurable
Co-authored-by: Jonathan Ingall <jonny@mondago.com>
* changed vscode setting to include extensions in link definition
* updated docs to include extension in wikilink definition
* updated readme to navigate to github pages instead of published site
* added support for graph middleware via local plugin
* added support for parsing extension points / plugins
* improved parser plugin and added docs
* improved name of parameter
* need to enable local plugins, and improved configuration system
For security reasons local plugins are off by default.
The feature can be enabled via a flag in the foam configuration, which has been expanded to support this case.
The configuration system now reads a `config.json` file inside the `.foam` directory as well as a `~/.foam/config.json` file to configure the system.
Only the user specific configuration file can be used to enable local plugins, as a security measure against malicious repos.
* added prettier configuration file
This ensures consistency across machines as well as an explicit source of truth
* Access correct property on error to display stack trace
* Fix crash when file contains only frontmatter
* Add test for generateHeadings when the file only contains frontmatter
Co-authored-by: Ankit Tiwari <ankitt255@gmail.com>
* Update math-support.md
Explains how this mechanism works and adds some ideas on alternatives.
* Improve document structure
Co-authored-by: Jani Eväkallio <jani.evakallio@gmail.com>
After #208, id for each note in NoteGraph is hashed. However, in generateReferenceList in file wikilink-reference-generation.ts, the id is still given by the file path, which compromised the core functionality. This PR fixed this bug.
* decoupled ID from note slug
* added vscode debug configuration to work with vscode-jest extension
* made things prettier
* Add a test for parsing empty frontmatter
* Use astPositionToVsCodePosition util function
* fixed a TODOs around URIs and added tests
* added tests around notes querying
* removing unused imports
* Fix typo
* implemented PR feedback
* fixed lint warnings and renamed method for consistency
* removed unnecessary checks and fix compilation error in tests
Co-authored-by: Ankit Tiwari <ankitt255@gmail.com>
* Fill out Migrating from OneNote stub
* Update Summary and improve grammatic consistency
* Added terminal navigation instructions
* kebab-case and update roadmap links
* feat: setup jest for foam-vscode
* Add failing test (fails due to missing vscode dependency)
* feat: add vscode mock
Co-authored-by: Jani Eväkallio <jani.evakallio@gmail.com>
* Add frontmatter data to NoteGraph node
* Store document start position inside NoteGraph node
* Add heading below the frontmatter
* Show a progress bar while running Janitor
* Fix tests
* Update note start position to make it 1-indexed
* Initialize frontmatter by an empty object instead of null
* Remove console logs
* Add how to update pushed Azure Wiki
Add the way to push to GitHub and Azure with one command.
* Update docs/azure-devops-wiki.md
Co-authored-by: Joe Previte <jjprevite@gmail.com>
* Update azure-devops-wiki.md
Add suggested changes
* Update docs/azure-devops-wiki.md
Co-authored-by: Joe Previte <jjprevite@gmail.com>
Co-authored-by: Joe Previte <jjprevite@gmail.com>
* revise vscode task and launch configs
- Removed commands from sub-package:
same can be achieved from the root
- Added build and no-build variants.
In case separate watcher is already running,
no need to build.
- Changed watch to build (no hot-reload in vscode by default)
- Show the build in console
Didn't update yarn.lock, seems to want to add
foam-core@0.3.0-alpha.0, but not really
related to this change
Note: the extension tests are failing due to
`Cannot find module '...foam-vscode/out/test/suite/index'`.
However that shouldn't be related to this change either.
* Simplify VS Code launch tasks (shift work to typescript compiler)
* Fix circular dependency index->janitor/index->index
* Use --build flag to use TSC in Build Mode
https://www.typescriptlang.org/docs/handbook/project-references.html#build-mode-for-typescript
This configures tsc to use multiple project roots (vscode, core) and run incremental builds on
changes to each projects. This will necessitate us running the core in commonjs build mode,
which is fine for testing and deployment to node environments, but won't work in the browser,
so foam-core will need a separate build config for UMD builds
* Build foam-core in commonjs mode by default (+cleanup unnecessary config)
* Create ES6 build config for distribution builds
* Cleanup yarn.lock
* Build package before running
* Fix missing lint paths and fix lint error
* Remove redundant .vscode settings files from foam-vscode project
* Add core test launch task
Co-authored-by: jojanaho <janne.ojanaho@iki.fi>
* Update creating-new-notes.md
Added a non-intuitive hotkey for entering notes.
* Add instructions on how to remap the key binding
Co-authored-by: Jani Eväkallio <jani.evakallio@gmail.com>
* Move applyTextEdit to core
* WIP: Add janitor command in foam-vscode
* basic janitor command done
* unsaved markdown janitor solved
* export bootstrap getConfig functions
* fixed multi unsaved files text edits
* Move applyTextEdit to core
* WIP: Add janitor command in foam-vscode
* basic janitor command done
* unsaved markdown janitor solved
* export bootstrap getConfig functions
* fixed multi unsaved files text edits
* Be less greedy about definitions, only include defs at end of file
* Use link reference definitions in janitor
* Add headers/footers to tests
* Ensure janitor doesn't touch unrelated reference definitions
* Format document, convert promise trampoline to async/await for readability
* Add error handling and friendly output
* Use workspace settings for extension
* Add flag to janitor
* Use note.eol
* Fix tests
Co-authored-by: Ankit Tiwari <ankitt255@gmail.com>
Co-authored-by: Jani Eväkallio <jani.evakallio@gmail.com>
* adding recipe for migrating from Onenote
* Update docs/roadmap.md
Co-authored-by: Joe Previte <jjprevite@gmail.com>
Co-authored-by: Joe Previte <jjprevite@gmail.com>
* Add notes to NoteGraph when they are created
* Add experimental events to foam-core to notify listeners about added/updated notes
* Update reference definitions in active editor when new note is added
* Update document in note graph before updating references
* Move cursor to end of file when opening daily note
* always move cursor to end of the file
* Only move cursor focus when file is newly created
Co-authored-by: Jani Eväkallio <jani.evakallio@gmail.com>
* Add Note.definitions and Note.end
* Use stringifyMarkdownLinkReferenceDefinition in foam-vscode
This commit also applies prettier to previously badly formatted files, so the diff is larger than necessary
* Add Note.end and Note.definitions to foam-core tests
* Export stringifyMarkdownLinkReferenceDefinition from foam-core
* Implement first version of generateLinkReferenceDefinitions janitor method
* Add partial tests for generateLinkReferenceDefinitions
* Setup Jest
* Add remove link definitions test to generateLinkReferences janitor method
* Add update link definitions test to generateLinkReferences janitor method
* export TextEdit interface
* Implement first version of applyText method
* Add no change in link definitions test to generateLinkReferences janitor method
* Add partial tests for writeFileToDisk method
* Implement generateHeading janitor method
Co-authored-by: CHIRAG SINGHAL <csinghal208@gmail.com>
* Move noteGraph scaffolding to utils
* Implement basic foam-cli janitor command
* kebab case file names while running janitor
* added generate Heading function to janitor
* added tests for generateHeading in janitor
* PR changes
* Add ora spinner
* Store endOfLine inside Note
* Use note.eol to append line endings
* check if given path is valid directory
* minor fixes
* added glob as dependency
* ignore link refrences with no file
* added tests files for migration
* Solves issue with roam migration
* fixed core tests
* Replace dashify by github-slugger
* used github slagger instead of dashify
* Add foam-core as dependency
* added foam migrate command
* updated foam janitor command
* minor fixes
* removed extra test files
* removed excess white space
* Refactor (PR changes)
1. Renamed initializeNoteGraph.ts to initialize-note-graph.ts to be consistent with naming
2. Refactored code in janitor and migrate commands
* Mock fs for tests
* Use Promise.resolve(null)
* Make fs tests no blocking by using promises
* Refactor renameFile to use path module
* Propagate the error from writeFileToDisk method
* Remove posttest command
* Run prettier before merge to get a cleaner diff
* Fix typo in variable name
* yarn lint --fix
* Update markdown-provider tests to support new API
* Add missing includeExtension argument
Co-authored-by: Jani Eväkallio <jani.evakallio@gmail.com>
Co-authored-by: chirag-singhal <csinghal208@gmail.com>
* Add .md extension when generating link definition section
The change in the definition allows links to be navigated in github
The changes in the JS inside _layouts maintains the html navigation when publishing to github pages.
For more info see https://foambubble.github.io/foam/link-reference-definition-improvements
* Updated existing docs to new link definition section
* better md file detection and consolidated code in parent template
* added mdx extension to markdown file detection
* added note about shortcut taken
* added configuration to toggle extensions in wikilinks + tests
* Revert "Updated existing docs to new link definition section"
This reverts commit 50e4a527e0.
We'll do this change once the version has been released
Co-authored-by: Jani Eväkallio <jani.evakallio@gmail.com>
* Add dateformat package dependency
* Implement Open Daily Note feature
- Activate command
- Add default keybindings for the command
- Use settings to configure the filename format, the file extension,
the title format and the directory where the note should be created
* Clarify how the repository should be opened in VS Code
* Change formatting and wording slightly
Co-authored-by: Jani Eväkallio <jani.evakallio@gmail.com>
description:Suggest an idea for the `Foam` project
body:
- type:markdown
attributes:
value:|
This issue form is for requesting features only!
If you want to report a bug, please use the [bug report](https://github.com/foambubble/foam/issues/new?assignees=&labels=&template=bug_report.yml) form.
- type:textarea
validations:
required:true
attributes:
label:Is your feature request related to a problem? Please describe.
description:A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
- type:textarea
validations:
required:true
attributes:
label:Describe the solution you'd like
description:A clear and concise description of what you want to happen.
placeholder:|
As a user, I expected ___ behavior but ___ ...
Ideal Steps I would like to see:
1. Go to '...'
2. Click on '....'
3. ....
- type:textarea
validations:
required:true
attributes:
label:Describe alternatives you've considered
description:A clear and concise description of any alternative solutions or features you've considered.
- type:textarea
attributes:
label:Screenshots or Videos
description:|
If applicable, add screenshots or a video to help explain your problem.
For more information on the supported file image/file types and the file size limits, please refer
to the following link: https://docs.github.com/en/github/writing-on-github/working-with-advanced-formatting/attaching-files
placeholder:|
You can drag your video or image files inside of this editor ↓
This repository is a [monorepo](https://en.wikipedia.org/wiki/Monorepo) managed by [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/).
- The [packages](packages/) directory contains all Foam core code packages
- The [docs](docs/) directory contains a Foam workspace that hosts the official [documentation site](https://foambubble.github.io/foam)
The foam starter template lives outside of this repository at [foambubble/foam-template](https://github.com/foambubble/foam-template).
See [Foam Contribution Guide](https://foambubble.github.io/foam/contribution-guide) on the rendered Foam workspace for more information on how to contribute to Foam.
Foam, at its heart and committed to in its [Principles](https://foambubble.github.io/foam/principles), allows the user to control their content in a flexible and non-prescriptive manner. This extends to user preferences, or requirements depending on application and context, around both privacy and security. One way that these use cases can be met is through the use of open-source and not-for-profit mechanisms in the user's workflow to provide a functional equivalence.
Here are a few suggestions on increasing privacy and security when using Foam.
## VS Codium: The Open Source build of VS Code
Foam is built upon VS Code, itself a Microsoft product built on top of an open source project.
As can be found [here](https://github.com/Microsoft/vscode/issues/60#issuecomment-161792005) the **VS Code product itself is not fully open source**. This means that its inner workings are not fully transparent, facilitating the collection and distribution of your data, as specified in its [Privacy Statement](https://devblogs.microsoft.com/visualstudio/privacy/).
If you prefer a fully open source editor based on the same core of VS Code (and for most intents and purposes equivalent to it), you can try [VSCodium](https://github.com/VSCodium).
In its own introduction it is described as, "Binary releases of VS Code without MS branding/telemetry/licensing". Installation packages are easily available across Windows, Unix and Linux (or you can build it from source!).
Access to the VS Code marketplace of add-ons remains in place, including the Foam extension.
The change you will notice in using VS Code versus VS Codium - simply speaking, none. It is, in just about every way you will think of, the same IDE, just without the Microsoft proprietary licence and telemetry. Your Foam experience will remain as smooth and productive as before the change.
## Version Control and Replication
In Foam's [Getting Started](https://foambubble.github.io/foam/#getting-started) section, the set up describes how to set up your notes with a GitHub repository in using the template provided. Doing so provides the user with the ability to see commits made and therefore versions of their notes, allows the user to work across devices or collaborate effectively with other users, and makes publishing to GitHub pages easy.
It's important at the same time to point out the closed-source nature of GitHub, being owned by Microsoft.
One alternative approach could be to use [GitLab](https://gitlab.com/), an open source alternative to GitHub. Whilst it improves on the aspect of transparency, it does also collect usage details and sends your content across the internet.
And of course data is still stored in clear in the cloud, making it susceptible to hacks of the service.
A more private approach would manage replication between devices and users with a serverless mechanism like [Syncthing](https://syncthing.net). Its continuous synchronisation means that changes in files are seen almost instantly and offers the choice of using only local network connections or securely using public relays when a local network connection is unavailable. This means that having two connected devices online will have them synchronised, but it is worth noting that the continuous synchronisation could result in corruption if two users worked on the same file simultaneously and it doesn't offer the same kind of version control that git does (though versioning support can be found and is described [here](https://docs.syncthing.net/users/versioning.html)). It is also not advisable to attempt to use a continuous synchronisation tool to sync local git repositories as the risk of corruption on the git files is high (see [here](https://forum.syncthing.net/t/can-syncthing-reliably-sync-local-git-repos-not-github/8404/18)).
If you need the version control and collaboration, but do not want to compromise on your privacy, the best course of action is to host the open source GitLab server software yourself. The steps (well described [here](https://www.techrepublic.com/article/how-to-set-up-a-gitlab-server-and-host-your-own-git-repositories/)) are not especially complex by any means and can be used exclusively on the local network, if required, offering a rich experience of "built-in version control, issue tracking, code review, CI/CD, and more", according to its website, [GitLab / GitLab Community Edition · GitLab](https://gitlab.com/rluna-gitlab/gitlab-ce).
Head over to the [[contribution-guide]]. `CONTRIBUTING.md` file name is blocklisted on GitHub pages, and doesn't appear in the [rendered output](https://foambubble.github.io/foam).
[//begin]: # "Autogenerated link references for markdown compatibility"
> [[todo]] [[good-first-task]] This contribution guide itself could be improved 😅
Foam is open to contributions of any kind, including but not limited to code, documentation, ideas and feedback. Here are some general tips on how to get started on contributing to Foam:
- Use Foam for yourself, figure out what could be improved.
- Check out [[roadmap]] to see what's already in the plans. I have thoughts about how to implement some of these, but open to ideas and code contributions!
- Read about our [[principles]] to understand Foam's philosophy and direction
- Read and act in accordance of our [[code-of-conduct]].
- Feel free to open [GitHub issues](https://github.com/foambubble/foam/issues) to give me feedback and ideas for new features.
- Foam code and documentation live in the monorepo at [foambubble/foam](https://github.com/foambubble/foam/)
- [/docs](https://github.com/foambubble/foam/docs): documentation and [[recipes]]
- [/packages/foam-vscode](https://github.com/foambubble/foam/tree/master/packages/foam-vscode): the core VSCode plugin
2. Install the necessary dependencies by running this command from the root:
`yarn install`
3. This project uses [Yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/).`foam-vscode` relies on `foam-workspace-manager`. This means we need to compile it before we do any extension development. From the root, run the command:
`yarn workspace foam-workspace-manager build`
4. Now we'll use the launch configuration defined at [`.vscode/launch.json`](https://github.com/foambubble/foam/blob/master/.vscode/launch.json) to start a new extension host of VS Code. From the root, or the `foam-vscode` workspace, press f5.
5. In the new extension host of VS Code that launched, open a Foam workspace (e.g. your personal one, or a test-specific one created from foam-template). This is strictly not necessary, but the extension won't auto-run unless it's in a workspace with a `.vscode/foam.json` file.
6. Test a command to make sure it's working as expected. Open the Command Palette (Ctrl/Cmd + Shift + P) and select "Foam: Update Markdown Reference List". If you see no errors, it's good to go!
For more resources related to the VS Code Extension, check out the links below:
[tutorial-adding-a-new-command-to-the-vs-code-extension]: tutorial-adding-a-new-command-to-the-vs-code-extension "Tutorial: Adding a New Command to the VS Code Extension"
- Write out a new `[[wiki-link]]` and `Cmd` + `Click` to create a new file.
-`Cmd` + `Shift` + `P` (`Ctrl` + `Shift` + `P` for Windows), execute `New Note` from [VS Code Markdown Notes](<(https://marketplace.visualstudio.com/items?itemName=kortina.vscode-markdown-notes)>) and enter a **Title Case Name** to create `title-case-name.md`
- Add a keyboard binding to make creating new notes easier.
- You shouldn't worry too much about categorising your notes. You can always [[search-for-notes]], and explore them using the [[graph-visualisation]].
[//begin]: # "Autogenerated link references for markdown compatibility"
[search-for-notes]: search-for-notes "Search for Notes"
The best way to develop docs for the Foam repo is to directly open the `$foam-repo/docs/` as the root folder in a new vscode window.
This automatically configures vscode with the necessary settings enabled (like [[link-reference-definitions]]) to efficiently write this documentation.
## Organization
The Foam documentation is organized into two areas:
* User docs, located at `$foam-repo/docs/user/*`, which are copied in their entirety into `$foam-template-repo/docs`.
* Developer docs, located at `$foam-repo/docs/dev/*`
New user docs should be added to the User docs folder in the main Foam repo, then copied over to the Foam Template repo.
> [[todo]]: Automate this process. Idea: github action to open a PR on any change to `/docs/user`
[//begin]: # "Autogenerated link references for markdown compatibility"
The Foam prototype is built by assembling third-party extensions, which seems like a good strategy because
- It supports picking and mixing of tools and workflows
- Less code to write an maintain
- Less code to write and maintain
But there's also a bunch of roadmap items that are hard to implement this way, as the third party plugins don't do exactly what we want them to do (e.g. Markdown All In One is not compatible with [[referencing-notes-by-title]].
Overall, we should strive to build big things from small things. Focused, interoperable modules are better, because they allow users to pick and mix which features work for them. A good example of why this matters is the Markdown All In One extension we rely on: While it provides many of the things we need, a few of its features are incompatible with how I would like to work, and therefore it becomes a limiter of how well I can improve my own workflow.
However, there becomes a point where we may benefit from implementing a centralised solution, e.g. a syntax, an extension or perhaps a VSCode language server. As much as possible, we should allow users to operate in a decentralised manner.
[//begin]: # "Autogenerated link references for markdown compatibility"
[referencing-notes-by-title]: referencing-notes-by-title "Referencing notes by title"
Foam is open to contributions of any kind, including but not limited to code, documentation, ideas, and feedback.
This guide aims to help guide new and seasoned contributors getting around the Foam codebase. For a comprehensive guide about contributing to open-source projects in general, [see here](https://sqldbawithabeard.com/2019/11/29/how-to-fork-a-github-repository-and-contribute-to-an-open-source-project/).
## Getting Up To Speed
Before you start contributing we recommend that you read the following links:
- [[principles]] - This document describes the guiding principles behind Foam.
- [[code-of-conduct]] - Rules we hope every contributor aims to follow, allowing everyone to participate in our community!
## Diving In
We understand that diving in an unfamiliar codebase may seem scary,
to make it easier for new contributors we provide some resources:
You can also see [existing issues](https://github.com/foambubble/foam/issues) and help out!
Finally, the easiest way to help, is to use it and provide feedback by [submitting issues](https://github.com/foambubble/foam/issues/new/choose) or participating in the [Foam Community Discord](https://foambubble.github.io/join-discord/g)!
## Contributing
If you're interested in contributing, this short guide will help you get things set up locally (assuming [node.js >= v16](https://nodejs.org/) and [yarn](https://yarnpkg.com/) are already installed on your system).
1. Fork the project to your Github account by clicking the "Fork" button on the top right hand corner of the project's [home repository page](https://github.com/foambubble/foam).
3. Install the necessary dependencies by running this command from the root of the cloned repository:
`yarn install`
4. From the repository root, run the command:
`yarn build`
You should now be ready to start working!
### Structure of the project
Foam code and documentation live in the monorepo at [foambubble/foam](https://github.com/foambubble/foam/).
- [/docs](https://github.com/foambubble/foam/tree/master/docs): documentation and [[recipes]].
Exceptions to the monorepo are:
- The starter template at [foambubble/foam-template](https://github.com/foambubble/)
- All other [[recommended-extensions]] live in their respective GitHub repos
This project uses [Yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/).
Originally Foam had:
- [/packages/foam-core](https://github.com/foambubble/foam/tree/ee7a8919761f168d3931079adf21c5ad4d63db59/packages/foam-core) - Powers the core functionality in Foam across all platforms.
- [/packages/foam-vscode](https://github.com/foambubble/foam/tree/master/packages/foam-vscode) - The core VS Code plugin.
To improve DX we have moved the `foam-core` module into `packages/foam-vscode/src/core`, but from a development point of view it's useful to think of the `foam-vscode/src/core` "submodule" as something that might be extracted in the future.
For all intents and purposes this means two things:
1. nothing in `foam-vscode/src/core` should depend on files outside of this directory
2. code in `foam-vscode/src/core` should NOT depend on `vscode` library
We have kept the yarn workspace for the time being as we might use it to pull out `foam-core` in the future, or we might need it for other packages that the VS Code plugin could depend upon (e.g. currently the graph visualization is inside the module, but it might be pulled out if its complexity increases).
### Testing
Code needs to come with tests.
We use the following convention in Foam:
-`*.test.ts` are unit tests
-`*.spec.ts` are integration tests
Tests live alongside the code in `src`.
### The VS Code Extension
This guide assumes you read the previous instructions and you're set up to work on Foam.
1. Now we'll use the launch configuration defined at [`.vscode/launch.json`](https://github.com/foambubble/foam/blob/master/.vscode/launch.json) to start a new extension host of VS Code. Open the "Run and Debug" Activity (the icon with the bug on the far left) and select "Run VSCode Extension" in the pop-up menu. Now hit F5 or click the green arrow "play" button to fire up a new copy of VS Code with your extension installed.
2. In the new extension host of VS Code that launched, open a Foam workspace (e.g. your personal one, or a test-specific one created from [foam-template](https://github.com/foambubble/foam-template)). This is strictly not necessary, but the extension won't auto-run unless it's in a workspace with a `.vscode/foam.json` file.
3. Test a command to make sure it's working as expected. Open the Command Palette (Ctrl/Cmd + Shift + P) and select "Foam: Update Markdown Reference List". If you see no errors, it's good to go!
### Submitting a Pull Request (PR)
After you have made your changes to your copy of the project, it is time to try and merge those changes into the public community project.
1. Return to the project's [home repository page](https://github.com/foambubble/foam).
2. Github should show you an button called "Compare & pull request" linking your forked repository to the community repository.
3. Click that button and confirm that your repository is going to be merged into the community repository. See [this guide](https://sqldbawithabeard.com/2019/11/29/how-to-fork-a-github-repository-and-contribute-to-an-open-source-project/) for more specifics.
4. Add as many relevant details to the PR message to make it clear to the project maintainers and other members of the community what you have accomplished with your new changes. Link to any issues the changes are related to.
5. Your PR will then need to be reviewed and accepted by the other members of the community. Any discussion about the changes will occur in your PR thread.
6. Once reviewed and accept you can complete the merge request!
7. Finally rest and watch the sun rise on a grateful universe... Or start tackling the other open issues ;)
---
Feel free to modify and submit a PR if this guide is out-of-date or contains errors!
---
[//begin]: # "Autogenerated link references for markdown compatibility"
[principles]: ../principles.md "Principles"
[code-of-conduct]: code-of-conduct.md "Code of Conduct"
This file is an example of a valid Foam file. Essentially it's just a markdown file with a bit of additional support for MediaWiki-style `[[wikilinks]]`.
Here are a few specific constraints, mainly because our tooling is a bit fragmented. Most of these should be eventually lifted, and our requirement should just be "Markdown with `[[wikilinks]]`:
- **The first top level `# Heading` will be used as title for the note.**
- If not available, we will use the file name
- **File name should have extension `.md`**
- This is a temporary limitation and will be lifted in future versions.
- At least `.mdx` will be supported, but ideally we'll support any file that you can map to `Markdown` language mode in VS Code
- **In addition to normal Markdown Links syntax you can use `[[MediaWiki]]` links.** See [[wikilinks]] for more details.
[//begin]: # "Autogenerated link references for markdown compatibility"
`foam-core`'s primary responsibility is to build an API on top of a workspace of markdown files, which allows us to:
- Treat files as a graph, based on links
- Can be either [[wiki-links]] or relative `[markdown](links.md)` style
- Can be either [[wikilinks]] or relative `[markdown](links.md)` style
- We need to know about the edges (connections) as well as nodes
- What link points to what other file, etc.
- Needs to have the exact link text, e.g. even if `[[some-page]]` or `[[some-page.md]]` or `[[Some Page]]` point to the same document (`./some-page.md`), we need to know which format was used, so linkreferencedefinitions can be generated correctly
- Needs to have the exact link text, e.g. even if `[[some-page]]` or `[[some-page.md]]` or `[[Some Page]]` point to the same document (`./some-page.md`), we need to know which format was used, so [[link-reference-definitions]] can be generated correctly
- Finding all documents with instances of `[[link]]`
- Visualisations
- Visualizations
- Full text search
- Or, if search is too expensive/complex, when given a list of file names and line/column positions from VS Code search API, can return the document context (e.g. full paragraph, preceding/following line etc)
@@ -96,12 +96,12 @@ Useful for knowing what needs to be supported. See [[feature-comparison]].
- [[foam-core-2020-07-11]]
[//begin]: # "Autogenerated link references for markdown compatibility"
# Inclusion of notes Proposal <!-- omit in TOC -->
Currently it is not possible within Foam to include other notes into a note. Next to including a full note it could be interesting to add functionalities that allow for greater flexibility. This proposal discusses some functionalities around inclusion of notes.
**IMPORTANT: This design is merely a proposal of a design that could be implemented. It DOES NOT represent a commitment by `Foam` developers to implement the features outlined in this document. This document is merely a mechanism to facilitate discussion of a possible future direction for `Foam`.**
- [Introduction](#introduction)
- [New features](#new-features)
- [Including a note](#including-a-note)
- [Include a section of a note](#include-a-section-of-a-note)
- [Include an attribute of a file (note property or frontmatter)](#include-an-attribute-of-a-file-note-property-or-frontmatter)
## Introduction
Initial work and thought on including a note was ignited by issue [#652](https://github.com/foambubble/foam/issues/652). Requested by a user was a likewise functionality as offered in Obsidian. This was simply the ability to include a note.
Whilst researching digital gardening for my own setup, I came across an in-depth overview by [Maggie Appleton](https://maggieappleton.com/roam-garden). Showing examples of her personal Roam Research I see valuable possibilites to connect more information, if we would add additional functionalities to the possibility of including a note. This proposal displays these possible functionalities and markup.
## New features
### Including a note
The minimal functionality is the ability to fully include a note. Markup used in Obsidian for this is `![[wikilink]]`. For Foam I would suggest to follow this syntax. Benefits being:
- Adds minimal amount of knowledge required as syntax is based on the syntax of creating a wikilink.
- Makes the auto-complete work ouf-of-the-box, without any additional code and listeners required.
**Important**. A risk exists that a loop of including the same notes arises. E.g. Note A includes note B which includes note A. This needs to be prevented by the implementation and made visible to the user.
### Include a section of a note
It could be interesting to only include a section of a note instead of the entire note. In order to do so thse user should be able to use the following syntax:
`![[wikilink#section-b]]`
As a result it will include the section title + section content until the next section *or* end of file.
### Include an attribute of a file (note property or frontmatter)
As a user I could be interested in collecting the value of any given proeprty for a note. For example, I might want to include the tags as defined in the frontmatter of note A. This should be possible via the syntax:
`![[wikilink:<property>]]`
The property value should be lookedup by foam defined properties, e.g. title, **or** any property defined in the frontmatter of a note.
So, the example of including the tags of a note should be:
For the time being, if you want to get [[wikilinks]] into all files within the workspace, you'll need to generate the link reference definitions yourself file-by-file (with the assistance of Foam).
### Wikilinks don't work on GitHub
> **TL;DR;** [workaround](#workaround) in the end of the chapter.
If you click any of the wikilinks on GitHub web UI (such as the `README.md` of a project), you'll notice that the links break with a 404 error.
At the time of writing (June 28 2020) this is a known, but unsolved error. To understand why this is the case, we need to understand what we are trading off.
So, why don't they work on GitHub?
The three components of [[link-reference-definitions]] are link label, link destination and Link Title.
The issue is the middle **link destination** component. It's configured to point to the file name **without file extension**, i.e. "file-name" instead of "file-name.md". This is to make the GitHub Pages rendering work, because if we generated the links to `file-name.md`, the links would point to the raw markdown files instead of their generated HTML versions.
So as you can see, we've prioritised GitHub Pages over GitHub Web UI for the time being.
Ideally, we'd like a solution that works with both, but it's not defined yet (see [[link-reference-definitions]] for more details)
#### Workaround
For the time being, you can use relative `[markdown links](markdown-link.md)` syntax.
**Pros:**
- This will work on all platforms.
**Cons:**
- It will break the Markdown Notes [[backlinking]] support
- Less convenient to write
### Finding certain words clutter the VS Code search results
Since link reference definitions have `[//begin]` and `[//end]` guards with explanatory text that use certain words, these words (like "generate") appear in VS Code search results if you happen to search matching strings from the workspace.
## Improvement Proposal
Problem space in essence:
- During edit-time (when modifying the markdown files in an editor)
- link reference definitions are needed if user uses editor extensions that don't understand wikilinks
- link reference definitions may be annoying since they
- add content to files that the user hasn't typed in by themselves
- get out of date if user uses a tool that doesn't autogenerate them
- may clutter the search results
- During build-time (when converting markdown to html for publishing purposes)
- link reference definitions are needed, if the files are published via such tools (or to such platforms) that don't understand wikilinks
- link reference definitions might have to be in different formats depending on the publish target (e.g. GitHub pages vs GitHub UI)
The potential solution:
- For edit-time
- Make edit-time link reference definition generation optional via user settings. They should be on by default, and generating valid markdown links with a relative path to a `.md` file.
- Make format of the link reference definition configurable (whether to include '.md' or not)
- Out of recommended extensions, currently only "markdown links" doesn't support them (?). However even its [code](https://github.com/tchayen/markdown-links/blob/master/src/parsing.ts#L25) seems to include wikilink parser, so it might just be a bug?
- For build-time
- To satisfy mutually incompatible constraints between GitHub UI, VSCode UI, and GitHub Pages, we should add a pre-processing/build step for pushing to GitHub Pages.
- This would be a GitHub action (or a local script, ran via foam-cli) that outputs publish-friendly markdown format for static site generators and other publishing tools
- This build step should be pluggable, so that other transformations could be ran during it
- Have publish targets defined in settings, that support both turning the link reference definitions on/off and defining their format (.md or not). Example draft (including also edit-time aspect):
```typescript
// settings json
// see enumerations below for explanations on values
{
"foam": {
"publish": [
{
"name": "Gitlab Mirror", // name of the publish target
"linkTranspilation": "Off",
"linkReferenceDefinitions": "withExtensions"
},
{
"name": "GitHub Pages",
"linkTranspilation": "Off",
"linkReferenceDefinitions": "withoutExtensions"
},
{
"name": "Blog",
"linkTranspilation": "Off",
"linkReferenceDefinitions": "Off"
},
{
"name": "My Amazing PDF book",
"linkTranspilation": "WikiLinksToMarkdown"
}
],
"edit": {
"linkReferenceDefinitions": "Off"
}
}
}
// Defines if and how links in markdown files are somehow converted (in-place) during build time
// Note that this enumeration is not valid edit-time, since we (probably) don't want to change text like this while user is editing it
enum LinkTranspilation {
Off, // links are not transpiled
WikiLinksToMarkdown, // links using wiki-format [[link]] are converted to normal md links: [link](./some/file.md)
// if this is set, not link reference definitions are generated (not needed)
}
// Defines if and how link reference definition section is generated
enum LinkReferenceDefinitions {
Off, // link reference definitions are not generated
WithoutExtensions // link reference definitions do not contain file extenions
}
```
- With Foam repo, just use edit-time link reference definitions with '.md' extension - this makes the links work in the GitHub UI
- Have publish target defined for GitHub pages, that doesn't use '.md' extension, but still has the link reference definitions. Generate the output into gh-pages branch (or separate repo) with automation.
- This naturally requires first removing the existing link reference definitions during the build
- Other
- To clean up the search results, remove link reference definition section guards (assuming that these are not defined by the markdown spec). Use unifiedjs parse trees to identify if there's missing (or surplus) definitions (check if they are identified properly by the library), and just add the needed definitions to the bottom of the file (without guards) AND remove them if they are not needed (anywhere from the file).
Note that the proposal above supports both (build-time) inline transpilation of wikilinks as well as creation reference definitions. Depending on the direction of Foam, also only one of them could be selected. In that case the other could be implemented at later point of time.
UI-wise, the publish targets could be picked in some similar fashion as the run/debug targets in vscode by implementing a separate panel, or maybe through command execution (CTRL+SHIFT+P) - not yet defined at this point.
## Links
- [tracking issue on GitHub](https://github.com/foambubble/foam/issues/16)
[//begin]: # "Autogenerated link references for markdown compatibility"
Items we plan on working next. Items in this stage don't need to have an owner, but before we start working on them should have enough specification that they can be picked up and worked on without having to seek consensus.
If you want to pick up work in this category, you should have a plan on how long the implementation will approximately take so we don't block progress by sitting on high priority issues.
- [[workspace-janitor]]
## Backlog
Everything else, categorised into themes. Just because something is on this list doesn't mean it'll get done. If you're interested in working on items in this category, check the [[contribution-guide]] for how to get started.
@@ -27,21 +23,24 @@ If a roadmap item is a stub, **consider** opening a [GitHub issue](https://githu
@@ -64,51 +63,41 @@ If a roadmap item is a stub, **consider** opening a [GitHub issue](https://githu
### Migration
The community is working on a number of automated scripts to help you migrate to Foam. The main work of developing such a method involves exporting your notes, converting them to the Markdown format, and then making sure that the links between notes (if you had those) still work.
The current capabilities of templates is limited in some important ways. This document aims to propose a design that addresses these shortcomings.
**IMPORTANT: This design is merely a proposal of a design that could be implemented. It DOES NOT represent a commitment by `Foam` developers to implement the features outlined in this document. This document is merely a mechanism to facilitate discussion of a possible future direction for `Foam`.**
- [Introduction](#introduction)
- [Limitations of current templating](#limitations-of-current-templating)
- [Too much friction to create a new note](#too-much-friction-to-create-a-new-note)
Creating of new notes in Foam is too cumbersome and slow. Despite their power, Foam templates can currently only be used in very limited scenarios.
This proposal aims to address these issues by streamlining note creation and by allowing templates to be used everywhere.
## Limitations of current templating
### Too much friction to create a new note
Creating new notes should an incredibly streamlined operation. There should be no friction to creating new notes.
Unfortunately, all of the current methods for creating notes are cumbersome.
#### Manual note creation (Mouse + Keyboard)
1. Navigate to the directory where you want the note
2. Click the new file button
3. Provide a filename
4. Manually enter the template contents you want
#### Manual note creation (Keyboard)
1. Navigate to the directory where you want the note
2.`⌘N` to create a new file
3.`⌘S` to save the file and give it a filename
4. Manually enter the template contents you want
#### Foam missing note creation
1. Open an existing note in the directory where you want the note
2. Use the wikilinks syntax to create a link to the title of the note you want to have
3. Use `Ctrl+Click`/`F12` to create the new file
4. Manually enter the template contents you want
#### `Markdown Notes: New Note` (Keyboard)
1. Navigate to the directory where you want the note
2.`Shift+⌘P` to open the command pallette
3. Type `New Note` until it appears in the list. Press `Enter/Return` to select it.
4. Enter a title for the note
5. Manually enter the template contents you want
#### Foam template note creation (Keyboard)
1.`Shift+⌘P` to open the command pallette
2. Type `Create New Note From Template` until it appears in the list. Press `Enter/Return` to select it.
3. Use the arrow keys (or type the template name) to select the template. Press `Enter/Return` to select it.
4. Modify the filepath to match the desired directory + filename. Press `Enter/Return` to select it.
All of these steps are far too cumbersome. And only the last one allows the use of templates.
### Templating of daily notes
Currently `Open Daily Note` opens an otherwise empty note, with a title defined by the `foam.openDailyNote.titleFormat` setting.
Daily notes should be able to be fully templated as well.
### Templating of filepaths
As discussed in ["Template the filepath in `openDailyNote`"](https://github.com/foambubble/foam/issues/523), it would be useful to be able to specify the default filepaths of templates. For example, many people include timestamps in their filepaths.
## Goal / Philosophy
In a sentence: **Creating a new note should be a single button press and should use templates.**
## Proposal
1. Add a new `Foam: Create New Note` that is the streamlined counterpart to the more flexible `Foam: Create New Note From Template`
2. Use templates everywhere
3. Add metadata into the actual templates themselves in order to template the filepaths themselves.
### Summary
This can be done through a series of changes to the way that templates are implemented:
1. Add a `${title}` and `${titleSlug}` template variables
2. Add a `Foam: Create New Note` command and hotkey
3. Change missing wikilinks to use the default template
4. Add a metadata section to templates
5. Add a replacement for `dateFormat`
6. Add support for daily note templates
7. Eliminate all `foam.openDailyNote` settings
I've broken it out into these steps to show that the overall proposal can be implemented piecemeal in independent PRs that build on one another.
### Add a `${title}` and `${titleSlug}` template variables
When you use `Markdown Notes: New Note`, and give it a title, the title is formatted as a filename and also used as the title in the resulting note.
**Example:**
Given the title `Living in a dream world` to `Markdown Notes: New Note`, the filename is `living-in-a-dream-world.md` and the file contents are:
```markdown
# Living in a dream world
```
When creating a note from a template in Foam, you should be able to use a `${title}` variable. If the template uses the `${title}` variable, the user will be prompted for a title when they create a note from a template.
Example:
Given this `.foam/templates/my_template.md` template that uses the `${title}` variable:
```markdown
# ${title}
```
When a user asks for a new note using this template (eg. `Foam: Create New Note From Template`), VSCode will first ask the user for a title then provide it to the template, producing:
```markdown
# Living in a dream world
```
There will also be a `${titleSlug}` variable made available, which will be the "slugified" version of the title (eg. `living-in-a-dream-world`). This will be useful in later steps where we want to template the filepath of a template.
### Add a `Foam: Create New Note` command and hotkey
Instead of using `Markdown Notes: New Note`, Foam itself will have a `Create New Note` command that creates notes using templates.
This would open use the template found at `.foam/templates/new-note.md` to create the new note.
`Foam: Create New Note` will offer the fastest workflow for creating a note when you don't need customization, while `Foam: Create New Note From Template` will remain to serve a fully customizable (but slower) workflow.
#### Case 1: `.foam/templates/new-note.md` doesn't exist
If `.foam/templates/new-note.md` doesn't exist, it behaves the same as `Markdown Notes: New Note`:
* it would ask for a title and create the note in the current directory. It would open a note with the note containing the title.
**Note:** this would use an implicit default template, making use of the `${title}` variable.
#### Case 2: `.foam/templates/new-note.md` exists
If `.foam/templates/new-note.md` exists:
* it asks for the note title and creates the note in the current directory
**Progress:** At this point, we have a faster way to create new notes from templates.
### Change missing wikilinks to use the default template
Clicking on a dangling/missing wikilink should be equivalent to calling `Foam: Create New Note` with the contents of the link as the title.
That way, creating a note by navigating to a missing note uses the default template.
### Add a metadata section to templates
* The `Foam: New Note` command creates a new note in the current directory. This is a sensible default that makes it quick, but lacks flexibility.
* The `Foam: Create New Note From Template` asks the user to confirm/customize the filepath. This is more flexible but slower since there are more steps involved.
Both commands use templates. It would be nice if we could template the filepaths as well as the template contents (See ["Template the filepath in `openDailyNote`"](https://github.com/foambubble/foam/issues/523) for a more in-depth discussion the benefits of filepath templating).
In order to template the filepath, there needs to be a place where metadata like this can be specified.
I think this metadata should be stored alongside the templates themselves. That way, it can make use of all the same template variable available to the templates themselves.
Conceptually, adding metadata to the templates is similar to Markdown frontmatter, though the choice of exact syntax for adding this metadata will have to be done with care since the templates can contain arbitrary contents including frontmatter.
#### Example
A workable syntax is still to be determined.
While this syntax probably doesn't work as a solution, for this example I will demonstrate the concept using a second frontmatter block:
```markdown
<!-- The below front-matter block is for foam-specific template settings -->
<!-- It is removed when the user creates a new note using this template -->
---
<!-- The default filepath to use when using this template -->
<!-- Relative paths are relative to the workspace, absolute paths are absolute -->
<!-- Note that you can include VSCode snippet variables to template the path -->
In this example, using this template improves the UX:
In `Foam: Create New Note` workflow, having `filepath` metadata within `.foam/templates/new-note.md` allows for control over the filepath without having to introduce any more UX steps to create a new note. It's still just a hotkey away and a title.
As we'll see, when it comes to allowing daily notes to be templated, we don't even need to use `${title}` in our template, in which case we don't we don't even need to prompt for a title.
In the `Create New Note From Template` workflow, during the step where we allow the user to customize the filepath, it will already templated according to the `filepath` in the template's metadata. This means that the user has to make fewer changes to the path, especially in cases where they want to include things like datetimes in the filenames. This makes it faster (eg. don't have to remember what day it is, and don't have to type it) and less error-prone (eg. when they accidentally type the wrong date).
### Add a replacement for `dateFormat`
`foam.openDailyNote.filenameFormat` uses `dateFormat()` to put the current timestamp into the daily notes filename. This is much more flexible than what is available in VSCode Snippet variables. Before daily notes are switched over to use templates, we will have to come up with another mechanism/syntax to allow for calls to `dateFormat()` within template files.
This would be especially useful in the migration of users to the new daily notes templates. For example, if `.foam/templates/daily-note.md` is unset, then we could generate an implicit template for use by `Foam: Open Daily Note`. Very roughly something like:
```markdown
<!-- The below front-matter block is for foam-specific template settings -->
<!-- It is removed when the user creates a new note using this template -->
---
<!-- The default filepath to use when using this template -->
<!-- Relative paths are relative to the workspace, absolute paths are absolute -->
<!-- Note that you can include VSCode snippet variables to template the path -->
<!-- The actual contents of the template begin after the `---` thematic break immediately below this line-->
---
# ${foam.openDailyNote.titleFormat}
```
### Add support for daily note templates
With the above features implemented, making daily notes use templates is simple.
We define a `.foam/templates/daily-note.md` filepath that the `Foam: Open Daily Note` command will always use to find its daily note template.
If `.foam/templates/daily-note.md` does not exist, it falls back to a default, implicitly defined daily notes template (which follows the default behaviour of the current `foam.openDailyNote` settings).
Both `Foam: Open Daily Note` and `Foam: Create New Note` can share all of the implementation code, with the only differences being the hotkeys used and the template filepath used.
Example daily note template (again using the example syntax of the foam-specific frontmatter block):
```markdown
<!-- The below front-matter block is for foam-specific template settings -->
<!-- It is removed when the user creates a new note using this template -->
---
<!-- The default filepath to use when using this template -->
<!-- Relative paths are relative to the workspace, absolute paths are absolute -->
<!-- Note that you can include VSCode snippet variables to template the path -->
Since there is no use of the `${title}` variable, opening the daily note behaves exactly as it does today and automatically opens the note with no further user interaction.
### Eliminate all `foam.openDailyNote` settings
Now that all of the functionality of the `foam.openDailyNote` settings have been obviated, these settings can be removed:
*`foam.openDailyNote.directory`, `foam.openDailyNote.filenameFormat`, and `foam.openDailyNote.fileExtension` can be specified in the `filepath` metadata of the daily note template.
*`foam.openDailyNote.titleFormat` has been replaced by the ability to fully template the daily note, including the title.
## Summary: resulting behaviour
### `Foam: Create New Note`
A new command optimized for speedy creation of new notes. This will become the default way to create new notes. In its fastest form, it simply opens the new note with no further user interaction.
### `Foam: Open Daily Note`
Simplified since it no longer has its custom settings, and re-uses all the same implementation code as `Foam: Create New Note`.
Templates can now be used with daily notes.
### Navigating to missing wikilinks
Now creates the new notes using the default template. Re-uses all the same implementation code as `Foam: Create New Note`
Now uses the contents of the wikilink as the `${title}` parameter for the template.
### `Foam: Create Note From Template`
Almost the exact same as it is today. However, with `${title}` and `filepath` templating, users will have less changes to make in the filepath confirmation step.
It's the slower but more powerful version of `Foam: Create New Note`, allowing you to pick any template, as well as customize the filepath.
## Extensions
In addition to the ideas of this proposal, there are ways we could imagine extending it. These are all "out of scope" for this design, but thinking about them could be useful to guide our thinking about this design.
### More variables in templates
`${title}` is necessary in this case to replace the functionality of `Markdown Notes: New Note`.
However, one could imagine that this pattern of "Ask the user for a value for missing variable values" could be useful in other situations too.
Perhaps users could even define their own (namespaced) template variables, and Foam would ask them for values to use for each when creating a note using a template that used those variables.
### `defaultFilepath`
By using `defaultFilepath` instead of `filepath` in the metadata section, you could have more control over the note creation without having to fall back to the full `Create New Note From Template` workflow.
*`filepath` will not ask the user for the file path, simply use the value provided (as described above)
*`defaultFilepath` will ask the user for the file path, pre-populating the file path using `defaultFilepath`
The first allows "one-click" note creation, the second more customization.
This might not be necessary, or this might not be the right way to solve the problem. We'll see.
### Arbitrary hotkey -> template mappings?
`Foam: Open Daily Note` and `Foam: Create New Note` only differ by their hotkey and their default template setting.
Is there a reason/opportunity to abstract this further and allow for users to define custom `hotkey -> template` mappings?
| 8 `[[/house/todo]]` | ✘ incorrect path from repo root | ✘ incorrect path from repo root |
## Non-unique identifiers
We can't prevent non-unique identifiers from occurring in Foam (first and foremost because a file could be edited with another editor) but we can flag them.
Therefore Foam follows the following strategy instead:
1. there is a clear resolution mechanism (alphabetic) so that if nothing changes a non-unique identifier will always return the same note. Resolution has to be deterministic
2. a diagnostic entry (warning or error) is showed to the user for non-unique identifiers, so she knows that she's using a "risky" identifier
1. The quick resolution for this item will show the available unique identifiers matching the non-unique one
## Thanks
Thanks to [@memplex](https://github.com/memeplex) for helping with the thinking around this proposal.
**[[todo]] This [[roadmap]] item needs more specification work.**
**[[todo]] This [[roadmap]] item needs more specification work.**
If you're interested in working on it, please start a conversation in [GitHub issues](https://github.com/foambubble/foam/issues).
## Notes
One of Roam's big features is the ability to find all instances of a reference, create a page for it and update all the references to link to the new page.
One of Foam's big features is the ability to find all instances of a reference, create a page for it and update all the references to link to the new page.
Implementing this is on the [[roadmap]], but for the time being you can achieve similar things by:
- `Cmd` + `Shift` + `F` ( `Ctrl` + `Shift` + `F` on Windows ) to find all the references, e.g. "Cat food"
- `Cmd` + `Shift` + `H` ( `Ctrl` + `Shift` + `F` on Windows ) to replace them with [[cat-food]].
- `Cmd` + `Shift` + `H` ( `Ctrl` + `Shift` + `H` on Windows ) to replace them with [[cat-food]].
- Click any of the references to create a new note.
[//begin]: # "Autogenerated link references for markdown compatibility"
You can use VS Code plugins such as [Mermaid](https://marketplace.visualstudio.com/items?itemName=bierner.markdown-mermaid) to draw and preview diagrams in your content.
⚠️ Be aware that Mermaid diagrams don't automatically get rendered in published Foams in [[github-pages]], and would require you to eject to another static site generation approach that supports Mermaid plugins.
---
[[todo]] [[good-first-task]] **Help improve this recipe!**
[[todo]] [[good-first-task]] Suggestions for alternative diagramming approaches welcome
[//begin]: # "Autogenerated link references for markdown compatibility"
[github-pages]: github-pages "Github Pages"
[good-first-task]: good-first-task "Good First Task"
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.