boutique 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/boutique +10 -0
- data/lib/boutique.rb +16 -7
- metadata +3 -3
data/README.md
CHANGED
@@ -123,7 +123,7 @@ To start the server for local development:
|
|
123
123
|
TODO
|
124
124
|
====
|
125
125
|
|
126
|
-
*
|
126
|
+
* add UI for error handling and invalid emails
|
127
127
|
* switch to Stripe
|
128
128
|
* add customizable? email integration for purchase receipts + recover
|
129
129
|
* add re-usable UI for purchasing, downloading, recover
|
data/boutique
CHANGED
@@ -29,6 +29,15 @@ module Boutique
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
def self.render(file)
|
33
|
+
emailer = Boutique::Emailer.new(nil, File.dirname(file))
|
34
|
+
puts emailer.render(
|
35
|
+
File.basename(file),
|
36
|
+
subscribe_url: 'http://example.com/?boutique=subscribe/example',
|
37
|
+
confirm_url: 'http://example.com/?boutique=confirm/example/0/0',
|
38
|
+
unsubscribe_url: 'http://example.com/?boutique=unsubscribe/example/0/0')
|
39
|
+
end
|
40
|
+
|
32
41
|
def self.migrate
|
33
42
|
load_config
|
34
43
|
DataMapper.auto_upgrade!
|
@@ -51,6 +60,7 @@ ARGV.options do |o|
|
|
51
60
|
o.on('-a', '--assets', 'create css/js assets') { Boutique::Command.assets; exit }
|
52
61
|
o.on('-d', '--drip', 'drip out emails') { Boutique::Command.drip; exit }
|
53
62
|
o.on('-m', '--migrate', 'initial migration') { Boutique::Command.migrate; exit }
|
63
|
+
o.on('-r', '--render file', 'render an email') { |f| Boutique::Command.render(f); exit }
|
54
64
|
o.on('-h', '--help', 'show this help message') { puts o; exit }
|
55
65
|
o.parse!
|
56
66
|
puts o
|
data/lib/boutique.rb
CHANGED
@@ -19,7 +19,7 @@ require 'cgi'
|
|
19
19
|
DataMapper::Model.raise_on_save_failure = true
|
20
20
|
|
21
21
|
module Boutique
|
22
|
-
VERSION = '0.0.
|
22
|
+
VERSION = '0.0.11'
|
23
23
|
|
24
24
|
class << self
|
25
25
|
def configure(setup_db=true)
|
@@ -87,15 +87,18 @@ module Boutique
|
|
87
87
|
end
|
88
88
|
|
89
89
|
class Emailer
|
90
|
-
def initialize(list)
|
90
|
+
def initialize(list, directory = nil)
|
91
91
|
@list = list
|
92
|
+
@directory = directory
|
92
93
|
end
|
93
94
|
|
94
95
|
def render(path, locals = {}, preamble = false)
|
95
|
-
path =
|
96
|
+
path = @directory ?
|
97
|
+
File.join(@directory, path) :
|
98
|
+
full_path(path)
|
96
99
|
raise "File not found: #{path}" if !File.exist?(path)
|
97
100
|
|
98
|
-
yaml, body =
|
101
|
+
yaml, body = preamble(path)
|
99
102
|
templates_for(path).each do |template|
|
100
103
|
blk = proc { body }
|
101
104
|
body = template.new(path, &blk).render(self, locals)
|
@@ -132,7 +135,7 @@ module Boutique
|
|
132
135
|
end
|
133
136
|
|
134
137
|
def blast(path, locals = {})
|
135
|
-
yaml, body =
|
138
|
+
yaml, body = preamble(full_path(path))
|
136
139
|
email_key = yaml['key']
|
137
140
|
@list.subscribers.all(confirmed: true).each do |subscriber|
|
138
141
|
# TODO: speed up by moving filter outside of loop
|
@@ -174,8 +177,8 @@ module Boutique
|
|
174
177
|
emails = {}
|
175
178
|
Dir.entries(@list.emails).each do |filename|
|
176
179
|
next if File.directory?(filename)
|
177
|
-
# TODO: stop duplicating calls to
|
178
|
-
yaml, body =
|
180
|
+
# TODO: stop duplicating calls to preamble, store in memory
|
181
|
+
yaml, body = preamble(full_path(filename))
|
179
182
|
if yaml && yaml['day'] && yaml['key']
|
180
183
|
emails[yaml['day']] = filename
|
181
184
|
end
|
@@ -183,6 +186,12 @@ module Boutique
|
|
183
186
|
emails
|
184
187
|
end
|
185
188
|
end
|
189
|
+
|
190
|
+
def preamble(path)
|
191
|
+
Preamble.load(path)
|
192
|
+
rescue
|
193
|
+
[{}, File.read(path)]
|
194
|
+
end
|
186
195
|
end
|
187
196
|
|
188
197
|
class Config
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boutique
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: .
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
@@ -205,7 +205,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
205
205
|
version: '0'
|
206
206
|
segments:
|
207
207
|
- 0
|
208
|
-
hash: -
|
208
|
+
hash: -1016337613
|
209
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
210
|
none: false
|
211
211
|
requirements:
|