d2 icon indicating copy to clipboard operation
d2 copied to clipboard

tooling: Embed script as URL?

Open alixander opened this issue 2 years ago • 13 comments

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

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

alixander avatar Nov 22 '22 19:11 alixander

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

nhooyr avatar Nov 22 '22 21:11 nhooyr

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 avatar Nov 22 '22 21:11 nhooyr

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 avatar Nov 22 '22 21:11 nhooyr

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.

nhooyr avatar Nov 22 '22 22:11 nhooyr

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

you mean something.d2 right

alixander avatar Nov 23 '22 22:11 alixander

Yup!

nhooyr avatar Nov 24 '22 00:11 nhooyr

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.

YashBhalodi avatar Nov 25 '22 07:11 YashBhalodi

@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!

alixander avatar Nov 27 '22 02:11 alixander

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.

YashBhalodi avatar Nov 27 '22 06:11 YashBhalodi

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.

Pyrolistical avatar Dec 01 '22 22:12 Pyrolistical

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.

nhooyr avatar Dec 28 '22 09:12 nhooyr

@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!

asknet avatar Feb 19 '24 17:02 asknet

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

alixander avatar Mar 20 '24 23:03 alixander