-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into publish_workflow
- Loading branch information
Showing
252 changed files
with
11,956 additions
and
8,561 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,17 @@ inputs: | |
CLOUDFLARE_ACCOUNT_ID: | ||
description: 'Cloudflare Account ID' | ||
required: true | ||
NODE_MAILER_TOKEN: | ||
description: 'Node Mailer Token' | ||
required: true | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Publish to cloudflare pages (production) | ||
env: | ||
CLOUDFLARE_API_TOKEN: ${{ inputs.CLOUDFLARE_API_TOKEN }} | ||
CLOUDFLARE_ACCOUNT_ID: ${{ inputs.CLOUDFLARE_ACCOUNT_ID }} | ||
NODE_MAILER_TOKEN: ${{ inputs.NODE_MAILER_TOKEN }} | ||
run: |- | ||
cd public | ||
npm i [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
{ | ||
"devDependencies": { | ||
"semantic-release": "^24.2.0" | ||
}, | ||
"dependencies": { | ||
"dotenv": "^16.4.7", | ||
"express": "^4.21.2", | ||
"nodemailer": "^6.9.16" | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dcfvgh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { Octokit } from '@octokit/rest'; | ||
import dotenv from 'dotenv'; | ||
import { fileURLToPath } from 'url'; | ||
import { dirname } from 'path'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
|
||
dotenv.config(); | ||
|
||
const octokit = new Octokit({ | ||
auth: process.env.GITHUB_TOKEN | ||
}); | ||
|
||
// Remove .git suffix if present | ||
const owner = process.env.GITHUB_OWNER; | ||
const repo = process.env.GITHUB_REPO.replace('.git', ''); | ||
|
||
async function deleteOldFiles() { | ||
try { | ||
console.log(`Checking repository: ${owner}/${repo}`); | ||
|
||
// First, ensure the crowdin folder exists | ||
try { | ||
await octokit.repos.getContent({ | ||
owner, | ||
repo, | ||
path: 'crowdin' | ||
}); | ||
} catch (error) { | ||
if (error.status === 404) { | ||
// Create an empty .gitkeep file to maintain the folder | ||
await octokit.repos.createOrUpdateFileContents({ | ||
owner, | ||
repo, | ||
path: 'crowdin/.gitkeep', | ||
message: 'Maintain crowdin folder structure', | ||
content: Buffer.from('').toString('base64') | ||
}); | ||
console.log('Created crowdin folder with .gitkeep file'); | ||
} | ||
} | ||
|
||
// Get repository contents specifically for the crowdin folder | ||
const { data: contents } = await octokit.repos.getContent({ | ||
owner, | ||
repo, | ||
path: 'crowdin' | ||
}); | ||
|
||
const twoMinutesAgo = new Date(Date.now() - 2 * 60 * 1000); | ||
|
||
// Skip .gitkeep file to maintain folder structure | ||
const filesToCheck = Array.isArray(contents) | ||
? contents.filter(file => file.type === 'file' && file.name !== '.gitkeep') | ||
: []; | ||
|
||
for (const file of filesToCheck) { | ||
// Get commit history for the file | ||
const { data: commits } = await octokit.repos.listCommits({ | ||
owner, | ||
repo, | ||
path: `crowdin/${file.name}`, | ||
per_page: 1 | ||
}); | ||
|
||
if (commits.length > 0) { | ||
const lastCommitDate = new Date(commits[0].commit.committer.date); | ||
|
||
if (lastCommitDate < twoMinutesAgo) { | ||
console.log(`Deleting crowdin/${file.name} - Last modified: ${lastCommitDate}`); | ||
|
||
await octokit.repos.deleteFile({ | ||
owner, | ||
repo, | ||
path: `crowdin/${file.name}`, | ||
message: `Delete crowdin/${file.name} - Last modified more than 2 minutes ago`, | ||
sha: file.sha | ||
}); | ||
} else { | ||
console.log(`Keeping crowdin/${file.name} - Last modified: ${lastCommitDate}`); | ||
} | ||
} | ||
} | ||
} catch (error) { | ||
if (error.status === 404) { | ||
console.error(`Error: Repository "${owner}/${repo}" not found. Please check your .env file settings.`); | ||
} else { | ||
console.error('Error:', error.message); | ||
} | ||
} | ||
} | ||
|
||
// Run the script | ||
deleteOldFiles(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "crowdin-test", | ||
"version": "1.0.0", | ||
"description": "Script to delete old files from GitHub repository", | ||
"main": "delete-old-files.js", | ||
"type": "module", | ||
"scripts": { | ||
"start": "node delete-old-files.js" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@octokit/rest": "^20.0.2", | ||
"dotenv": "^16.3.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Email Sender</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
max-width: 1200px; | ||
margin: 0 auto; | ||
padding: 20px; | ||
background-color: #f5f5f5; | ||
} | ||
.container { | ||
background-color: white; | ||
padding: 30px; | ||
border-radius: 8px; | ||
box-shadow: 0 2px 4px rgba(0,0,0,0.1); | ||
} | ||
.form-group { | ||
margin-bottom: 20px; | ||
} | ||
label { | ||
display: block; | ||
margin-bottom: 8px; | ||
font-weight: bold; | ||
color: #333; | ||
} | ||
input[type="text"], | ||
input[type="email"], | ||
input[type="url"] { | ||
width: 100%; | ||
padding: 8px; | ||
border: 1px solid #ddd; | ||
border-radius: 4px; | ||
font-size: 16px; | ||
} | ||
.editor-container { | ||
display: flex; | ||
gap: 20px; | ||
margin-bottom: 20px; | ||
} | ||
.html-editor { | ||
flex: 1; | ||
height: 500px; | ||
} | ||
.preview { | ||
flex: 1; | ||
border: 1px solid #ddd; | ||
border-radius: 4px; | ||
padding: 15px; | ||
background-color: white; | ||
height: 500px; | ||
overflow: auto; | ||
} | ||
textarea { | ||
width: 100%; | ||
height: 100%; | ||
padding: 8px; | ||
border: 1px solid #ddd; | ||
border-radius: 4px; | ||
font-family: monospace; | ||
font-size: 14px; | ||
resize: none; | ||
} | ||
button { | ||
background-color: #ff444f; | ||
color: white; | ||
padding: 10px 20px; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
font-size: 16px; | ||
margin-right: 10px; | ||
} | ||
button:hover { | ||
background-color: #e63e47; | ||
} | ||
.message { | ||
font-size: 24px; | ||
text-align: center; | ||
padding: 40px; | ||
display: none; | ||
} | ||
.success { | ||
color: #4CAF50; | ||
} | ||
.error { | ||
color: #f44336; | ||
} | ||
.input-group { | ||
display: flex; | ||
gap: 10px; | ||
align-items: flex-end; | ||
} | ||
.or-divider { | ||
text-align: center; | ||
margin: 20px 0; | ||
font-weight: bold; | ||
color: #666; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div id="formContainer"> | ||
<h1>Email Sender</h1> | ||
<form id="emailForm"> | ||
<div class="form-group"> | ||
<label for="to">To:</label> | ||
<input type="email" id="to" name="to" value="[email protected]" readonly> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="subject">Email Subject:</label> | ||
<input type="text" id="subject" name="subject" required> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="htmlUrl">HTML File URL:</label> | ||
<div class="input-group"> | ||
<input type="url" id="htmlUrl" name="htmlUrl" placeholder="Enter URL to HTML file"> | ||
<button type="button" onclick="fetchHtmlContent()">Load HTML</button> | ||
</div> | ||
</div> | ||
|
||
<div class="or-divider">- OR -</div> | ||
|
||
<div class="form-group"> | ||
<label>Email Content:</label> | ||
<div class="editor-container"> | ||
<div class="html-editor"> | ||
<textarea id="htmlContent" placeholder="Enter your HTML content here..." required></textarea> | ||
</div> | ||
<div class="preview" id="preview"> | ||
<!-- Live preview will appear here --> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<button type="submit">Send Email</button> | ||
</form> | ||
</div> | ||
<div id="resultMessage" class="message"></div> | ||
</div> | ||
|
||
<script> | ||
// Fetch HTML content from URL | ||
async function fetchHtmlContent() { | ||
const urlInput = document.getElementById('htmlUrl'); | ||
const htmlContent = document.getElementById('htmlContent'); | ||
const preview = document.getElementById('preview'); | ||
|
||
if (!urlInput.value) { | ||
alert('Please enter a URL'); | ||
return; | ||
} | ||
|
||
try { | ||
const response = await fetch(urlInput.value); | ||
if (!response.ok) throw new Error('Failed to fetch HTML content'); | ||
|
||
const content = await response.text(); | ||
htmlContent.value = content; | ||
preview.innerHTML = content; | ||
} catch (error) { | ||
alert('Failed to load HTML content: ' + error.message); | ||
} | ||
} | ||
|
||
// Live preview functionality | ||
const htmlContent = document.getElementById('htmlContent'); | ||
const preview = document.getElementById('preview'); | ||
|
||
htmlContent.addEventListener('input', () => { | ||
preview.innerHTML = htmlContent.value; | ||
}); | ||
|
||
// Form submission | ||
document.getElementById('emailForm').addEventListener('submit', async (e) => { | ||
e.preventDefault(); | ||
|
||
const to = document.getElementById('to').value; | ||
const subject = document.getElementById('subject').value; | ||
const html = htmlContent.value; | ||
|
||
try { | ||
const response = await fetch('https://static.deriv.com/automation/sendemail/api', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ | ||
to, | ||
subject, | ||
html | ||
}) | ||
}); | ||
|
||
const formContainer = document.getElementById('formContainer'); | ||
const resultMessage = document.getElementById('resultMessage'); | ||
|
||
formContainer.style.display = 'none'; | ||
resultMessage.style.display = 'block'; | ||
|
||
if (response.ok) { | ||
resultMessage.textContent = 'Email sent successfully!'; | ||
resultMessage.className = 'message success'; | ||
} else { | ||
resultMessage.textContent = 'Failed to send email'; | ||
resultMessage.className = 'message error'; | ||
} | ||
} catch (error) { | ||
const formContainer = document.getElementById('formContainer'); | ||
const resultMessage = document.getElementById('resultMessage'); | ||
|
||
formContainer.style.display = 'none'; | ||
resultMessage.style.display = 'block'; | ||
resultMessage.textContent = 'Failed to send email'; | ||
resultMessage.className = 'message error'; | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.