Skip to content

Commit

Permalink
Merge pull request #500 from dwyl/contact-form-spam-#487
Browse files Browse the repository at this point in the history
Resolve Contact form `SPAM` #487
  • Loading branch information
SimonLab committed Jan 19, 2023
2 parents a14a62c + c736a44 commit 9158a08
Show file tree
Hide file tree
Showing 18 changed files with 160 additions and 3,715 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "07:00"
timezone: Europe/London
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
# - run: npm run build --if-present
- run: npm test
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v1
3 changes: 0 additions & 3 deletions .travis.yml

This file was deleted.

32 changes: 17 additions & 15 deletions _home/compile.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
'use strict';
var fs = require('fs');
var path = require('path');
var http_request = require('./http_request');
var cheerio = require('cheerio'); // Server-side JQuery. v. useful for scraping!

// Adding Colors to Terminal *Without* a Library/Module
var bgRedBlack = '\x1b[41m\x1b[30m';
var bgGreenBlack = '\x1b[42m\x1b[30m';
var RESET = '\x1b[0m'; // see: https://stackoverflow.com/a/41407246/1148249
// var bgRedBlack = '\x1b[41m\x1b[30m';
// var bgGreenBlack = '\x1b[42m\x1b[30m';
// var RESET = '\x1b[0m'; // see: https://stackoverflow.com/a/41407246/1148249

var URL = 'https://github.com/dwyl/home/blob/master/README.md';

http_request(URL, function (status, html) {
// eslint forces us to have all vars declared before logic ...
var $ = cheerio.load(html); // load the HTML of the rendered markdown "page"
var body = $('#readme').html(); // parse the contents of #readme (article)
var css = fs.readFileSync(path.resolve(__dirname, './style.css'), 'utf8');
var template = fs.readFileSync(path.resolve(__dirname, './template.html'),
'utf8'); // rudimentary "template" with string subtitution.
var out = template.replace('{css}', css).replace('{content}', body);

if (status !== 200 || !html) {
console.log(bgRedBlack,
" - - - GitHub Scraper FAIL >> " + URL + " - - - ", RESET);
process.exit();
}
else {
var $ = cheerio.load(html); // load the HTML of the rendered markdown "page"
var body = $('#readme').html() // parse the contents of #readme (article)
var css = fs.readFileSync(path.resolve(__dirname, './style.css'), 'utf8');
var template = fs.readFileSync(path.resolve(__dirname, './template.html'),
'utf8'); // rudimentary "template" with string subtitution.
var out = template.replace('{css}', css).replace('{content}', body);
// console.log(bgRedBlack,
// " - - - GitHub Scraper FAIL >> " + URL + " - - - ", RESET);
// process.exit();
} else {
fs.writeFileSync('./home.html', out, 'utf8'); // save the file
console.log(bgGreenBlack, 'done.', RESET);
// console.log(bgGreenBlack, 'done.', RESET);
}
});
13 changes: 5 additions & 8 deletions _home/http_request.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict';

var http = require('https'); // ALWAYS use TLS over the internets!
var bgRedBlack = '\x1b[41m\x1b[30m';
var RESET = '\x1b[0m'; // see: https://stackoverflow.com/a/41407246/1148249
// var bgRedBlack = '\x1b[41m\x1b[30m';
// var RESET = '\x1b[0m'; // see: https://stackoverflow.com/a/41407246/1148249
/**
* simple_http_request is a bare-bones http request using node.js core http
* see: https://nodejs.org/api/http.html#http_http_request_options_callback
Expand All @@ -13,7 +12,6 @@ var RESET = '\x1b[0m'; // see: https://stackoverflow.com/a/41407246/1148249
* response is a JSON Object unless there is an error.
*/
module.exports = function simple_http_request (path, callback) {

var options = {
headers: {
'Accept': 'text/html',
Expand All @@ -22,14 +20,14 @@ module.exports = function simple_http_request (path, callback) {
hostname: 'github.com',
port: '443',
path: path
}
};

http.request(options, function (res) {
var resStr = '';
var response;
// var response;
// console.log(res.statusCode);
if (res.statusCode !== 200) { // anything other than "200" is an Error.
console.log(bgRedBlack, ' GOT ', res.statusCode, ' for ', options, RESET);
// console.log(bgRedBlack, 'GOT', res.statusCode, ' for', options, RESET);
return callback(res.statusCode);
}

Expand All @@ -43,5 +41,4 @@ module.exports = function simple_http_request (path, callback) {

return true;
}).end();

};
55 changes: 4 additions & 51 deletions careers.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,59 +128,10 @@ <h3 class="dwyl-yellow">Job Opportunities</h3>
</section>
</section>

<section class="dwyl-bg-mint center pv5-ns pb5-ns relative z-0">
<a id="contact" class="h2 dib h0-l di-l absolute top--2"></a>
<div class="mw8 center">
<div class="dib-ns w-50-ns dtc v-top">
<div class="w-80 w-60-ns white center tr">
<h2 class="mt0-ns mb3 pl4-ns f-xl fw9">Let's</h2>
<h2 class="pl4-ns mt3 f-xl fw9">Talk</h2>
</div>
<div class="w-80-ns w-90 ml3">
<a href="tel:+447708796446" class="link"><h2 class="tr white"><span class="dwyl-dark-gray fw9">Tel: </span>+44 (0) 7708 796446</h2></a>
<a href="mailto:hello@dwyl.com" class="link"><h2 class="tr white"><span class="dwyl-dark-gray fw9">Email:</span> hello@dwyl.com</h2></a>
<h2 class="tr white"><span class="dwyl-dark-gray lh-copy fw9">Address:</span> dwyl, First Floor, <br>149 Fonthill Rd,<br> London, N4 3HF, UK</h2>
<p class="tr dwyl-dark-gray">(We'll get back to you within 24 hours)</p>
</div>
</div>

<div class="dib-ns bg-white pt4 pa2 shadow-4 ml3-ns ml3-m ml4-l w-40-ns">

<form id="gform" method="POST" class="tc tl-ns" action="https://script.google.com/a/dwyl.com/macros/s/AKfycbzWvg1lK6-FddTv8gQxiUW76FCtC_-pD05rZpuurI4_5sST3eI/exec">
<!-- change the form action to your script url -->
<div class="mt2 ml3">
<label for="name" class="db mb2 tl pl3 pl0-ns">Your Name</label>
<input id="name" name="name" class="br2 ba dwyl-b--dark-gray pa2 w-90 border-box" placeholder="Tim Berners-Lee" />
</div>
<div class="mt3 ml3">
<label for="email" class="db mb2 tl pl3 pl0-ns">Email Address</label>
<input id="email" name="email" class="br2 ba dwyl-b--dark-gray pa2 w-90 border-box" type="email" value="" required placeholder="tim@cern.com" />
</div>
<div class="mt3 ml3">
<label for="message" class="db mb2 tl pl3 pl0-ns">Message</label>
<textarea id="message" name="message" class="br2 ba w-90 dwyl-b--dark-gray pa2" rows="10" placeholder="What problem can we solve for you?"></textarea>
</div>
<button class="bn dib link mt3 mb3 ph3 pv2 dwyl-bg-orange white br2 f5 ml3 shadow-4 pointer montserrat">
<i class="fa fa-paper-plane"></i>&nbsp; Say Hello
</button>
</form>

<div style="display:none;" class="tc pb4 dwyl-dark-gray" id="thankyou_message">
<h2>Thanks for contacting us!</h2>
<h2>We will get back to you soon!</h2>
</div>

<!-- Submit the Form to Google Using "AJAX" -->
<script data-cfasync="false" type="text/javascript" src="/js/app_contact_form_handler.js"></script>
<!-- END -->
</div>
</div>
</section>
<footer class="dwyl-bg-dark-gray white pt1 pt3-ns pb4 tc center">
<div class="bb b--white w-90-ns w-80 center">
<ul class="list tc pl0 pt3 pb3-ns mv0 f3 f5-ns ">
<li class="ph4 fw3 f6 dib-ns pv2"><a href="/" class="white link">Home</a></li>
<li class="ph4 fw3 f6 dib-ns pv2"><a href="/portfolio" class="white link">Portfolio</a></li>
<li class="ph4 fw3 f6 dib-ns pv2"><a href="/careers" class="white link">Careers</a></li>
<div class="dib">
<li class="ph4 fw3 f6 dib-ns pv2"><a href="/community" class="white link">Community</a></li>
Expand All @@ -197,9 +148,11 @@ <h2>We will get back to you soon!</h2>
</a>
</div>
<p class="w-80 w-90-ns center f7 pt2-ns">
Copyright 2019 &copy; DWYL LTD, company number 09525434 registered in England &amp; Wales at First Floor, 149 Fonthill Rd, London N4 3HF. All rights reserved.
Copyright 2023 &copy; DWYL LTD,
company number 09525434 registered
in England &amp; Wales at First Floor,
149 Fonthill Rd, London N4 3HF.
</p>
<img src="/img/common/dwyl-grey-heart.png" alt="dwyl heart logo" class="pv4">
</footer>

<section id="cookie-notification" class="w-100 dwyl-bg-dark-gray bottom-0 fixed h-auto tc-ns tl ph4-ns pt3-ns pb2-ns pt3 ph3 ">
Expand Down
59 changes: 6 additions & 53 deletions community.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@
</a>
</li>
<li class="ph4 pt5 pb2 tl dn-l"><a href="/" class="dwyl-dark-gray link">Home</a></li>
<li class="ph4 di-l pv2 tl pv0-l"><a href="/portfolio" class="dwyl-dark-gray link">Portfolio</a></li>
<li class="ph4 di-l pv2 tl pv0-l"><a href="/values" class="dwyl-dark-gray link">Values</a></li>
<li class="ph4 di-l pv2 tl pv0-l"><a href="/team" class="dwyl-dark-gray link">Team</a></li>
<li class="ph4 dib-l pv2 tl pv0-l"><a href="/time-app" class="dwyl-dark-gray link">App
<span class="dwyl-bg-yellow fw3 pa1 br2 f7 shadow-6">BETA</span></a></li>
<!-- <li class="ph4 di-l pv2 tl pv0-l"><a href="/blog" class="dwyl-dark-gray link">Blog</a></li> -->
<li class="ph4 di-l pt2 pb3 tl pv0-l"><a href="#contact" id="contact-link" class="dwyl-dark-gray link">Contact</a></li>
<!-- <li class="ph4 di-l pt2 pb3 tl pv0-l"><a href="#contact" id="contact-link" class="dwyl-dark-gray link">Contact</a></li> -->
</ul>
</nav>

Expand Down Expand Up @@ -93,59 +92,11 @@ <h2 class="dwyl-light-gray w-90 w-50-ns center lh-copy mt4 mt2-ns f4">dwyl is a
</p>
</section>

<section class="dwyl-bg-mint center pv5-ns pb5-ns relative z-0">
<a id="contact" class="h2 dib h0-l di-l absolute top--2"></a>
<div class="mw8 center">
<div class="dib-ns w-50-ns dtc v-top">
<div class="w-80 w-60-ns white center tr">
<h2 class="mt0-ns mb3 pl4-ns f-xl fw9">Let's</h2>
<h2 class="pl4-ns mt3 f-xl fw9">Talk</h2>
</div>
<div class="w-80-ns w-90 ml3">
<a href="tel:+447708796446" class="link"><h2 class="tr white"><span class="dwyl-dark-gray fw9">Tel: </span>+44 (0) 7708 796446</h2></a>
<a href="mailto:hello@dwyl.com" class="link"><h2 class="tr white"><span class="dwyl-dark-gray fw9">Email:</span> hello@dwyl.com</h2></a>
<h2 class="tr white"><span class="dwyl-dark-gray lh-copy fw9">Address:</span> dwyl, First Floor, <br>149 Fonthill Rd,<br> London, N4 3HF, UK</h2>
<p class="tr dwyl-dark-gray">(We'll get back to you within 24 hours)</p>
</div>
</div>

<div class="dib-ns bg-white pt4 pa2 shadow-4 ml3-ns ml3-m ml4-l w-40-ns">

<form id="gform" method="POST" class="tc tl-ns" action="https://script.google.com/a/dwyl.com/macros/s/AKfycbzWvg1lK6-FddTv8gQxiUW76FCtC_-pD05rZpuurI4_5sST3eI/exec">
<!-- change the form action to your script url -->
<div class="mt2 ml3">
<label for="name" class="db mb2 tl pl3 pl0-ns">Your Name</label>
<input id="name" name="name" class="br2 ba dwyl-b--dark-gray pa2 w-90 border-box" placeholder="Tim Berners-Lee" />
</div>
<div class="mt3 ml3">
<label for="email" class="db mb2 tl pl3 pl0-ns">Email Address</label>
<input id="email" name="email" class="br2 ba dwyl-b--dark-gray pa2 w-90 border-box" type="email" value="" required placeholder="tim@cern.com" />
</div>
<div class="mt3 ml3">
<label for="message" class="db mb2 tl pl3 pl0-ns">Message</label>
<textarea id="message" name="message" class="br2 ba w-90 dwyl-b--dark-gray pa2" rows="10" placeholder="What problem can we solve for you?"></textarea>
</div>
<button class="bn dib link mt3 mb3 ph3 pv2 dwyl-bg-orange white br2 f5 ml3 shadow-4 pointer montserrat">
<i class="fa fa-paper-plane"></i>&nbsp; Say Hello
</button>
</form>

<div style="display:none;" class="tc pb4 dwyl-dark-gray" id="thankyou_message">
<h2>Thanks for contacting us!</h2>
<h2>We will get back to you soon!</h2>
</div>

<!-- Submit the Form to Google Using "AJAX" -->
<script data-cfasync="false" type="text/javascript" src="/js/app_contact_form_handler.js"></script>
<!-- END -->
</div>
</div>
</section>

<footer class="dwyl-bg-dark-gray white pt1 pt3-ns pb4 tc center">
<div class="bb b--white w-90-ns w-80 center">
<ul class="list tc pl0 pt3 pb3-ns mv0 f3 f5-ns ">
<li class="ph4 fw3 f6 dib-ns pv2"><a href="/" class="white link">Home</a></li>
<li class="ph4 fw3 f6 dib-ns pv2"><a href="/portfolio" class="white link">Portfolio</a></li>
<li class="ph4 fw3 f6 dib-ns pv2"><a href="/careers" class="white link">Careers</a></li>
<div class="dib">
<li class="ph4 fw3 f6 dib-ns pv2"><a href="/community" class="white link">Community</a></li>
Expand All @@ -162,9 +113,11 @@ <h2>We will get back to you soon!</h2>
</a>
</div>
<p class="w-80 w-90-ns center f7 pt2-ns">
Copyright 2019 &copy; DWYL LTD, company number 09525434 registered in England &amp; Wales at First Floor, 149 Fonthill Rd, London N4 3HF. All rights reserved.
Copyright 2023 &copy; DWYL LTD,
company number 09525434 registered
in England &amp; Wales at First Floor,
149 Fonthill Rd, London N4 3HF.
</p>
<img src="/img/common/dwyl-grey-heart.png" alt="dwyl heart logo" class="pv4">
</footer>

<section id="cookie-notification" class="w-100 dwyl-bg-dark-gray bottom-0 fixed h-auto tc-ns tl ph4-ns pt3-ns pb2-ns pt3 ph3 ">
Expand Down
Loading

0 comments on commit 9158a08

Please sign in to comment.