Link to Julia questions on StackOverflow

I recently noticed that the halide mailing list receives posts from StackOverflow, with the question and with a link back to the StackOverflow posting. I find this idea quite nice, as it means I don’t need to check multiple sites for things I’m interested in.

I’d like to propose that we do the same with Julia, where StackOverflow posts get sent, here, with a link back to the StackOverflow. I’m not entirely sure of the best way to do this, but one possibility is through Log In - Meta Stack Exchange.

Thoughts?

Cheers,
Kevin

4 Likes

StackExchange has pretty good API, so getting new questions should be straightforward (something like this).

Discourse also has an API, but for some reason, I can only find clients in multiple languages and not docs for REST methods. I’ll check if I can find something useful in existing clients.

Maybe this is relevant: Discourse API Documentation - developers - Discourse Meta

Yep, or more specifically http://docs.discourse.org/.
And the very first thing it says is:

To become authenticated you will need to create an API Key from the admin panel.

Seems like it implies that only admins of the forum can provide a key :slight_smile: If some of these brave guys can send me a key, I’ll try to make a service to retrieve latest posts from SO and post it here (probably in a separate category or with a specific tag).

@oxinabox has previously done this for the Gitter Julia channel.

2 Likes

I am bit worried that there are going to be two places discussing the same question and if the noise associated is going to be large. Since gitter is a chatroom I see it as less of a problem there.

1 Like

In the version I’ve seen, the user is directed to post a response on StackOverflow. Perhaps we could even make the Discourse thread read-only (is this possible?).

Cheers,
Kevin

Ok, @vchuravy provided me with the API key, but this forum seems to have non-standard API configuration: when I call locally installed Discourse instance with the request like this:

using Requests
get("http://localhost/admin/users/list/active.json?api_key=<local api key>&api_username=dfdx")

I get a correct JSON response. However, the same call to discourse.julialang.org:

get("http://discourse.julialang.org/admin/users/list/active.json?api_key=<discourse.julialang.org api key>&api_username=dfdx")

returns 404 error - page not found.

I don’t know much about Discourse, but I guess there’s a special config for API calls, maybe different port or something. Alternatively, there may be an issue with routing.

Does HTTPS work?

Nope, same result.

What’s also interesting is that if I change api_username or api_key to a random string, the server returns 500 Internal Server Error. So at least credentials are correct :slight_smile:

@djsegal is using the API for his integration with juliaobserver.com, maybe he can shine light on how to use the API properly.

On Julia Observer, I use the discourse gem because the project is written in rails. // see code below…

My guess is that you have to send the key & username as headers instead of as query params?

https://github.com/djsegal/julia_observer/blob/41fd8126489e467ed8a134669562998850dd82bc/lib/tasks/news.rake#L143-L145


and @kevin.squire, not to seem annoying, but I could add stack overflow as a news item on juliaobserver.com. maybe that makes more sense than to put it on discourse?

@djsegal, definitely not annoying. I hadn’t realized that you had a news section on juliaobserver. It certainly seems to fit there.

I still think that it would work on Discourse as well. I think it has the potential to increase the set of individuals contributing StackOverflow answers to Julia questions by making those questions more visible, and it should help limit cross posting the same question to both StackOverflow and Discourse (which isn’t that common, but still happens from time to time).

(@dfdx, thanks for trying to pull this together!)

Cheers,
Kevin

Rather than “some service on someone’s random server” (that might expire when they graduate/move), it might be simpler to set up a (well-obfuscated) gmail address subscribed to the appropriate SO tags, and have a read-only Discourse category poll that address:

It didn’t work either. I’ll check existing API clients and how they handle endpoints.

As far as I understand in this case it would be impossible to modify content of the topic, e.g. add a link to SO question or a text explaining that users should answer there. Am I right?

Yes. But the category can have a permanent banner at the top, and the SO email already includes a link (though not necessarily the full text of the question, I guess that’s not ideal). If more customization is needed then using the API makes sense.

It turns out the example endpoint from Discourse docs is just available only for admins. I tried other endpoints and they work fine. In fact, this post is created using an API call instead of web UI.
I’ll try to create the tool for re-posting SO questions here in the next couple of days.

BTW, since we may need more Discourse-related stuff and posting to Julia forum from Julia itself is always funnier, I will put all API methods to a separate repository.

3 Likes

Here’s a test topic created via API:

Notes / questions:

  1. StackOverflow returns HTML of a question. Discourse seems to process it correctly except for <code> tag which is escaped. From discussions on forums, I suppose this tag can be whitelisted and be inserted correctly here. If it doesn’t break any other configs, can somebody from admins take a look at it?

  2. Currently, I set the service to re-post questions to the “Usage” category on this forum. Does it make sense to create a separate category? Are there better ideas how to distinguish topics created here and reposted from SO?

  3. We may want a separate user to publish reposted questions. Otherwise, I will very quickly become the most active user here :slight_smile:

1 Like