automise/simplify newsletter #267
Labels
No labels
Component: User interface
Component: Wymeditor
Help wanted
Level: Difficult
Level: Easy
Level: Moderate
Pagetype: Festival
Pagetype: Mailinglist
Pagetype: Peer reviewed article
Pagetype: Text
Privacy GDPR AVG
status: has conflicts
Status: Needs changes
Status: Needs discussion
Status: Needs review
Status: Ready to merge
Status: Waiting for response
Type: Bug
Type: Enhancement
Type: Question
Usecase: De Stadsbron
Usecase: Koppelting
Usecase: MeetjeStad
Value: Coders
Value: Security
Value: Users
Value: Visitors
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
harmen/hypha#267
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
making the weekly newsletter now costs a lot of time. It would be nice to be able to import the abstracts and titles of articles into a newsletter, add an introduction, and automatically add header and footer.
@dianawi This is assigned to you and marked as in-progress, are you actively working on this? Or should we move it back to the To-do pile?
I have been thinking on this a bit, and can imagine the following:
These copy icons should only be shown to logged in users, or if we think that would be confusing to users that are not working on the newsletter, maybe it should be hidden by default and enabled using a button or preference somewhere (but I'm not sure what would a nice UI would look like that is also easy to implement).
One improved version of this would be to, once you click the first copy icon, change the copy icons to checkboxes (or show a checkbox in addition) and then whenever you check or uncheck a checkbox, copy all selected articles to the clipboard. This means you would go to the Tijdlijn page, check all articles that need to go into the newsletter in the Tijdlijn and paste them into the newsletter in one go.
One easy way to implement this could be to just put a bit of javascript into the theme that adds the copy buttons to the page and handles them. Alternatively, this could be added as an option to the pagelist macro maybe.
This does require that (the HTML structure of) the excerpt shown on the homepage/tijdlijn is already suitable to be pasted into the newsletter verbatim. Or if some mechanical changes are needed, those could maybe be done automatically (but because such changes are likely specific to the site, this is more suitable for the script-in-theme approach than the builtin-to-hypha approach).
I had a closer look at the HTML used for newsletters, and it seems that it is subtly, but importantly different. Currently, the newsletter items consist of a link containing the title, author, date and image, followed by the excerpt outside of the link. The excerpt generated by the pagelist macro has everything in the link tag. If used as-is in the newsletter, this would end up coloring and underlining the excerpt text, which isn't particularly nice (on the website, this is resolved by applying CSS styling, but we can't really add a stylesheet to the newsletter).
To solve this, I think we must modify the copied HTML to either:
I'm not sure how easy it is to modify HTML before copying from javascript, that probably involves duplicating the DOM structure (ideally off-screen), making changes and copying that. Alternatively, one could use a separate page for this and generate the modified HTML directly from PHP.
For the latter, maybe a separate macro (subclass of pagelist) could work, which acts like pagelist, but slightly modifies the resulting HTML, or maybe keeps the HTML the same, but applies a customizable list of styling rules to the output. The latter would maybe allow keeping this code generic and included in Hypha (though it still requires actually creating a page, calling the macro, etc. before this can be used).
I ended up adding a Stadsbron-specific script to the theme: https://www.destadsbron.nl/data/themes/destadsbron/newsletter.js
This script does the following. On the "Tijdlijn" page (only), for logged in users, it shows small copy icons next to each article (all the way to the right):
When you click one such icon, the selected article is copied to the clipboard. Also, all copy icons change to checkboxes:
Now, whenever you (un)check a checkbox, all checked articles are copied to the clipboard again.
To put them in a newsletter, simply edit the newsletter and paste in the articles. Note that this copies raw HTML as text, so you need to paste this into the raw HTML editor:
The articles are not copied exactly as-is, but a little bit of transformation happens to prepare the HTML for pasting into the newsletter. This makes sure that everything looks good in an e-mail without the CSS stylesheet that is used on the website, by adding inline styles instead.