Skip to content

Commit

Permalink
Merge pull request raviriley#11 from morozgrafix/formspree_legacy
Browse files Browse the repository at this point in the history
Adapts contact form to new [Formspree Form ID update](https://help.formspree.io/hc/en-us/articles/360017735154-How-to-prevent-spam) with formspree_form_path site variable. Legacy forms (using email) are being phased out by Formspree. Click [here](https://help.formspree.io/hc/en-us/articles/360056076314) for more info.
  • Loading branch information
raviriley authored Nov 1, 2020
2 parents ec6be0a + a69b55b commit 46e8c6e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
10 changes: 7 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This config file is meant for settings that affect your whole blog, values
# which you are expected to set up once and rarely edit after that.
# This file is *NOT* reloaded automatically when you use 'bundle exec jekyll serve'.
# This file is *NOT* reloaded automatically when you use 'bundle exec jekyll serve'.
# If you change this file, please restart the server process.

# Site settings
Expand All @@ -16,7 +16,7 @@ theme: jekyll-agency
url : "" # the base hostname & protocol for your site, e.g. http://example.com
baseurl: "" # the subpath of your site, e.g. /blog

title : Your Awesome Website
title : Your Awesome Website
email : [email protected] #this is also the email contact forms will go to
description: "Site description"
author : Your Name
Expand All @@ -30,4 +30,8 @@ analytics:
collections:
portfolio:

markdown: kramdown
markdown: kramdown

# Uncomment following line to use Formspree form ID based URL instead of email based URL
# Details: https://help.formspree.io/hc/en-us/articles/360017735154-How-to-prevent-spam
# formspree_form_path: "f/a_form_id"
4 changes: 2 additions & 2 deletions _includes/contact.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ <h3 class="section-subheading text-muted">{{ site.data.sitetext.contact.text | d
</div>
<div class="row">
<div class="col-lg-12">
<form id="contactForm" action="https://formspree.io/{{ site.email }}" novalidate="novalidate" method="POST">
<!--name="sentMessage"-->
<form id="contactForm" action="https://formspree.io/{% if site.formspree_form_path %}{{ site.formspree_form_path }}{% else %}{{ site.email }}{% endif %}" novalidate="novalidate" method="POST">
<!--name="sentMessage"-->
<div class="row">
<div class="col-md-6">
<div class="form-group">
Expand Down
10 changes: 5 additions & 5 deletions assets/js/contact_me.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $(function() {
submitSuccess: function($form, event) {
event.preventDefault(); // prevent default submit behaviour
// get values from FORM
var url = "https://formspree.io/" + "{{ site.email }}";
var url = "https://formspree.io/" + "{% if site.formspree_form_path %}{{ site.formspree_form_path }}{% else %}{{ site.email }}{% endif %}";
var name = $("input#name").val();
var email = $("input#email").val();
var phone = $("input#phone").val();
Expand All @@ -25,15 +25,15 @@ $(function() {
$.ajax({
url: url,
type: "POST",
dataType: "json",
dataType: "json",
data: {
name: name,
phone: phone,
email: email,
message: message
},
cache: false,

success: function() {
// Success message
$('#success').html("<div class='alert alert-success'>");
Expand All @@ -46,7 +46,7 @@ $(function() {
//clear all fields
$('#contactForm').trigger("reset");
},

error: function() {
// Fail message
$('#success').html("<div class='alert alert-danger'>");
Expand All @@ -57,7 +57,7 @@ $(function() {
//clear all fields
$('#contactForm').trigger("reset");
},

complete: function() {
setTimeout(function() {
$this.prop("disabled", false); // Re-enable submit button when AJAX call is complete
Expand Down

0 comments on commit 46e8c6e

Please sign in to comment.