lotus_admin 0.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 (91) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +63 -0
  4. data/Rakefile +20 -0
  5. data/app/assets/config/lotus_admin_manifest.js +2 -0
  6. data/app/assets/images/lotus_admin/profile-menu.png +0 -0
  7. data/app/assets/javascripts/lotus_admin/application.js +5 -0
  8. data/app/assets/stylesheets/lotus_admin/application.css.scss +9 -0
  9. data/app/assets/stylesheets/lotus_admin/components/_alerts.scss +5 -0
  10. data/app/assets/stylesheets/lotus_admin/components/_all.scss +4 -0
  11. data/app/assets/stylesheets/lotus_admin/components/_devise.scss +3 -0
  12. data/app/assets/stylesheets/lotus_admin/components/_forms.scss +7 -0
  13. data/app/assets/stylesheets/lotus_admin/components/_tables.scss +27 -0
  14. data/app/controllers/concerns/lotus_admin/devise_controllers.rb +7 -0
  15. data/app/controllers/concerns/lotus_admin/exposure.rb +27 -0
  16. data/app/controllers/concerns/lotus_admin/permitted_params.rb +18 -0
  17. data/app/controllers/lotus_admin/application_controller.rb +20 -0
  18. data/app/controllers/lotus_admin/authenticated_controller.rb +20 -0
  19. data/app/controllers/lotus_admin/confirmations_controller.rb +3 -0
  20. data/app/controllers/lotus_admin/dashboard_controller.rb +5 -0
  21. data/app/controllers/lotus_admin/passwords_controller.rb +3 -0
  22. data/app/controllers/lotus_admin/profiles_controller.rb +20 -0
  23. data/app/controllers/lotus_admin/sessions_controller.rb +3 -0
  24. data/app/controllers/lotus_admin/users_controller.rb +45 -0
  25. data/app/helpers/lotus_admin/application_helper.rb +18 -0
  26. data/app/helpers/lotus_admin/form_helpers.rb +25 -0
  27. data/app/helpers/lotus_admin/link_helpers.rb +27 -0
  28. data/app/helpers/lotus_admin/pagination_helpers.rb +7 -0
  29. data/app/helpers/lotus_admin/panel_helpers.rb +24 -0
  30. data/app/helpers/lotus_admin/sidebar_helpers.rb +25 -0
  31. data/app/jobs/lotus_admin/application_job.rb +4 -0
  32. data/app/mailers/lotus_admin/application_mailer.rb +6 -0
  33. data/app/mailers/lotus_admin/user_mailer.rb +10 -0
  34. data/app/models/lotus_admin/application_record.rb +5 -0
  35. data/app/models/lotus_admin/user.rb +17 -0
  36. data/app/views/administrators/_links.html.haml +20 -0
  37. data/app/views/administrators/confirmations/new.html.haml +13 -0
  38. data/app/views/administrators/passwords/edit.html.haml +15 -0
  39. data/app/views/administrators/passwords/new.html.haml +11 -0
  40. data/app/views/administrators/sessions/new.html.haml +11 -0
  41. data/app/views/kaminari/lotus_admin/_first_page.html.haml +2 -0
  42. data/app/views/kaminari/lotus_admin/_gap.html.haml +1 -0
  43. data/app/views/kaminari/lotus_admin/_last_page.html.haml +2 -0
  44. data/app/views/kaminari/lotus_admin/_next_page.html.haml +2 -0
  45. data/app/views/kaminari/lotus_admin/_page.html.haml +2 -0
  46. data/app/views/kaminari/lotus_admin/_paginator.html.haml +12 -0
  47. data/app/views/kaminari/lotus_admin/_prev_page.html.haml +2 -0
  48. data/app/views/layouts/lotus_admin/_devise_footer.html.haml +0 -0
  49. data/app/views/layouts/lotus_admin/_favicons.html.haml +0 -0
  50. data/app/views/layouts/lotus_admin/_footer.html.haml +2 -0
  51. data/app/views/layouts/lotus_admin/_footer_scripts.html.haml +2 -0
  52. data/app/views/layouts/lotus_admin/_header.html.haml +31 -0
  53. data/app/views/layouts/lotus_admin/_header_dropdown_items.html.haml +0 -0
  54. data/app/views/layouts/lotus_admin/_html_head.html.haml +9 -0
  55. data/app/views/layouts/lotus_admin/_javascripts.html.haml +1 -0
  56. data/app/views/layouts/lotus_admin/_sidebar.html.haml +22 -0
  57. data/app/views/layouts/lotus_admin/_sidebar_items.html.haml +9 -0
  58. data/app/views/layouts/lotus_admin/_stylesheets.html.haml +5 -0
  59. data/app/views/layouts/lotus_admin/application.html.haml +22 -0
  60. data/app/views/layouts/lotus_admin/devise.html.haml +19 -0
  61. data/app/views/layouts/lotus_admin/mailer.html.haml +10 -0
  62. data/app/views/layouts/lotus_admin/mailer.text.erb +4 -0
  63. data/app/views/lotus_admin/dashboard/show.html.haml +1 -0
  64. data/app/views/lotus_admin/profiles/edit.html.haml +26 -0
  65. data/app/views/lotus_admin/shared/_collection_pagination.html.haml +7 -0
  66. data/app/views/lotus_admin/user_mailer/invited.html.haml +8 -0
  67. data/app/views/lotus_admin/user_mailer/invited.text.erb +5 -0
  68. data/app/views/lotus_admin/users/_form.html.haml +10 -0
  69. data/app/views/lotus_admin/users/edit.html.haml +12 -0
  70. data/app/views/lotus_admin/users/index.html.haml +30 -0
  71. data/app/views/lotus_admin/users/new.html.haml +9 -0
  72. data/app/views/lotus_admin/users/show.html.haml +24 -0
  73. data/config/initializers/devise.rb +280 -0
  74. data/config/initializers/simple_form.rb +170 -0
  75. data/config/initializers/simple_form_bootstrap.rb +155 -0
  76. data/config/initializers/simple_form_material.rb +35 -0
  77. data/config/locales/dates.en.yml +11 -0
  78. data/config/locales/devise.en.yml +64 -0
  79. data/config/locales/mailers.en.yml +5 -0
  80. data/config/locales/page_titles.en.yml +30 -0
  81. data/config/locales/simple_form.en.yml +31 -0
  82. data/config/locales/users.en.yml +29 -0
  83. data/config/routes.rb +8 -0
  84. data/db/migrate/20180228124526_devise_create_lotus_admin_users.rb +46 -0
  85. data/db/migrate/20180228210938_add_timezone_to_users.rb +5 -0
  86. data/lib/lotus_admin.rb +17 -0
  87. data/lib/lotus_admin/engine.rb +19 -0
  88. data/lib/lotus_admin/version.rb +3 -0
  89. data/lib/tasks/lotus_admin_tasks.rake +6 -0
  90. data/lib/templates/erb/scaffold/_form.html.erb +14 -0
  91. metadata +371 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d8db608db954a0263ed08e5b450a4e6857143319
4
+ data.tar.gz: '09320de0916f85e8612710f3821f55738d40c8e1'
5
+ SHA512:
6
+ metadata.gz: 31474451eae9ea44c0f188210679c8c26583779ea436b5b95e882f28b1f8f16cf168def36a82df318078037ef78865d0d71b102252d0afc938cf5eddf0c8475b
7
+ data.tar.gz: 77762962f586a912732d82095a6047aa641836459ea5de06d4ecadb7bc8a87cc086b00291648be0c86501b7cb49f3e39f16eef5cbcc43aa5fd35f59f33e969c4
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2018 Matt Millsaps-Brewer
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.md ADDED
@@ -0,0 +1,63 @@
1
+ # Lotus Admin
2
+ Provides a simple, Bootstrap 3 Material Design UI to administer your web app.
3
+
4
+ [ ![Codeship Status for madebylotus/lotus-admin](https://app.codeship.com/projects/df7c4300-feb0-0135-4b73-065227294bbd/status?branch=master)](https://app.codeship.com/projects/279526)
5
+
6
+ ## Usage
7
+ Install and subclass any controllers, models, or views as needed.
8
+
9
+ ## Installation
10
+ Add this line to your application's Gemfile and then mount the engine in your application.
11
+
12
+ ### Requirements
13
+ * Ruby 2.4
14
+ * Rails 5
15
+
16
+ ### Required Secrets
17
+ You will need to define these secrets.
18
+
19
+ * `action_mailer_default_sender_address`
20
+
21
+ ### Setup
22
+
23
+ ```ruby
24
+ # Gemfile
25
+ gem 'lotus_admin', '~> 0.1.0'
26
+ ```
27
+
28
+ And then execute:
29
+ ```bash
30
+ $ bundle
31
+ ```
32
+
33
+ Add to your routes
34
+ ```ruby
35
+ # config/routes.rb
36
+ mount LotusAdmin::Engine, at: 'admin'
37
+ ```
38
+
39
+ Seed an administrator account, optional.
40
+
41
+ ```
42
+ $> rake lotus_admin:seed
43
+ ```
44
+
45
+ You can now login at [http://localhost:3000/admin](http://localhost:3000/admin).
46
+
47
+ ## Contributing
48
+ Contribution directions go here.
49
+
50
+ ## Testing
51
+
52
+ ```shell
53
+ $> bundle exec rspec spec
54
+ ```
55
+
56
+ You can run the included test rails app as well:
57
+
58
+ ```shell
59
+ $> cd spec/dummy && rails s
60
+ ```
61
+
62
+ ## License
63
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,20 @@
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 = 'LotusAdmin'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+ load 'rails/tasks/statistics.rake'
20
+ require 'bundler/gem_tasks'
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/lotus_admin .js
2
+ //= link_directory ../stylesheets/lotus_admin .css
@@ -0,0 +1,5 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //= require bootstrap-sprockets
4
+
5
+ //= require lotus_admin/theme/app
@@ -0,0 +1,9 @@
1
+ @import "lotus_admin/theme/inc/variables";
2
+
3
+ $footer-height: 70px;
4
+
5
+ @import "bootstrap";
6
+ @import "font-awesome";
7
+ @import "lotus_admin/theme/app";
8
+
9
+ @import "lotus_admin/components/all";
@@ -0,0 +1,5 @@
1
+ .alert {
2
+ &.alert-danger, &.alert-warning, &.alert-success, &.alert-info, &.alert-primary {
3
+ color: white;
4
+ }
5
+ }
@@ -0,0 +1,4 @@
1
+ @import "lotus_admin/components/alerts";
2
+ @import "lotus_admin/components/devise";
3
+ @import "lotus_admin/components/forms";
4
+ @import "lotus_admin/components/tables";
@@ -0,0 +1,3 @@
1
+ .devise-shared-links-container {
2
+ margin-top: 25px;
3
+ }
@@ -0,0 +1,7 @@
1
+ .form-actions {
2
+ .btn.waves-effect {
3
+ i.zmdi, i.fa {
4
+ margin-left: 5px;
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,27 @@
1
+ table.table {
2
+ .actions-col {
3
+ text-align: right;
4
+ .btn {
5
+ margin-left: 5px;
6
+
7
+ &:first-child {
8
+ margin-left: 0px;
9
+ }
10
+ }
11
+ }
12
+
13
+ td.avatar {
14
+ width: 60px !important;
15
+ padding: 13px 0 0 15px !important;
16
+ }
17
+
18
+ tr.with-avatar {
19
+ td:not(.avatar) {
20
+ padding-top: 27px;
21
+
22
+ @media(max-width: $screen-sm) {
23
+ padding-top: 18px;
24
+ }
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,7 @@
1
+ module LotusAdmin::DeviseControllers
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ layout 'lotus_admin/devise'
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ module LotusAdmin
2
+ module Exposure
3
+ extend ActiveSupport::Concern
4
+
5
+ class_methods do
6
+ def let(attribute_name, &block)
7
+
8
+ # instance setter method
9
+ define_method("#{ attribute_name }=") do |value|
10
+ instance_variable_set("@#{ attribute_name }", value)
11
+ end
12
+
13
+ # instance method to meomize the block result
14
+ define_method(attribute_name) do
15
+ instance_variable_get("@#{ attribute_name }") || begin
16
+ value = instance_eval(&block)
17
+ public_send("#{ attribute_name }=", value)
18
+
19
+ value
20
+ end
21
+ end
22
+ helper_method(attribute_name)
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,18 @@
1
+ module LotusAdmin
2
+ module PermittedParams
3
+ extend ActiveSupport::Concern
4
+
5
+ class_methods do
6
+ def permit_params(*args, &block)
7
+ define_method :permitted_params do
8
+ base_params = params.require(resource_class.model_name.singular_route_key)
9
+ if block.present?
10
+ block.call(base_params)
11
+ else
12
+ base_params.permit(args)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ module LotusAdmin
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+
5
+ include Exposure
6
+
7
+ helper LotusAdmin::ApplicationHelper
8
+ helper LotusAdmin::FormHelpers
9
+ helper LotusAdmin::LinkHelpers
10
+ helper LotusAdmin::PaginationHelpers
11
+ helper LotusAdmin::PanelHelpers
12
+ helper LotusAdmin::SidebarHelpers
13
+
14
+ private
15
+
16
+ def paginate(collection)
17
+ collection.page(params[:page])
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ class LotusAdmin::AuthenticatedController < LotusAdmin::ApplicationController
2
+ include LotusAdmin::PermittedParams
3
+
4
+ before_action :authenticate_administrator!
5
+ around_action :use_user_time_zone, if: :administrator_signed_in?
6
+
7
+ let(:menu_identifier) do
8
+ action = :index
9
+ action = :new if %w(new create).include?(action_name)
10
+ action = :edit if %w(edit update).include?(action_name)
11
+
12
+ [controller_name, action].join('_').to_sym
13
+ end
14
+
15
+ private
16
+
17
+ def use_user_time_zone(&block)
18
+ Time.use_zone(current_administrator.time_zone, &block)
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ class LotusAdmin::ConfirmationsController < Devise::ConfirmationsController
2
+ include LotusAdmin::DeviseControllers
3
+ end
@@ -0,0 +1,5 @@
1
+ module LotusAdmin
2
+ class DashboardController < LotusAdmin::AuthenticatedController
3
+ let(:menu_identifier) { :dashboard_show }
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ class LotusAdmin::PasswordsController < Devise::PasswordsController
2
+ include LotusAdmin::DeviseControllers
3
+ end
@@ -0,0 +1,20 @@
1
+ module LotusAdmin
2
+ class ProfilesController < LotusAdmin::AuthenticatedController
3
+ let(:resource_class) { LotusAdmin::User }
4
+
5
+ permit_params do |params|
6
+ params.permit(:first_name, :last_name, :email, :time_zone, :password, :password_confirmation).delete_if do |k,v|
7
+ k.start_with?('password') && v.blank?
8
+ end
9
+ end
10
+
11
+ def update
12
+ if current_administrator.update(permitted_params)
13
+ bypass_sign_in(current_administrator, scope: :administrator)
14
+ redirect_to lotus_admin.root_path, notice: 'Changes to your profile have been saved'
15
+ else
16
+ render :edit
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ class LotusAdmin::SessionsController < Devise::SessionsController
2
+ include LotusAdmin::DeviseControllers
3
+ end
@@ -0,0 +1,45 @@
1
+ module LotusAdmin
2
+ class UsersController < LotusAdmin::AuthenticatedController
3
+ let(:menu_identifier) { :users_index }
4
+ let(:resource_class) { LotusAdmin::User }
5
+ let(:users) { paginate(resource_class.all) }
6
+ let(:user) { resource_class.find(params[:id]) }
7
+
8
+ permit_params :first_name, :last_name, :email, :time_zone
9
+
10
+ def new
11
+ self.user = resource_class.new
12
+ end
13
+
14
+ def create
15
+ self.user = resource_class.new(permitted_params)
16
+ user.password = Devise.friendly_token.first(8)
17
+
18
+ if user.save
19
+ user.send_invited_email_notification
20
+
21
+ redirect_to [lotus_admin, resource_class], notice: "Created new #{ resource_class.model_name.human }"
22
+ else
23
+ render :new
24
+ end
25
+ end
26
+
27
+ def update
28
+ if user.update(permitted_params)
29
+ redirect_to [lotus_admin, user], notice: 'Changes saved'
30
+ else
31
+ render :edit
32
+ end
33
+ end
34
+
35
+ def destroy
36
+ if user.destroy
37
+ flash[:notice] = "#{ resource_class.model_name.human } has been removed"
38
+ else
39
+ flash[:error] = "There was an error removing that #{ resource_class.model_name.human }"
40
+ end
41
+
42
+ redirect_to [lotus_admin, resource_class]
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,18 @@
1
+ module LotusAdmin
2
+ module ApplicationHelper
3
+ def body_class(*extra)
4
+ [controller_name, action_name.parameterize].concat(extra)
5
+ end
6
+
7
+ def flash_message(message, type='alert')
8
+ css_class = case type.to_sym
9
+ when :alert then 'alert-alert alert-warning'
10
+ when :error then 'alert-error alert-danger'
11
+ when :notice then 'alert-success alert-notice'
12
+ when :info then 'alert-info'
13
+ end
14
+
15
+ content_tag(:div, message, class: "alert #{css_class}")
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,25 @@
1
+ module LotusAdmin
2
+ module FormHelpers
3
+ def material_form_for(resource, options = {}, &block)
4
+ options[:wrapper] = :material_form
5
+ options[:wrapper_mappings] = {
6
+ boolean: :material_boolean_horizontal
7
+ }
8
+
9
+ simple_form_for(resource, options, &block)
10
+ end
11
+
12
+ def material_form_submit(resource)
13
+ label = "Create #{ resource.class.model_name.human }"
14
+ label = "Save Changes" if resource.persisted?
15
+
16
+ button_tag class: 'btn btn-success' do
17
+ label.html_safe + content_tag(:i, nil, class: 'zmdi zmdi-arrow-forward')
18
+ end
19
+ end
20
+
21
+ def material_form_cancel(path)
22
+ link_to 'Cancel', path, class: 'btn btn-link'
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,27 @@
1
+ module LotusAdmin
2
+ module LinkHelpers
3
+ def view_link(resource)
4
+ link_to lotus_admin.polymorphic_path(resource) do
5
+ content_tag(:i, nil, class: 'zmdi zmdi-eye')
6
+ end
7
+ end
8
+
9
+ def new_link
10
+ link_to lotus_admin.new_polymorphic_path(resource_class) do
11
+ content_tag(:i, nil, class: 'zmdi zmdi-plus-circle')
12
+ end
13
+ end
14
+
15
+ def edit_link(resource)
16
+ link_to lotus_admin.edit_polymorphic_path(resource) do
17
+ content_tag(:i, nil, class: 'zmdi zmdi-edit')
18
+ end
19
+ end
20
+
21
+ def destroy_link(resource)
22
+ link_to lotus_admin.polymorphic_path(resource), data: { method: :delete, confirm: "Are you sure you want to remove this #{ resource.model_name.human }?" } do
23
+ content_tag(:i, nil, class: 'zmdi zmdi-delete')
24
+ end
25
+ end
26
+ end
27
+ end