Is it possible to write a custom client other than a web browser?

I would like to make a micro-sized lightweight forum-browser style client for directly interfacing with the ReST of a server-side forum.

Among the requirements are that the format not be ordinary HTML but XHTML, custom XML or JSON instead. In this way, I can use a simple library to parse the markup from the forum. Another less stringent requirement is that images be able to open on a full-screen display with only a shallow color-depth thumbnail to indicate its contents. CSS won’t be needed either because I will be replacing the customization with native GUI elements.

Will this require a plug-in? Is the Ruby on Rails portion of Discourse up to the task? Will I run into hard-coded limits?

One final note: I don’t have a Postgres SQL host right now so if I can’t do it I need to know so I can look at other ReST interfacing forum software that will work with my current host.

Hi Samuel_Crow welcome to the forum

I’m not clear about exactly what you have in mind to do, but most Discourse pages can be output as RSS (maybe not exactly what you had in mind as XML, but it is a subset) or JSON.

For example
https://meta.discourse.org/t/is-it-possible-to-write-a-custom-client-other-than-a-web-browser/51671.rss
https://meta.discourse.org/t/is-it-possible-to-write-a-custom-client-other-than-a-web-browser/51671.json

1 Like

SInce the RSS didn’t view the whole post by default in the RSS Feed Reader I tried, I’d still have to use a Web Browser to view the whole post. The JSON file looked more useful though. Is there documentation on the “cooked” field of each post? It appears to be HTML or XHTML but if it is a limited subset, that would be ideal!

I believe “cooked” will be HTML5

<!DOCTYPE html>

I have never noticed any XHTML-specific style tags. eg. self-closing tags with the slash.

<link .... >

vs.

<link .... />

Discourse needs PostgreSQL, so this won’t work.

2 Likes

Adding different hosting is not a deal breaker but having to implement HTML5 completely just for a forum browser would be. Are there any plans to export the posts as XHTML in the future?

Going backwards from HTML5 to XHTML? I don’t think so.

If you want something to parse use the raw post.

XHTML 5 is very similar to HTML 5 and shouldn’t take much effort but I have another idea. If the cooked HTML5 uses only a subset of the HTML 5 tags I could formulate a mini-browser just for that subset. The only thing that scares me about HTML 5 is that it tries to be semantically rich with tag names like “sidebar” and “caption”. If it can be guaranteed that the posts returned by the server never use some of the uncommon tag names, I’d be happy with that for now.

Whoops! I missed this line. What format is the raw post in?

Markdown, another not so strict markup language :smile:.

But when we get to move to CommonMark you will have a way better strict parser.

2 Likes

No, you’d just need to do multiple requests to pull out all of the messages. As a rule, you get 20 posts at a time. Here is a Ruby program I wrote to download a topic (or all topics in a category) as text or HTML files.

Sweet. I can probably implement CommonMark in C as a plugin to the GUI I will use. In fact, that is probably the way to go.

1 Like

After looking at the CommonMark spec, it appears to have HTML passthrough but maybe I can patch the reference code to generate XHTML 5 instead.