Remove email testing scripts and related files to streamline the project. This includes the deletion of various SMTP test scripts, contact form tests, and associated HTML files, which were previously used for testing email delivery and configuration.

This commit is contained in:
becarta
2025-05-10 02:34:48 +02:00
parent 84222f3de1
commit bbed1d3135
14 changed files with 0 additions and 1542 deletions

View File

@@ -1,252 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Form Test</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 600px;
margin: 0 auto;
padding: 20px;
}
.form-group {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
input, textarea {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
}
button {
background-color: #4CAF50;
color: white;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
}
.success {
background-color: #d4edda;
color: #155724;
padding: 15px;
margin-bottom: 20px;
border-radius: 4px;
display: none;
}
.error {
background-color: #f8d7da;
color: #721c24;
padding: 15px;
margin-bottom: 20px;
border-radius: 4px;
display: none;
}
.debug {
background-color: #f8f9fa;
border: 1px solid #ddd;
padding: 15px;
margin-top: 20px;
border-radius: 4px;
}
#debug-log {
max-height: 200px;
overflow-y: auto;
white-space: pre-wrap;
font-family: monospace;
font-size: 12px;
}
</style>
</head>
<body>
<h1>Contact Form Test</h1>
<div id="success-message" class="success">
Your message has been sent successfully!
</div>
<div id="error-message" class="error">
There was an error sending your message. Please try again.
</div>
<form id="contact-form">
<input type="hidden" name="csrf_token" id="csrf_token" value="">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
</div>
<div class="form-group">
<label for="message">Message:</label>
<textarea id="message" name="message" rows="5" required></textarea>
</div>
<div class="form-group">
<label>
<input type="checkbox" id="disclaimer" name="disclaimer" required>
I agree to the terms and conditions
</label>
</div>
<button type="submit">Send Message</button>
</form>
<div class="debug">
<h3>Debug Log</h3>
<div id="debug-log"></div>
</div>
<script>
// Debug logging function
function log(message) {
const debugLog = document.getElementById('debug-log');
const timestamp = new Date().toISOString();
debugLog.innerHTML += `[${timestamp}] ${message}\n`;
console.log(message);
}
// Fetch CSRF token
async function fetchCsrfToken() {
log('Fetching CSRF token...');
try {
const response = await fetch('/api/contact?csrf=true');
log(`CSRF response status: ${response.status}`);
if (!response.ok) {
log(`CSRF request failed: ${response.statusText}`);
return '';
}
const text = await response.text();
log(`CSRF response text: ${text}`);
try {
const data = JSON.parse(text);
log(`CSRF token received: ${data.csrfToken ? 'yes' : 'no'}`);
return data.csrfToken;
} catch (parseError) {
log(`Error parsing CSRF response: ${parseError.message}`);
return '';
}
} catch (error) {
log(`Error fetching CSRF token: ${error.message}`);
return '';
}
}
// Initialize form
async function initForm() {
log('Initializing form...');
const csrfToken = await fetchCsrfToken();
if (csrfToken) {
document.getElementById('csrf_token').value = csrfToken;
log('CSRF token set in form');
} else {
log('Failed to get CSRF token');
}
// Set default values for testing
document.getElementById('name').value = 'Test User';
document.getElementById('email').value = 'richard@bergsma.it';
document.getElementById('message').value = 'This is a test message from the test-contact-form.html page. ' + new Date().toISOString();
log('Form initialized with test values');
}
// Handle form submission
async function handleSubmit(event) {
event.preventDefault();
log('Form submitted');
// Reset messages
document.getElementById('success-message').style.display = 'none';
document.getElementById('error-message').style.display = 'none';
// Get form data
const form = document.getElementById('contact-form');
const formData = new FormData(form);
// Log form data
log('Form data:');
for (const [key, value] of formData.entries()) {
log(`${key}: ${value}`);
}
// Add timestamp
formData.append('timestamp', Date.now().toString());
try {
log('Sending form data to /api/contact');
const response = await fetch('/api/contact', {
method: 'POST',
body: formData,
headers: {
'Accept': 'application/json'
}
});
log(`Response status: ${response.status}`);
const text = await response.text();
log(`Response text: ${text}`);
try {
const result = JSON.parse(text);
log(`Response parsed: ${JSON.stringify(result)}`);
if (result.success) {
log('Form submission successful');
document.getElementById('success-message').style.display = 'block';
form.reset();
// Get a new CSRF token
const newToken = await fetchCsrfToken();
if (newToken) {
document.getElementById('csrf_token').value = newToken;
}
} else {
log(`Form submission failed: ${JSON.stringify(result.errors || {})}`);
document.getElementById('error-message').style.display = 'block';
if (result.errors && result.errors.csrf) {
log('CSRF token invalid, getting new token');
const newToken = await fetchCsrfToken();
if (newToken) {
document.getElementById('csrf_token').value = newToken;
}
}
}
} catch (parseError) {
log(`Error parsing response: ${parseError.message}`);
document.getElementById('error-message').style.display = 'block';
}
} catch (error) {
log(`Error submitting form: ${error.message}`);
document.getElementById('error-message').style.display = 'block';
}
}
// Initialize when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
log('DOM loaded');
initForm();
// Add form submit handler
document.getElementById('contact-form').addEventListener('submit', handleSubmit);
});
</script>
</body>
</html>

View File

@@ -1,183 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Language Persistence Test</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
line-height: 1.6;
}
h1 {
color: #333;
border-bottom: 1px solid #eee;
padding-bottom: 10px;
}
.test-section {
margin-bottom: 30px;
padding: 15px;
border: 1px solid #ddd;
border-radius: 5px;
background-color: #f9f9f9;
}
.test-buttons {
display: flex;
gap: 10px;
margin-top: 15px;
}
button {
padding: 8px 16px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
.language-status {
margin-top: 15px;
padding: 10px;
background-color: #e9f7ef;
border-radius: 4px;
}
.navigation-links {
margin-top: 20px;
}
.navigation-links a {
display: inline-block;
margin-right: 15px;
padding: 8px 16px;
background-color: #2196F3;
color: white;
text-decoration: none;
border-radius: 4px;
}
.navigation-links a:hover {
background-color: #0b7dda;
}
</style>
</head>
<body>
<h1>Language Persistence Test</h1>
<div class="test-section">
<h2>Current Language Status</h2>
<div class="language-status">
<p><strong>URL Language:</strong> <span id="url-language">Checking...</span></p>
<p><strong>LocalStorage Language:</strong> <span id="localstorage-language">Checking...</span></p>
<p><strong>Cookie Language:</strong> <span id="cookie-language">Checking...</span></p>
</div>
</div>
<div class="test-section">
<h2>Test Language Selection</h2>
<p>Click on a language to test the language persistence:</p>
<div class="test-buttons">
<button onclick="changeLanguage('en')">English</button>
<button onclick="changeLanguage('nl')">Dutch</button>
<button onclick="changeLanguage('de')">German</button>
<button onclick="changeLanguage('fr')">French</button>
</div>
</div>
<div class="test-section">
<h2>Navigation Test</h2>
<p>Use these links to test language persistence during navigation:</p>
<div class="navigation-links">
<a href="/" id="home-link">Home</a>
<a href="/aboutme" id="aboutme-link">About Me</a>
</div>
</div>
<script>
// Function to get language from URL
function getLanguageFromURL() {
const pathSegments = window.location.pathname.split('/').filter(Boolean);
const supportedLanguages = ['en', 'nl', 'de', 'fr'];
if (pathSegments.length > 0 && supportedLanguages.includes(pathSegments[0])) {
return pathSegments[0];
}
return null;
}
// Function to get language from localStorage
function getStoredLanguage() {
return localStorage.getItem('preferredLanguage');
}
// Function to get language from cookie
function getLanguageFromCookie() {
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
if (cookie.startsWith('preferredLanguage=')) {
return cookie.substring('preferredLanguage='.length);
}
}
return null;
}
// Function to update the language status display
function updateLanguageStatus() {
document.getElementById('url-language').textContent = getLanguageFromURL() || 'Not set';
document.getElementById('localstorage-language').textContent = getStoredLanguage() || 'Not set';
document.getElementById('cookie-language').textContent = getLanguageFromCookie() || 'Not set';
}
// Function to change language
function changeLanguage(langCode) {
// Store language in localStorage
localStorage.setItem('preferredLanguage', langCode);
// Store language in cookie
const expirationDate = new Date();
expirationDate.setFullYear(expirationDate.getFullYear() + 1);
document.cookie = `preferredLanguage=${langCode}; expires=${expirationDate.toUTCString()}; path=/; SameSite=Lax`;
// Update the language status display
updateLanguageStatus();
// Update navigation links with the selected language
updateNavigationLinks(langCode);
// Dispatch a custom event for language change
const event = new CustomEvent('languageChanged', {
detail: {
langCode,
previousLangCode: getLanguageFromURL() || 'en',
willReload: false
}
});
document.dispatchEvent(event);
// Show a success message
alert(`Language changed to ${langCode}. Navigation links have been updated.`);
}
// Function to update navigation links with the selected language
function updateNavigationLinks(langCode) {
const homeLink = document.getElementById('home-link');
const aboutmeLink = document.getElementById('aboutme-link');
homeLink.href = `/${langCode}/`;
aboutmeLink.href = `/${langCode}/aboutme`;
}
// Initialize the page
document.addEventListener('DOMContentLoaded', function() {
// Update the language status display
updateLanguageStatus();
// Update navigation links with the current language
const currentLang = getStoredLanguage() || getLanguageFromCookie() || 'en';
updateNavigationLinks(currentLang);
});
</script>
</body>
</html>

View File

@@ -1,177 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Language Switching Test</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
line-height: 1.6;
}
h1 {
color: #333;
border-bottom: 1px solid #eee;
padding-bottom: 10px;
}
.test-section {
margin-bottom: 30px;
padding: 15px;
border: 1px solid #ddd;
border-radius: 5px;
background-color: #f9f9f9;
}
.test-button {
display: inline-block;
margin: 5px;
padding: 8px 15px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
text-decoration: none;
}
.test-button:hover {
background-color: #45a049;
}
.language-button {
display: inline-block;
margin: 5px;
padding: 8px 15px;
background-color: #2196F3;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
text-decoration: none;
}
.language-button:hover {
background-color: #0b7dda;
}
.result {
margin-top: 10px;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
background-color: #fff;
}
code {
background-color: #f1f1f1;
padding: 2px 4px;
border-radius: 3px;
font-family: monospace;
}
</style>
</head>
<body>
<h1>Language Switching Test</h1>
<div class="test-section">
<h2>Current URL Information</h2>
<div class="result" id="url-info">Loading...</div>
</div>
<div class="test-section">
<h2>Switch Language</h2>
<p>Click on a language to switch:</p>
<div>
<a href="#" class="language-button" data-lang="en">English</a>
<a href="#" class="language-button" data-lang="nl">Dutch</a>
<a href="#" class="language-button" data-lang="de">German</a>
<a href="#" class="language-button" data-lang="fr">French</a>
</div>
</div>
<div class="test-section">
<h2>Test Hash Navigation</h2>
<p>Click on a section to navigate:</p>
<div>
<a href="#services" class="test-button">Services</a>
<a href="#contact" class="test-button">Contact</a>
<a href="#about" class="test-button">About</a>
</div>
</div>
<div class="test-section">
<h2>Test Page Navigation</h2>
<p>Navigate to different pages:</p>
<div>
<a href="/" class="test-button">Home</a>
<a href="/aboutme" class="test-button">About Me</a>
</div>
</div>
<script>
// Display current URL information
function updateUrlInfo() {
const url = new URL(window.location.href);
const pathSegments = url.pathname.split('/').filter(Boolean);
const currentLang = pathSegments[0] || 'none';
const infoDiv = document.getElementById('url-info');
infoDiv.innerHTML = `
<p><strong>Full URL:</strong> ${url.href}</p>
<p><strong>Path:</strong> ${url.pathname}</p>
<p><strong>Hash:</strong> ${url.hash || 'none'}</p>
<p><strong>Current Language:</strong> ${currentLang}</p>
<p><strong>Path Segments:</strong> ${JSON.stringify(pathSegments)}</p>
`;
}
// Initialize
document.addEventListener('DOMContentLoaded', () => {
updateUrlInfo();
// Set up language buttons
document.querySelectorAll('.language-button').forEach(button => {
button.addEventListener('click', (e) => {
e.preventDefault();
const lang = button.getAttribute('data-lang');
if (!lang) return;
// Get current URL information
const currentUrl = new URL(window.location.href);
const currentPath = currentUrl.pathname.replace(/\/$/, '');
const currentHash = currentUrl.hash;
const pathSegments = currentPath.split('/').filter(Boolean);
// Check if we're on a language-specific path
const supportedLanguages = ['en', 'nl', 'de', 'fr'];
const isLangPath = supportedLanguages.includes(pathSegments[0]);
// Extract the page path without language
let pagePath = '';
if (isLangPath && pathSegments.length > 1) {
// If we're on a language-specific path, get everything after the language code
pagePath = `/${pathSegments.slice(1).join('/')}`;
} else if (!isLangPath && pathSegments.length > 0) {
// If we're not on a language-specific path, use the current path
pagePath = `/${pathSegments.join('/')}`;
}
// Handle special case for root path
const isRootPath = pathSegments.length === 0 || (isLangPath && pathSegments.length === 1);
// Construct the new URL
let newUrl = isRootPath ? `/${lang}` : `/${lang}${pagePath}`;
// Append hash fragment if it exists
if (currentHash) {
newUrl += currentHash;
}
// Navigate to the new URL
window.location.href = newUrl;
});
});
// Update URL info when hash changes
window.addEventListener('hashchange', updateUrlInfo);
});
</script>
</body>
</html>