chimp_contact 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/chimp_contact.gemspec +1 -0
- data/config.ru +3 -0
- data/lib/chimp_contact/configuration.rb +5 -0
- data/lib/chimp_contact/converter.rb +2 -2
- data/lib/chimp_contact/dashboard/views/index.erb +30 -0
- data/lib/chimp_contact/dashboard/views/layout.erb +21 -0
- data/lib/chimp_contact/dashboard/views/show.erb +4 -0
- data/lib/chimp_contact/dashboard.rb +37 -0
- data/lib/chimp_contact/template.rb +30 -7
- data/lib/chimp_contact/version.rb +1 -1
- data/lib/chimp_contact.rb +26 -0
- metadata +31 -14
data/chimp_contact.gemspec
CHANGED
data/config.ru
ADDED
@@ -11,8 +11,8 @@ module ChimpContact
|
|
11
11
|
|
12
12
|
def initialize(document, options = {})
|
13
13
|
@document = document
|
14
|
-
@params = options[
|
15
|
-
@title = options[
|
14
|
+
@params = options["params"] || {}
|
15
|
+
@title = options["title"] || "Newsletter"
|
16
16
|
end
|
17
17
|
|
18
18
|
def convert
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<form action="/" method="post" class="form-stacked">
|
2
|
+
|
3
|
+
<fieldset>
|
4
|
+
<label for="title">Subject</label>
|
5
|
+
<input type="text" name="title" id="title" value="" class="span8">
|
6
|
+
</fieldset>
|
7
|
+
|
8
|
+
<fieldset>
|
9
|
+
<legend>URL Parameters</legend>
|
10
|
+
|
11
|
+
<label>UTM Source</label>
|
12
|
+
<input type="text" name="params[utm_source]" value="" />
|
13
|
+
|
14
|
+
<label>UTM Campaign</label>
|
15
|
+
<input type="text" name="params[utm_campaign]" value="" />
|
16
|
+
|
17
|
+
<label>UTM Medium</label>
|
18
|
+
<input type="text" name="params[utm_medium]" value="" />
|
19
|
+
</fieldset>
|
20
|
+
|
21
|
+
<label for="template_id">Choose a template</label>
|
22
|
+
<select name="template_id" class="span8">
|
23
|
+
<% @templates.each do |template| %>
|
24
|
+
<option value="<%= template[:id] %>"><%= template[:name] %></option>
|
25
|
+
<% end %>
|
26
|
+
</select>
|
27
|
+
<br />
|
28
|
+
<br />
|
29
|
+
<input type="submit" value="Convert Template" class="btn danger large span8" />
|
30
|
+
</form>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
|
5
|
+
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css">
|
6
|
+
<title>Chimp Contact</title>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<div class="container">
|
10
|
+
<h1>Chimp Contact <small>Mailchimp to constant contact template converter</small></h1>
|
11
|
+
|
12
|
+
<div id="content" class="offset4">
|
13
|
+
<%= yield %>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div id="footer">
|
17
|
+
<p class="pull-right">Powered by <a href="http://github.com/stinkyink/chimp_contact">Chimp Contact</a> v<%=ChimpContact::VERSION %></p>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
</body>
|
21
|
+
</html>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
require 'chimp_contact'
|
3
|
+
|
4
|
+
module ChimpContact
|
5
|
+
|
6
|
+
class MailChimpError < StandardError;end
|
7
|
+
|
8
|
+
class Dashboard < Sinatra::Base
|
9
|
+
dir = File.dirname(File.expand_path(__FILE__))
|
10
|
+
|
11
|
+
set :views, "#{dir}/dashboard/views"
|
12
|
+
set :public_folder, "#{dir}/dashboard/public"
|
13
|
+
|
14
|
+
error MailChimpError do
|
15
|
+
'Mailchimp failed to respond, please try refreshing your browser'
|
16
|
+
end
|
17
|
+
|
18
|
+
get "/" do
|
19
|
+
begin
|
20
|
+
@templates = Template.all
|
21
|
+
rescue
|
22
|
+
raise MailChimpError
|
23
|
+
end
|
24
|
+
erb :index
|
25
|
+
end
|
26
|
+
|
27
|
+
post "/" do
|
28
|
+
begin
|
29
|
+
html = Template.find(params["template_id"]).to_inline_css
|
30
|
+
@result = Converter.new(Nokogiri::HTML(html), params).convert.to_xhtml
|
31
|
+
rescue
|
32
|
+
raise MailChimpError
|
33
|
+
end
|
34
|
+
erb :show
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -2,20 +2,43 @@ module ChimpContact
|
|
2
2
|
|
3
3
|
class Template
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@
|
5
|
+
def initialize(template_info)
|
6
|
+
@template_info = template_info
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.find(id)
|
10
|
+
id = id.gsub(".0", "").to_i
|
11
|
+
new(ChimpContact.hominid.template_info(id))
|
12
|
+
rescue EOFError
|
13
|
+
unless @find_failed
|
14
|
+
@find_failed = true
|
15
|
+
retry
|
16
|
+
end
|
7
17
|
end
|
8
18
|
|
9
|
-
def
|
10
|
-
|
19
|
+
def self.all
|
20
|
+
ChimpContact.hominid.templates["user"].inject([]) do |result, element|
|
21
|
+
result << {:name => element["name"], :id => element["id"]}
|
22
|
+
result
|
23
|
+
end
|
24
|
+
rescue EOFError
|
25
|
+
unless @all_failed
|
26
|
+
@all_failed = true
|
27
|
+
retry
|
28
|
+
end
|
11
29
|
end
|
12
30
|
|
13
31
|
def content
|
14
|
-
template_info["source"]
|
32
|
+
@template_info["source"]
|
15
33
|
end
|
16
34
|
|
17
|
-
def
|
18
|
-
|
35
|
+
def to_inline_css
|
36
|
+
ChimpContact.hominid.inline_css(content, true)
|
37
|
+
rescue EOFError
|
38
|
+
unless @to_inline_css_failed
|
39
|
+
@to_inline_css_failed = true
|
40
|
+
retry
|
41
|
+
end
|
19
42
|
end
|
20
43
|
end
|
21
44
|
end
|
data/lib/chimp_contact.rb
CHANGED
@@ -1,5 +1,31 @@
|
|
1
1
|
require 'nokogiri'
|
2
2
|
require 'hominid'
|
3
3
|
require "chimp_contact/version"
|
4
|
+
require "chimp_contact/configuration"
|
4
5
|
require "chimp_contact/template"
|
5
6
|
require "chimp_contact/converter"
|
7
|
+
|
8
|
+
module ChimpContact
|
9
|
+
|
10
|
+
extend self
|
11
|
+
attr_accessor :configuration
|
12
|
+
|
13
|
+
# Returns the current Hominid Mailchimp API connection. If none has been created, will
|
14
|
+
# create a new one.
|
15
|
+
def hominid
|
16
|
+
@hominid ||= Hominid::API.new(configuration.mailchimp_api_key)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Call this method to modify defaults in your initializers.
|
20
|
+
#
|
21
|
+
# @example
|
22
|
+
# ChimpContact.configure do |config|
|
23
|
+
# config.mailchimp_api_key = 'akueoq3royowyvrowy5o3coq3yr-us2'
|
24
|
+
# end
|
25
|
+
def configure
|
26
|
+
self.configuration ||= Configuration.new
|
27
|
+
yield(configuration)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
ChimpContact.configure {}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chimp_contact
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-12-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
17
|
-
requirement: &
|
17
|
+
requirement: &70132690234620 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70132690234620
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rake
|
28
|
-
requirement: &
|
28
|
+
requirement: &70132690234180 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70132690234180
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: fakeweb
|
39
|
-
requirement: &
|
39
|
+
requirement: &70132690233720 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70132690233720
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: nokogiri
|
50
|
-
requirement: &
|
50
|
+
requirement: &70132690233300 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,21 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70132690233300
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: sinatra
|
61
|
+
requirement: &70132690232840 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
type: :runtime
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: *70132690232840
|
59
70
|
- !ruby/object:Gem::Dependency
|
60
71
|
name: hominid
|
61
|
-
requirement: &
|
72
|
+
requirement: &70132690232340 !ruby/object:Gem::Requirement
|
62
73
|
none: false
|
63
74
|
requirements:
|
64
75
|
- - ! '>='
|
@@ -66,7 +77,7 @@ dependencies:
|
|
66
77
|
version: '0'
|
67
78
|
type: :runtime
|
68
79
|
prerelease: false
|
69
|
-
version_requirements: *
|
80
|
+
version_requirements: *70132690232340
|
70
81
|
description: Converts mailchimp templates to constant contact format but more verbose
|
71
82
|
email:
|
72
83
|
- rob@r-williams.com
|
@@ -79,8 +90,14 @@ files:
|
|
79
90
|
- Gemfile
|
80
91
|
- Rakefile
|
81
92
|
- chimp_contact.gemspec
|
93
|
+
- config.ru
|
82
94
|
- lib/chimp_contact.rb
|
95
|
+
- lib/chimp_contact/configuration.rb
|
83
96
|
- lib/chimp_contact/converter.rb
|
97
|
+
- lib/chimp_contact/dashboard.rb
|
98
|
+
- lib/chimp_contact/dashboard/views/index.erb
|
99
|
+
- lib/chimp_contact/dashboard/views/layout.erb
|
100
|
+
- lib/chimp_contact/dashboard/views/show.erb
|
84
101
|
- lib/chimp_contact/template.rb
|
85
102
|
- lib/chimp_contact/version.rb
|
86
103
|
- spec/chimp_contact_spec.rb
|
@@ -100,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
117
|
version: '0'
|
101
118
|
segments:
|
102
119
|
- 0
|
103
|
-
hash: -
|
120
|
+
hash: -3210440901720047518
|
104
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
122
|
none: false
|
106
123
|
requirements:
|
@@ -109,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
126
|
version: '0'
|
110
127
|
segments:
|
111
128
|
- 0
|
112
|
-
hash: -
|
129
|
+
hash: -3210440901720047518
|
113
130
|
requirements: []
|
114
131
|
rubyforge_project: chimp_contact
|
115
132
|
rubygems_version: 1.8.10
|