mvpkit 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/mvpkit.gemspec +135 -76
  4. data/project/.gitignore +43 -14
  5. data/project/Gemfile +7 -3
  6. data/project/Gemfile.lock +500 -0
  7. data/project/Procfile +1 -1
  8. data/project/app/assets/javascripts/application.js +5 -1
  9. data/project/app/assets/javascripts/cable.js +12 -0
  10. data/project/app/assets/javascripts/pack-compiled.js +37394 -0
  11. data/project/app/assets/javascripts/pack-compiled.js.map +1 -0
  12. data/project/app/assets/stylesheets/application.scss +3 -1
  13. data/project/app/assets/stylesheets/pack-compiled.css +33946 -0
  14. data/project/app/assets/stylesheets/pack-compiled.css.map +1 -0
  15. data/project/app/controllers/application_controller.rb +13 -4
  16. data/project/app/engines/admin/.gitignore +7 -0
  17. data/project/app/engines/admin/Gemfile +14 -0
  18. data/project/app/engines/admin/Gemfile.lock +118 -0
  19. data/project/app/engines/admin/MIT-LICENSE +20 -0
  20. data/project/app/engines/admin/README.md +28 -0
  21. data/project/app/engines/admin/Rakefile +37 -0
  22. data/project/app/engines/admin/admin.gemspec +22 -0
  23. data/project/app/engines/admin/app/assets/config/admin_manifest.js +2 -0
  24. data/project/app/engines/admin/app/assets/images/admin/.keep +0 -0
  25. data/project/app/engines/admin/app/assets/javascripts/admin/application.js +13 -0
  26. data/project/app/engines/admin/app/assets/stylesheets/admin/application.css +15 -0
  27. data/project/app/engines/admin/app/controllers/admin/application_controller.rb +5 -0
  28. data/project/app/engines/admin/app/controllers/admin/conversions_controller.rb +64 -0
  29. data/project/app/engines/admin/app/controllers/admin/users_controller.rb +62 -0
  30. data/project/app/engines/admin/app/helpers/admin/application_helper.rb +4 -0
  31. data/project/app/engines/admin/app/helpers/admin/conversions_helper.rb +4 -0
  32. data/project/app/engines/admin/app/helpers/admin/users_helper.rb +4 -0
  33. data/project/app/engines/admin/app/jobs/admin/application_job.rb +4 -0
  34. data/project/app/engines/admin/app/mailers/admin/application_mailer.rb +6 -0
  35. data/project/app/engines/admin/app/models/admin/application_record.rb +5 -0
  36. data/project/app/engines/admin/app/views/admin/conversions/_form.html.erb +11 -0
  37. data/project/app/engines/admin/app/views/admin/conversions/edit.html.erb +3 -0
  38. data/project/app/engines/admin/app/views/admin/conversions/index.html.erb +31 -0
  39. data/project/app/engines/admin/app/views/admin/conversions/new.html.erb +3 -0
  40. data/project/app/engines/admin/app/views/admin/conversions/show.html.erb +13 -0
  41. data/project/app/engines/admin/app/views/admin/users/_form.html.erb +22 -0
  42. data/project/app/engines/admin/app/views/admin/users/edit.html.erb +6 -0
  43. data/project/app/engines/admin/app/views/admin/users/index.html.erb +27 -0
  44. data/project/app/engines/admin/app/views/admin/users/new.html.erb +5 -0
  45. data/project/app/engines/admin/app/views/admin/users/show.html.erb +9 -0
  46. data/project/app/engines/admin/app/views/layouts/admin/_header.html.erb +21 -0
  47. data/project/app/engines/admin/app/views/layouts/admin/application.html.erb +5 -0
  48. data/project/app/engines/admin/bin/rails +13 -0
  49. data/project/app/engines/admin/config/routes.rb +6 -0
  50. data/project/app/engines/admin/lib/admin/engine.rb +5 -0
  51. data/project/app/engines/admin/lib/admin/version.rb +3 -0
  52. data/project/app/engines/admin/lib/admin.rb +5 -0
  53. data/project/app/engines/admin/lib/tasks/admin_tasks.rake +4 -0
  54. data/project/app/engines/admin/test/admin_test.rb +7 -0
  55. data/project/app/engines/admin/test/controllers/admin/conversions_controller_test.rb +52 -0
  56. data/project/app/engines/admin/test/controllers/admin/users_controller_test.rb +52 -0
  57. data/project/app/engines/admin/test/integration/navigation_test.rb +8 -0
  58. data/project/app/engines/admin/test/test_helper.rb +20 -0
  59. data/project/app/models/application_record.rb +3 -0
  60. data/project/app/models/conversion.rb +1 -2
  61. data/project/app/models/user.rb +6 -0
  62. data/project/app/views/layouts/_header.html.erb +17 -20
  63. data/project/app/views/static/internal_server_error.html.erb +1 -0
  64. data/project/app/views/static/not_found.html.erb +1 -0
  65. data/project/app/webpack/javascripts/lib/analytics.js +22 -0
  66. data/project/app/webpack/javascripts/lib/controllers.js +28 -0
  67. data/project/app/webpack/javascripts/lib/forms.js +28 -0
  68. data/project/app/webpack/javascripts/pack.js +11 -8
  69. data/project/app/webpack/stylesheets/config/variables.scss +1 -1
  70. data/project/app/webpack/stylesheets/skin/tables.scss +14 -0
  71. data/project/config/application.rb +2 -2
  72. data/project/config/initializers/devise.rb +277 -0
  73. data/project/config/initializers/stripe.rb +0 -7
  74. data/project/config/locales/devise.en.yml +64 -0
  75. data/project/config/routes.rb +2 -0
  76. data/project/db/migrate/2017000000000_add_uuid_pk_by_default.rb +5 -0
  77. data/project/db/migrate/20170415224839_create_conversions.rb +9 -0
  78. data/project/db/migrate/20170415225327_devise_create_users.rb +42 -0
  79. data/project/db/schema.rb +20 -3
  80. data/project/package.json +7 -7
  81. metadata +64 -5
  82. data/project/config/initializers/rails_admin.rb +0 -49
  83. data/project/db/migrate/20160728235100_create_conversions.rb +0 -9
@@ -0,0 +1,21 @@
1
+ <nav class="navbar navbar-toggleable-md navbar-inverse bg-inverse">
2
+ <div class="container">
3
+ <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
4
+ <span class="navbar-toggler-icon"></span>
5
+ </button>
6
+ <a class="navbar-brand" href="/">__PROJECT_NAME__ <span class="text-danger">Admin</span></a>
7
+
8
+ <div class="collapse navbar-collapse" id="navbarSupportedContent">
9
+ <ul class="navbar-nav mr-auto">
10
+ </ul>
11
+ <ul class="navbar-nav">
12
+ <li class="nav-item <%= 'active' if controller_name == 'conversions' %>">
13
+ <%= link_to 'Conversions', conversions_path, class: "nav-link" %>
14
+ </li>
15
+ <li class="nav-item <%= 'active' if controller_name == 'users' %>">
16
+ <%= link_to 'Users', users_path, class: "nav-link" %>
17
+ </li>
18
+ </ul>
19
+ </div>
20
+ </div>
21
+ </nav>
@@ -0,0 +1,5 @@
1
+ <%- content_for :header do %>
2
+ <%= render 'layouts/admin/header' %>
3
+ <% end %>
4
+
5
+ <%= render template: "layouts/application" %>
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
6
+ ENGINE_PATH = File.expand_path('../../lib/admin/engine', __FILE__)
7
+
8
+ # Set up gems listed in the Gemfile.
9
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
10
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
11
+
12
+ require 'rails/all'
13
+ require 'rails/engine/commands'
@@ -0,0 +1,6 @@
1
+ Admin::Engine.routes.draw do
2
+ resources :conversions
3
+ resources :users
4
+
5
+ root to: redirect('conversions')
6
+ end
@@ -0,0 +1,5 @@
1
+ module Admin
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Admin
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Admin
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,5 @@
1
+ require "admin/engine"
2
+
3
+ module Admin
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :admin do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class Admin::Test < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, Admin
6
+ end
7
+ end
@@ -0,0 +1,52 @@
1
+ require 'test_helper'
2
+
3
+ module Admin
4
+ class ConversionsControllerTest < ActionDispatch::IntegrationTest
5
+ include Engine.routes.url_helpers
6
+
7
+ setup do
8
+ @conversion = admin_conversions(:one)
9
+ end
10
+
11
+ test "should get index" do
12
+ get conversions_url
13
+ assert_response :success
14
+ end
15
+
16
+ test "should get new" do
17
+ get new_conversion_url
18
+ assert_response :success
19
+ end
20
+
21
+ test "should create conversion" do
22
+ assert_difference('Conversion.count') do
23
+ post conversions_url, params: { conversion: { email: @conversion.email } }
24
+ end
25
+
26
+ assert_redirected_to conversion_url(Conversion.last)
27
+ end
28
+
29
+ test "should show conversion" do
30
+ get conversion_url(@conversion)
31
+ assert_response :success
32
+ end
33
+
34
+ test "should get edit" do
35
+ get edit_conversion_url(@conversion)
36
+ assert_response :success
37
+ end
38
+
39
+ test "should update conversion" do
40
+ patch conversion_url(@conversion), params: { conversion: { email: @conversion.email } }
41
+ assert_redirected_to conversion_url(@conversion)
42
+ end
43
+
44
+ test "should destroy conversion" do
45
+ assert_difference('Conversion.count', -1) do
46
+ delete conversion_url(@conversion)
47
+ end
48
+
49
+ assert_redirected_to conversions_url
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,52 @@
1
+ require 'test_helper'
2
+
3
+ module Admin
4
+ class UsersControllerTest < ActionDispatch::IntegrationTest
5
+ include Engine.routes.url_helpers
6
+
7
+ setup do
8
+ @user = admin_users(:one)
9
+ end
10
+
11
+ test "should get index" do
12
+ get users_url
13
+ assert_response :success
14
+ end
15
+
16
+ test "should get new" do
17
+ get new_user_url
18
+ assert_response :success
19
+ end
20
+
21
+ test "should create user" do
22
+ assert_difference('User.count') do
23
+ post users_url, params: { user: { email: @user.email } }
24
+ end
25
+
26
+ assert_redirected_to user_url(User.last)
27
+ end
28
+
29
+ test "should show user" do
30
+ get user_url(@user)
31
+ assert_response :success
32
+ end
33
+
34
+ test "should get edit" do
35
+ get edit_user_url(@user)
36
+ assert_response :success
37
+ end
38
+
39
+ test "should update user" do
40
+ patch user_url(@user), params: { user: { email: @user.email } }
41
+ assert_redirected_to user_url(@user)
42
+ end
43
+
44
+ test "should destroy user" do
45
+ assert_difference('User.count', -1) do
46
+ delete user_url(@user)
47
+ end
48
+
49
+ assert_redirected_to users_url
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class NavigationTest < ActionDispatch::IntegrationTest
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
8
+
@@ -0,0 +1,20 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
5
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
6
+ ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__)
7
+ require "rails/test_help"
8
+
9
+ # Filter out Minitest backtrace while allowing backtrace from other libraries
10
+ # to be shown.
11
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
12
+
13
+
14
+ # Load fixtures from the engine
15
+ if ActiveSupport::TestCase.respond_to?(:fixture_path=)
16
+ ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
17
+ ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
18
+ ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files"
19
+ ActiveSupport::TestCase.fixtures :all
20
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -1,4 +1,3 @@
1
- class Conversion < ActiveRecord::Base
2
- # validates :name, presence: true
1
+ class Conversion < ApplicationRecord
3
2
  validates :email, presence: true, uniqueness: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i }
4
3
  end
@@ -0,0 +1,6 @@
1
+ class User < ApplicationRecord
2
+ # Include default devise modules. Others available are:
3
+ # :confirmable, :lockable, :timeoutable and :omniauthable
4
+ devise :database_authenticatable, :registerable,
5
+ :recoverable, :rememberable, :trackable, :validatable
6
+ end
@@ -1,24 +1,21 @@
1
1
  <nav class="navbar navbar-toggleable-md navbar-light bg-faded">
2
- <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
3
- <span class="navbar-toggler-icon"></span>
4
- </button>
5
- <a class="navbar-brand" href="/">__PROJECT_NAME__</a>
2
+ <div class="container">
3
+ <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
4
+ <span class="navbar-toggler-icon"></span>
5
+ </button>
6
+ <a class="navbar-brand" href="/">__PROJECT_NAME__</a>
6
7
 
7
- <div class="collapse navbar-collapse" id="navbarSupportedContent">
8
- <ul class="navbar-nav mr-auto">
9
- <li class="nav-item active">
10
- <%= link_to 'Examples', examples_path, class: 'nav-link' %>
11
- </li>
12
- <li class="nav-item">
13
- <a class="nav-link" href="#">Link</a>
14
- </li>
15
- <li class="nav-item">
16
- <a class="nav-link disabled" href="#">Disabled</a>
17
- </li>
18
- </ul>
19
- <form class="form-inline my-2 my-lg-0">
20
- <input class="form-control mr-sm-2" type="text" placeholder="Search">
21
- <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
22
- </form>
8
+ <div class="collapse navbar-collapse" id="navbarSupportedContent">
9
+ <ul class="navbar-nav mr-auto">
10
+ </ul>
11
+ <ul class="navbar-nav">
12
+ <li class="nav-item">
13
+ <%= link_to 'Examples', examples_path, class: 'nav-link' %>
14
+ </li>
15
+ <li class="nav-item">
16
+ <%= link_to 'Admin', admin_path, class: 'nav-link' %>
17
+ </li>
18
+ </ul>
19
+ </div>
23
20
  </div>
24
21
  </nav>
@@ -0,0 +1 @@
1
+ <h1>500 Server Error</h1>
@@ -0,0 +1 @@
1
+ <h1>404 Not Found</h1>
@@ -0,0 +1,22 @@
1
+ window.track = function(event, attributes, fn){
2
+ console.log("Track: " + event + " " + JSON.stringify(attributes))
3
+
4
+ if (is.fn(attributes)) fn = attributes, attributes = null;
5
+ if (is.undefined(attributes)) { attributes = {} }
6
+ if ($.cookie('invisible') == "true") {
7
+ if (!is.undefined(fn)) { fn() }
8
+ return
9
+ }
10
+
11
+ var attrs = _.extend({
12
+ iteration: $('body').data('iteration')
13
+ }, attributes)
14
+
15
+ if (typeof(analytics) != 'undefined') {
16
+ analytics.track(event, attrs, fn);
17
+ }
18
+
19
+ if (typeof(amplitude) != 'undefined') {
20
+ amplitude.getInstance().logEvent(event, attrs, fn);
21
+ }
22
+ }
@@ -0,0 +1,28 @@
1
+ window.controllers = {}
2
+
3
+ let handler = function(){
4
+ var $body = $("body");
5
+ var controller = $body.data("controller").replace(/\//g, "_");
6
+ var action = $body.data("action");
7
+
8
+ var activeController = window.controllers[controller];
9
+
10
+ if (activeController !== undefined) {
11
+ if (window.env == "development") {
12
+ console.log("[Controllers] " + controller + "." + action + "()");
13
+ }
14
+
15
+ if ($.isFunction(activeController.init)) {
16
+ activeController.init();
17
+ }
18
+
19
+ if ($.isFunction(activeController[action])) {
20
+ activeController[action]();
21
+ }
22
+ }
23
+ }
24
+
25
+ $(function(){
26
+ document.addEventListener("turbolinks:load", handler)
27
+ handler()
28
+ })
@@ -0,0 +1,28 @@
1
+ const _ = require('lodash')
2
+ const is = require('is')
3
+
4
+ $(function(){
5
+ $('form.no-enter-submit').bind("keypress", function(e) {
6
+ if (e.keyCode == 13) {
7
+ e.preventDefault();
8
+ return false;
9
+ }
10
+ });
11
+
12
+ $('form.disable-on-submit').on('submit', function(e){
13
+ $(this).find(".btn").addClass('disabled')
14
+ })
15
+ })
16
+
17
+ // Submit forms when you command + enter on a textarea
18
+ // $(function(){
19
+ // // submit form on command + enter if in a textarea
20
+ // $(document).on('keydown', 'body', function(e) {
21
+ // if (!(e.keyCode == 13 && e.metaKey)) return;
22
+ //
23
+ // var $target = $(e.target);
24
+ // if ($target.is('textarea')) {
25
+ // $target.closest('form').submit();
26
+ // }
27
+ // });
28
+ // });
@@ -1,22 +1,25 @@
1
- // Courtesy of https://medium.com/@chrismnicola/leaving-sprockets-for-webpack-ccf7c6993ffa
2
- function requireAll(r) { r.keys().forEach(r); }
3
- function requireTree(path) { requireAll(require.context('./', true, /\.(js|coffee)$/)) }
1
+ // https://webpack.github.io/docs/context.html#require-context
2
+ function requireAll(requireContext) {
3
+ return requireContext.keys().map(requireContext);
4
+ }
4
5
 
5
6
  window.$ = window.jQuery = require('jquery')
6
7
  window._ = require('lodash')
7
8
  window.is = require('is')
8
9
  window.Mustache = require('mustache/mustache')
9
10
 
10
- require('mvpkit/assets/js/application')
11
+ require('jquery')
12
+ require('jquery-ujs')
13
+ require('js-cookie')
11
14
  require('bootstrap/dist/js/bootstrap')
12
15
  require('selectize/dist/js/selectize')
13
16
  require('mustache')
14
17
 
15
- requireTree('lib')
16
- requireTree('behaviors')
17
- requireTree('controllers')
18
+ requireAll(require.context("./lib", true, /\.js$/));
19
+ requireAll(require.context("./behaviors", true, /\.js$/));
20
+ requireAll(require.context("./controllers", true, /\.js$/));
18
21
 
19
- document.addEventListener("turbolinks:load", function(){
22
+ $(function(){
20
23
  // $('*[data-toggle="popover"]').popover()
21
24
  // $('select').selectize()
22
25
  $('[data-toggle="tooltip"]').tooltip()
@@ -18,7 +18,7 @@ $brand-info: #fff !default;
18
18
  $brand-warning: $color-yellow;
19
19
  $brand-danger: $color-orange;
20
20
 
21
- $gray-dark: #001837 !default;
21
+ // $gray-dark: #001837 !default;
22
22
  $gray: #55595c !default;
23
23
  $gray-light: #818a91 !default;
24
24
  $gray-lighter: #eceeef !default;
@@ -8,3 +8,17 @@
8
8
  border-top: 0;
9
9
  }
10
10
  }
11
+
12
+ .table.table-flush {
13
+ tr {
14
+ td, th {
15
+ &:first-child { padding-left: 0; }
16
+ }
17
+ }
18
+
19
+ tr {
20
+ td, th {
21
+ &:last-child { padding-right: 0; }
22
+ }
23
+ }
24
+ }
@@ -8,9 +8,9 @@ Bundler.require(*Rails.groups)
8
8
 
9
9
  module Project
10
10
  class Application < Rails::Application
11
- # config.middleware.use Rack::Static, :urls => ["/javascripts", "/stylesheets", "/images", "/assets"], :root => "public"
12
-
11
+ config.active_record.primary_key = :uuid
13
12
  config.active_record.raise_in_transactional_callbacks = true
13
+
14
14
  config.generators do |g|
15
15
  g.helper false
16
16
  g.decorator false