Displaying Bookmarks Publicly

Interesting thread here - this might allow me to repurpose my bookmarks for something else I have been thinking about … BUT … I am clearly doing it wrong - how do you add any of this code to the site? It isn’t on the page itself I assume?

You’re right; these snippets can’t go into a page or post. They have to be included in a custom template. Or one could construct a shortcode for easy inclusion anywhere.

I might get around to releasing this as a plug-in in the future, if no one beats me to it. :blush:

I thought the same too. Check out the thread linked in @jsonbecker’s response.

1 Like

This does work and might be as close as possible to achieving what I’m going for; however, the content.html part automatically includes added “footer” text. The only solution I can come up with is to limit the truncation further so that gets chopped off. But by doing that, defeats the goal of what I want to do.

I also tried automatically importing the JSON feed through the Micro.blog import tool (then I could run a filter to categorize it), but it won’t allow importing from M.b sources.

So I feel like every solution gets me 90% of the way there. Might be something to put on the back burner and see if things change on any part of it.

What do you mean by footer text? Can you provide an example?

content_html is the actual content from the page you’ve bookmarked. So it will vary greatly depending on which websites you’re bookmarking. It’s probably hard to come up with a general solution, unfortunately.

Sorry, I could’ve worded that better. Within the content, the text “Read: link.com” is appended at the end for every link.

Okay, it could probably be solved as long as it’s consistent. Can you provide an unaltered bookmark from your JSON feed? Something like this:

{
  "id": "14915304",
  "content_html": "Bookmark improvements in Micro.blog <a href=\"https://www.manton.org/2022/03/23/bookmark-improvements-in.html\">manton.org</a>",
  "url": "https://www.manton.org/2022/03/23/bookmark-improvements-in.html",
  "date_published": "2022-03-23T14:54:40+00:00",
  "author": {
    "name": "Manton.org",
    "url": "http://Manton.org/",
    "avatar": "https://micro.blog/photos/200/https%3A%2F%2Fmicro.blog%2Fmanton%2Ffavicon.png",
    "_microblog": {
      "username": "manton.org"
    }
  }
}

The Bookmarks Shortcode plug-in (BETA) is a thing now, @JohnPhilpin. :blush: Install, add your bookmarks JSON feed in the settings, and paste this snippet on any page: {{< bookmarks />}}. More detailed instructions can be found on the plug-in page.

1 Like

Here ya go:

    {
      "id": "14630634",
      "content_html": "<p>For today's <a href=\"https://dahlstrand.net/search-space/?q=%23FeedReaderFriday\">#FeedReaderFriday</a>, I made my RSS feed prettier. Before, the browser served a bunch of messy XML, but now you're greeted by <a href=\"https://dahlstrand.net/notes/feed.xml\">a friendly preview and instructions</a>. 🥳</p>\n\n<p>Based on <a href=\"https://github.com/genmon/aboutfeeds/blob/main/tools/pretty-feed-v3.xsl\">pretty-feed.xsl</a> by Matt Webb. You should add <a href=\"https://interconnected.org/home/\">Matt's blog</a> to your feed reader! 👀</p>\n\n<p><img src=\"https://cdn.micro.blog/photos/1000x/https%3A%2F%2Fdahlstrand.net%2Fimages%2Fpretty-rss.png\" alt=\"A split view of the same web feed: before and after. The before shows a plain text XML representation of content. Boring! The after shows a pretty-looking preview of the same.\" width=\"1224\" height=\"1224\" loading=\"lazy\"></p><p class=\"post_archived_links\">Read: <a href=\"https://micro.blog/bookmarks/470113\">dahlstrand.net</a> </p>",
      "url": "https://dahlstrand.net/1670017739/",
      "date_published": "2022-12-02T21:48:59+00:00",
      "author": {
        "name": "Sven Dahlstrand",
        "url": "https://dahlstrand.net",
        "avatar": "https://avatars.micro.blog/avatars/2022/38001.jpg",
        "_microblog": {
          "username": "sod"
        }
      }
    }

What a nice bookmark you got there. :wink: You could remove the offending HTML with Hugo’s replaceRE: replaceRE "<p class=\"post_archived_links\">.+</p>" "". Merged with the previous example:

{{ $bookmarks := getJSON "https://micro.blog/feeds/yourname/bookmarks/decc3dfad46628dc2cac.json" }}

{{ range $bookmarks.items }}
  {{ if not .title }}
    <div class="h-entry">
      <a class="u-bookmark-of h-cite" href="{{ .url }}">
        <p>{{ .content_html | replaceRE "<p class=\"post_archived_links\">.+</p>" "" | plainify | truncate 140 }}</p>
      </a>
    </div>
  {{ end }}
{{ end }}

well - look at that - of course you have … and of course I tried it … and of course it isn’t working for me :frowning:

I am pretty sure that I am using the wrong JSON

This is clearly not right

https://micro.blog/feeds/johnphilpin/bookmarks/decc3dfad46628dc2cac.json

but have tried this and various versions - to no avail - except on one occasion where it all appeared - I danced for joy and then it went away again.

No, that looks like my made-up example, slightly modified. You’ll want your personal (secret) URL found on this page. There’s a link at the bottom: “Saved bookmarks go in your unique read later feed”.

1 Like

And there we are … all done and working …

Thankyou.

And of course the random collection of resultant bookmarks clearly demonstrates different ways I have been using them over time … next job is to clean up … and then enable what I am thinking.

1 Like

I too use Bookmarks to well, bookmark posts and replies on Micro.blog so not sure how useful they will be to display publicly. But I was following this thread to see that it’s possible.

In your case, it’s another option instead of Pinboard. Would have to be used with that in mind.

I added a new bookmark on MicroBlog yesterday … at this point it still isn’t showing on my bookmarks page … I assumed there would be a delay … any idea how long?

Your bookmarks page updates every time your blog is built. That happens, for example, when a post or page is published (or edited). But also when you change settings related to your blog. And, at any point in time, you can choose to manually start a build.

It would be really cool if adding a new bookmark automatically triggered a build but that’s something only @manton can implement.

Aah, I see - thankyou for the clarity Sven.

Just as an FYI-- books work the same way. Adding these kind of “data” elements don’t trigger blog builds, only posts do.

Seems like we should change this to automatically republish the blog. Thanks everyone!

2 Likes