Merge branch 'master' of github.com:JohnMcLear/ep_email_notifications
This commit is contained in:
commit
4813d8f766
6 changed files with 196 additions and 24 deletions
|
@ -30,7 +30,7 @@ NOTE: You will NOT receive an email if you(the author that registered their emai
|
|||
```
|
||||
|
||||
# Translation
|
||||
This plugin has for now an english and french translation.
|
||||
This plugin has for now translations for english, french and german.
|
||||
In case you would like to have it in another language, you can easily translate the few sentences and then contact us on irc (#etherpad-lite-dev on irc.freenode.net) or create a Pull-Request on the GitHub repository.
|
||||
You can find the sentences to translate in the ep_email_notifications/locales/ directory.
|
||||
Specials chars written in unicode (See https://fr.wikipedia.org/wiki/Table_des_caract%C3%A8res_Unicode_%280000-0FFF%29)
|
||||
|
|
|
@ -17,7 +17,7 @@ exports.eejsBlock_styles = function (hook_name, args, cb) {
|
|||
|
||||
exports.clientVars = function(hook, context, callback) {
|
||||
var pluginSettings = settings.ep_email_notifications;
|
||||
var panelDisplayLocation = (pluginSettings && pluginSettings.panelDisplayLocation)?pluginSettings.panelDisplayLocation:"undefiend";
|
||||
var panelDisplayLocation = (pluginSettings && pluginSettings.panelDisplayLocation)?pluginSettings.panelDisplayLocation:"undefined";
|
||||
// return the setting to the clientVars, sending the value
|
||||
return callback({ "panelDisplayLocation": panelDisplayLocation });
|
||||
};
|
||||
|
|
19
locales/de.json
Normal file
19
locales/de.json
Normal file
|
@ -0,0 +1,19 @@
|
|||
{ "ep_Email_notifications.titleGritterError": "Email Benachrichtigungs-Fehler"
|
||||
, "ep_Email_notifications.titleGritterSubscr": "Email Benachrichtigung"
|
||||
, "ep_Email_notifications.titleGritterUnsubscr": "Email Benachrichtung - Abmeldung"
|
||||
, "ep_Email_notifications.headerGritterSubscr": "(Eine Email schicken, wenn jemand dieses Pad verändert)"
|
||||
, "ep_Email_notifications.msgOptionsNotChecked": "Sie müssen mindestens eine der beiden Optionen aus 'Eine Email Schicken wenn jemand..' auswählen'"
|
||||
, "ep_Email_notifications.msgParamsMissing": "Einstellungen für das 'Email_Notifications' Plugin nicht gefunden.<br />Bitte wenden Sie sich an ihren Administrator."
|
||||
, "ep_Email_notifications.msgEmailMalformed": "Diese Email-Adresse ist nicht korrekt"
|
||||
, "ep_Email_notifications.msgAlreadySubscr": "Sie erhalten bereits Email-Benachtichtigungen für dieses Pad"
|
||||
, "ep_Email_notifications.msgUnsubscrNotExisting": "Diese Email-Adresse ist nicht für dieses Pad registriert"
|
||||
, "ep_Email_notifications.msgUnknownErr": "Unbekannter Fehler"
|
||||
, "ep_Email_notifications.msgSubscrSuccess": "Eine Email wurde an Sie geschickt.<br />Klicken Sie auf den Link um ihre Anmeldung zu bestätigen."
|
||||
, "ep_Email_notifications.msgUnsubscrSuccess": "Eine Email wurde an Sie geschickt.<br />Klicken Sie auf den Link um ihre Abmeldung zu bestätigen."
|
||||
, "ep_Email_notifications.menuLabel": "Email Benachrichtungen"
|
||||
, "ep_Email_notifications.formOptionsTitle": "Eine Email schicken, wenn jemand.."
|
||||
, "ep_Email_notifications.formOptionOnStart": "anfängt, dieses Pad zu bearbeiten"
|
||||
, "ep_Email_notifications.formOptionOnEnd": "aufhört, das Pad zu bearbeiten"
|
||||
, "ep_Email_notifications.formBtnSubscr": "Anmelden"
|
||||
, "ep_Email_notifications.formBtnUnsubscr": "Abmelden"
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "ep_email_notifications",
|
||||
"description": "Subscribe to a pad and receive an email when someone edits your pad",
|
||||
"version": "0.0.7",
|
||||
"version": "0.0.9",
|
||||
"author": {
|
||||
"name": "John Mclear",
|
||||
"email": "john@mclear.co.uk",
|
||||
|
@ -20,6 +20,10 @@
|
|||
"engines": {
|
||||
"node": ">= 0.4.1"
|
||||
},
|
||||
"repository" : {
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/JohnMcLear/ep_email_notifications.git"
|
||||
},
|
||||
"readme": "# Description\nThis plugin allows users to subscribe to pads and receive email updates when a pad is being modified. You can modify the frequency. This plugin is very much in alpha stage and has a lot of things TODO (See TODO).\n\n# Installation\nMake sure an SMTP gateway is installed IE postfix\nConfigure SPF and RDNS records to ensure proper mail flow <-- Search online\nCopy/Edit the below to your settings.json\nConnect to a pad, Click on the Share/Embed link and enter in your email address.\nOpen that pad in ANOTHER BROWSER then begin modifying, you should receive an email when the pad has begun editing and once the pad has gone stale (when everyone stops editing it and a time period passes).\nNOTE: You will NOT receive an email if you(the author that registered their email) are currently on or editing that pad!\n\n```\n \"ep_email_notifications\" : {\n checkFrequency: 6000, // checkFrequency = How frequently(milliseconds) to check for pad updates -- Move me to the settings file\n staleTime: 30000, // staleTime = How stale(milliseconds) does a pad need to be before notifying subscribers? Move me to settings\n fromName: \"Etherpad SETTINGS FILE!\",\n fromEmail: \"pad@etherpad.org\",\n urlToPads: \"http://beta.etherpad.org/p/\", // urlToPads = The URL to your pads note the trailing /\n emailServer: { // See https://github.com/eleith/emailjs for settings\n host: \"127.0.0.1\"\n }\n }\n```\n\n# TODO\n* Clean up all code\n\n# FUTURE VERSIONS TODO\n* v2 - Get the modified contents from the API HTML diff and append that to the Email and make the email from the server HTML not plain text\n* v2 - a point to unsubscribe and validate/verify email https://github.com/alfredwesterveld/node-email-verification\n* v2 - Keep a record of when a user was last on a pad\n",
|
||||
"readmeFilename": "README.md",
|
||||
"_id": "ep_email_notifications@0.0.7",
|
||||
|
|
|
@ -22,7 +22,6 @@ exports.postAceInit = function(hook, context){
|
|||
$('#options-emailNotifications').on('click', function() {
|
||||
if (!optionsAlreadyRecovered) {
|
||||
getDataForUserId('ep_email_form_mysettings');
|
||||
optionsAlreadyRecovered = true;
|
||||
} else {
|
||||
$('.ep_email_settings').slideToggle();
|
||||
}
|
||||
|
@ -101,6 +100,9 @@ exports.handleClientMessage_emailUnsubscriptionSuccess = function(hook, context)
|
|||
|
||||
exports.handleClientMessage_emailNotificationGetUserInfo = function (hook, context) { // return the existing options for this userId
|
||||
var result = context.payload;
|
||||
|
||||
// Only use first data from the server. (case when 2 emails subscribed for the same pad & authorId)
|
||||
if (optionsAlreadyRecovered == false) {
|
||||
if(result.success == true){ // If data found, set the options with them
|
||||
$('[name=ep_email]').val(result.email);
|
||||
$('[name=ep_email_onStart]').prop('checked', result.onStart);
|
||||
|
@ -113,6 +115,9 @@ exports.handleClientMessage_emailNotificationGetUserInfo = function (hook, conte
|
|||
if (result.formName == 'ep_email_form_mysettings') {
|
||||
$('.ep_email_settings').slideToggle();
|
||||
}
|
||||
|
||||
optionsAlreadyRecovered = true;
|
||||
}
|
||||
}
|
||||
|
||||
exports.handleClientMessage_emailNotificationMissingParams = function (hook, context) { // Settings are missing in settings.json file
|
||||
|
@ -123,7 +128,9 @@ exports.handleClientMessage_emailNotificationMissingParams = function (hook, con
|
|||
// (string | mandatory) the text inside the notification
|
||||
text: window._('ep_email_notifications.msgParamsMissing'),
|
||||
// (bool | optional) if you want it to fade out on its own or just sit there
|
||||
sticky: true
|
||||
sticky: true,
|
||||
// (string | optional) add a class name to the gritter msg
|
||||
class_name: "emailNotificationsParamsMissing"
|
||||
});
|
||||
|
||||
// Hide the notification menu in mysettings
|
||||
|
@ -177,8 +184,8 @@ function askClientToEnterEmail(){
|
|||
text: "<p class='ep_email_form_popup_header'>" + window._('ep_email_notifications.headerGritterSubscr') + "</p>" + formContent,
|
||||
// (bool | optional) if you want it to fade out on its own or just sit there
|
||||
sticky: true,
|
||||
// (int | optional) the time you want it to be alive for before fading out
|
||||
time: 2000,
|
||||
// (string | optional) add a class name to the gritter msg
|
||||
class_name: "emailNotificationsPopupForm",
|
||||
// the function to bind to the form
|
||||
after_open: function(e){
|
||||
$('#ep_email_form_popup').submit(function(){
|
||||
|
@ -198,8 +205,14 @@ function askClientToEnterEmail(){
|
|||
checkAndSend(e);
|
||||
});
|
||||
|
||||
if (optionsAlreadyRecovered == false) {
|
||||
getDataForUserId('ep_email_form_popup');
|
||||
optionsAlreadyRecovered = true;
|
||||
} else {
|
||||
// Get datas from form in mysettings menu
|
||||
$('#ep_email_form_popup [name=ep_email]').val($('#ep_email_form_mysettings [name=ep_email]').val());
|
||||
$('#ep_email_form_popup [name=ep_email_onStart]').prop('checked', $('#ep_email_form_mysettings [name=ep_email_onStart]').prop('checked'));
|
||||
$('#ep_email_form_popup [name=ep_email_onEnd]').prop('checked', $('#ep_email_form_mysettings [name=ep_email_onEnd]').prop('checked'));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -219,7 +232,9 @@ function checkAndSend(e) {
|
|||
// (string | mandatory) the heading of the notification
|
||||
title: window._('ep_email_notifications.titleGritterError'),
|
||||
// (string | mandatory) the text inside the notification
|
||||
text: window._('ep_email_notifications.msgOptionsNotChecked')
|
||||
text: window._('ep_email_notifications.msgOptionsNotChecked'),
|
||||
// (string | optional) add a class name to the gritter msg
|
||||
class_name: "emailNotificationsSubscrOptionsMissing"
|
||||
});
|
||||
} else if (email) {
|
||||
$('#' + formName).submit();
|
||||
|
@ -278,7 +293,9 @@ function showRegistrationSuccess(){
|
|||
// (string | mandatory) the text inside the notification
|
||||
text: window._('ep_email_notifications.msgSubscrSuccess'),
|
||||
// (int | optional) the time you want it to be alive for before fading out
|
||||
time: 10000
|
||||
time: 10000,
|
||||
// (string | optional) add a class name to the gritter msg
|
||||
class_name: "emailNotificationsSubscrResponseGood"
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -299,7 +316,9 @@ function showAlreadyRegistered(type){
|
|||
// (string | mandatory) the text inside the notification
|
||||
text: msg,
|
||||
// (int | optional) the time you want it to be alive for before fading out
|
||||
time: 7000
|
||||
time: 7000,
|
||||
// (string | optional) add a class name to the gritter msg
|
||||
class_name: "emailNotificationsSubscrResponseBad"
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -314,7 +333,9 @@ function showUnregistrationSuccess(){
|
|||
// (string | mandatory) the text inside the notification
|
||||
text: window._('ep_email_notifications.msgUnsubscrSuccess'),
|
||||
// (int | optional) the time you want it to be alive for before fading out
|
||||
time: 10000
|
||||
time: 10000,
|
||||
// (string | optional) add a class name to the gritter msg
|
||||
class_name: "emailNotificationsUnsubscrResponseGood"
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -328,7 +349,9 @@ function showWasNotRegistered(){
|
|||
// (string | mandatory) the text inside the notification
|
||||
text: window._('ep_email_notifications.msgUnsubscrNotExisting'),
|
||||
// (int | optional) the time you want it to be alive for before fading out
|
||||
time: 7000
|
||||
time: 7000,
|
||||
// (string | optional) add a class name to the gritter msg
|
||||
class_name: "emailNotificationsUnsubscrResponseBad"
|
||||
});
|
||||
|
||||
}
|
||||
|
|
126
static/tests/frontend/specs/email_notifications.js
Normal file
126
static/tests/frontend/specs/email_notifications.js
Normal file
|
@ -0,0 +1,126 @@
|
|||
describe("email notifications plugin", function(){
|
||||
//create a new pad before each test run
|
||||
beforeEach(function(cb){
|
||||
helper.newPad(cb);
|
||||
this.timeout(60000);
|
||||
});
|
||||
|
||||
// Subscribe malformed email
|
||||
var malformedEmail = "tutti@bad-email";
|
||||
|
||||
// Subscribe good email
|
||||
var goodEmail = "tutti@non-existing-domain.org";
|
||||
|
||||
// Test the form in mysetting menu
|
||||
|
||||
// Launch the tests
|
||||
// First test without options selected
|
||||
it("makes test without options selected", function(done) {
|
||||
var chrome$ = helper.padChrome$;
|
||||
|
||||
//click on the settings button to make settings visible
|
||||
var $settingsButton = chrome$(".buttonicon-settings");
|
||||
$settingsButton.click();
|
||||
|
||||
// Show the notification form
|
||||
chrome$('.ep_email_settings').slideDown(function() {
|
||||
|
||||
chrome$('#ep_email_form_mysettings [name=ep_email]').val(goodEmail);
|
||||
chrome$('#ep_email_form_mysettings [name=ep_email_onStart]').prop('checked', false);
|
||||
chrome$('#ep_email_form_mysettings [name=ep_email_onEnd]').prop('checked', false);
|
||||
|
||||
chrome$('#ep_email_form_mysettings [name=ep_email_subscribe]').click(); //function() {
|
||||
|
||||
// Is the correct gritter msg there
|
||||
helper.waitFor(function() {
|
||||
return chrome$(".gritter-item").is(':visible') == true;
|
||||
})
|
||||
.done(function(){
|
||||
expect(chrome$(".emailNotificationsSubscrOptionsMissing").is(':visible')).to.be(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Second, test with a malformed email
|
||||
it("makes test subscription with malformed email address", function(done) {
|
||||
var chrome$ = helper.padChrome$;
|
||||
|
||||
//click on the settings button to make settings visible
|
||||
var $settingsButton = chrome$(".buttonicon-settings");
|
||||
$settingsButton.click();
|
||||
|
||||
// Show the notification form
|
||||
chrome$('.ep_email_settings').slideDown(function() {
|
||||
|
||||
chrome$('#ep_email_form_mysettings [name=ep_email]').val(malformedEmail);
|
||||
chrome$('#ep_email_form_mysettings [name=ep_email_onStart]').prop('checked', true);
|
||||
|
||||
chrome$('#ep_email_form_mysettings [name=ep_email_subscribe]').click();
|
||||
|
||||
// Is the correct gritter msg there
|
||||
helper.waitFor(function() {
|
||||
return chrome$(".gritter-item").is(':visible') == true;
|
||||
})
|
||||
.done(function(){
|
||||
expect(chrome$(".emailNotificationsSubscrResponseBad").is(':visible')).to.be(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Third, test unsubscription with an email not registered
|
||||
it("makes test unsubscription with an unregistered email address", function(done) {
|
||||
var chrome$ = helper.padChrome$;
|
||||
|
||||
//click on the settings button to make settings visible
|
||||
var $settingsButton = chrome$(".buttonicon-settings");
|
||||
$settingsButton.click();
|
||||
|
||||
// Show the notification form
|
||||
chrome$('.ep_email_settings').slideDown(function() {
|
||||
|
||||
chrome$('#ep_email_form_mysettings [name=ep_email]').val(goodEmail);
|
||||
|
||||
chrome$('#ep_email_form_mysettings [name=ep_email_unsubscribe]').click();
|
||||
|
||||
// Is the correct gritter msg there
|
||||
helper.waitFor(function() {
|
||||
return chrome$(".gritter-item").is(':visible') == true;
|
||||
})
|
||||
.done(function(){
|
||||
expect(chrome$(".emailNotificationsUnsubscrResponseBad").is(':visible')).to.be(true);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Fourth, test subscription with a good email
|
||||
it("makes test subscription with an unregistered email address", function(done) {
|
||||
var chrome$ = helper.padChrome$;
|
||||
|
||||
//click on the settings button to make settings visible
|
||||
var $settingsButton = chrome$(".buttonicon-settings");
|
||||
$settingsButton.click();
|
||||
|
||||
// Show the notification form
|
||||
chrome$('.ep_email_settings').slideDown(function() {
|
||||
|
||||
chrome$('#ep_email_form_mysettings [name=ep_email]').val(goodEmail);
|
||||
chrome$('#ep_email_form_mysettings [name=ep_email_onStart]').prop('checked', true);
|
||||
|
||||
chrome$('#ep_email_form_mysettings [name=ep_email_subscribe]').click();
|
||||
|
||||
// Is the correct gritter msg there
|
||||
helper.waitFor(function() {
|
||||
return chrome$(".gritter-item").is(':visible') == true;
|
||||
})
|
||||
.done(function(){
|
||||
expect(chrome$(".emailNotificationsSubscrResponseGood").is(':visible')).to.be(true);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue