chimpmunk 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d386eba35aefc48e80041d30e14d09a76405b46
4
- data.tar.gz: 4666331e2c9a3af08a8dad237f88795ca8004359
3
+ metadata.gz: f3cdedd77cb163a90c5a283b3c8bb07d24ef9c9c
4
+ data.tar.gz: 338e3a9c77dddf0fe3b8b0170102fc014e988266
5
5
  SHA512:
6
- metadata.gz: 9af58d721920b15da3585335185bff6ba724eb2c99ded5204b7d7d55ffaec316cdac28c7957b91c00629c16b692e46f4788fceb0f205db78a042ddf530251645
7
- data.tar.gz: 333c516acc181af90045ef63d2a054eb9e64b2cf8037b10eeebaf4d61a122cedcbaaf39162e548e39b2bfb71dcaf491895afb9d36fda92360709f122325a10f4
6
+ metadata.gz: bf04cb13c4be53c944ce7726bbf5781d9cee7a1e7c82074e907abd8c9490c50de89ae0b4ce493f05c0e79e8daaf2cc644be70e8c9a6b5631195704d16cc44c10
7
+ data.tar.gz: da88388e5fb6b2b483480c7cb69c0109f838b4802bf5e6721008e0c24d865d3d3c3581da8cf82b12bb9af55c297e10d6feebca592b600ecf053d325e48c6ea2e
data/README.md CHANGED
@@ -36,28 +36,43 @@ Set your mailchimp api key:
36
36
 
37
37
  2. create headers, texts and images definitions for any strings, text or images needed in the campaign.
38
38
 
39
- 3. If you need assocations with the email campaign, generate the association models and add the `associated` definition in the email campaign subclass.
39
+ ```
40
+ headers :hero_header, :bottom_header
41
+ texts :top_body, :info_body
42
+ images :hero_image, :logo, :footer_image
43
+ ```
40
44
 
41
- 4. override the content method, details coming soon
45
+ 3. If you need assocations with the email campaign, generate the association models and add the `associated` definition in the campaign.
42
46
 
47
+ ```
48
+ associated :many, :posts, :comments
49
+ associated :one, :user
50
+ ```
43
51
 
44
- example:
52
+ 4. Create editable_area definitions. These will be the same name as the MC:EDIT areas in your template. Create the partials for then in `app/viaews/chimpmunk/_posts.html.haml` All chimpmunk partials will have access to a `campaign` local variable.
53
+
54
+ ```
55
+ editable_areas :posts
56
+ ```
45
57
 
58
+ example usage:
46
59
 
47
60
  ```
48
61
  rails g model EmailCampaignPost email_campaign:references post:references
49
62
  rails g model EmailCampaignComment email_campaign:references post:references
63
+ rails g model EmailCampaignUser email_campaign:references user:references
50
64
  ```
51
65
 
52
-
66
+ in `app/models` :
53
67
 
54
68
  ```
55
69
  class TestEmailCampaign < Chimpmunk::EmailCampaign
56
70
  headers :hero_header, :bottom_header
57
71
  texts :top_body, :info_body
58
72
  images :hero_image, :logo, :test_image
59
- associated :many, :posts # will have many :email_campaign_posts
60
- associated :one, :comment # will have one :email_campaign_comment
73
+ associated :many, :posts, :comments # will have many :email_campaign_posts
74
+ associated :one, :user # will have one :email_campaign_comment
75
+ editable_areas :posts
61
76
 
62
77
  #
63
78
  # must have a content method
@@ -67,7 +82,7 @@ example:
67
82
  {sections: sections}
68
83
  end
69
84
 
70
- rails_admin down
85
+ rails_admin do
71
86
  edit do
72
87
  field :title
73
88
  field :email_list
@@ -88,6 +103,16 @@ example:
88
103
  end
89
104
  end
90
105
  ```
106
+
107
+ in `app/views/chimpmunk/_posts.html.haml`, you should have an `mc:edit` somewhere in your template called 'posts'
108
+
109
+ ```
110
+ - campaign.email_campaign_posts.map(&:post).each do |post|
111
+ .post.span-6
112
+ %h1= post.name
113
+ %p= post.body
114
+ ```
115
+
91
116
  ## Contributing
92
117
 
93
118
  1. Fork it ( https://github.com/[my-github-username]/chimpmunk/fork )
@@ -3,6 +3,9 @@ module Chimpmunk
3
3
  class EmailCampaign < ::ActiveRecord::Base
4
4
  attr_accessor :skip_update_callbacks, :skip_create_callbacks
5
5
 
6
+ # MC:EDIT tags used in email template sections
7
+ @@mc_edit_tags = []
8
+
6
9
  # rails 3
7
10
  attr_accessible :title, :from_email, :from_name, :email_list_id, :subject, :email_template_id, :mailchimp_list_id, :send_date,
8
11
  :mailchimp_campaign_id, :emails_sent, :clicked, :opened, :status, :hard_bounces, :soft_bounces, :unsubscribes, :forwards,
@@ -62,6 +65,17 @@ module Chimpmunk
62
65
  end
63
66
  end
64
67
 
68
+ #
69
+ # store mc:edit tag names
70
+ #
71
+ def self.editable_areas(*mc_edit_tags)
72
+ @@mc_edit_tags = mc_edit_tags
73
+ end
74
+
75
+ def self.mc_edit_tags
76
+ @@mc_edit_tags
77
+ end
78
+
65
79
  #
66
80
  # create has_many associations
67
81
  #
@@ -169,14 +183,24 @@ module Chimpmunk
169
183
  end
170
184
  end
171
185
 
172
- ##
173
- # TODO: figure out how to do this
174
- # returns the html content for the new campaign
186
+ private
187
+
188
+ #
189
+ # content for campaign
190
+ #
175
191
  def content
176
- raise "Content must be overriden"
177
- end
192
+ sections = {}
178
193
 
179
- private
194
+ @@tags.each do |tag|
195
+ directory = "chimpmunk"
196
+
197
+ if File.directory?("app/views/#{directory}") && !Dir["app/views/#{directory}/_#{tag}**"].empty?
198
+ sections[tag] = action_view.render "#{directory}/#{tag}", campaign: self
199
+ end
200
+ end
201
+
202
+ {sections: sections}
203
+ end
180
204
 
181
205
  def action_view
182
206
  @action_view ||= ActionView::Base.new(Rails.configuration.paths["app/views"])
@@ -1,3 +1,3 @@
1
1
  module Chimpmunk
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chimpmunk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Franken
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-12 00:00:00.000000000 Z
11
+ date: 2015-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord