No internet connection
  1. Home
  2. Ideas

Read API

By @sam2021-01-28 12:00:46.659Z

An API which allows you to read information about one or more disscusionid's. I want it because I need to get the comment count on each of my blog cards. So before they opened the post, so people have an idea how much discussion is going on.

If I take a look at one of these links:
https://comments-for-www-example-com.talkyard.net/-/embedded-comments?discussionId=12345&embeddingUrl=https://example.com/hi
Then you'll receive html back, in it you see something like this:
<script id="theVolatileJson" type="application/json">
<script id="thePageJson" type="application/json">
<script id="theStaticJson" type="application/json">

Now these seem to have useful information already. But requests to those pages are CORS protected which is fine.
Anyway something that gives back useful information like that would already be helpful.

If you want to make it really user friendly, which for me isn't necessary but maybe some people prefer it. You could do what commento does.

All you do is add a pre-made js file to your html page and add #commento behind you links and will automatically add the comment count to the card. Eitherway something like this would be very helpful.

Thanks!
Sam

NOTE: It's good to mention that this API should NOT contain sensitive information. It's meant for something you could use as an ajax call without allowing people to read things like all the users, etc. So export-site-json is too much,

Linked from:

  1. support-chat
  • 5 replies
  1. In reply tosam:
    KajMagnus @KajMagnus2021-02-04 15:30:18.114Z2021-02-04 15:42:42.882Z

    I see here: https://docs.commento.io/configuration/frontend/count.html
    that Commento replaces the contents of the <a href=..> tag with the comment count,
    if the href ends with #commento, like so:

    <a href="https://example.com/foo#commento"></a>
    // becomes:
    <a href="https://example.com/foo#commento">12 comments</a>
    

    That seems like a good approach.

    Hmm I think one wouldn't always want to use an <a> tag for displaying the comments count.
    Because ... could that slightly encourage people to jump to the comments before reading the blog post?
    & I'd like to lookup the tags to insert the comment count in, via a CSS class, (a tiny bit faster)

    maybe something like:

    <a href="https://example.com/some-blog-post"><span>Blog Post Title</span> <span class="talkyard-num-comments"></span></a>
    

    and then the Talkyard script finds the href=... url in the enclosing <a> tag and replaces with the comment count — I suppose this'd need to be language specific, e.g. "1 comment" or "3 comments" in English, but "3 kommentarer" if Swedish.

    And you could do like this if you wanted to get the Commento behavior:

    <a href="https://example.com/some-blog-post#comments-section" class="talkyard-num-comments"></a>
    

    It's meant for something you could use as an ajax call without allowing people to read things like all the users, etc.

    Probably the upcoming API endpoint for this will be able to return different kinds of data: Num replies, latest reply on each page, latest replyer (author). And there's authorization checks so only public data gets returned, yes

    1. S@sam2021-02-07 16:59:21.715Z2021-02-07 17:09:39.304Z

      Hmm yea, now that you mention it, there are some caveats to commento's approach. I think youre on the right thinking path.

      Things to consider, maybe not everybody wants their comments to be a part to be clickable to the blog link? So another option is to do a span with a class and a custom attribute that has the link included?
      Another thing is that I don't think you have to worry about languages, it should just say the number, People can add their own text on it afterwards (either with css or in a span next to it). Or you can also let that be handeled by a custom attribute for example:
      <span class="talkyard-num-comments" link="https://example.com/some-blog-post" singular="comment" plural="comments"></span>

      Then if people don't want text (like me) they could do this:
      <span class="talkyard-num-comments" link="https://example.com/some-blog-post" singular="" plural=""></span>

      The reason I don't want any text is because my design looks as follows:

      For me personally the commento thing is not a must-have but I did think it was a nice feature for those not tech savy.

      1. KajMagnus @KajMagnus2021-02-08 07:29:13.076Z

        a span with a class and a custom attribute that has the link included?

        Good idea — now I'm thinking Talyard can find the blog post iink either from a data-href="..." directly on the num-comments tag (or the closest tag with such an attr),
        or if absent, the closest <a href=...>.
        Now in step 1: looking only at the closest <a href=...> probably.

        I don't think you have to worry about languages, it should just say the number

        Good point. Now when I think about it, all blogs / websites that I can remember now, shows a comments icon (just like you do), not any "NN comments" text. So, just the number then.

        The screenshot: It's nice to see num Likes too (num Medium "claps") — maybe this'll make the implementation just a tiny bit different, good that I get to think about now directly.

        1. S@sam2021-02-12 10:58:17.579Z

          I don't use the talkyard likes, reason is that I can't seperate that from the iframe (or don't know how to).
          I would prefer to use talkyards likes so I don't have to use multiple different tools but right now I don't see that as a viable option. Perhaps another idea for the future?

    2. Progress
      with doing this idea
    3. @KajMagnus marked this topic as Planned 2021-01-29 09:26:23.825Z.