Feature JSON data exporting

eggman

New member
Mafia should have the ability to move data that is currently shown in the GUI out in the JSON (or XML I guess, I already wrote part in JSON though). This would allow for 3rd party webUI's to be more easily created and potentially ease the transition into android development. Examples of data sets that should be avalible to 3rd party devs in JSON are Items, Adventure options (this is the one I used as an example in my code), the speculative maximize output, etc.

EX of code here.
http://pastebin.com/Wv4XfsZp
 

Catch-22

Active member
I actually think the way we are tackling WebUI support in KoLmafia is all wrong. In my opinion, in order for KoLmafia to have any decent WebUI support it needs to be able to serve it's own pages, not just a proxy to the relay browser listening on the internet. We need some sort of broker that's actually listening for incoming connections, capable of running 24/7. Once you connect to the broker, from there you can manage your sessions.

I don't really have it all figured out in my head yet, or I would've feature requested it myself, but I am really leaning towards asking for a proper SVN branch to be made where multiple authors can actively work on the project and submit changes/fixes that aren't going to affect the trunk until we merge the changes back in, rather than one-by-one patching in bits and pieces and ending up with a less robust system in the end.

Don't take this as a criticism of your patch, rather an opinion on the way we should tackling the problem of having a robust WebUI.
 

eggman

New member
I don't really have it all figured out in my head yet, or I would've feature requested it myself, but I am really leaning towards asking for a proper SVN branch to be made where multiple authors can actively work on the project and submit changes/fixes that aren't going to affect the trunk until we merge the changes back in, rather than one-by-one patching in bits and pieces and ending up with a less robust system in the end.

Don't take this as a criticism of your patch

Agree on this 100%, and seeing as how the WebUI is basically something chish and I are writing while (re-)learning java and sharpening our (very blunt) web dev abilities, I don't think any one has the ability to criticize me as I'll just learn from it.
 

Chish

Member
He's saying he's just smart enough to realize how dumb he is and thus won't take any criticism personally.
 

eggman

New member
Catch-22 what do you mean about mafia being able to serve its own pages vs acting as a proxy to the main site? I am unclear on the implications and the differing implementations between these two ideas. Currently mafia pulls all the info from the KoL servers and parses/automates it. The JSON moving of variables out of mafia allows a web page to access the info that is on the KoL servers via mafia and update those variables without having to refresh the page which seems like it would be nessicary if mafia was constructing and serving its own pages. PS sorry about the double post.
 

holatuwol

Developer
I think Catch-22 is thinking of some kind of hosting service, rather than a WebUI that you can browse from inside your network.

That being said, what if I just add a to_json() capability to all ASH aggregates? You've always been able to request the path to a relay ASH script directly, and ASH can write raw text (or JSON strings).
 

holatuwol

Developer
There is an HTTP server already embedded in KoLmafia; that's what the relay server is. o_0

Or do you mean something that actually makes you authenticate with it and generates a unique KoLmafia session token for you that allows you to interact with an existing KoLmafia session?
 

Catch-22

Active member
Or do you mean something that actually makes you authenticate with it and generates a unique KoLmafia session token for you that allows you to interact with an existing KoLmafia session?

Yeah, or allows you to start a new one. Along those lines anyway, still thinking it through :)

There is an HTTP server already embedded in KoLmafia; that's what the relay server is. o_0

My understanding of the relay server may be flawed, so feel free to correct me on this, but I had the relay server figured as more of a proxy server that only modifies the HTTP response before relaying it to the users browser (pseudoResponse) and has not been designed in a way which easily facilitates the serving of it's own content.
 
Last edited:

lostcalpolydude

Developer
Staff member
Good, but for a real WebUI we need a number of things that you can't currently get via ASH. For example, a list of every location, or a list of all current effects.

I think $locations[] and $effects[] could be used to get those. I haven't followed too closely, but
Code:
foreach thing in $locations[] print(thing)
prints out every location mafia knows about, and from there I imagine you can accomplish quite a bit.
 

Chish

Member
I think $locations[] and $effects[] could be used to get those. I haven't followed too closely, but
Code:
foreach thing in $locations[] print(thing)
prints out every location mafia knows about, and from there I imagine you can accomplish quite a bit.

Huh, I didn't know ASH could do that. Can I get some documentation on that sort of stuff? I can't find it in the Wiki.

Edit: found some stuff in Data Types.
 
Last edited:

eggman

New member
The relay browser is not currently useful, for example, if you want to start a new session that doesn't already exist.

That's a simple matter of when the relay server is started and if there is a page to pass log-in information to the main java program. That's fairly simple as far as the whole webUI thing goes.
 

Catch-22

Active member
That's a simple matter of when the relay server is started and if there is a page to pass log-in information to the main java program. That's fairly simple as far as the whole webUI thing goes.

Then there's still the issue of authentication. I've seen some client-side authentication implementations in JS but they're pretty terrible.

Also there is the question of whether or not it should be possible to login to more than one character from the WebUI. Currently this is not possible even in the GUI/CLI (you have to start a new instance of KoLmafia).
 

eggman

New member
Then there's still the issue of authentication. I've seen some client-side authentication implementations in JS but they're pretty terrible.
We will cross that bridge when we come to it, currently if you can access the relay browser from a mobile device (iPad/iPhone/Kindle Fire) anyone on your current LAN can also access mafia, so security is kinda taking a back seat to building this functionality. I'm thinking that down the road we can replace the swing in mafia with GWT, which would handle authentication and the js side of things.
Also there is the question of whether or not it should be possible to login to more than one character from the WebUI. Currently this is not possible even in the GUI/CLI (you have to start a new instance of KoLmafia).
This is because mafia only handles one database per character, it would require a lot more new code to allow multiple sign ins from the same instance of mafia.
 
Top