antwort 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +19 -0
  5. data/.ruby-version +1 -0
  6. data/CHANGELOG.md +249 -0
  7. data/Gemfile +3 -0
  8. data/Guardfile +14 -0
  9. data/README.md +108 -0
  10. data/Rakefile +14 -0
  11. data/antwort.gemspec +45 -0
  12. data/bin/antwort +5 -0
  13. data/lib/antwort.rb +13 -0
  14. data/lib/antwort/builder.rb +8 -0
  15. data/lib/antwort/builder/builder.rb +104 -0
  16. data/lib/antwort/builder/email.rb +61 -0
  17. data/lib/antwort/builder/flattener.rb +37 -0
  18. data/lib/antwort/builder/helpers/logic.rb +82 -0
  19. data/lib/antwort/builder/helpers/sanitizers.rb +29 -0
  20. data/lib/antwort/builder/partial.rb +80 -0
  21. data/lib/antwort/builder/style.rb +59 -0
  22. data/lib/antwort/cli.rb +7 -0
  23. data/lib/antwort/cli/cli.rb +275 -0
  24. data/lib/antwort/cli/helpers.rb +44 -0
  25. data/lib/antwort/cli/send.rb +79 -0
  26. data/lib/antwort/cli/upload.rb +89 -0
  27. data/lib/antwort/helpers.rb +19 -0
  28. data/lib/antwort/server.rb +70 -0
  29. data/lib/antwort/server/assets.rb +23 -0
  30. data/lib/antwort/server/helpers.rb +67 -0
  31. data/lib/antwort/server/markup.rb +39 -0
  32. data/lib/antwort/version.rb +3 -0
  33. data/spec/builder/builder_spec.rb +30 -0
  34. data/spec/builder/email_spec.rb +21 -0
  35. data/spec/builder/flattener_spec.rb +64 -0
  36. data/spec/builder/helpers_logic_spec.rb +244 -0
  37. data/spec/builder/partial_spec.rb +87 -0
  38. data/spec/builder/style_spec.rb +66 -0
  39. data/spec/cli/helpers_spec.rb +60 -0
  40. data/spec/cli/upload_spec.rb +47 -0
  41. data/spec/cli_spec.rb +46 -0
  42. data/spec/fixtures/assets/images/1-demo/placeholder.png +0 -0
  43. data/spec/fixtures/assets/images/newsletter/placeholder.png +0 -0
  44. data/spec/fixtures/assets/images/shared/placeholder-grey.png +0 -0
  45. data/spec/fixtures/assets/images/shared/placeholder-white.png +0 -0
  46. data/spec/fixtures/build/demo-123456/build.html +7 -0
  47. data/spec/fixtures/build/demo-123457/build.html +7 -0
  48. data/spec/fixtures/build/demo-bar-123/build.html +7 -0
  49. data/spec/fixtures/build/foo-1/build.html +7 -0
  50. data/spec/fixtures/data/1-demo.yml +3 -0
  51. data/spec/fixtures/emails/1-demo/index.html.erb +9 -0
  52. data/spec/fixtures/emails/2-no-layout/index.html.erb +6 -0
  53. data/spec/fixtures/emails/3-no-title/index.html.erb +1 -0
  54. data/spec/fixtures/views/404.html.erb +1 -0
  55. data/spec/fixtures/views/index.html.erb +14 -0
  56. data/spec/fixtures/views/layout.erb +8 -0
  57. data/spec/fixtures/views/server.erb +5 -0
  58. data/spec/server_spec.rb +54 -0
  59. data/spec/spec_helper.rb +38 -0
  60. data/spec/support/capture.rb +17 -0
  61. data/template/email/css/include.scss +5 -0
  62. data/template/email/css/inline.scss +5 -0
  63. data/template/email/email.html.erb +11 -0
  64. data/template/email/images/.empty_directory +0 -0
  65. data/template/project/.env.sample +21 -0
  66. data/template/project/.gitignore.tt +17 -0
  67. data/template/project/.ruby-version +1 -0
  68. data/template/project/Gemfile.tt +9 -0
  69. data/template/project/Guardfile +9 -0
  70. data/template/project/assets/css/demo/include.scss +3 -0
  71. data/template/project/assets/css/demo/inline.scss +33 -0
  72. data/template/project/assets/css/server.scss +167 -0
  73. data/template/project/assets/css/shared/_base.scss +64 -0
  74. data/template/project/assets/css/shared/_mixins.scss +25 -0
  75. data/template/project/assets/css/shared/_reset.scss +59 -0
  76. data/template/project/assets/css/shared/_vars.scss +12 -0
  77. data/template/project/assets/css/shared/include.scss +23 -0
  78. data/template/project/assets/css/shared/inline.scss +9 -0
  79. data/template/project/assets/images/.gitkeep +0 -0
  80. data/template/project/assets/images/shared/placeholder.png +0 -0
  81. data/template/project/build/.empty_directory +0 -0
  82. data/template/project/data/.empty_directory +0 -0
  83. data/template/project/data/config.yml +3 -0
  84. data/template/project/data/demo.yml +4 -0
  85. data/template/project/emails/demo/_partial.html.erb +9 -0
  86. data/template/project/emails/demo/index.html.erb +54 -0
  87. data/template/project/views/404.html.erb +8 -0
  88. data/template/project/views/index.html.erb +18 -0
  89. data/template/project/views/layout.erb +38 -0
  90. data/template/project/views/markup/_button.html.erb +5 -0
  91. data/template/project/views/markup/_image_tag.html.erb +10 -0
  92. data/template/project/views/server.erb +32 -0
  93. metadata +443 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3e59b19fe569c6bedd6aa867d777da670503f8d6
4
+ data.tar.gz: 16999bba4fcd7566d0da5000de95b9be271d5faf
5
+ SHA512:
6
+ metadata.gz: 670993ca347300e1599aa03c6d7e7cc01b5465fa7b0c7fc6ebeee921d64b3bb64eca82e7e8d30a8ac316d5a9d42e0aa482dd5fa06def7c066a3c7e700a474415
7
+ data.tar.gz: 38833ee46c6c0c8025776cfa31fb77a371cdcfcfb0593c09620e619ec2e916ea745fb298298072dc2352b8f35afa695ac65a391403fdbcb447c30cde07185776
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ # bundler and gems config
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ Gemfile.lock
6
+
7
+ # Packaged gem
8
+ pkg
9
+
10
+ # Environment variables
11
+ .env
12
+
13
+ # Mac Finder file
14
+ .DS_Store
15
+
16
+ # build directory
17
+ /build
18
+
19
+ # Temp files and cache
20
+ *.sass-cache
21
+ /tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,19 @@
1
+ AllCops:
2
+ Include:
3
+ - '*.gemspec'
4
+ - '**/Gemfile'
5
+ - '**/Rakefile'
6
+ Exclude:
7
+ - tmp/**/*
8
+
9
+ SymbolArray:
10
+ Enabled: true
11
+
12
+ Metrics/LineLength:
13
+ Enabled: false
14
+
15
+ Metrics/MethodLength:
16
+ Max: 16
17
+
18
+ Documentation:
19
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,249 @@
1
+ # Change Log
2
+
3
+ ## 0.0.12
4
+
5
+ Released: 14 March 2016
6
+
7
+ __Fixed__
8
+
9
+ * Preserve multiline partials
10
+ * Fixed typo in image tag markup. It should be `style=""`.
11
+
12
+ __Updated__
13
+
14
+ * Sending a test email now uses the email's `<title>` as the subject line, prefixed by "[test] "
15
+ * Change CSS output style short flag to -c, more logical than -o
16
+ * Our `include.scss` is now added after `<title>` instead of just before `</head>`, so we do not accidentlly override email specific included CSS.
17
+ * `data-roadie-` attributes are removed after inlining.
18
+ * Updated some templates used when initializing a new project
19
+
20
+
21
+ ## 0.0.11
22
+
23
+ Released: 2 December 2015
24
+
25
+ In this release, Partial Inlining was updated, not just to add and fix missing logic, but more importantly to establish syntax patterns.
26
+
27
+ __Added__
28
+
29
+ * New `--all` flag to `build` command, which will build all emails.
30
+ * `each_with_index` loops are also now preserved. Example conversion: `cats.each_with_index do |cat, i|` becomes `{% for cat in cats with: {@index: i} %}`
31
+ * Locals passed to partials are now referenced using a more generic `with` instead of ruby-esqe `locals` like so: {% partial 'foo' with: {size: 1} %}
32
+ * ERB's `unless` is now converted to `if !(condition)`
33
+ * ERB Statements without output or conditionals are also now preserved. Example: `<% product.merge({featured: false}) %>`
34
+ * `button` and `image_tag` helpers are converted to use statement `{% … %}` syntax, not `{{ … }}` output syntax
35
+
36
+ __Fixed__
37
+
38
+ * Inlining partials no longer results in extra `<p>` tags. They were added by Nokogiri to create complete DOM trees should be addressed.
39
+ * Fixed edge cases where conditionals using a less than `<` operator resulted in large chunks of missing code. Nokogiri, interpreted it as the start of an HTML tag, often chopping off parts until it found the next orphaned `>`, often in another conditional.
40
+ * Antwort now always sends the correct email by matching `email_id`s exactly (#45).
41
+
42
+ __Updated__
43
+
44
+ * Closing logic tags are now simply `{% end %}`, deviating from Twig's `{% endif %}` and `{% endfor %}`, which cannot reliably be captured using regular expressions. We're choosing consistency and reliability over strict adherence to Twig syntax.
45
+ * Updated some specs to test conversion of ERB logic to Twig-style logic.
46
+
47
+ ## 0.0.10
48
+
49
+ Released: 15 November 2015
50
+
51
+ __Added__
52
+
53
+ * New Feature: `--css-style` or `-o` flag for [Sass output style](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#output_style). Possible values: `expanded, `nested`, `compact`, or `compressed`.
54
+ * Building partials now also builds the emails
55
+
56
+ __Fixed__
57
+
58
+ * Adding and removing emails now also adds and removes respective `data/[email_id].yml` data file.
59
+
60
+ __Updated__
61
+
62
+ * `symbolize_keys` helper is now a generic antwort helper.
63
+
64
+ ## 0.0.9
65
+
66
+ Released: 20 Oct 2015
67
+
68
+ __Added__
69
+ * Preserve more logic for partials, including:
70
+ - conditionals
71
+ - variables
72
+ - varibles in lines
73
+ - non brekaing spaces
74
+ - code comments
75
+ - assignments including `||=` asssignments
76
+ * add Yahoo table `align="center"` workaround to inline css.
77
+
78
+ __Breaking Changes__
79
+
80
+ * Stylesheets have been renamed to more accurately reflect how they are integrated into the email.
81
+ - `styles.scss` is now `inline.scss`, because it will be inlined.
82
+ - `responsive.scss` is now `include.scss`, because it will be included in the `<head>`, not all of which are responsive styles. Some are just CSS resets.
83
+ * Meta data variables are now set directly as instance variables and can be accessed directly. For example, use `@title` instead of `@metadata[:title]`
84
+
85
+ __Fixed__
86
+ * Create `./build` directory if it doesn't exist (#30)
87
+ * Build email before send if not already built and inlined (#31)
88
+ * Restore variables inside links (#32)
89
+ * Make default server layout responsive (#29)
90
+ * [`Sinatra::ContentFor`](http://www.sinatrarb.com/contrib/content_for.html) helper now works
91
+
92
+ __Updated__
93
+ * Cleaned up existing and added more specs
94
+ * Update `.env.sample` defaults and add missing `SEND_FROM`
95
+
96
+
97
+ ## 0.0.8
98
+
99
+ Released: 12 Jan 2015
100
+
101
+ __Added__
102
+
103
+ * Added `SEND_FROM` environment variable to use as sender address, in case it differs from SMTP username
104
+ * Refactored Builder to generate both templates and partials
105
+ * Preserve ERB code in partials by changing to [Twig](http://twig.sensiolabs.org/) syntax, which is ignored by our inliner.
106
+
107
+ __Fixed__
108
+
109
+ * Make sure partials always have `.html` file extension, in case file is named `_partial.erb`
110
+ * Default buttons now work in Outlook (missing border property)
111
+ * Default email now also responsive (missing media query)
112
+ * Prevent double slashes in image asset URLs when building templates without an `ASSET_SERVER` environment variable
113
+ * Only creates a build subfolder if it exists
114
+ * Preserves `&nbsp;` in code
115
+
116
+ __Updated__
117
+
118
+ * Various code cleanup
119
+ * Updated project templates
120
+ * Added default font styles
121
+ * Updated meta tags in layout to support media queries on Windows Phone
122
+ * Added more getting started text in demo email
123
+ * Added sample placeholder image for `image_tag` example
124
+ * Added `button` helper examples
125
+ * Added examples using partials
126
+ * Updated sample .ruby-version to use latest version of ruby
127
+ * Removed deprecated button defualts via `config.yml`. Use CSS instead
128
+
129
+
130
+ ## 0.0.7
131
+
132
+ Released: 13 Nov 2014
133
+
134
+ __Added__
135
+
136
+ * Added `data/config.yml` to store global defaults, e.g. button colors. Updated new project templates to reflect this.
137
+
138
+ __Updated__
139
+
140
+ * Changed button markup to use Litmus Bulletproof strategy
141
+ * Updated CSS organization; use underscore prefixes for included styles
142
+ * Only parses data YAML if we have it; fixes errors from `symbolize_keys!` on `false`
143
+
144
+ __Removed__
145
+
146
+ * Removed Rake tasks remnants, including `Rakefile`
147
+ * Removed `Sinatra::ConfigFile`
148
+
149
+
150
+ ## 0.0.6
151
+
152
+ Released: 6 Nov 2014
153
+
154
+ __Added__
155
+
156
+ * Added `$antwort remove [EMAIL_ID]` command to remove emails, incl. css and image assets
157
+ * Allows upload of shared images directory via `$antwort upload shared`
158
+ * New emails get a blank title
159
+ * Add username password to new project `init`
160
+
161
+ __Fixed__
162
+
163
+ * Defaults border color to background color if no border color is defined
164
+ * Always render 404 with content_type `text/html`
165
+
166
+
167
+ ## 0.0.5
168
+
169
+ Released: 15 Oct 2014
170
+
171
+ __Added__
172
+
173
+ * Added `$ antwort send [EMAIL_ID]` command to send emails
174
+ * Added `$ antwort list` command to list all emails
175
+
176
+ __Fixed__
177
+
178
+ * Respect port number option when running server
179
+
180
+ __Removed__
181
+
182
+ * Removed `send.rake`
183
+ * Removed duplicate dotenv load in `upload.rb`
184
+
185
+
186
+ ## 0.0.4
187
+
188
+ Released: 13 Oct 2014
189
+
190
+ __Added__
191
+
192
+ * Added `$ antwort build` command to build emails
193
+ * Added `$ antwort prune` command to empty `./build` directory
194
+ * Added `$ antwort version` to output version, with `--version` option on executable
195
+ * Made `bundle` and `git init` optional when initializing new antwort project
196
+ * Various CLI output improvements
197
+ * Various new project template improvements
198
+
199
+ __Removed__
200
+
201
+ * Removed `build.rake` tasks after integrating them into antwort executable
202
+
203
+
204
+ ## 0.0.3
205
+
206
+ Released: 7 Oct 2014
207
+
208
+ __Added__
209
+
210
+ * Added `$ antwort server` command
211
+ * Styled server pages
212
+
213
+ - Lists all templates by title
214
+ - If no templates, shows message to add one
215
+ - Styled 404 template not found page
216
+ * Refactored Builder
217
+
218
+ - Builder now uses regex to remove rack live reload code
219
+ - Cleaned up CSS markup required for inlining css. Removed `roadie` references from project templates.
220
+ - Templates now use just `styles.scss` (inlined) and `responsive.scss` (outputed to `<head>`)
221
+ * Individual email metadata via YAML frontmatter
222
+ * Custom layouts per email via metadata
223
+ * Adjusted templates included in project initializer based on code changes
224
+ * Added some specs for Antwort::Server
225
+
226
+
227
+ __Fixed__
228
+
229
+ * Fixed port number, should be 9292 instead of 9494.
230
+ * Include `lib/cli/upload` too
231
+ * `image_tag` now respects absolute URLs starting with `http:` or `https:`
232
+ * `image_tag` only prefxes template directory to path if image src does *not* start with `/`
233
+
234
+
235
+ ## 0.0.2
236
+
237
+ Released: 8 Sept 2014
238
+
239
+ __Added__
240
+
241
+ * Gemified antwort generator
242
+ * Added `antwort` CLI
243
+ * `$ antwort init MY_PROJECT` initializes the project
244
+ * `$ antwort new FOO_LETTER` sets up a new email
245
+ * `$ antwort upload FOO_LETTER` uploads the assets to Amazon S3
246
+
247
+ __Fixed__
248
+
249
+ * Create `./build` directory if it does not exist
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,14 @@
1
+ # Note: The cmd option is now required due to the increasing number of ways
2
+ # rspec may be run, below are examples of the most common uses.
3
+ # * bundler: 'bundle exec rspec'
4
+ # * bundler binstubs: 'bin/rspec'
5
+ # * spring: 'bin/rsspec' (This will use spring if running and you have
6
+ # installed the spring binstubs per the docs)
7
+ # * zeus: 'zeus rspec' (requires the server to be started separetly)
8
+ # * 'just' rspec: 'rspec'
9
+ guard :rspec, cmd: 'bundle exec rspec', results_file: File.expand_path('tmp/rspec_guard_result') do
10
+ watch(%r{^spec/.+_spec\.rb$})
11
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
12
+ watch('spec/spec_helper.rb') { "spec" }
13
+ end
14
+
data/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # Antwort E-Mail Generator
2
+
3
+ Author: Julie Ng
4
+ Version 0.0.12 (14 March 2016)
5
+
6
+
7
+ ### Speed up your email design and development workflow:
8
+
9
+ - design in code with **live preview** of markup using Antwort's local development server
10
+ - **build html** and **inline css** from multiple templates
11
+ - **upload images** to content server (S3 only)
12
+ - **send email** test via SMTP
13
+ - includes **useful helpers**, e.g. `image_tag` that automatically includes email specific markup.
14
+
15
+ See [CHANGELOG.md](https://github.com/jng5/antwort-generator/blob/master/CHANGELOG.md) for full functionality list.
16
+
17
+ ## Setup
18
+
19
+ ### Requirements
20
+
21
+ - [Bundler](http://bundler.io/)
22
+ - Ruby 2.0+
23
+ - AWS S3 Account, for email upload (optional)
24
+ - SMTP credentials, for sending test emails (optional)
25
+
26
+ ### Environment
27
+
28
+ In the project root, create a `.env` file with the following attributes
29
+
30
+
31
+ ASSET_SERVER: https://example.s3.amazonaws.com
32
+ AWS_ACCESS_KEY_ID: {{aws_access_key_id}}
33
+ AWS_SECRET_ACCESS_KEY: {{aws_secret_access_key}}
34
+ AWS_BUCKET: example
35
+ FOG_REGION: eu-west-1
36
+
37
+ SMTP_SERVER: smtp.mandrillapp.com
38
+ SMTP_PORT: 587
39
+ SMTP_USERNAME: {{username}}
40
+ SMTP_PASSWORD: {{password}}
41
+ SMTP_DOMAIN: {{domain}}
42
+ SEND_TO: {{default_recipient}}
43
+ SEND_FROM: {{default_sender}}
44
+
45
+ See `.env.sample` for an example.
46
+
47
+ ## Use
48
+
49
+ ### Structure
50
+
51
+ .
52
+ +-- .env
53
+ +-- build
54
+ +-- assets
55
+ | +-- css
56
+ | +-- images
57
+ +-- emails
58
+ +-- views
59
+ +-- tmp
60
+
61
+
62
+ To create a new email template, for example `newsletter`, simply run: `bundle exec antwort new newsletter` and all the proper files will be created for you.
63
+
64
+
65
+
66
+ ## Commands
67
+
68
+
69
+ ```
70
+ Commands:
71
+ antwort build EMAIL_ID # Builds email markup and inlines CSS from source
72
+ antwort help [COMMAND] # Describe available commands or one specific command
73
+ antwort init PROJECT_NAME # Initializes a new Antwort Email project
74
+ antwort list # Lists all emails in the ./emails directory by id
75
+ antwort new EMAIL_ID # Creates a new email template
76
+ antwort prune # Removes all files in the ./build directory
77
+ antwort send EMAIL_ID # Sends built email via SMTP
78
+ antwort server # Starts http://localhost:9292 server for coding and previewing emails
79
+ antwort upload EMAIL_ID # Uploads email assets to AWS S3
80
+ antwort version # ouputs version number
81
+ ```
82
+
83
+ __Notes__
84
+
85
+ - You should run the commands prefixed with `bundle exec` to make sure the correct version of gems are used.
86
+
87
+
88
+ ## License (MIT)
89
+
90
+ Copyright (c) 2014-2016 Julie Ng.
91
+
92
+ Permission is hereby granted, free of charge, to any person obtaining a copy
93
+ of this software and associated documentation files (the "Software"), to deal
94
+ in the Software without restriction, including without limitation the rights
95
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
96
+ copies of the Software, and to permit persons to whom the Software is
97
+ furnished to do so, subject to the following conditions:
98
+
99
+ The above copyright notice and this permission notice shall be included in
100
+ all copies or substantial portions of the Software.
101
+
102
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
103
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
104
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
105
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
106
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
107
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
108
+ THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ ENV['gem_push'] = 'false'
2
+ require 'bundler/gem_tasks'
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task default: :spec
7
+
8
+ desc 'Opens a console with antwort preloaded'
9
+ task :console do
10
+ require 'pry'
11
+ require 'antwort'
12
+ include Antwort
13
+ Pry.start
14
+ end