-
-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of UI for webmention reactions. #2572
Conversation
This helps in local development to check that the webmentions are actually getting fetched and rendered properly.
I've staged the PR here: https://20211122t101742-dot-webalmanac.uk.r.appspot.com/en/2021/ @SaptakS @tunetheweb I'm getting 0 reactions on all chapters. Is that a dev env CORS issue? How did it work for the screenshots above? |
Not sure if it's available in all chapters. I saw webmentions data in structured-data and third-parties. I tested in structured-data. And seems it's showing up there: https://20211122t101742-dot-webalmanac.uk.r.appspot.com/en/2021/structured-data |
src/templates/base/base_chapter.html
Outdated
id="likes-tab" | ||
tabindex="0" | ||
> | ||
<span id="likes-count">0</span> {{ self.likes() }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'd need additional logic to handle singular and plural grammar, ie "1 like" vs "2 likes".
This is complicated for translations that follow different rules than simply 1 or not-1. @tunetheweb do we have any precedent for how to handle that in the translations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup:
almanac.httparchive.org/src/static/js/almanac.js
Lines 471 to 479 in 4b332ca
if (comments === 1) { | |
document.querySelectorAll('.comment-singular').forEach(el => { | |
el.removeAttribute('data-translation'); | |
}); | |
} else { | |
document.querySelectorAll('.comment-plural').forEach(el => { | |
el.removeAttribute('data-translation'); | |
}); | |
} |
Though suspect we need more than that for Slavic languages that have more than just singlar and plural. We have a plural_ru
macro for that but looks like we never implemented that for the comment/comments. Can look at that later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok. Let's get basic singular/plural support into this PR then we can worry about the more complex rules in a separate issue.
I also just came across Intl.PluralRules.select()
which looks like it could be useful.
- use textContent instead of innerHTML where only text is added - use key instead of keyCode which is deprecated - use DOMParser and appendChild instead of innerHTML - removes DOMContentLoaded eventListener
I have tried to address most of the comments above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fantastic work @SaptakS !
Particularly appreciate the effort to make it accessible (and today I learned how to make accessible tablists!).
Got some requested changes though.
- Uses the text part of content in replies and mentions - Unifies the rendering logic for different render types - Rewrites the code using createElement instead of string parse
@tunetheweb I have addressed all the comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much cleaner. Will have a deeper look later but a few quick comments for you upfront.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty happy with this now. I think these last few suggestions will make CI pass and allow us to merge this.
Co-authored-by: Barry Pollard <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good to go! Great work on it.
@rviscomi you wanna have another look or happy to merge?
Great job @SaptakS ! Thanks a lot for this. Btw there's another tab index dev issue if interested?: #1325 (comment) |
I can take a stab at it after the security chapter related stuff is done with. |
Refs #2192
I have added the UI implementation for the webmention reactions corresponding to like, reposts, replies and mentions of the chapter link. The tabs are keyboard navigable and have aria-notations similar to https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/tab_role
Screenshot for likes in 2021 restructured data:
Screenshot for reposts in 2021 restructured data:
Screenshot for replies in 2021 restructured data:
Screenshot for mention in 2021 restructured data:
Things that can still be improved or added:
Staged URL: https://20211122t101742-dot-webalmanac.uk.r.appspot.com/en/2021/