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
Configurable events #22
Configurable events #22
Conversation
9cf192e
to
f4acab4
Compare
Hello @rowanthorpe, it's nice to hear from you again! I've rapidly skimmed over your code and from what I could see you've done an oustdanding work - as usual ;-) I will get back to you as soon as I manage to finish my exams, which should mean a week or so. Thank you again! |
OK, no rush. Good luck with the exams. |
* | ||
* Open up https://calendar.google.com, in the menu on the left click on the arrow next to the birthday calendar |
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.
Does this calendar have a default name?
In italian it's called "Compleanni ed eventi" which would translate into "Birthdays and events". I don't know the exact english version, but we should use it here.
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.
Mine is presently set to "Birthdays & Anniversaries" but I am almost sure I've edited that name at some point, and Google seems to have no way to see the default pre-edited name. Are you able to temporarily change your settings to English to see what the default name becomes? Otherwise we should find another user with language set to English who knows they haven't edited the calendar name yet.
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 I might have edited It as well...
I'll try and have a look with my backup account tomorrow morning.
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.
Finally I have some time to address this!
In the end I've finally decided to implement all of your changes, because, as you said, they actually are really nice 😄
I've submitted some comments in my review about some minor problems which should be solved before merging.
I'd like to hear some feedback about the comment at line 99 as I don't know which way would be the best to make it the most user friendly.
When everything is fixed I'll proceed to merge into a development branch to update all the translations as per your suggestion.
Thank you again for the great work!
code.gs
Outdated
// START OPTIONAL CUSTOMIZATION | ||
|
||
// Types of events to report, in a list. Can include one or more of 'BIRTHDAY', 'ANNIVERSARY', 'CUSTOM' | ||
var eventTypes = ['BIRTHDAY']; |
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 am thinking that something along these lines could be easier for users to setup:
var eventTypes = {
BIRTHDAY: true,
ANNIVERSARY: false,
CUSTOM: false
}
eventTypes = Object.keys(eventTypes).filter(function(x) { return eventTypes[x] == true; });
What do you think?
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.
Yes, I think making the editable part a hash/dict of explicit booleans as you suggest would be more friendly to non-techies (and self-documenting, so the comment-line can be removed). I think the conversion one-liner can be slightly simplified too due to the filter-method coercing the test-retval to boolean anyway, but maybe I'm just showing more familiarity with other languages than JS (please tell me if I'm assuming wrong for JS here). Let me know if the below looks good and I'll update the commit accordingly.
// START OPTIONAL CUSTOMIZATION
var eventTypes = {
BIRTHDAY: true,
ANNIVERSARY: false,
CUSTOM: false,
}
// END OPTIONAL CUSTOMIZATION
//// other stuff...
eventTypes = Object.keys(eventTypes).filter(function(x) { return eventTypes[x]; });
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.
It's OK for me 👍
|
||
doLog('Contact # ' + i + ' ' + eventTypeNamePlural + '.'); | ||
contact = new Contact(event, eventType); | ||
subjectBuilder.push(contact.fullName); |
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.
If a contact has two events in the same notification (e.g. birthday in 7 days and anniversary in 1 day) his/her name will be duplicated in the subject.
This could be prevented by collecting all the contacts names in an array, keeping them unique and building the subject after all the contacts have been processed.
code.gs
Outdated
var line; | ||
line = ['\n', indent]; | ||
if (self.eventType === 'CUSTOM') { | ||
line.push('{' + dateLabel + '} '); |
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'd replace the {} around the custom event type with <>.
Affects line 590 as well.
code.gs
Outdated
self.dateLabels.forEach(function (dateLabel) { | ||
var line, imgCount; | ||
line = ['<li>']; | ||
if (self.eventType === 'CUSTOM') { |
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 am planning to add a default "blank user" thumbnail for users without a profile photo: I'd move the custom event name after the photo so as not to disrupt the layout of the email (keeping all the thumbnails aligned vertically).
Hi, I was away from internet for a few days, but am back now, so will get a chance to look at this and make changes hopefully tomorrow, or the day after at the latest :-) |
General renaming/rewording of var/function-names and comments in preparation for the upcoming refactoring, to hopefully make that diff easier to read. Also includes a small comment grammar-fix at line 344.
f4acab4
to
b292f23
Compare
I just rebased the branch to address all the changes you suggested. For the naming of the calendar in the comments I used a wording which I think strikes a balance between "most likely default name" and "making it clear it might have a non-default name anyway". Of course if I missed something, made any presumptions you don't like, or need to do more changes, let me know. |
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.
Except for this little thing everything is OK.
code.gs
Outdated
line.push(' - '); | ||
// Custom label | ||
if (self.eventType === 'CUSTOM') { | ||
line.push('<' + dateLabel + '> '); |
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.
<
and >
need to be escaped in the HTML, otherwise the result is going to be interpreted as a tag and won't be rendered in the message.
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.
Oh bugger, sorry I missed that (thanks for catching it), I tested it late last night in a hurry and only looked at the plaintext result when running test(). Fixing it and pushing in a minute...
This now configurably handles birthdays and anniversaries, and custom events (potentially more than one per contact) with added labels per custom event. Also includes one or two minor added newlines and improved spacing in plaintext email output (too much hassle to split to separate commit).
Remove unneeded entries, add TODOs
Use mailto: anchor for email address, remove redundant "send email now" link, remove unneeded line from translations.
b292f23
to
2cd9efb
Compare
Does GitHub let you change the target branch for this PR form master to my repository's/configurable-events? |
Yes, I just changed the target branch as requested. |
Inspired by the closing of #9 yesterday (and particularly the mention that recently Google seems to have fixed API support for non-birthday events), I checked that the API had in fact been fixed (it has!), and then I did a big refactor to configurably handle birthdays and anniversaries, and custom events (potentially more than one per contact, which required looping) with added labels per custom event. It has been running nicely for me under various test-runs (in English and Greek). I am very aware that @GioBonvi said
but I wanted this functionality for my own use anyway (even more than the birthday functionality). Therefore - now that the API handles it - I did these changes and made them as non-invasive as possible from the user-perspective (if users don't edit the default
eventTypes
array underOPTIONAL CUSTOMIZATION
then it should behave the same as before, with the exception of some more generic wording in titles, to make sense for more than just birthdays). @GioBonvi I am posting the changes in this PR because:If you want to include these changes then perhaps the repo could afford another rename (e.g. GoogleBirthdayNotifier -> GoogleContactsEventsNotifier) at some point, but before that maybe the changes should stay in a non-master ("devel"?) branch for a while until other translators have caught up with rewordings. If you don't want to include the non-birthday functionality I will maintain my changes as a patch-fork in my own repo, called GoogleContactsEventsNotifier.