Skip to content

Add plugin: Share Note #2417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 11, 2023
Merged

Add plugin: Share Note #2417

merged 2 commits into from
Oct 11, 2023

Conversation

alangrainger
Copy link
Contributor

@alangrainger alangrainger commented Sep 7, 2023

I am submitting a new Community Plugin

Repo URL

Link to my plugin: https://github.com/alangrainger/obsidian-share

👉 Notes for Obsidian Team

This plugin is different from the two existing plugins QuickShare and OzanShare. QuickShare does not support images or the theme of your note. OzanShare is a paid service.

Regarding the Developer policies, all data sent to the server is pre-encrypted client-side with a key that only exists inside the user's vault. At no time is the decryption key ever sent to the server. An API key is required to use, but the account ID and API key are random data. There is no personal data collected or sent, and the user does not need to manually create an account on the server.

Regarding the code, I will be very interested to get your feedback. What I've done works perfectly, but I'm not sure how "best practice" my methods are, for example how I get the pixel-perfect rendered HTML here.

Here's an example shared note (unencrypted) showing off the support for themes, images, callouts, and even Dataview queries. And here's an encrypted example. The decryption key is the part of the URL after the #. A URI hash fragment is exclusively client-sided and not sent to the web server, so it's perfect for this use.

This sharing service has been running for over a year now, I just finally got around to turning it into a plugin - it was a Templater script originally.

Here are the docs for the server side of things. All data sent to the server is already encrypted with a key that only exists in the user's Obsidian vault, and no PII (Personally Identifiable Information) is sent, so the specific backend implementation is fairly irrelevant.

Keen to hear feedback! Thank you.

Release Checklist

  • I have tested the plugin on
    • Windows
    • macOS
    • Linux
    • Android (if applicable)
    • iOS (if applicable)
  • My GitHub release contains all required files
    • main.js
    • manifest.json
    • styles.css (optional)
  • GitHub release name matches the exact version number specified in my manifest.json (Note: Use the exact version number, don't include a prefix v)
  • The id in my manifest.json matches the id in the community-plugins.json file.
  • My README.md describes the plugin's purpose and provides clear usage instructions.
  • I have read the tips in https://docs.obsidian.md/Plugins/Releasing/Plugin+guidelines and have self-reviewed my plugin to avoid these common pitfalls.
  • I have added a license in the LICENSE file.
  • My project respects and is compatible with the original license of any code from other plugins that I'm using.
  • I have given proper attribution to these other projects in my README.md.

@joethei
Copy link
Collaborator

joethei commented Sep 27, 2023

if (!file) {
The command that calls this function should use a checkCallback, then you can remove this code.

new Setting(containerEl)
The first section in settings should not have a heading: https://docs.obsidian.md/Plugins/Releasing/Plugin+guidelines#Only+use+headings+under+settings+if+you+have+more+than+one+section.

@joethei joethei self-assigned this Sep 27, 2023
@joethei joethei added Changes requested Additional review required PR needs to be reviewed by another person, after the currently requested changes have been made and removed Ready for review labels Sep 27, 2023
@alangrainger
Copy link
Contributor Author

alangrainger commented Sep 27, 2023

Hi @joethei - changes have been made and published in 0.3.17.

  • checkCallback is added.
  • Section title removed.

@alangrainger
Copy link
Contributor Author

alangrainger commented Sep 27, 2023

I have also updated the docs for checkCallback with an example, because it was very confusing. I had to find another plugin who had already implemented the command so I could look at their code and figure out what I was meant to do.

@joethei joethei added Ready for review and removed Changes requested Additional review required PR needs to be reviewed by another person, after the currently requested changes have been made labels Sep 28, 2023
@liamcain
Copy link
Collaborator

liamcain commented Oct 4, 2023

Hi Alan, thanks for your plugin submission!

We noticed that when users share notes using your plugin they are hosted at obsidianshare.com.

The word "Obsidian" is a trademark, and therefore you cannot use it this way. The problem with obsidianshare.com is that it may confuse people into thinking that pages are hosted on an official Obsidian service.

Please update your domain to not include the word obsidian and we will be happy to approve the plugin to the community directory. Thank you!

@alangrainger
Copy link
Contributor Author

alangrainger commented Oct 6, 2023

Hi @liamcain I have migrated to a new domain:

https://share.note.sx/8HitpABlzq2mOu4W

The old service has been disabled, and old versions of the plugin will no longer function.

Would it be ok for existing users to be given a chance to update their shared links before I turn that server off? I hope you can understand that from their perspective.

@alangrainger
Copy link
Contributor Author

alangrainger commented Oct 9, 2023

@liamcain I see the 👍 - I'm just checking you're not waiting on anything from me here before approving the plugin to the community directory?

@alangrainger
Copy link
Contributor Author

All links on the old domain have been redirected to the new domain, so the old domain is no longer visible.

@liamcain
Copy link
Collaborator

Sorry, gave the thumbs up, but was waiting to get a response from the rest of the team (Monday was a holiday for us, and Tuesday was a bit busy with releases).

  • fs this import is a Node.JS import so it will fail on mobile.
  • fs.readFileSync you will need to use the Filesystem adapter instead, but we don't have a synchronous version of read exposed
  • domCopy Why not use render instead?

I think the 'fs' import is worth fixing before we merge this. Let me know if you have any questions!

@alangrainger
Copy link
Contributor Author

alangrainger commented Oct 11, 2023

fs replaced with FileSystemAdapter: in 0.5.10 (although I will note that I share from mobile every day and haven't experienced any issues?)

I don't understand regarding render sorry: I'm reading the total document into a DOM parser so I can get the Document <body> classes/styles and some other element classes/styles, plus be able to manipulate that DOM without affecting the user's Obsidian instance.

render() appears to be a function for converting Markdown to HTML.

@liamcain
Copy link
Collaborator

I'm reading the total document into a DOM parser so I can get the Document classes/styles and some other element classes/styles, plus be able to manipulate that DOM without affecting the user's Obsidian instance.

Yes, I was suggesting you convert the md file to HTML directly instead of ripping the HTML from the DOM.

@github-actions github-actions bot changed the title Add "Share Note" plugin Add plugin: Share Note Oct 11, 2023
@liamcain liamcain merged commit da0b254 into obsidianmd:master Oct 11, 2023
@alangrainger
Copy link
Contributor Author

alangrainger commented Oct 11, 2023

Ahh, we're talking about different things. The domCopy is to get theme styles and custom CSS snippets, it's not about the note content. I will see if I can get the same style information from render (for example the height of the pusher element - required to get the Banner plugin to look correct) or if the function can be used elsewhere, it's handy to know about it!

Thanks for the assist and the merge! 🙏

@alangrainger
Copy link
Contributor Author

alangrainger commented Oct 12, 2023

edit: You can ignore this question - it's a moot point as using render() does not produce HTML content added by any plugin, for example the banners added by the Banner plugin. So I still have to use the preview view to get the final DOM as Obsidian would present it to the user.


@liamcain thanks for the suggestion regarding render(). I've found an issue which prevents me from using it, and could use some assistance.

If I render this simple markdown for a callout:

> [!NOTE] Title
> Contents

I get this HTML which does not include the SVG callout icon - it's just an empty <svg> element:

<div data-callout-metadata="" data-callout-fold="" data-callout="note" class="callout node-insert-event">
  <div class="callout-title">
    <div class="callout-icon">
      <svg width="16" height="16"></svg> <!-- 👈 Empty svg here -->
    </div>
    <div class="callout-title-inner">Title</div>
  </div>
  <div class="callout-content">
    <p>Contents</p>
  </div>
</div>

What am I doing wrong here? Thank you!

@alangrainger alangrainger deleted the patch-6 branch October 13, 2023 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants