-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b182245
Showing
9 changed files
with
1,736 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dist/dear-senator-* | ||
node_modules | ||
npm-debug.log | ||
.DS_Store |
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 @@ | ||
lts/fermium |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Simon Brazell | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,19 @@ | ||
# DearSenator.js | ||
|
||
A tool to help contact senators, members of parliament and other decision makers, driving change and action. | ||
|
||
## Usage | ||
|
||
1. Download the appropriate executable for your OS (Windows, Linux, or MacOS), or build it yourself. | ||
2. Create the files `recipients.csv` and `template.txt`, populating as required, locating them in the same folder as the executable. | ||
3. Run the executable. | ||
|
||
**Note -** the `recipients.csv` must contain the `email` and `subject` columns for the executable to work, everything else is up to you, just make sure you reference it in `template.tx` using the same column title included in `recipents.csv`. | ||
|
||
See the examples in `dist/` | ||
|
||
## Build | ||
|
||
1. `npm install` | ||
2. `npm run build` | ||
3. See `dist/` for outputs. |
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,20 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const csv = require("csv-parser"); | ||
const open = require("open"); | ||
const ejs = require("ejs"); | ||
|
||
const template = fs.readFileSync( | ||
path.join(path.dirname(process.execPath), "template.txt"), | ||
"utf-8" | ||
); | ||
fs.createReadStream(path.join(path.dirname(process.execPath), "recipients.csv")) | ||
.pipe(csv()) | ||
.on("data", (data) => { | ||
const mailto = `mailto:${data.email}?subject=${encodeURIComponent( | ||
data.subject | ||
)}&body=${encodeURIComponent( | ||
ejs.render(template, data).replace("'", "'") | ||
)}`; | ||
open(mailto); | ||
}); |
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,2 @@ | ||
title,first_name,last_name,email,subject | ||
Mr,Joe,Bloggs,[email protected],Email Subject |
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,8 @@ | ||
Dear <%= title %> <%= first_name %> <%= last_name %>, | ||
|
||
Say something... | ||
|
||
Yours faithfully, | ||
Your Name | ||
Your Address | ||
Your Phone Number |
Oops, something went wrong.