Name: post
Owner: TABLEFLIP
Description: :love_letter: The TABLEFLIP contact form handler
Created: 2016-03-21 15:28:19.0
Updated: 2017-10-13 00:50:35.0
Pushed: 2018-02-14 15:53:22.0
Size: 131
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Store and forward data posted to it from forms on static sites. Data is stored in leveldb. Periodically sent on to recipients.
Copy config/defaults.json
to config/local.json
and fill out your mailgun credentials.
Create a reCAPTCHA key pair here https://www.google.com/recaptcha/ for the domain from which you are posting.
In the post-infrastructure
project add the following two pieces of config
ogle: {
captcha: {
"new-domain.name": "_SECRET_KEY_FROM_GOOGLE_"
}
/roles/post/templates/local.json
ogle: {
captcha: {
"new-domain.name": "{{secret.google.capcha['new-domain.name']}}",
"another-domain": "{{secret.google.capcha['another-domain']}}"
}
From the command line
npm watch
=> to run the site in dev mode, with automagic restarting on change.npm start
=> to run it for real.Files of note
server.js
is an express app.db.js
initialises a leveldb instance.pages
dir holds our route. /pages/home
is mounted under /
Load the google recaptcha api in the <head>
of the page
ipt src="https://www.google.com/recaptcha/api.js" async defer></script>
Create an html form. Set method="post"
the action
to point to
https://post.tableflip.io/butterfield-diet.com
Replace butterfield-diet.com
with your domain that will be sending the posts.
m id="your-form-id" action="https://post.tableflip.io/butterfield-diet.com" method="post">
abel for="email" class="label">Your email address</label>
nput id="email" name="email" type="email" required="" class="input border-box">
abel for="info" class="label">Any info</label>
extarea id="info" name="info" rows="3" class="textarea border-box"></textarea>
cript>function onSubmit (token) {document.getElementById('your-form-id').submit()}</script>
utton class="btn btn-primary g-recaptcha" data-sitekey="_PUBLIC_KEY_FROM_GOOGLE_CAPTCHA_" data-callback='onSubmit'>Send</button>
rm>
The name
values on your inputs will show up as labels in your notification, to give the values some context.
Use the admin screen at https://post.tableflip.io/routes
to configure a route for https://butterfield-diet.com
, to tell it where to send the message, and where to redirect the user afterwards.
You can be in a situation where you just want to post to post and skip the Google's recaptcha. You can do this by adding a “skip” flag on your post's payload:
"name": "Bernard",
"email": "bernard@tableflip.io",
"open-source": "true",
"g-recaptcha-response": "skip"
See: http://dailyjs.com/2013/04/18/leveldb-and-node-1/
For looking up where to send a message to, we have general purpose domain routes, that'll be used when a more specific domain + path route can't be found.
This let's you configure a default handler for all forms on a site, and occasionally override it for a specific form if you need to. The path can be as deeply nested as you need, it just needs to correspond to the path that you append to https://post.tableflip.io/yoursite.com/path/to/your/special/form/here
e!tableflip.io => { email: 'hello@tableflip.io', frequency: 'daily' }
e!tableflip.io/startup => { email: 'hello@tableflip.io', frequency: 'all' }
e!marmalade-productions.com => { email: 'hello@tableflip.io', frequency: 'daily' }
We look up for a specific match on domain + path, then a domain match if there isn't a specific match.
tableflip.io/foo/bar
, not found.tableflip.io
. found; make it so.A (?°?°???TABLEFLIP side project.