Share Note plugin 🚀 - share individual notes with full support for themes, images, Dataview, callouts, and more

@AlanG This is really neat! Thank you!

I haven’t been able to get the private php version working on my Azure Static Site, but it got me thinking… would you be able to modify the script so that instead of doing a bunch of await upload() it would write those outputs locally?

Having the .html, .css, and other assets cleansed/created locally could open up other use-cases.

Absolutely! Just use fs.writeFileSync and you can output anywhere to disk.

Very cool! Forgive me because my JS/Node skills are fairly weak…do you know how to set the path to somewhere on my drive (e.g. C:\)? Looks like currently it’s writing to C:\Users\myusername\AppData\Local\Obsidian).

Just put the path before the filename:

fs.writeFileSync('c:/somewhere/else/file.txt', ...

Figured it out. Added PR to the repo with an example if you’d like it. No hard feelings if you don’t accept it – this is working nicely for me! Thank you!!

I believe I got all the ‘non-local’ stuff out of there. Kept a modified version of getHash that could likely be cleaned up throughout but it was the easiest way to deal with all the .woff and .woff2 files. I tossed those all in a assets/ folder when you loop over the the base64 attachments.

Might be cool to have an issues tab on the repo?

I did notice that some of the code blocks and callout blocks are not “exact” when using the Minimal theme and a few extra settings with the Styler plugin (code blocks lose formatting and some subtle padding/margin changes elsewhere).

Also the copy button in the code blocks is there, but not functional. Likewise, header folding looks like it’s there but not functional.

I’m glad you got it working!

Mainly the script is just a reference implementation, as it’s easy to modify and base something off which fits your own workflow. If I turn it into a plugin I’ll do the full shebang and add an issues tracker and all that.

Regarding the copy button and folding - that’s because it doesn’t include any of the Javascript along with the page. Perhaps something to consider adding, but of course then there will be security concerns to think about.

1 Like

@AlanG If I turn it into a plugin I’ll do the full shebang and add an issues tracker and all that.

FYI, there is a plugin that has much of the same functionality as your script, including exporting the Javascript. However, it doesn’t do the main thing yours does, publish. I’ve forked this plugin and added publishing based on your script. It works well with my initial testing. I have different plans for this particular plugin and am not sure if it will be released to the community or just for private use. I wanted to let you know that there is a plugin that is similar to what you might intend to create someday.

3 Likes

This is pretty cool. Thanks for doing this. One thing you said it supports callouts; I’m assuming that is the official obsidian callouts. I use the Admonitions plug-in and it doesn’t work. I’ll change them to obsidian and see how it does.

I have Preformatted text > [!info] - Chart Preformatted text > Preformatted text > ![[../attachments/autism.png]]

on 3 separate lines. (I can’t get it to show up properly here).

In obsidian it shows collapsed as it should. But when shared, it is not collapsed and there is no option to collapse or expand. Are callouts working? I’m using 1.1.5.

Here’s a published page which includes both Obsidian default and Admonition plugin callouts, and both published without any issues:

What issue are you seeing?

This is correct - they won’t collapse/expand, as there is no Javascript exported with the published webpage. Javascript is needed to make the collapse/expand functionality happen, it’s not plain HTML.

I should have thought of that. Thanks.

Hi, this is a really awesome service!! Have you thought about turning it into a proper plugin that has a command to upload a note, and maybe a panel that lists links to all of the notes you’ve shared so far? That would really take it to the next level for me.

Heya! Thanks for making this. I have run into an issue though where the note I upload doesn’t seem to be in the correct format?

Here’s the note I’m trying to share: higher-ranked lifetime error

And its missing the CSS as well as the HTML doctype.

Did I maybe use templater wrong? Looking at the source code of the upload script, it seems that everything goes ‘well’ as I do get the “File has been shared” notice at the end.

This is fantastic! This was the last feature which was holding me back from a full switch. I’ve been able to set it up with my own hosting which is fantastic! However, seems the images won’t want to upload at all. See the test note being shared:

I read above that base64 is needed to be supported on the hosting end, which I use hostinger and it is supported, so I’m not sure what else could be wrong? Thanks!

Thanks for the heads-up @RickyJez

It was a small change that Obsidian app made to the local image location. You can update your script by making this tiny change (replacing local with \w+):

1 Like

Hi @Hemera - as the CSS is missing, we’ll do some quick troubleshooting:

  1. First, delete all share_ values from your YAML, then try and re-upload the note. This will force the CSS to re-upload. If that works, you’re all done. If it doesn’t work, there might be something specific to the theme you’re using that’s causing it to fail.
  2. If the previous step didn’t work, try opening the Sandbox vault (from the help menu), and trying the share script using the default theme and without any plugins installed except for Templater. If this works, then it means there’s something in your normal vault which is preventing it from working.
  3. To find out what’s causing it to fail, first start by using the default theme in your normal vault and see if that fixes it. If that doesn’t fix it, then perhaps some plugin is causing it to fail. Are there any helpful messages in the Javascript console?

@bryan00 I have now built this as a plugin, with a bunch of great updates. Firstly the note content is now stored encrypted on the server, with you holding the only key. The key is never sent to the server at any point so the contents of your notes are not accessible to anyone except you and whoever you send the shared link to. The sharing has also been updated to work with all the new Obsidian functionality.

I will be adding functions to manage you shared notes like you suggest - see which notes were published, have been changed, and let you unshare them.

The plugin has been submitted to the community store, but you can test it immediately by installing it through the BRAT plugin.

The Github repository for adding to BRAT is:

https://github.com/alangrainger/obsidian-share

3 Likes

@AlanG Any chance you are going to publish the server-side code, similar to your original share service’s php script? I’d like to self-host locally. Thanks for considering.

It’s essentially the same thing on the backend as before - I just need to add a frontend setting to allow you to specify your own server URL.

Will do :+1:

1 Like

Excellent… I was hoping that was the case. I did notice the plugin utilizes an API key. Is that for encryption only? or does that control access to the share service? or both?