Skip to content

Commit

Permalink
ConvertKit email submission
Browse files Browse the repository at this point in the history
  • Loading branch information
Shpigford committed Apr 29, 2024
1 parent e8b6d86 commit 9cb9125
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CONVERTKIT_API_KEY=
CONVERTKIT_API_SECRET=
CONVERTKIT_FORM_ID=
CONVERTKIT_TAG_ID=
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ gem "stimulus-rails"
gem "turbo-rails"

# Other
gem "faraday"
gem "jbuilder"
gem "tzinfo-data", platforms: %i[ windows jruby ]

Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ GEM
rubocop
smart_properties
erubi (1.12.0)
faraday (2.9.0)
faraday-net_http (>= 2.0, < 3.2)
faraday-net_http (3.1.0)
net-http
ffi (1.16.3)
globalid (1.2.1)
activesupport (>= 6.1)
Expand Down Expand Up @@ -182,6 +186,8 @@ GEM
mini_mime (1.1.5)
minitest (5.21.2)
msgpack (1.7.2)
net-http (0.4.1)
uri
net-imap (0.4.10)
date
net-protocol
Expand Down Expand Up @@ -320,6 +326,7 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
uri (0.13.0)
useragent (0.16.10)
web-console (4.2.1)
actionview (>= 6.0.0)
Expand Down Expand Up @@ -350,6 +357,7 @@ DEPENDENCIES
debug
dotenv-rails
erb_lint
faraday
hotwire-livereload
importmap-rails
jbuilder
Expand Down
9 changes: 9 additions & 0 deletions app/controllers/signups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,14 @@ def new
end

def create
form_id = ENV["CONVERTKIT_FORM_ID"]
tag_id = ENV["CONVERTKIT_TAG_ID"]
api_key = ENV["CONVERTKIT_API_KEY"]
email = params[:email]

Faraday.post("https://api.convertkit.com/v3/forms/#{form_id}/subscribe") do |req|
req.headers["Content-Type"] = "application/json; charset=utf-8"
req.body = { api_key: api_key, email: email, tags: [ tag_id ] }.to_json
end
end
end
4 changes: 2 additions & 2 deletions app/views/pages/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="text-center">
<div class="max-w-xl pt-8 mx-auto text-3xl mb-4">
<div class="max-w-xl pt-8 mx-auto mb-4 text-3xl">
Maybe <%= image_tag("icon-maybe-color.svg", alt: "Maybe Logo", class: "inline") %> is a <em class="relative"><span class="border-b-2 border-dotted border-neutral-400">fully</span><sup>*</sup> <span class="absolute w-64 text-xs text-left left-16 -top-7 -rotate-3 text-neutral-400"><sup>*</sup>your finances are secure</span></em> open-source
<div class="inline-flex border rounded-md shadow-[0_1px_8px_0_rgba(0,0,0,0.04)] border-neutral-200">
<%= link_to "https://github.com/maybe-finance/maybe", class: "px-2 py-1.5 border-r shadow-[inset_0_-2px_5px_0_rgba(0,0,0,0.07)] bg-neutral-100 rounded-l-md border-neutral-200 flex items-center justify-center" do %>
Expand All @@ -9,7 +9,7 @@
</div>
OS for your personal finances <%= image_tag("icon-chart.svg", alt: "Chart", class: "inline") %> built by a small team <%= image_tag("icon-team.png", alt: "Maybe Team", class: "inline h-9") %> alongside an incredible community <%= image_tag("icon-discord.svg", alt: "Discord", class: "inline") %>
</div>
<div class="max-w-96 mx-auto">
<div class="mx-auto max-w-96">
<%= render_signup_form %>
</div>
</div>

0 comments on commit 9cb9125

Please sign in to comment.