Skip to content

Instantly share code, notes, and snippets.

View JeffTD's full-sized avatar

Jeff Dunne JeffTD

View GitHub Profile
@JeffTD
JeffTD / _partial_bablic_language_select.html
Created March 21, 2018 05:43
Write bablic locale to custom field on form submit.
{% if page.signup.is_all_info_collected? == false %}
{% if request.sorta_logged_in? %}
<div id="bablic-submit">
{% submit_tag "Update info", class:"submit-button" %}
</div>
{% else %}
<div id="bablic-submit">
{% submit_tag "Signup", class:"submit-button" %}
</div>
{% endif %}
@JeffTD
JeffTD / utm_javascript.html
Created February 10, 2018 00:28
JS to scrape URL for UTM parameters and inject into form inputs
<!-- inputs - replace these exmaples with the custom fields for your nation -->
<input type="text" id="utmCampaign" />
<input type="text" id="utmSource" />
<input type="text" id="utmMedium" />
<input type="text" id="utmContent" />
<input type="text" id="utmTerm" />
<script>
// Parse URL Queries Method - this scrapes the URL
@JeffTD
JeffTD / mailing_address_partial_fields.html
Created February 5, 2018 20:02
Mailing Address street_name and street_number
<h4>Mailing Address</h4>
<div class="row-fluid">
<div class="span12"><label for="signup_mailing_address_address1">street name</label>{% text_field "mailing_address.street_name", class:"text", placeholder:"Street Name" %}</div>
</div>
<div class="row-fluid">
<div class="span12"><label for="signup_mailing_address_address1">street number</label>{% text_field "mailing_address.street_number", class:"integer", placeholder:"Street Number" %}</div>
</div>
@JeffTD
JeffTD / pages_show_join_bablic.html
Created August 15, 2017 20:27
Capturing Bablic Language selections into a custom field
{% include "breadcrumbs" %}
{% if page.headline.size > 0 %}
<h2 class="headline">{{ page.headline }}</h2>
{% endif %}
<div id="content">
{% if page.signup.content.size > 0 %}
<div id="intro" class="intro">
@JeffTD
JeffTD / capture_nation_slug
Created August 11, 2017 22:29
Use Liquid to capture the slug of a NationBuilder website.
{% assign NationSlug = '' %} <!-- zero out variable at top of page -->
{% capture ThemeURLString %}{{ theme[''] }}{% endcapture %} <!-- capture a dummy theme call which gives us a URL string containing the non-custom domain -->
{% assign url_parts = ThemeURLString | split:'/' %} <br> <!-- split this URL on /'s to extract the domain (aka slug) -->
{% assign SubDomain = url_parts[2] | split:'.' %} <!-- split the subdomain from nationbuilder.com -->
{% if SubDomain[0] contains '-' %} <!-- if subdomain contains hyphen aka if site is not primary site -->
{% assign NationSlugParts = SubDomain[0] | split:'-' %} <!-- split site.slug from nation.slug -->
{% assign NationSlug = NationSlugParts[1] %}
{% else %} <!-- if subdomain doesn't contain hyphen -->
{% assign NationSlug = SubDomain[0] %} <!-- assign subdomain (aka nation slug) as NationSlug variable -->
{% endif %}
@JeffTD
JeffTD / page_tag_embed_widgets.html
Created June 15, 2017 17:16
Using page tags to control embed codes
// To create a reliable string of page tags to use for comparison in Liquid conditional statements, place this in layout.html between the <head> and <body>:
{% assign tags_list = "" %}
{% for tag in page.tags %}
{% assign tags_list = tag.name | append: ", " | append: tags_list %}
{% endfor %}
// We'll need a consistent tag naming convention that contains a 'trigger' phrase and an 'id' to use in the link to the embedded widget.
// In this case, we need an ID for a Phone2Action widget, so we'll be using the tag format 'p2a-12345'
//
@JeffTD
JeffTD / iwf_api_update.rb
Last active June 15, 2017 17:27 — forked from JiMaverick/iwf_api_update.rb
First API mod. Inserting html descriptions into a customer nation
require 'nationbuilder'
require 'csv'
slug = 'NATION'
token = 'INSERT TOKEN HERE'
client = NationBuilder::Client.new(slug, token)
i = CSV.open("/Users/jeffdunne/Desktop/iwf-first_upload-profiles.csv", headers: true).count
CSV.foreach("/Users/jeffdunne/Desktop/iwf-first_upload-profiles.csv", headers: true) do |row|
begin
@JeffTD
JeffTD / pages_show_signup_bablic.html
Created March 8, 2017 22:40
Bablic signup page, hidden multiple choice custom field for language
<h2 class="headline">{{ page.headline }}</h2>
<div id="content">
{% if page.signup.content.size > 0 %}
<div id="intro" class="intro">{{ page.signup.content }}</div>
{% endif %}
{% if page.show_social_slider? and page.public_activities_count > 0 %}
{% include "social_slider" %}
@JeffTD
JeffTD / _partial_signup_fields.html
Created March 1, 2017 20:18
Available Signup Fields
<script>
$(document).ready(function () {
$('#signup_type_organization').change(function () {
if (this.checked)
// ^
$('#signup_first_name_row').fadeOut('slow');
else
$('#signup_first_name_row').fadeIn('slow');
});
});
@JeffTD
JeffTD / 1_col_boilerplate.html
Last active March 14, 2017 23:16
NB 1 col email template
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="initial-scale=1.0"> <!-- So that mobile webkit will display zoomed in -->
<meta name="format-detection" content="telephone=no"> <!-- disable auto telephone linking in iOS -->
<title>{{ broadcaster.name }}</title>
{% assign preheader_text = body | strip_html %} <!-- optional pre-header text; text must be in "quotes" -->