email_marketing 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/javascripts/email_marketing/application.js +13 -0
  6. data/app/assets/stylesheets/email_marketing/application.css +13 -0
  7. data/app/assets/stylesheets/scaffold.css +56 -0
  8. data/app/controllers/email_marketing/admin/admins_controller.rb +12 -0
  9. data/app/controllers/email_marketing/admin/marketing_deliveries_controller.rb +62 -0
  10. data/app/controllers/email_marketing/admin/marketing_lists_controller.rb +17 -0
  11. data/app/controllers/email_marketing/admin/marketing_templates_controller.rb +23 -0
  12. data/app/controllers/email_marketing/application_controller.rb +4 -0
  13. data/app/helpers/email_marketing/application_helper.rb +13 -0
  14. data/app/views/email_marketing/admin/marketing_deliveries/index.html.haml +12 -0
  15. data/app/views/email_marketing/admin/marketing_deliveries/new.html.haml +19 -0
  16. data/app/views/email_marketing/admin/marketing_lists/index.html.haml +10 -0
  17. data/app/views/email_marketing/admin/marketing_lists/show.html.haml +10 -0
  18. data/app/views/email_marketing/admin/marketing_templates/index.html.haml +10 -0
  19. data/app/views/email_marketing/admin/marketing_templates/show.html.haml +1 -0
  20. data/app/views/email_marketing/admin/shared/_menu.html.haml +12 -0
  21. data/app/views/email_marketing/marketing_templates/index.html.haml +0 -0
  22. data/app/views/layouts/blank.html.haml +1 -0
  23. data/config/routes.rb +9 -0
  24. data/lib/email_marketing.rb +4 -0
  25. data/lib/email_marketing/engine.rb +7 -0
  26. data/lib/email_marketing/version.rb +3 -0
  27. data/lib/tasks/email_marketing_tasks.rake +4 -0
  28. data/test/dummy/README.rdoc +28 -0
  29. data/test/dummy/Rakefile +6 -0
  30. data/test/dummy/app/assets/javascripts/application.js +13 -0
  31. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  32. data/test/dummy/app/controllers/application_controller.rb +5 -0
  33. data/test/dummy/app/helpers/application_helper.rb +2 -0
  34. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  35. data/test/dummy/bin/bundle +3 -0
  36. data/test/dummy/bin/rails +4 -0
  37. data/test/dummy/bin/rake +4 -0
  38. data/test/dummy/config.ru +4 -0
  39. data/test/dummy/config/application.rb +23 -0
  40. data/test/dummy/config/boot.rb +5 -0
  41. data/test/dummy/config/database.yml +25 -0
  42. data/test/dummy/config/environment.rb +5 -0
  43. data/test/dummy/config/environments/development.rb +29 -0
  44. data/test/dummy/config/environments/production.rb +80 -0
  45. data/test/dummy/config/environments/test.rb +36 -0
  46. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  47. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  48. data/test/dummy/config/initializers/inflections.rb +16 -0
  49. data/test/dummy/config/initializers/mime_types.rb +5 -0
  50. data/test/dummy/config/initializers/secret_token.rb +12 -0
  51. data/test/dummy/config/initializers/session_store.rb +3 -0
  52. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  53. data/test/dummy/config/locales/en.yml +23 -0
  54. data/test/dummy/config/routes.rb +4 -0
  55. data/test/dummy/log/development.log +0 -0
  56. data/test/dummy/public/404.html +58 -0
  57. data/test/dummy/public/422.html +58 -0
  58. data/test/dummy/public/500.html +57 -0
  59. data/test/dummy/public/favicon.ico +0 -0
  60. data/test/email_marketing_test.rb +7 -0
  61. data/test/integration/navigation_test.rb +10 -0
  62. data/test/test_helper.rb +15 -0
  63. metadata +182 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b6d8af79f3c75b6bbb44376116e4ca66422c938e
4
+ data.tar.gz: 264508c832cacf79e462c38a210cfb77be913da5
5
+ SHA512:
6
+ metadata.gz: 1dacf99edf4c03fc51ea6f5d625939f8c320795920b7505cf5cee37dd03f2764a2301b2056369abc199641fc27095f56d5af9622031b08d5916cfaca1b945084
7
+ data.tar.gz: ca86aab31dd32575feca1bb7c466c7b86950c4c68d0c2fa972fcf873d226b32ca1b6e366fde2dcba6c6ccb58e0c68456119fc8857467735df3346a32d985f4dd
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = EmailMarketing
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'EmailMarketing'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,12 @@
1
+ module EmailMarketing
2
+ module Admin
3
+ class AdminsController < ::Admin::AdminsController
4
+ helper EmailMarketing::ApplicationHelper
5
+
6
+ def marketing_connection
7
+ ::MarketingConnection::Base.new(api_key: ::MarketingConnection.api_key, api_secret: ::MarketingConnection.api_secret)
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,62 @@
1
+ module EmailMarketing
2
+ module Admin
3
+ class MarketingDeliveriesController < AdminsController
4
+ before_action :set_values, only: [:new, :create]
5
+
6
+ def index
7
+ response = marketing_connection.deliveries.list
8
+ @deliveries = response["deliveries"]
9
+ end
10
+
11
+ def new
12
+ @delivery = Delivery.new
13
+ end
14
+
15
+ def create
16
+ got_params = params.require(:admin_delivery).permit(:name, :domain, :gun_name, :template_id, :from, :list_id)
17
+ @delivery = Delivery.new(got_params)
18
+ @delivery.domain = @domains.first["name"] if @domains.count == 1
19
+ response = @delivery.submit
20
+ errors = response["errors"]
21
+ if errors
22
+ errors.each do |k,v|
23
+ k = k.to_s + "_id" if k == "template" || k == "list"
24
+ @delivery.errors.add(k.to_sym, v.first)
25
+ end
26
+ render "new"
27
+ else
28
+ redirect_to admin_marketing_deliveries_path, flash: {success: "Enviado"}
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def set_values
35
+ response = marketing_connection.lists.list
36
+ @lists = response["lists"]
37
+ response = marketing_connection.templates.list
38
+ @templates = response["templates"]
39
+ response = marketing_connection.guns.list
40
+ guns = response["guns"]
41
+ mailgun = Mailgun::Base.new(api_key: guns.first["key"])
42
+ @domains = mailgun.domains.list
43
+ end
44
+
45
+ end
46
+
47
+
48
+ class Delivery < AdminsController
49
+ include ActiveModel::Model
50
+ attr_accessor :name, :template_id, :from, :list_id, :domain, :gun, :gun_name
51
+
52
+
53
+ def submit
54
+ json = JSON(self.to_json)
55
+ parameters = {delivery: json}
56
+ response = marketing_connection.deliveries.create(parameters)
57
+ end
58
+
59
+ end
60
+
61
+ end
62
+ end
@@ -0,0 +1,17 @@
1
+ module EmailMarketing
2
+ module Admin
3
+ class MarketingListsController < AdminsController
4
+
5
+ def index
6
+ response = marketing_connection.lists.list
7
+ @lists = response["lists"]
8
+ end
9
+
10
+ def show
11
+ response = marketing_connection.lists.find(params[:id])
12
+ @emails = response["emails"]
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,23 @@
1
+ module EmailMarketing
2
+ module Admin
3
+ class MarketingTemplatesController < AdminsController
4
+ layout :get_layout
5
+ def index
6
+ response = marketing_connection.templates.list
7
+ @templates = response["templates"]
8
+ end
9
+
10
+ def show
11
+ response = marketing_connection.templates.find(params[:id])
12
+ @template = response
13
+ end
14
+
15
+
16
+ private
17
+ def get_layout
18
+ "blank" if action_name == "show"
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ module EmailMarketing
2
+ class ApplicationController #< #ActionController::Base#::Admin::AdminsController
3
+ end
4
+ end
@@ -0,0 +1,13 @@
1
+ module EmailMarketing
2
+ module ApplicationHelper
3
+
4
+ def method_missing(method, *args, &block)
5
+ if (method.to_s.end_with?('_path') || method.to_s.end_with?('_url')) && main_app.respond_to?(method)
6
+ main_app.send(method, *args)
7
+ else
8
+ super
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ =render "email_marketing/admin/shared/menu"
2
+ %h1.page-header Envíos
3
+
4
+ =link_to "Nuevo", new_admin_marketing_delivery_path, class: "btn btn-primary"
5
+ %table.table.table-striped.table-hover
6
+ %thead
7
+ %tr
8
+ %th Nombre
9
+ %tbody
10
+ -@deliveries.each do |delivery|
11
+ %tr
12
+ %td=delivery["name"]
@@ -0,0 +1,19 @@
1
+ %h1.page-header Nuevo envio
2
+
3
+ =simple_form_for @delivery, url: admin_marketing_deliveries_path do |f|
4
+ =@delivery.errors.inspect
5
+ .row
6
+ .col-md-6
7
+ = f.input :name
8
+ .row
9
+ .col-md-6
10
+ = f.input :domain, collection: @domains.map{|h| h["name"]} if @domains.count > 1
11
+ =# f.input :gun_name, as: :string
12
+ .col-md-6
13
+ = f.input :from
14
+ .row
15
+ .col-md-6
16
+ = f.input :template_id, collection: @templates.map{|h| [h["name"], h["id"]]}
17
+ .col-md-6
18
+ = f.input :list_id, collection: @lists.map{|h| [h["name"], h["id"]]}
19
+ =f.submit "Guardar", class: "btn btn-primary"
@@ -0,0 +1,10 @@
1
+ =render "email_marketing/admin/shared/menu"
2
+ %h1.page-header Listas
3
+ %table.table.table-striped.table-hover
4
+ %thead
5
+ %tr
6
+ %th Nombre
7
+ %tbody
8
+ -@lists.each do |list|
9
+ %tr
10
+ %td=link_to list["name"], admin_marketing_list_path(list["slug"])
@@ -0,0 +1,10 @@
1
+ =render "email_marketing/admin/shared/menu"
2
+ %h1.page-header Lista - #{params[:id]}
3
+ %table.table.table-striped.table-hover
4
+ %thead
5
+ %tr
6
+ %th Email
7
+ %tbody
8
+ -@emails.each do |email|
9
+ %tr
10
+ %td= email["email"]
@@ -0,0 +1,10 @@
1
+ =render "email_marketing/admin/shared/menu"
2
+ %h1.page-header Templates
3
+ %table.table.table-striped.table-hover
4
+ %thead
5
+ %tr
6
+ %th Nombre
7
+ %tbody
8
+ -@templates.each do |template|
9
+ %tr
10
+ %td=link_to template["name"], admin_marketing_template_path(template["slug"])
@@ -0,0 +1 @@
1
+ =@template["content"].html_safe
@@ -0,0 +1,12 @@
1
+ %ul.nav.nav-pills
2
+ %li.admin_marketing_lists= link_to "Listas", admin_marketing_lists_path
3
+ %li.admin_marketing_templates= link_to "Templates", admin_marketing_templates_path
4
+ %li.admin_marketing_deliveries= link_to "Envios", admin_marketing_deliveries_path
5
+
6
+
7
+
8
+ :coffeescript
9
+ $ ->
10
+ class_name = ".admin_#{controller_name}"
11
+ console.log class_name
12
+ $(class_name).addClass("active")
@@ -0,0 +1 @@
1
+ =yield
data/config/routes.rb ADDED
@@ -0,0 +1,9 @@
1
+ EmailMarketing::Engine.routes.draw do
2
+
3
+ namespace :admin do
4
+ resources :marketing_templates, only: [:index, :show]
5
+ resources :marketing_lists, only: [:index, :show]
6
+ resources :marketing_deliveries, only: [:index, :new, :create]
7
+ end
8
+
9
+ end
@@ -0,0 +1,4 @@
1
+ require "email_marketing/engine"
2
+
3
+ module EmailMarketing
4
+ end
@@ -0,0 +1,7 @@
1
+ module EmailMarketing
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace EmailMarketing
4
+ require "mailgun"
5
+ require "marketing_connection"
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module EmailMarketing
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :email_marketing do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.