Commit f3891267 authored by Luc Didry's avatar Luc Didry

Fix #1 and #3

parent 5db3236d
......@@ -8,10 +8,16 @@ Install the plugin and put this in your `settings.json`:
"ep_delete_after_delay": {
"delay": 86400, // one day, in seconds
"loopDelay": 3600, // one hour, in seconds
"deleteAtStart": true,
"text": "The content of this pad has been deleted since it was older than the configured delay."
},
`delay` (mandatory) is in seconds. You can't put `7*86400` for a week, you have to put `604800`.
`delay` (mandatory) delay in seconds with no edition of the pad before deletion. You can't put `7*86400` for a week, you have to put `604800`.
`loopDelay` delay in seconds between deletion loops. Deletion loop will check all pads to see if they have to be deleted. You can't put `60*60` for a hour, you have to put `3600`. Default is one hour.
`deleteAtStart` binary, tells if you want to start a deletion loop at Etherpad startup. Default is true.
`text` is the text that will replace the deleted pad's content. Default is what is in the example above.
......
This diff is collapsed.
......@@ -4,10 +4,12 @@
"name": "ep_delete_after_delay",
"hooks": {
"handleMessage" : "ep_delete_after_delay/delete",
"eejsBlock_scripts": "ep_delete_after_delay/delete"
"eejsBlock_scripts": "ep_delete_after_delay/delete",
"expressCreateServer" : "ep_delete_after_delay/delete:registerRoute"
},
"client_hooks": {
"handleClientMessage_CUSTOM":"ep_delete_after_delay/static/js/reconnect"
"handleClientMessage_CUSTOM":"ep_delete_after_delay/static/js/reconnect",
"documentReady": "ep_delete_after_delay/static/js/reconnect"
}
}
]
......
{
"ep_delete_after_delay.warning": "❎ WARNING!",
"ep_delete_after_delay.reload": "The pad has expired. The page will be reloaded in 5 seconds.",
"ep_delete_after_delay.close": "❎ Delay before deletion",
"ep_delete_after_delay.days": "Without edition, your pad will be deleted in approximatively XXXX days.",
"ep_delete_after_delay.hours": "Without edition, your pad will be deleted in approximatively XXXX hours.",
"ep_delete_after_delay.minutes": "Without edition, your pad will be deleted in approximatively XXXX minutes.",
"ep_delete_after_delay.suggest": "I suggest you to either edit your pad or export it to save your work."
}
{
"ep_delete_after_delay.warning": "❎ ATTENTION !",
"ep_delete_after_delay.reload": "Le pad a expiré. La page sera rechargée dans 5 secondes.",
"ep_delete_after_delay.close": "❎ Délai avant suppression",
"ep_delete_after_delay.days": "Sans édition, votre pad sera supprimé dans approximativement XXXX jours.",
"ep_delete_after_delay.hours": "Sans édition, votre pad sera supprimé dans approximativement XXXX heures.",
"ep_delete_after_delay.minutes": "Sans édition, votre pad sera supprimé dans approximativement XXXX minutes.",
"ep_delete_after_delay.suggest": "Je vous suggère d'éditer votre pad ou de l'exporter pour sauvegarder votre travail."
}
{
"name": "ep_delete_after_delay",
"version": "0.0.3",
"version": "0.0.4",
"description": "Automatically deletes pads after a configured delay",
"author": {
"name": "Luc Didry",
......
if(typeof exports == 'undefined'){
var exports = this['mymodule'] = {};
}
var already_notified = false;
var delay;
function get_ttl(callback) {
$.ajax({
url: '../ttl/'+window.location.pathname.replace(/.*\/p\//, ''),
method: 'GET',
dataType: 'json',
success: function(data, textStatus, jqXHR) {
$('.ttl').remove();
if (data.ttl === null) {
delay = 1000;
}
if (data.ttl !== null && data.ttl > 0) {
var text, ttl;
if (data.ttl > 3600 * 24) {
text = window._('ep_delete_after_delay.days');
ttl = data.ttl/(3600 * 24);
delay = 3500 * 1000;
} else if (data.ttl > 3600) {
text = window._('ep_delete_after_delay.hours');
ttl = data.ttl/3600;
delay = 1800 * 1000; // 30 minutes
} else {
text = window._('ep_delete_after_delay.minutes');
ttl = data.ttl/60;
delay = 600 * 1000 // 10 minutes
}
ttl = Math.floor(ttl * 10)/10;
text = text.replace(/XXXX/, ttl);
$.gritter.add({
class_name: 'ttl',
title: window._('ep_delete_after_delay.close'),
text: text+'<br>'+window._('ep_delete_after_delay.suggest'),
sticky: true,
});
}
},
complete: function() {
callback(delay);
}
});
}
function timeout_ttl(delay) {
setTimeout(function() {
get_ttl(timeout_ttl);
}, delay);
}
exports.handleClientMessage_CUSTOM = function(hook, context, wut){
if(context.payload.action === 'requestRECONNECT'){
window.location.reload();
if(already_notified === false && context.payload && context.payload.action === 'requestRECONNECT'){
already_notified = true;
$.gritter.add({
title: window._('ep_delete_after_delay.warning'),
text: window._('ep_delete_after_delay.reload'),
sticky: true,
});
setTimeout(function() {
window.location.reload();
}, 6000);
}
}
exports.documentReady = function() {
setTimeout(function() {
get_ttl(timeout_ttl);
}, 1000);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment