Giter VIP home page Giter VIP logo

obsidian-wielder's Introduction

Obsidian Wielder

Clojure inside your Obsidian documents!

Demonstration Video

This Obsidian plugin allows you to use the full power of Clojure directly inside of your documents in Obsidian! If you view documents with code blocks marked as clojure in the view-mode of Obsidian, this plugin will automatically run the code you have specified inside the block.

The plugin goes block by block for your entire document, so you can build pipelines of data with descriptive text in-between, and slowly build up to the final data and then present it. All directly in your documents without doing anything outside of Obsidian.

Add in rendering React components with Reagent, and you can build fully interactive applications by just writing in markdown files, rendered in Obsidian!

Wielder also allows you to access the Obsidian API directly (via window.app), so anything you can do with a plugin, you could also do directly in just document.

Installation Instructions

Take a look at the Installation Tutorial to learn how you can install Wielder in Obsidian

Warning: Wielder can run any code defined as Clojure code-blocks in your Obsidian documents

Just like Templater or Dataview, Wielder executes code defined by your Obsidian documents. This means any sort of code.

Unless you know exactly what the code you're executing does, it can be harmful to your Vault, Obsidian installation or even complete system.

You should take care to only run Wielder with code you understand what it does, and also not copy-paste code from strangers into your Vault without fully understanding what it does.

Wielder will never run any code defined from outside your Obsidian Vault, so you are yourself responsible for the code that gets executed.

Again, take care of what code you run with Wielder, as it can be potentially destructive.

Demonstration Vault

It's hard to describe exactly what you can do with Wielder with just text, so easiest is to just install the plugin and checkout the demo-vault provided in this repository.

If you don't want to install the plugin before seeing it in action, you can checkout a web version of the vault (and Wielder) here: https://wielder.victor.earth (ah yeah I forgot to mention: of course it works with webpages as well as inside Obsidian!)

Code Layout

The main pieces are the following files:

  • sci-js/src/sci/api.cljs - ClojureScript file which provides a JS<>CLJS interface to be used by this plugin
  • src/evaluator.ts - TypeScript source for initializing the SCI environment and evaluating code snippets from DOM elements
  • src/main.ts - Obsidian Plugin's main source file. Is what gets compiled into main.js and published as the plugin
  • src/publish.ts - Source of the publisher part. Include the compiled version of this library and your published site will work (mostly) the same way as your vault when loaded via desktop Obsidian.

obsidian-wielder's People

Contributors

victorb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

obsidian-wielder's Issues

Load other Vault notes that contain Clojure

I just started using the Wielder plugin and I'm loving it. Many kudos @victorb!

Proposal

Today I was using it to prototype a plugin idea of my own, and as the code grew I found myself wishing for a way to break it up, while remaining within Obsidian. Essentially what I'm proposing is a built-in function that can "load" an arbitrary Vault note. Loading a note would consist of evaluating each Clojure code block it contains in the current context.

The function itself may look something like:

(*load "[[clojure/libraries/foo]]")

This could leverage Obsidian links to benefit from the existing autocomplete and make the paths easy to understand given the context. Wielder is already awesome, and I think this simple change could turn Obsidian into a very capable ClojureScript literate programming environment.

What I'm asking for

I would be happy to work on this and attempt to put a working Pull request together. However, before I get started I'd like to know if @victorb or other people from the community that may stumble onto this have any feedback or pointers.

FYI: Sanitizer is not production ready yet

Hi,

your repository showed up as user of the sanitizer-polyfill.
Thank you for showing your interest in our tiny project. Unfortunately, the implementation does not match what browsers currently do and also does not match the intended specification end state for the Sanitiezr API.

This issue is to tell you that you are of course welcome to use the polyfill as you see fit but also to remind you that this is likely to change in the forseeable future.

Offer alternative version of publish.js

Currently, publish.js is kind of big (3.6M on disk, 446KB gzipped) because we're not doing any minifying nor tree-shaking (which is hard when we want to evaluate arbitrary code). Biggest reason for not doing any minifying yet is because it'll make the errors a lot harder to understand when you're doing something wrong, so not sure if we can address that somehow.

But in the meantime, we could probably offer two versions of the publish.js. The first one being the existing one which is the full errors / non-minified one. And a second one which is minified/production/cryptic errors one, that people can use if they want to instead of the full-errors one.

[Bug] Wielder Causing Issues with Templater's Startup Template

The plugin templater has the ability to set a "startup template" that runs when Obsidian is started. However, when wielder is enabled, the startup template fails to run with a vast error. Prior to the template running (as it happens onLayoutReady), Wielder prints the following error:

Uncaught (in promise) TypeError: import_sci.default.init is not a function
    at initialize (plugin:wielder:85392:29)
    at ObsidianClojure.eval (plugin:wielder:85553:21)
    at Generator.next (<anonymous>)
    at fulfilled (plugin:wielder:36:24)

After that, the startup template runs and results in a very big error that mentions certain wielder properties. The error is massive, and hence is attached as a error.txt.

From a basic scan of the error, it looks like it may be related to my startup template's use of obsidian-requirejs that isn't playing nicely with it.

I hadn't restarted Obsidian in a while and hence only just saw this!

[ FR ] Mobile Support

Would you consider making the plugin available for mobile?

I did install it via BRAT and can't wait to try it out.

Thank you!

Evaluate on command?

Is it possible to evaluate code blocks on command rather than instantaneously as code gets typed? I could see this potentially being problematic if I’m typing code that does something state changing like, say, modifies my vault (e.g., I’m deleting a file by path name and I’m typing out the path name in quotes).

Website is down

Could you move the information to the Github wiki, or place it in the project so it's available if your website is down again in the future?

[Question] Document Size and Performance

I'd love to try this plugin out, but I'm slightly worried that due to the eager evaluation model (it seems to try and parse all code blocks in a page eagerly) it won't cope with large files? I don't necessarily want to use it in massive files, but I'm more worried about opening a huge file in general and having things bog down. Are there any plans to make it less eagerly evaluated?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.