Bay 12 Games Forum

Dwarf Fortress => DF Modding => Utilities and 3rd Party Applications => Topic started by: schmichael on January 03, 2016, 03:12:17 pm

Title: Legendary Gopher: a new legends viewer written in Go
Post by: schmichael on January 03, 2016, 03:12:17 pm
I don't have a Windows machine, so I've never used any of the existing legends viewers before. So I thought I'd write my own in Go and cross-compile binaries for all to enjoy!

Right now it doesn't do much. There's a bare bones webui and an even barer bones HTTP JSON API.

Everything is bundled into the executable, so all you should have to do is download the binary for your platform and pass it an xml dump (.gz compressed files supported; sample file linked in README).

I'm not much of a forum user, so all of the relevant information is on Github:

Project Page: https://github.com/schmichael/legendarygopher
Bugs / Features: https://github.com/schmichael/legendarygopher/issues
Releases / Downloads: https://github.com/schmichael/legendarygopher/releases

Releases are built automatically, so expect frequent updates.

Bug reports, feature requests, ideas, pull requests, etc. all welcome. Also feel free to just swipe any useful code you find.

Are there good docs on the legend's xml format somewhere? If not I'll start writing my own.
Title: Re: Legendary Gopher: a new legends viewer written in Go
Post by: Max™ on January 03, 2016, 03:36:47 pm
Waiting on a library to finish killing everyone off and thus delagging and I'll check it out.
Title: Re: Legendary Gopher: a new legends viewer written in Go
Post by: jaked122 on January 03, 2016, 09:25:42 pm
While I inexplicably hate working in Go, I'm happy to see that someone has made something a little bit... less OS dependent perhaps. Ooh, gzip capabilities. That's nice.


[sarcasm]Call me when you get 7zip support[/sarcasm]
Title: Re: Legendary Gopher: a new legends viewer written in Go
Post by: schmichael on January 04, 2016, 01:31:58 am
While I inexplicably hate working in Go, I'm happy to see that someone has made something a little bit... less OS dependent perhaps. Ooh, gzip capabilities. That's nice.

[sarcasm]Call me when you get 7zip support[/sarcasm]

I would have chosen Python, but I love that I can automate builds with Go. People can download a single executable instead of having to have Python installed + dependencies. I guess there are things like py2exe, but I was too lazy to look into it. Also, Go's xml library made parsing really easy.

( I'm probably going to have to sneak this in now just for you: https://godoc.org/github.com/smira/lzma )
Title: Re: Legendary Gopher: a new legends viewer written in Go
Post by: milo christiansen on January 04, 2016, 12:37:38 pm
Hey, another Go programmer!

You should probably use some other port, as 6060 is the default for godoc when running in local mode. I know most DF users won't be running godoc, but most of the time I will be :)

I did some work with automatically starting the user's web browser for the Rubble web UI. On windows I use cgo to call the shellex API, but for other systems I call a shell script. If you have a C cross compiler you can use my Windows launcher code (which comes with the Rubble package), but my Linux launcher script really sucks you probably don't want to even look at that (I don't know shell script).
Title: Re: Legendary Gopher: a new legends viewer written in Go
Post by: schmichael on January 04, 2016, 12:50:56 pm
You should probably use some other port, as 6060 is the default for godoc when running in local mode. I know most DF users won't be running godoc, but most of the time I will be :)

Ha, yeah. I just lazily copied that. Will change ASAP. https://github.com/schmichael/legendarygopher/issues/16

I did some work with automatically starting the user's web browser for the Rubble web UI. On windows I use cgo to call the shellex API, but for other systems I call a shell script. If you have a C cross compiler you can use my Windows launcher code (which comes with the Rubble package), but my Linux launcher script really sucks you probably don't want to even look at that (I don't know shell script).

Oooh, I'm not familiar with Rubble. Is it open source? Sorry, I've only ever played vanilla DF until I had a fortress prematurely become the mountainhome due to goblins sacking my civ's capital! After they sacked me as well I suddenly became very interested in digging into Legends!

I think every OS has a way to open a file/URL using the default application registered to handle it.

On OSX I think the "open http://..." command will Do The Right Thing.

On Linux it's "xdg-open" because "open" is some useless command from the 80s Linux wouldn't dare override. :)

I haven't used Windows since XP, but back then you could call "start.exe http://..." and it would open the url in your default browser.

Might help you avoid shell scripts and cgo!
Title: Re: Legendary Gopher: a new legends viewer written in Go
Post by: milo christiansen on January 04, 2016, 01:05:28 pm
Thanks for the OSX and Linux info, I know next to nothing about them... I kinda like cgo so long as I don't have to cross compile, and I don't know if open.exe is still a thing. I used it for some autorun.inf stuff eons ago, but haven't tried it since...

Rubble is open source, but I don't have a repository (I don't have home internet). All source is included in the normal download package, so if you want to look feel free :)

It has some nice stuff, such as a re-implementation of the raw merging engine BAMM uses (but with some Rubble specific extensions), a workshop image render (parts of which I should probably rewrite), a raw parser, and a few other bits and pieces that may be of interest to any Go programmer with a DF hobby.
Title: Re: Legendary Gopher: a new legends viewer written in Go
Post by: lethosor on January 04, 2016, 05:30:44 pm
It's worth noting that xdg-open isn't necessarily installed by default - PyLNP distributes its own version, which could work (but leads to maintainability issues if it's embedded in the executable, although that's easier to handle with Go's cross-compilation).
Edit: maybe I'm thinking of xdg-terminal, actually.