Chimpmunk
Mailchimp list administration and Campaign builder. ( in development )
Installation
Add this line to your application's Gemfile:
gem 'chimpmunk'
And then execute:
$ bundle
Install with (make sure you have followed all rails_admin install steps first)
$ rails g chimpmunk:install
Post Installation
Install migrations
$ rake chimpmunk_engine:install:migrations
Run migrations
$ rake db:migrate
Set your mailchimp api key in an initializer:
Gibbon::API.api_key = "your_api_key"
Set your domain name in an initializer:
Chimpmunk.domain_name = 'example.com'
Usage
Create a new model for your campaign
app/models/test_email_campaign.rb
that extendsChimpmunk::EmailCampaign
Create headers, texts and images definitions for any strings, text or images needed in the campaign. These will be the same name as the MC:EDIT areas in your template
headers :hero_header, :bottom_header
texts :top_body, :info_body
images :hero_image, :logo, :footer_image
- If you need assocations with the email campaign, generate the association models and add the
associated
definition in the campaign.
associated :many, :posts, :comments
associated :one, :user
- 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 acampaign
local variable.
editable_areas :posts
example usage:
rails g model EmailCampaignPost email_campaign:references post:references
rails g model EmailCampaignComment email_campaign:references post:references
rails g model EmailCampaignUser email_campaign:references user:references
in app/models
:
class TestEmailCampaign < Chimpmunk::EmailCampaign
headers :hero_header, :bottom_header
texts :top_body, :info_body
images :hero_image, :logo, :test_image
associated :many, :posts, :comments # will have many :email_campaign_posts
associated :one, :user # will have one :email_campaign_comment
editable_areas :posts
rails_admin do
edit do
field :title
field :email_list
field :email_list_group
field :email_template
field :subject
field :from_name
field :from_email
field :send_date
field :hero_header
field :bottom_header
field :top_body
field :info_body
field :hero_image
field :logo
field :test_image
end
end
end
in app/views/chimpmunk/_posts.html.haml
, you should have an mc:edit
somewhere in your template called 'posts'
- posts.each do |post|
.post.span-6
%h1= post.name
%p= post.body
Contributing
- Fork it ( https://github.com/[my-github-username]/chimpmunk/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request