mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 13:24:24 +00:00
prepare newsletter plugin
This commit is contained in:
180
src/server/backend/plugins/others/newsletter/html/compose.html
Normal file
180
src/server/backend/plugins/others/newsletter/html/compose.html
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!-- Include Quill stylesheet -->
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>New Mail :: Webmail | Language School Hossegor - Admin</title>
|
||||||
|
<link rel="stylesheet" href="/admin/css/webmail-compose.css">
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
|
||||||
|
<link href="https://cdn.quilljs.com/1.0.0/quill.snow.css" rel="stylesheet" />
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="top-bar">
|
||||||
|
<div class="top-toolbar">
|
||||||
|
<a href="/admin/panel" title="Back to admin panel" id="back" class="top-buttons"><span class="material-symbols-outlined">arrow_back</span></a>
|
||||||
|
<a href="/admin/mail" title="Back to webmail" id="new" class="top-buttons"><span class="material-symbols-outlined">arrow_back_ios_new</span></a>
|
||||||
|
</div>
|
||||||
|
<p id="title">Webmail - Language School Hossegor</p>
|
||||||
|
<p id="spacer"></p>
|
||||||
|
</div>
|
||||||
|
<div class="mail-app">
|
||||||
|
<h1>New message</h1>
|
||||||
|
<p>All mails written here can get one of four different styles. Please choose your style in the dropdown below. You can preview them by clicking <a href="/admin/mail/preview" target="_blank">here</a></p>
|
||||||
|
<p>If you select "Newsletter", the mail will automatically be sent to everybody that subscribed to the newsletter with the correct styling. Note that you need to create a newsletter in German and English and send them separately</p>
|
||||||
|
<select id="mailTypeSelector" onchange="updateType()" title="Mail template">
|
||||||
|
<option value="default">Default</option>
|
||||||
|
<option value="booking">Booking</option>
|
||||||
|
<option value="newsletter">Newsletter</option>
|
||||||
|
<option value="plain">Plain text</option>
|
||||||
|
</select>
|
||||||
|
<select id="mailLangSelector" title="Language">
|
||||||
|
<option value="de">Deutsch</option>
|
||||||
|
<option value="en">English</option>
|
||||||
|
</select>
|
||||||
|
<!--<button onclick="getContent()">Get html</button>--><br>
|
||||||
|
<table>
|
||||||
|
<tr id="to">
|
||||||
|
<td>
|
||||||
|
<label for="mail">To: </label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="email" name="mail" id="mail"><br>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="subject">Subject:</label>
|
||||||
|
</td><td>
|
||||||
|
<input type="text" name="subject" id="subject"><br>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- Create the toolbar container -->
|
||||||
|
<div id="toolbar">
|
||||||
|
<span class="ql-formats">
|
||||||
|
<select class="ql-font" title="Fonts">
|
||||||
|
<option selected="" title="Default"></option>
|
||||||
|
<option value="serif" title="Serif"></option>
|
||||||
|
<option value="monospace" title="Monospace"></option>
|
||||||
|
</select>
|
||||||
|
<select class="ql-size" title="Font size">
|
||||||
|
<option value="small" title="Small"></option>
|
||||||
|
<option selected="" title="Default"></option>
|
||||||
|
<option value="large" title="Large"></option>
|
||||||
|
<option value="huge" title="Huge"></option>
|
||||||
|
</select>
|
||||||
|
</span>
|
||||||
|
<span class="ql-formats">
|
||||||
|
<button class="ql-bold" title="Bold"></button>
|
||||||
|
<button class="ql-italic" title="Italic"></button>
|
||||||
|
<button class="ql-underline" title="Underlined"></button>
|
||||||
|
<button class="ql-strike" title="Strikethrough"></button>
|
||||||
|
</span>
|
||||||
|
<span class="ql-formats">
|
||||||
|
<select class="ql-color" title="Text colour"></select>
|
||||||
|
<select class="ql-background" title="Background colour"></select>
|
||||||
|
</span>
|
||||||
|
<span class="ql-formats">
|
||||||
|
<button class="ql-list" value="ordered" title="Ordered list"></button>
|
||||||
|
<button class="ql-list" value="bullet" title="Bullet points"></button>
|
||||||
|
<select class="ql-align" title="Alignment">
|
||||||
|
<option selected="" title="left"></option>
|
||||||
|
<option value="center" title="center"></option>
|
||||||
|
<option value="right" title="right"></option>
|
||||||
|
<option value="justify" title="block"></option>
|
||||||
|
</select>
|
||||||
|
</span>
|
||||||
|
<span class="ql-formats">
|
||||||
|
<button class="ql-link" title="Insert link"></button>
|
||||||
|
<button class="ql-image" title="Insert image"></button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Create the editor container -->
|
||||||
|
<div id="editor">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button onclick="sendMail()"><span class="material-symbols-outlined">send</span>Send</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- Include the Quill library -->
|
||||||
|
<script src="https://cdn.quilljs.com/1.0.0/quill.js"></script>
|
||||||
|
|
||||||
|
<!-- Initialize Quill editor -->
|
||||||
|
<script>
|
||||||
|
var editor = new Quill('#editor', {
|
||||||
|
modules: { toolbar: '#toolbar' },
|
||||||
|
theme: 'snow',
|
||||||
|
});
|
||||||
|
function getContent () {
|
||||||
|
console.log( document.getElementsByClassName( 'ql-editor' )[0].innerHTML );
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout( updateType, 200 );
|
||||||
|
|
||||||
|
function updateType () {
|
||||||
|
if ( document.getElementById( 'mailTypeSelector' ).value === 'newsletter' ) {
|
||||||
|
$( '#to' ).slideUp();
|
||||||
|
$( '#mailLangSelector' ).slideDown();
|
||||||
|
} else {
|
||||||
|
$( '#to' ).slideDown();
|
||||||
|
$( '#mailLangSelector' ).slideUp();
|
||||||
|
};
|
||||||
|
if ( window.location.search.slice( 1, 8 ) === 'replyTo' ) {
|
||||||
|
document.getElementById( 'subject' ).value = 'Re: ' + sessionStorage.getItem( 'mailSubject' );
|
||||||
|
document.getElementById( 'mail' ).value = sessionStorage.getItem( 'mailAddress' );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function sendMail () {
|
||||||
|
let ok = false;
|
||||||
|
if ( document.getElementById( 'mailTypeSelector' ).value !== 'newsletter' ) {
|
||||||
|
if ( document.getElementById( 'mail' ).value != '' && document.getElementById( 'subject' ).value != '' ) {
|
||||||
|
ok = true;
|
||||||
|
} else {
|
||||||
|
alert( 'A mail address and a subject are required!' );
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
if ( document.getElementById( 'subject' ).value != '' ) {
|
||||||
|
if ( confirm( 'Do you really want to send the newsletter?' ) ) {
|
||||||
|
ok = true;
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
alert( 'A subject is required!' );
|
||||||
|
};
|
||||||
|
};
|
||||||
|
if ( ok ) {
|
||||||
|
let dat = { 'receiver': document.getElementById( 'mail' ).value, 'subject': document.getElementById( 'subject' ).value, 'mode': document.getElementById( 'mailTypeSelector' ).value, 'lang': document.getElementById( 'mailLangSelector' ).value };
|
||||||
|
dat[ 'message' ] = document.getElementsByClassName( 'ql-editor' )[0].innerHTML;
|
||||||
|
if ( window.location.search.slice( 1, 8 ) === 'replyTo' ) {
|
||||||
|
dat[ 'inReplyTo' ] = sessionStorage.getItem( 'replyTo' );
|
||||||
|
sessionStorage.removeItem( 'replyTo' );
|
||||||
|
sessionStorage.removeItem( 'mailSubject' );
|
||||||
|
sessionStorage.removeItem( 'mailAddress' );
|
||||||
|
window.location = '/admin/mail/compose';
|
||||||
|
};
|
||||||
|
let options = {
|
||||||
|
method: 'post',
|
||||||
|
body: JSON.stringify( dat ),
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'charset': 'utf-8'
|
||||||
|
},
|
||||||
|
};
|
||||||
|
fetch( '/admin/mail/send', options ).then( res => {
|
||||||
|
if ( res.status === 200 ) {
|
||||||
|
alert( 'Mail sent successfully' );
|
||||||
|
} else {
|
||||||
|
alert( 'There was an error sending the mail. Please try again. If the error persists, please contact the developer and tell this status code: ' + res.status );
|
||||||
|
};
|
||||||
|
} );
|
||||||
|
document.getElementById( 'subject' ).value = '';
|
||||||
|
document.getElementById( 'mail' ).value = '';
|
||||||
|
document.getElementsByClassName( 'ql-editor' )[0].innerHTML = '';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Unsubscribe from Newsletter</title>
|
||||||
|
<link rel="stylesheet" href="/css/errorstyle.css">
|
||||||
|
<style>
|
||||||
|
.input {
|
||||||
|
width: 40%;
|
||||||
|
padding: 0.5%;
|
||||||
|
font-size: 120%;
|
||||||
|
border-radius: 15px;
|
||||||
|
margin: 2%;
|
||||||
|
margin-bottom: 4%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="content">
|
||||||
|
<h1>Unsubscribe from newsletter</h1>
|
||||||
|
<form action="/mail/unsubscribe/go?lang=en" method="post" class="unsub">
|
||||||
|
<label for="mail" style="font-size: 120%;">Your email address</label><br>
|
||||||
|
<input type="email" name="mail" id="mail" class="input" required><br>
|
||||||
|
|
||||||
|
<input type="submit" value="Unsubscribe" class="button" style="font-size: 130%;">
|
||||||
|
</form>
|
||||||
|
<a href="?lang=de" class="button" style="margin-top: 4%;">DE</a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Unsubscribed from Newsletter</title>
|
||||||
|
<link rel="stylesheet" href="/css/errorstyle.css">
|
||||||
|
<style>
|
||||||
|
.input {
|
||||||
|
width: 40%;
|
||||||
|
padding: 0.5%;
|
||||||
|
font-size: 120%;
|
||||||
|
border-radius: 15px;
|
||||||
|
margin: 2%;
|
||||||
|
margin-bottom: 4%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="content">
|
||||||
|
<h1>Unsubscribed from newsletter</h1>
|
||||||
|
<p>You have successfully unsubscribed from the newsletter.</p>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
setTimeout( redirect, 7000 );
|
||||||
|
|
||||||
|
function redirect () {
|
||||||
|
location.href = '/';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Error - Unsubscribe from Newsletter</title>
|
||||||
|
<link rel="stylesheet" href="/css/errorstyle.css">
|
||||||
|
<style>
|
||||||
|
.input {
|
||||||
|
width: 40%;
|
||||||
|
padding: 0.5%;
|
||||||
|
font-size: 120%;
|
||||||
|
border-radius: 15px;
|
||||||
|
margin: 2%;
|
||||||
|
margin-bottom: 4%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="content">
|
||||||
|
<h1>An error occurred whilst unsubscribing from the newsletter</h1>
|
||||||
|
<p>Please check your entries and try again!</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -11,7 +11,7 @@ const path = require( 'path' );
|
|||||||
const mm = require( '../../../mail/mailSender.js' );
|
const mm = require( '../../../mail/mailSender.js' );
|
||||||
const sendMail = new mm();
|
const sendMail = new mm();
|
||||||
|
|
||||||
module.exports = ( app, settings ) => {
|
module.exports = ( app ) => {
|
||||||
app.get( '/admin/mail/compose', ( request, response ) => {
|
app.get( '/admin/mail/compose', ( request, response ) => {
|
||||||
if ( request.session.loggedInAdmin ) {
|
if ( request.session.loggedInAdmin ) {
|
||||||
response.sendFile( path.join( __dirname + '/html/compose.html' ) );
|
response.sendFile( path.join( __dirname + '/html/compose.html' ) );
|
||||||
|
|||||||
Reference in New Issue
Block a user