ispmail-on-rails 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +61 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +41 -0
  8. data/Rakefile +6 -0
  9. data/app/assets/images/.keep +0 -0
  10. data/app/assets/javascripts/application.js +25 -0
  11. data/app/assets/javascripts/virtual_aliases.coffee +3 -0
  12. data/app/assets/javascripts/virtual_domains.coffee +3 -0
  13. data/app/assets/javascripts/virtual_users.coffee +3 -0
  14. data/app/assets/stylesheets/_settings.scss +566 -0
  15. data/app/assets/stylesheets/application.css +21 -0
  16. data/app/assets/stylesheets/clearance.scss +6 -0
  17. data/app/assets/stylesheets/foundation_and_overrides.scss +51 -0
  18. data/app/assets/stylesheets/virtual_aliases.scss +3 -0
  19. data/app/assets/stylesheets/virtual_domains.scss +3 -0
  20. data/app/assets/stylesheets/virtual_users.scss +3 -0
  21. data/app/controllers/api/base_controller.rb +90 -0
  22. data/app/controllers/api/virtual_aliases_controller.rb +12 -0
  23. data/app/controllers/api/virtual_domains_controller.rb +15 -0
  24. data/app/controllers/api/virtual_users_controller.rb +15 -0
  25. data/app/controllers/application_controller.rb +9 -0
  26. data/app/controllers/concerns/.keep +0 -0
  27. data/app/controllers/virtual_aliases_controller.rb +6 -0
  28. data/app/controllers/virtual_domains_controller.rb +6 -0
  29. data/app/controllers/virtual_users_controller.rb +6 -0
  30. data/app/helpers/application_helper.rb +33 -0
  31. data/app/helpers/virtual_aliases_helper.rb +2 -0
  32. data/app/helpers/virtual_domains_helper.rb +2 -0
  33. data/app/helpers/virtual_users_helper.rb +2 -0
  34. data/app/mailers/.keep +0 -0
  35. data/app/models/.keep +0 -0
  36. data/app/models/concerns/.keep +0 -0
  37. data/app/models/user.rb +3 -0
  38. data/app/models/virtual_alias.rb +16 -0
  39. data/app/models/virtual_domain.rb +22 -0
  40. data/app/models/virtual_user.rb +35 -0
  41. data/app/validators/domain_name_validator.rb +21 -0
  42. data/app/validators/password_validator.rb +10 -0
  43. data/app/views/api/virtual_aliases/index.json.jbuilder +6 -0
  44. data/app/views/api/virtual_aliases/show.json.jbuilder +6 -0
  45. data/app/views/api/virtual_domains/index.json.jbuilder +4 -0
  46. data/app/views/api/virtual_domains/show.json.jbuilder +4 -0
  47. data/app/views/api/virtual_users/index.json.jbuilder +5 -0
  48. data/app/views/api/virtual_users/show.json.jbuilder +5 -0
  49. data/app/views/application/_heading.html.erb +12 -0
  50. data/app/views/clearance_mailer/change_password.html.erb +8 -0
  51. data/app/views/clearance_mailer/change_password.text.erb +5 -0
  52. data/app/views/layouts/application.html.erb +41 -0
  53. data/app/views/passwords/create.html.erb +3 -0
  54. data/app/views/passwords/edit.html.erb +18 -0
  55. data/app/views/passwords/new.html.erb +16 -0
  56. data/app/views/sessions/_form.html.erb +22 -0
  57. data/app/views/sessions/new.html.erb +6 -0
  58. data/app/views/users/_form.html.erb +9 -0
  59. data/app/views/users/new.html.erb +15 -0
  60. data/app/views/virtual_aliases/index.html.erb +58 -0
  61. data/app/views/virtual_domains/index.html.erb +56 -0
  62. data/app/views/virtual_users/_password_form.html.erb +23 -0
  63. data/app/views/virtual_users/index.html.erb +57 -0
  64. data/bin/bundle +3 -0
  65. data/bin/console +14 -0
  66. data/bin/rails +9 -0
  67. data/bin/rake +9 -0
  68. data/bin/setup +29 -0
  69. data/bin/spring +15 -0
  70. data/config.ru +4 -0
  71. data/config/application.rb +30 -0
  72. data/config/boot.rb +3 -0
  73. data/config/database.yml +31 -0
  74. data/config/environment.rb +5 -0
  75. data/config/environments/development.rb +42 -0
  76. data/config/environments/production.rb +82 -0
  77. data/config/environments/test.rb +43 -0
  78. data/config/initializers/assets.rb +11 -0
  79. data/config/initializers/backtrace_silencers.rb +7 -0
  80. data/config/initializers/clearance.rb +4 -0
  81. data/config/initializers/cookies_serializer.rb +3 -0
  82. data/config/initializers/filter_parameter_logging.rb +4 -0
  83. data/config/initializers/inflections.rb +16 -0
  84. data/config/initializers/mime_types.rb +4 -0
  85. data/config/initializers/session_store.rb +3 -0
  86. data/config/initializers/wrap_parameters.rb +14 -0
  87. data/config/locales/clearance.en.yml +59 -0
  88. data/config/locales/en.yml +23 -0
  89. data/config/routes.rb +74 -0
  90. data/config/secrets.yml +22 -0
  91. data/db/development.sqlite3 +0 -0
  92. data/db/migrate/20160321130230_create_virtual_domains.rb +13 -0
  93. data/db/migrate/20160321130250_create_virtual_users.rb +16 -0
  94. data/db/migrate/20160321130353_create_virtual_aliases.rb +15 -0
  95. data/db/migrate/20160321133546_create_users.rb +14 -0
  96. data/db/schema.rb +59 -0
  97. data/db/seeds.rb +8 -0
  98. data/ispmail-on-rails.gemspec +25 -0
  99. data/lib/assets/.keep +0 -0
  100. data/lib/ispmail/on/rails.rb +9 -0
  101. data/lib/ispmail/on/rails/version.rb +7 -0
  102. data/lib/tasks/.keep +0 -0
  103. data/log/.keep +0 -0
  104. data/public/404.html +67 -0
  105. data/public/422.html +67 -0
  106. data/public/500.html +66 -0
  107. data/public/favicon.ico +0 -0
  108. data/public/robots.txt +5 -0
  109. data/tmp/.keep +0 -0
  110. data/vendor/assets/javascripts/.keep +0 -0
  111. data/vendor/assets/stylesheets/.keep +0 -0
  112. metadata +198 -0
@@ -0,0 +1,6 @@
1
+ json.virtual_alias do
2
+ json.id @virtual_alias.id
3
+ json.source @virtual_alias.source
4
+ json.destination @virtual_alias.destination
5
+ json.domain_id @virtual_alias.domain_id
6
+ end
@@ -0,0 +1,4 @@
1
+ json.virtual_domains @virtual_domains do |virtual_domain|
2
+ json.id virtual_domain.id
3
+ json.name virtual_domain.name
4
+ end
@@ -0,0 +1,4 @@
1
+ json.virtual_domain do
2
+ json.id @virtual_domain.id
3
+ json.name @virtual_domain.name
4
+ end
@@ -0,0 +1,5 @@
1
+ json.virtual_users @virtual_users do |virtual_user|
2
+ json.id virtual_user.id
3
+ json.domain_id virtual_user.domain_id
4
+ json.email virtual_user.email
5
+ end
@@ -0,0 +1,5 @@
1
+ json.virtual_user do
2
+ json.id @virtual_user.id
3
+ json.email @virtual_user.email
4
+ json.domain_id @virtual_user.domain_id
5
+ end
@@ -0,0 +1,12 @@
1
+ <!-- domain-heading from application/_heading.html.erb -->
2
+ <div class="row domain-heading">
3
+ <div class="small-6 columns">
4
+ <h1>Virtual users for <%= @domain.name %></h1>
5
+ </div>
6
+ <div class="small-6 columns">
7
+ <p>
8
+ <%= @domain.name %> MX record does <b><%= "NOT" unless @domain.does_resolve_to_host? %></b> resolve to this server
9
+ <p>
10
+ </div>
11
+ </div>
12
+
@@ -0,0 +1,8 @@
1
+ <p><%= t(".opening") %></p>
2
+
3
+ <p>
4
+ <%= link_to t(".link_text", default: "Change my password"),
5
+ edit_user_password_url(@user, token: @user.confirmation_token.html_safe) %>
6
+ </p>
7
+
8
+ <p><%= raw t(".closing") %></p>
@@ -0,0 +1,5 @@
1
+ <%= t(".opening") %></p>
2
+
3
+ <%= edit_user_password_url(@user, token: @user.confirmation_token.html_safe) %>
4
+
5
+ <%= raw t(".closing") %>
@@ -0,0 +1,41 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+
7
+ <title><%= content_for?(:title) ? yield(:title) : "ISPmail" %></title>
8
+
9
+ <%= stylesheet_link_tag "application" %>
10
+ <%= javascript_include_tag "application", 'data-turbolinks-track' => true %>
11
+ <%= csrf_meta_tag %>
12
+ </head>
13
+ <body>
14
+ <div class="top-bar">
15
+ <div class="top-bar-left">
16
+ <ul class="menu">
17
+ <li class="menu-text">ISPmail for <%=Socket.gethostname %></li>
18
+ <%= content_tag :li, link_to("Virtual domains", virtual_domains_path) %>
19
+ <%= yield(:menu) %>
20
+ </ul>
21
+ </div>
22
+
23
+ <div class="top-bar-right">
24
+ <ul class="menu">
25
+ <% if signed_in? -%>
26
+ <li><%= button_to t(".sign_out"), sign_out_path, method: :delete, class: "button" %></li>
27
+ <% end -%>
28
+ </ul>
29
+ </div>
30
+ </div>
31
+
32
+ <div class="reveal" id="messages" data-reveal data-show-flash="<%=!flash.empty?%>">
33
+ <%= flash_messages flash.collect {|k,v| "<div class='callout #{k}'>#{v}</div>" }.join("\n").html_safe, !flash.alert.nil? %>
34
+ </div>
35
+
36
+ <div class="column row">
37
+ <%= yield %>
38
+ </div>
39
+
40
+ </body>
41
+ </html>
@@ -0,0 +1,3 @@
1
+ <div id="clearance" class="password-reset">
2
+ <p><%= t(".description") %></p>
3
+ </div>
@@ -0,0 +1,18 @@
1
+ <div id="clearance" class="password-reset">
2
+ <h2><%= t(".title") %></h2>
3
+
4
+ <p><%= t(".description") %></p>
5
+
6
+ <%= form_for :password_reset,
7
+ url: user_password_path(@user, token: @user.confirmation_token),
8
+ html: { method: :put } do |form| %>
9
+ <div class="password-field">
10
+ <%= form.label :password %>
11
+ <%= form.password_field :password %>
12
+ </div>
13
+
14
+ <div class="submit-field">
15
+ <%= form.submit class: "button" %>
16
+ </div>
17
+ <% end %>
18
+ </div>
@@ -0,0 +1,16 @@
1
+ <div id="clearance" class="password-reset">
2
+ <h2><%= t(".title") %></h2>
3
+
4
+ <p><%= t(".description") %></p>
5
+
6
+ <%= form_for :password, url: passwords_path do |form| %>
7
+ <div class="text-field">
8
+ <%= form.label :email %>
9
+ <%= form.text_field :email, type: 'email' %>
10
+ </div>
11
+
12
+ <div class="submit-field">
13
+ <%= form.submit class: "button" %>
14
+ </div>
15
+ <% end %>
16
+ </div>
@@ -0,0 +1,22 @@
1
+ <%= form_for :session, url: session_path do |form| %>
2
+ <div class="text-field">
3
+ <%= form.label :email %>
4
+ <%= form.text_field :email, type: 'email' %>
5
+ </div>
6
+
7
+ <div class="password-field">
8
+ <%= form.label :password %>
9
+ <%= form.password_field :password %>
10
+ </div>
11
+
12
+ <div class="submit-field">
13
+ <%= form.submit class: "button" %>
14
+ </div>
15
+
16
+ <div class="other-links">
17
+ <% if Clearance.configuration.allow_sign_up? %>
18
+ <%= link_to t(".sign_up"), sign_up_path %>
19
+ <% end %>
20
+ <%= link_to t(".forgot_password"), new_password_path %>
21
+ </div>
22
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <div id="clearance" class="sign-in">
2
+ <h2><%= t(".title") %></h2>
3
+
4
+ <%= render partial: '/sessions/form' %>
5
+
6
+ </div>
@@ -0,0 +1,9 @@
1
+ <div class="text-field">
2
+ <%= form.label :email %>
3
+ <%= form.text_field :email, type: 'email' %>
4
+ </div>
5
+
6
+ <div class="password-field">
7
+ <%= form.label :password %>
8
+ <%= form.password_field :password %>
9
+ </div>
@@ -0,0 +1,15 @@
1
+ <div id="clearance" class="sign-up">
2
+ <h2><%= t(".title") %></h2>
3
+
4
+ <%= form_for @user do |form| %>
5
+ <%= render partial: '/users/form', object: form %>
6
+
7
+ <div class="submit-field">
8
+ <%= form.submit class: "button" %>
9
+ </div>
10
+
11
+ <div class="other-links">
12
+ <%= link_to t(".sign_in"), sign_in_path %>
13
+ </div>
14
+ <% end %>
15
+ </div>
@@ -0,0 +1,58 @@
1
+ <%= content_for :menu do %>
2
+ <li><%= @domain.name %>/</li>
3
+ <li><%= link_to "users", virtual_users_path(@domain.name) %></li>
4
+ <% end %>
5
+
6
+ <div class="column row">
7
+ <%= render partial: "heading" %>
8
+
9
+ <%= form_for @virtual_alias, url: api_virtual_aliases_path, remote: true do |f| %>
10
+ <div class="input-group">
11
+ <%= f.hidden_field :domain_id %>
12
+ <%= content_tag :span, "Source", class: "input-group-label" %>
13
+ <%= f.text_field :source, class: "input-group-field", placeholder: "john@#{@domain.name}" %>
14
+ <%= content_tag :span, "Destination", class: "input-group-label" %>
15
+ <%= f.text_field :destination, class: "input-group-field", placeholder: "jill@#{@domain.name}" %>
16
+ <%= content_tag :div, class: "input-group-button" do %>
17
+ <%= f.submit class: "button" %>
18
+ <% end %>
19
+ </div>
20
+ <% end # form %>
21
+
22
+ <table>
23
+ <thead>
24
+ <tr>
25
+ <th>Source</th>
26
+ <th>Destination</th>
27
+ <th>Actions</th>
28
+ </tr>
29
+ </thead>
30
+ <tbody>
31
+ <% @domain.virtual_aliases.each do |virtual_alias| %>
32
+ <tr id="virtual_alias_<%= virtual_alias.id %>">
33
+ <%= content_tag :td, virtual_alias.source %>
34
+ <%= content_tag :td, virtual_alias.destination %>
35
+ <%= content_tag :td do %>
36
+ <%= link_to 'Delete', api_virtual_alias_path(virtual_alias),
37
+ method: :delete, remote: true, data: { confirm: "Are you sure?" } %>
38
+ <% end %>
39
+ </tr>
40
+ <% end %>
41
+ </tbody>
42
+ </table>
43
+
44
+ <script type="text/javascript">
45
+ <%= form_error_callout("new_virtual_alias") %>
46
+
47
+ $('form#new_virtual_alias').bind('ajax:success', function(evt, data, status, xhr){
48
+ $("tbody").append("<tr><td>" + data.virtual_alias.source +
49
+ "</td><td>" + data.virtual_alias.destination +
50
+ "</td></tr>");
51
+ })
52
+
53
+ $('[data-remote][data-method="delete"]').bind('ajax:success', function(evt, data, status, xhr){
54
+ $(evt.target).closest('tr').remove();
55
+ })
56
+ </script>
57
+ </div>
58
+
@@ -0,0 +1,56 @@
1
+ <div class="row">
2
+ <div class="">
3
+ <h1>Virtual domains</h1>
4
+
5
+ <%= form_for @domain, url: api_virtual_domains_path, remote: true do |f| %>
6
+ <div class="input-group">
7
+ <%= content_tag :span, "Add new virtual domain", class: "input-group-label" %>
8
+ <%= f.text_field :name, class: "input-group-field", placeholder: "example.com" %>
9
+ <%= content_tag :div, class: "input-group-button" do %>
10
+ <%= f.submit class: "button" %>
11
+ <% end %>
12
+ </div>
13
+ <% end # form %>
14
+
15
+ <table>
16
+ <thead>
17
+ <tr>
18
+ <th>Domain name</th>
19
+ <th>Does MX resolve here?</th>
20
+ <th>Number of users</th>
21
+ <th>Number of aliases</th>
22
+ <th>Actions</th>
23
+ </tr>
24
+ </thead>
25
+ <tbody>
26
+ <% @domains.each do |domain| %>
27
+ <tr>
28
+ <%= content_tag :td, link_to(domain.name, virtual_users_path(domain.name)) %>
29
+ <%= content_tag :td, domain.does_resolve_to_host? %>
30
+ <%= content_tag :td, link_to(domain.virtual_users.count, virtual_users_path(domain.name)) %>
31
+ <%= content_tag :td, link_to(domain.virtual_aliases.count, virtual_aliases_path(domain.name)) %>
32
+ <%= content_tag :td do %>
33
+ <%= link_to 'Delete', api_virtual_domain_path(domain),
34
+ method: :delete, remote: true, data: { confirm: "Are you sure?" } %>
35
+ <% end %>
36
+ </tr>
37
+ <% end %>
38
+ </tbody>
39
+ </table>
40
+
41
+ <script type="text/javascript">
42
+ <%= form_error_callout("new_virtual_domain") %>
43
+
44
+ $('form#new_virtual_domain').bind('ajax:success', function(evt, data, status, xhr){
45
+ $("tbody").append(
46
+ "<tr><td><a href='/" + data.virtual_domain.name + "/users'>" +
47
+ data.virtual_domain.name + "</a>" +
48
+ "</td></tr>");
49
+ })
50
+
51
+ $('[data-remote][data-method="delete"]').bind('ajax:success', function(evt, data, status, xhr){
52
+ $(evt.target).closest('tr').remove();
53
+ })
54
+ </script>
55
+ </div>
56
+ </div>
@@ -0,0 +1,23 @@
1
+ <h5><%= virtual_user.email %></h5>
2
+ <%= form_for virtual_user, url: api_virtual_user_path(virtual_user), remote: true do |f| %>
3
+ <div class="row">
4
+ <div class="medium-12 columns">
5
+ <%= f.hidden_field :domain_id %>
6
+ <%= f.label :new_password %>
7
+ <%= f.text_field :new_password %>
8
+ </div>
9
+ </div>
10
+ <div class="row">
11
+ <div class="medium-6 columns">
12
+ <%= f.submit "Save new password", class: "button" %>
13
+ </div>
14
+ </div>
15
+ <% end %>
16
+
17
+ <script type="text/javascript">
18
+ <%= form_error_callout("edit_virtual_user_#{virtual_user.id}") %>
19
+
20
+ $('form#edit_virtual_user_<%= virtual_user.id %>').bind('ajax:success', function(evt, data, status, xhr){
21
+ $(evt.target.parentElement).foundation('close');
22
+ })
23
+ </script>
@@ -0,0 +1,57 @@
1
+ <%= content_for :menu do %>
2
+ <li><%= @domain.name %>/</li>
3
+ <li><%= link_to "aliases", virtual_aliases_path(@domain.name) %></li>
4
+ <% end %>
5
+
6
+ <div class="column row">
7
+ <%= render partial: "heading" %>
8
+
9
+ <%= form_for @virtual_user, url: api_virtual_users_path, remote: true do |f| %>
10
+ <div class="input-group">
11
+ <%= f.hidden_field :domain_id %>
12
+ <%= content_tag :span, "Add new virtual user", class: "input-group-label" %>
13
+ <%= f.text_field :email, class: "input-group-field", placeholder: "john@example.com" %>
14
+ <%= content_tag :span, "Password", class: "input-group-label" %>
15
+ <%= f.text_field :new_password, class: "input-group-field" %>
16
+ <%= content_tag :div, class: "input-group-button" do %>
17
+ <%= f.submit class: "button" %>
18
+ <% end %>
19
+ </div>
20
+ <% end # form %>
21
+
22
+ <table>
23
+ <thead>
24
+ <tr>
25
+ <th>Email</th>
26
+ <th>Actions</th>
27
+ </tr>
28
+ </thead>
29
+ <tbody>
30
+ <% @domain.virtual_users.each do |user| %>
31
+ <tr id="virtual_user_<%= user.id %>">
32
+ <%= content_tag :td, user.email %>
33
+ <%= content_tag :td do %>
34
+ <%= link_to "Delete", api_virtual_user_path(user), class: "warning",
35
+ method: :delete, remote: true, data: { confirm: "Are you sure?" } %>
36
+ <%= link_to "Change password", "#", "data-toggle" => "change_user_#{user.id}" %>
37
+ <div class="dropdown-pane top" id="<%= "change_user_#{user.id}" %>" data-dropdown data-close-on-click=true>
38
+ <%= render partial: "password_form", locals: { virtual_user: user } %>
39
+ </div>
40
+ <% end %>
41
+ </tr>
42
+ <% end %>
43
+ </tbody>
44
+ </table>
45
+
46
+ <script type="text/javascript">
47
+ <%= form_error_callout("new_virtual_user") %>
48
+
49
+ $('form#new_virtual_user').bind('ajax:success', function(evt, data, status, xhr){
50
+ $("tbody").append("<tr><td>" + data.virtual_user.email + "</td></tr>");
51
+ })
52
+
53
+ $('[data-remote][data-method="delete"]').bind('ajax:success', function(evt, data, status, xhr){
54
+ $(evt.target).closest('tr').remove();
55
+ })
56
+ </script>
57
+ </div>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ispmail/on/rails"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
7
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
8
+ require_relative '../config/boot'
9
+ require 'rails/commands'
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
7
+ require_relative '../config/boot'
8
+ require 'rake'
9
+ Rake.application.run