Skip to content

Instantly share code, notes, and snippets.

@rawsh
Last active October 24, 2016 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rawsh/554d3aa0d8519816c891ac4021ffc11f to your computer and use it in GitHub Desktop.
Save rawsh/554d3aa0d8519816c891ac4021ffc11f to your computer and use it in GitHub Desktop.
Ghost subscribe page used with a mailgrunt server

Make sure to change the url in the fetch part of the js code. This is used with the https://github.com/rawsh/devpygrunt code to hack email subscribtions into ghost. Note: This does not use ghost built in subscribers. This uses mailgun. To make it send emails for every new post, sign up for zapier and add a mailgun rss sender.

<!doctype html>
<!--[if (IE 8)&!(IEMobile)]><html class="no-js lt-ie9" lang="en"><![endif]-->
<!--[if (gte IE 9)| IEMobile |!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Subscribe to DevPy</title>
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="shortcut icon" href="{{asset "favicon.ico"}}">
<meta http-equiv="cleartype" content="on">
<link rel="stylesheet" type='text/css' href='//fonts.googleapis.com/css?family=Open+Sans:400,300,700'>
<link rel="stylesheet" href="{{asset "ghost.css" ghost="true" minifyInProduction="true"}}" />
<style>
#subscribe-result {
padding-top: 5px;
}
</style>
</head>
<body>
<div class="gh-app">
<div class="gh-viewport">
<main class="gh-main" role="main">
<div class="gh-flow">
<header class="gh-flow-head">
<nav class="gh-flow-nav">
<a href="{{@blog.url}}" class="gh-flow-back"><i class="icon-arrow-left"></i> Back</a>
</nav>
</header>
<div class="gh-flow-content-wrap">
<section class="gh-flow-content">
<header>
<h1>Subscribe to {{@blog.title}}</h1>
</header>
<form class="gh-signin" id="subscribe-form">
<div id="subscribe">
<div class="form-group"><input type="email" value="" name="EMAIL" class="email gh-input" id="sub-email" placeholder="email address" autofocus></div>
<input type="submit" value="Subscribe" name="subscribe" class="btn btn-blue btn-block" onclick="doSub();return false;">
</div>
<p id="subscribe-result"></p>
</div>
</form>
</section>
</div>
</div>
</main>
</div>
</div>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.js"></script>
<script type="text/javascript">
function doSub() {
var em = document.getElementById("sub-email").value;
console.log(em);
//get the email
fetch('http://grunt.devpy.me/subscribe', {method: 'POST',body: JSON.stringify({email: em}), headers: {"Content-Type": "application/json"}}).then(function(response) {
return response.json();
}).then(function(data) {
if(data.success) {
document.getElementById("subscribe-result").innerHTML = "You are now subscribed.";
ga('send', 'event', 'Subscribe', 'subscribe-post');
} else {
document.getElementById("subscribe-result").innerHTML = data.error;
}
}).catch(function(ex) {
document.getElementById("subscribe-result").innerHTML = ex;
});
}
</script>
{{! Activate GoogleAnalytics }}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-77238872-2', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment