endonend / Hains-Point

A theme for micro.blog
MIT License
0 stars 0 forks source link

Support for On This Day plugin? #16

Closed toddgrotenhuis closed 2 years ago

toddgrotenhuis commented 2 years ago

I'm not sure if I need to change something on my end to re-enable on-this-day or if it's something that needs to be done in the theme?

This one (for example) isn't showing when I hit the On-This-Day plugin page: https://blog.grotenhuis.info/2020/03/09/pyramid-arcade-reboxing.html

endonend commented 2 years ago

Good question! I can look into this... can you link where you got the "on this day" code from? (I didn't see in plugins, though I thought I saw it there before...)

toddgrotenhuis commented 2 years ago

Oh yeah, I don't see it as a plug-in either. Here's the page code:

`

Loading...

`
toddgrotenhuis commented 2 years ago

and here is the js:

` var container = document.getElementById('on-this-day');

function renderPost(post) { var postEl = document.createElement('div'); postEl.className = 'post'; container.appendChild(postEl);

if (post['properties']['name'] != null) {
    var titleEl = document.createElement('h2');
    titleEl.className = 'p-name';
    titleEl.innerText = post['properties']['name'][0];
    postEl.appendChild(titleEl);
}

var permalinkEl = document.createElement('a');
permalinkEl.className = 'post-date u-url';
permalinkEl.href = post['properties']['url'][0];
postEl.appendChild(permalinkEl);

var publishedEl = document.createElement('time');
publishedEl.className = 'dt-published';
publishedEl.datetime = post['properties']['published'][0];

var published = post['properties']['published'][0];
published = new Date(published.slice(0,19).replace(' ', 'T'));

publishedEl.innerText = published.toDateString();
permalinkEl.appendChild(publishedEl);

var contentEl = document.createElement('div');
contentEl.className = 'e-content';
contentEl.innerHTML = post['properties']['content'][0]['html'];
postEl.appendChild(contentEl);

}

function renderNoContent() { var noPostsEl = document.createElement('p'); noPostsEl.innerText = 'No posts found for this day. Check back tomorrow!'; container.appendChild(noPostsEl); }

var xhr = new XMLHttpRequest(); xhr.responseType = "json"; xhr.open('GET', "https://micromemories.cleverdevil.io/posts?tz=US/Pacific", true); xhr.send();

xhr.onreadystatechange = function(e) { if (xhr.readyState == 4 && xhr.status == 200) { container.innerHTML = ''; if (xhr.response.length == 0) { renderNoContent(); } else { xhr.response.forEach(function(post) { renderPost(post); }); } } } `

endonend commented 2 years ago

Looks like this may be the issue, per the Github readme for micro memories: https://github.com/cleverdevil/micromemories

Micro Memories is known to work on all of the standard themes in Micro.blog. If you are using a custom theme, you need to ensure that your theme makes proper use of microformats, especially the h-entry microformat. The open source Micro.blog themes are a good place to look for guidance.

To ensure a good experience, your posts should be marked up with the h-entry microformat, with a u-url property, a p-name property, a dt-published property, and a e-content property. To check how your posts parse with a microformats2 parser, you can use the tool on microformats.io to verify that all properties are being discovered.

I have some of these set up but need to verify all.

endonend commented 2 years ago

Did a quick test and that was it... will get this added since it's important even beyond this plugin. Thanks for the report!

endonend commented 2 years ago

This is in 2022.1.9, which I just checked in...