terrastruct / d2

D2 is a modern diagram scripting language that turns text to diagrams.
https://d2lang.com
Mozilla Public License 2.0
18.2k stars 448 forks source link

tooling: Embed script as URL? #153

Open alixander opened 2 years ago

alixander commented 2 years ago

https://news.ycombinator.com/item?id=33710146

Interesting idea. maybe we can have https://d2.dev/?lksadjlkjadsf return SVG?

nhooyr commented 2 years ago

note: Upgraded version with no rate limits that users can pay for. Requested on discord. https://discord.com/channels/1039184639652265985/1039185315685998693/1044721094222942240

nhooyr commented 2 years ago

This ties into our plan to allow rendering D2 files in github repos within their README.

e.g. d2.dev/github?file=something.svg and we automatically know which repo it is based on the Referer header.

nhooyr commented 2 years ago

ooo we need a D2 playground and it ties into this.

see https://www.reddit.com/r/programming/comments/z1qoxc/d2_is_now_open_source_a_new_modern_language_that/ixczyul/

play.d2lang.com for the live editor.

api.d2lang.com for the API to text -> svg and with files in repos.

nhooyr commented 2 years ago

Each example on https://text-to-diagram.com/ then should link to play.d2lang.com. Including TALA.

Only the API should require a paid license for TALA.

alixander commented 2 years ago

e.g. d2.dev/github?file=something.svg

you mean something.d2 right

nhooyr commented 2 years ago

Yup!

YashBhalodi commented 2 years ago

Hey guys.

I was fascinated by D2 and wanted to contribute somehow, and I saw this issue. So i decided to work on this.

Api

An web-api that takes diagram code and returns an svg. here is the link to go server repo serving this API.

Playground

https://playground-d2-lang.netlify.app/

Currently, I don't have a way to host the golang server, because I literally wrote the "hello world" in go first time just yesterday. I thought maybe I could host it in netlify, but that's not gonna work, and heroku is not free anymore. So if you guys have any suggestion, lemme know.

All of this is just an MVP, so I hope we can collaborate to make things better on both playground and API front.

Note

Currently, since I haven't hosted API anywhere, you will need to clone the repo and do the usual go installation, starting go program stuff. Then the playground will interact with that local server and yep that should work.

alixander commented 2 years ago

@YashBhalodi so glad to hear you're interested in helping out!

The API and playground are core to D2 and our user's experience, and it's important to develop a high-quality offering quickly. As such, these are best developed in-house and then open-sourcing it when it's ready. That's not to say multiple playgrounds can't coexist though. Mermaid and Graphviz and PlantUML all have multiple online servers users can choose from, with different pros and cons. Feel free to keep hacking away, and thanks again!

YashBhalodi commented 2 years ago

Hi @alixander!

That makes sense. Since I was eager, I have managed to build a basic playground anyone can try. no need to run local server anymore, because I have hosted the api server.

https://playground-d2-lang.netlify.app/

Just wanted to ping here, in case people came looking for it, they can try it out until the official playground is ready.

Pyrolistical commented 2 years ago

https://playground-d2-lang.netlify.app/

That is hitting https://d2api.fly.dev/getSvg and its returning 502. Probably best to turn off the playground for now. Its unusable.

nhooyr commented 1 year ago

There is an official playground now!

See https://play.d2lang.com/ and https://github.com/terrastruct/d2-playground

We don't have the API/github file rendering yet though.

asknet commented 9 months ago

@alixander Unlike mermaid.live, I see the playground makes a server call for rendering. Is there a plan to not make a server call for live rendering?

Thanks!

alixander commented 8 months ago

@asknet yes, when WASM is done: https://github.com/terrastruct/d2/issues/136