Slurps webpages, cleans off all the crud, and saves them to Obsidian as nice, tidy Markdown files. Think Pocket, but better.
Slurps webpages, cleans off all the crud, and saves them to Obsidian as nice, tidy Markdown files. Think Pocket, but better.
Slurp exposes a custom URI which can be used for one-click saves.
Bookmarklets are a simple option for those who prefer them. Simply create a new bookmark with the following URL set:
javascript:(() => document.location.href=`obsidian://slurp?url=${document.URL}`)();
Browser extensions are also coming soon for Firefox and Chrome-compatible browsers. If you want to get started right away, they are currently in beta and can be manually installed. See https://github.com/inhumantsar/slurp-extension for details.
Note properties are used by Obsidian to add metadata to notes. Supported data types include checkboxes (true
and false
values), dates and datetimes, lists, numbers, and good ol’ plaintext.
By default, Slurp will try to find relevant metadata and add it to new notes. The plugin settings screen offers a few ways to adjust how this metadata is handled and presented:
Custom and built-in properties can be formatted using a simple template string. Strings, datetimes, and booleans are currently supported.
Format templates have three main components:
Note that, by default, Obsidian will display newly written properties using an existing format (dates in particular) if there are notes which use the same property name. It will also sometimes guess incorrectly at what format to use on new fields. Correcting these issues manually should ensure future notes get the new format.
Date format templates start with d|
and use Moment.js formatting syntax.
d|YYYY-MM-DDTHH:mm
➡️ 2024-04-20T11:05
d|dddd, MMMM Do YYYY, h:mm:ss a
➡️ Tuesday, April 20th 2024, 11:05:50 pm
d|[Today is] dddd
➡️ Today is Tuesday
d|YY[Q]Q
➡️ 24Q2
There are limitations however.
String format templates can be used to format built-in properties or to provide a default value to custom properties. They start with s|
and use {s}
as a replacement placeholder.
Jane Doe
➕ s|Written by {s}
➡️ Written by Jane Doe
poodle
➕ s|{s}{s}{s}
➡️ poodlepoodlepoodle
@inhumantsar
➕ s|https://twitter.com/{s}
➡️ https://twitter.com/@inhumantsar
Some built-in properties allow the use multi-placeholder format templates. These start with S|
and use named replacement placeholders. For example, the tag property uses S|{prefix}/{tag}
. This can be customized in the same way as other string format templates with a few limitations:
{prefix}
to add the tag prefix to the title property.S|{tag}
and S|{prefix}
are valid, but S|my static template
is not.s|...{s}...
.Boolean templates aren’t templates per-se, since booleans can only ever be true
or false
. They can be used to provide a default for custom properties though.
For example, if you wanted a checkbox which indicates whether or not you’ve read a slurped page, you could create a custom property called read
and set its template to b|false
. This will ensure that new notes include read: false
in their front matter.
Obsidian can display booleans as checkboxes, though it may display it as text at first. This can be fixed in Reading Mode by clicking the icon next to the property and changing its type to Checkbox.
If you would like to help test new features before they are officially released:
BRAT: Add a beta plugin for testing
.
https://github.com/inhumantsar/slurp
.BRAT will regularly look for updates and install them. This can be configured/disabled in the BRAT settings menu.
Slurp does a couple things differently from the standard Obsidian plugin development setup:
If you are a plugin developer already, using a separate environment for Slurp is recommended.
The Zen of Python is a great styleguide for any language.
When it comes to Typescript specifically, I try to follow the guidelines below. Take these with a grain of salt though. I’m still new to Typescript though and I don’t have a ton of professional experience with Javascript generally. If any of these are superdumb, please let me know!
@ts-ignore
unless it’s absolutely necessary.I
and type names with T
.map(...)
> for (...) {}
.(k, v) => {...}
and for (let i in somevar)
.Also:
There is a direnv
config which can be used to quickly configure a completely isolated local environment. Setting it up requires a few extra steps though.
sh <(curl -L https://nixos.org/nix/install) --no-daemon
flakes
and nix-command
are enabled, eg: mkdir -p ~/.local/nix && echo "experimental-features = nix-command flakes" >> nix.conf
direnv
, adjusting or removing bin_path
as needed: curl -sfL https://direnv.net/install.sh | bin_path=~/.local/bin bash
direnv
will instruct you to add a line to your .bashrc
, once that’s done, run direnv allow
.npm install # not required if using direnv
npm run dev # enable hot-rebuilds of main.js
The usual semantic versioning applies.
manifest-beta.json
provides the dev channel specifications for BRAT.
test-resources/vault
is an Obisidian vault that can be used for testing. As a side-benefit, it’s a place to keep development notes.
There is a symlink in the vault’s plugins directory which uses a relative path to reference the repository root. This may or may not work for you after cloning. Remove and recreate it if Obsidian doesn’t see the plugin properly.
NOTE: The plugin won’t work (and may not even be recognized) if you haven’t built the project yet!
Hot Reload is a commonly used plugin for Obsidian plugin development. It will watch for modified plugins and automatically reload it within a running Obsidian instance. It’s included in the test vault as a submodule, so you will need to update it on first clone:
git submodule update
On Linux:
xdg-open "obsidian://slurp?url=https://..."