Feature - Rejected visit_url sans decoration

Could we have another parameter in visit_url asking mafia not to decorate the response? Or, if that's too much overloading (it already has what, like 4 definitions..) would it be too much to just have it so that API.php doesn't get decoration?
 

zarqon

Well-known member
Here we go. Veracity excluded api.php from results processing but not decoration, since decoration only happens in the relay browser, not visit_url(). Sounds like nothing else needs to be done here.
 
Last edited:
I'm pretty sure api.php was already specifically excluded from both decoration and results processing. Do you have evidence suggesting otherwise?

Unless I've just been playing with mafia so long I forgot that [acc1] and similar equip links are part of KoL proper, then yes, I do. Results don't get processed, decorations do get added, however.
 

Veracity

Developer
Staff member
decoration only happens in the relay browser, not visit_url(). Sounds like nothing else needs to be done here.
Correct.

Can you explain exactly what you do to get a "decorated" api.php? I am quite certain that simply calling visit_url( "api.php" ) will fetch precisely the JSON that KoL emits without "decoration".
 

Veracity

Developer
Staff member
Can you explain exactly what you do to get a "decorated" api.php? I am quite certain that simply calling visit_url( "api.php" ) will fetch precisely the JSON that KoL emits without "decoration".
If it only happens "in the relay browser" as stated, then it makes sense. I don't like it, but I'm pretty sure there's nothing I can do to get around it.
See http://kolmafia.us/showthread.php?7863-relay_api.php
I'm not sure how to interpret your response.

This feature request asks for a version of visit_url() which does not "decorate" the response text before passing it back to the ASH script that invoked visit_url. In particular, you mention api.php as a URL which KoLmafia "decorates". You cite "acc1" links on equipment as an example of a "decoration" that KoLmafia is applying, somehow, to the JSON.

I pointed out that KoLmafia doesn't "decorate" the page that it fetches for a visit_url(). I'll also additionally point out that I find it really difficult to believe that a JSON string looks like anything that KoLmafia would decorate with a Use Link like "acc1".

In other words, there is nothing to be done for the Feature Request as originally presented; visit_url() does not "decorate" pages.

Your response points to another thread which has some sort of script in it. I have no idea how that script is supposed to be used; your thread doesn't explain where you put it, what you do to invoke it, or what it does for you. You say "this is a handy script to make the calls and grab the return data, and it also helps to make the data easier to look at". Make WHAT calls? Grab WHAT data?

I looked at it. I find the formatting fairly impenetrable - single space indentation? a 280-character line containing a foreach, an if, and some sort of massive string concatenation all mashed together? really? - but I was able to locate a visit_url within it that fetches api.php. Apparently, your script will fetch it back as either a JSON or a PHP formatted list. It then seems to format the result and use "write" and such to generate HTML.

I deduce, therefore, that this is some sort of relay script.

Is it your claim that KoLmafia somehow "decorates" the HTML that you generate by putting in "use" links and such?

I don't want to spend any more time trying to figure out what you did, what results you expected, what results you got, and why you think they are incorrect. That's Bug Reporting 101. YOU should have done that initially, rather than requesting a specific "change" which you thought would fix your problem for you, only to have us waste time investigating and discovering that visit_url already behaves exactly as requested.

I don't know why I'm here, anyway. You are on my ignore list for repeated dickish behavior. I only responded to confirm zarqon's analysis. I had to go out of my way to even SEE your comment. Why am I wasting my time on YOUR script?

In any case, the original post requests that visit_url not "decorate" the page it fetches. I respond "done! that's how it's always worked!" and will close this. If you think there is a bug in how KoLmafia does relay scripts, follow the guidelines (linked above) that hola wrote up and stickied almost 5 years ago, and make a new bug report.
 

zarqon

Well-known member
bordem, I believe you weren't requesting what you actually want. I'm pretty sure that this is what happens:

1) your script fetches api.php via visit_url(). It is not altered in any way by mafia at this point.
2) your script does its stuff, whatever that is.
3) You output stuff via write(). This is the point where mafia decorates your page as it passes to the relay browser.

(ETA: all the above is wrong.)

So, I think what you were really requesting is a way to specify in a relay script that its output should not be decorated. I think that this, too, probably already exists. Have you tried this:

PHP:
set_property("relayAddsUseLinks","false");
write(myalteredpagetext);
set_property("relayAddsUseLinks","true");

I'm not entirely sure if that would work but it's worth a shot. If it works, there are several other preferences that control various decorations which you may also need to switch.
 
Last edited:

jasonharper

Developer
1) your script fetches api.php via visit_url(). It is not altered in any way by mafia at this point.
2) your script does its stuff, whatever that is.
3) You output stuff via write(). This is the point where mafia decorates your page as it passes to the relay browser.

Re #1: visit_url() DOES apply decorations if called from within a relay override. However, there still shouldn't be anything being done to api.php.

Re #3: This is wrong, mafia would have no idea how to decorate your modified page since it may bear no resemblance to the underlying URL being requested.
 

zarqon

Well-known member
In that case bordem, try moving the preference toggles above the visit_url() call and see if that does what you want.

Jason: In the above-linked bug report, Veracity mentioned:

Revision 9248 does not do result parsing for api.php.
I'm not going to put special code in to exclude decoration, since you don't normally visit it in the relay browser.

So if visit_url() DOES apply decorations when called in a relay script, then it looks like it does it for api.php too.
 

Veracity

Developer
Staff member
Re #1: visit_url() DOES apply decorations if called from within a relay override. However, there still shouldn't be anything being done to api.php.
Interesting.

This reinforces my call for explaining EXACTLY what was done to cause the undesired behavior, rather than saying "change such-and-such".

So if visit_url() DOES apply decorations when called in a relay script, then it looks like it does it for api.php too.
I find it really difficult to believe that a JSON string looks like anything that KoLmafia would decorate with a Use Link like "acc1".
 
Last edited:

zarqon

Well-known member
When I made that original report, I observed decoration using the PHP format, not JSON. But it probably happens with JSON as well -- when retrieving kmail, at least, the message fields often contain plenty of "You acquire an item:" tables.
 
Top