Discourse Posts External HTML


#1

Hello, I was wondering if anyone can point me in the right direction in what I’m trying to achieve here.

I’m trying to set up a fresh new website using discourse and some custom HTML for my homepage.
I wan to pull information from certain categories like “Blog” and “Updates” and have the first post of the topic load on the screen with information on how many replies and such.

Long story short, I am asking if theres anyway I can do this just like SMF’s SSI function.

Thank you!


#2

Well, there are actually tons of ways you can achieve it with discourse.

  • You can pull virtually whatever data you wish from the REST api
    Topics tagged api
  • You can get most of public data from Discourse via plain, old RSS
    Topics tagged rss
  • If you are really stubborn, you could even try to make Discourse send you a webhook everytime something changes, and save data from it…

(Simon Cossar) #3

There is a Discourse API gem that is great if your site is made with Ruby. I’ve done some work to make something similar to SMF’s SSI functions with WordPress shortcodes, but I don’t think there is a general PHP library for interacting with Discourse.

As @MakaryGo mentioned, the Discourse API is great. Append .json to any page you view on this forum and you will see what would be returned if you made a json request to the URL.


#4

How would a complete noob understand this?
The most experience I have so far is just HTML and CSS.


(Michael Brown) #5

If you’re just trying to put HTML and CSS that you have written somewhere, the easiest way to get started would be to get a Digital Ocean droplet (virtual server) and use that for playing around with a web server such as nginx.

To retrieve and parse statistics will take knowledge of a programming language such as JavaScript (loading the stats and displaying them would happen in the browser) or Ruby/Python/C if you want that loading and parsing to happen on the server before sending the rendered page to the user.

This is a deep, deep topic and not really something that is appropriate for our support forum, but I would suggest you look for some examples on the Internet such jquery ajax json parsing.

Good luck!


#6

First of all, keep cool. It’s only code.
Also, I don’t really believe you!

You never used a news reader? :wink: Most of new posts and replies from Discourse forum you can get same way - by RSS channel. And this is pure XML, which is basically almost HTML. No, wait, don’t listen to this part.

Well, there is great and exciting adventure ahead of you, but believe me, it’s not really that much complicated. As @supermathie pointed out, you’ll have to use something more sophisticated than SHTML to work with data in machine formats, but… Not very much sophisticated. Explore, try, and don’t be afraid to ask :wink: