administrador 0.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +73 -0
  4. data/Rakefile +22 -0
  5. data/app/assets/config/administrador_manifest.js +2 -0
  6. data/app/assets/javascripts/administrador/application.js +16 -0
  7. data/app/assets/stylesheets/administrador/application/bootstrap-btn-responsive.css +7 -0
  8. data/app/assets/stylesheets/administrador/application/bootstrap-btn-xs.css +6 -0
  9. data/app/assets/stylesheets/administrador/application/bootstrap-circular-buttons.css +30 -0
  10. data/app/assets/stylesheets/administrador/application/bootstrap-table-xs.css +7 -0
  11. data/app/assets/stylesheets/administrador/application/colors.css +7 -0
  12. data/app/assets/stylesheets/administrador/application/engine-sidebar.css +7 -0
  13. data/app/assets/stylesheets/administrador/application/layout.css +43 -0
  14. data/app/assets/stylesheets/administrador/application/page-actions.css +3 -0
  15. data/app/assets/stylesheets/administrador/application/query_form.css +8 -0
  16. data/app/assets/stylesheets/administrador/application.css +15 -0
  17. data/app/concerns/administrador/controller/application_concern.rb +15 -0
  18. data/app/concerns/administrador/controller/engine_concern.rb +21 -0
  19. data/app/concerns/administrador/controller/resource_concern.rb +50 -0
  20. data/app/concerns/administrador/controller/resources_concern.rb +70 -0
  21. data/app/concerns/administrador/controller/service_concern.rb +17 -0
  22. data/app/concerns/administrador/engine_routable/localized_concern.rb +21 -0
  23. data/app/controllers/administrador/application_controller.rb +5 -0
  24. data/app/controllers/administrador/home_controller/base.rb +7 -0
  25. data/app/controllers/administrador/home_controller.rb +6 -0
  26. data/app/controllers/administrador/resource_controller/base.rb +7 -0
  27. data/app/controllers/administrador/resources_controller/base.rb +7 -0
  28. data/app/controllers/administrador/service_controller/base.rb +7 -0
  29. data/app/controllers/administrador/sidebar_controller/base.rb +17 -0
  30. data/app/jobs/administrador/application_job.rb +4 -0
  31. data/app/mailers/administrador/application_mailer.rb +6 -0
  32. data/app/models/administrador/application_record.rb +5 -0
  33. data/app/view_helpers/administrador/application_view_helper.rb +44 -0
  34. data/app/view_helpers/administrador/breadcrumbs_view_helper.rb +59 -0
  35. data/app/view_helpers/administrador/offcanvas_view_helper.rb +8 -0
  36. data/app/views/administrador/application/_main_sidebar_right.html.haml +1 -0
  37. data/app/views/administrador/application/_navbar.html.haml +14 -0
  38. data/app/views/administrador/application/sidebars/_engine.html.haml +32 -0
  39. data/app/views/administrador/application/sidebars/_i18n.html.haml +8 -0
  40. data/app/views/administrador/application/sidebars/_messages.html.haml +5 -0
  41. data/app/views/administrador/application/sidebars/_notifications.html.haml +5 -0
  42. data/app/views/administrador/application/sidebars/_search.html.haml +5 -0
  43. data/app/views/administrador/application/sidebars/_settings.html.haml +5 -0
  44. data/app/views/administrador/application/sidebars/_user.html.haml +5 -0
  45. data/app/views/administrador/application_view_helper/_flash_messages.html.haml +3 -0
  46. data/app/views/administrador/application_view_helper/_render_engine_sidebars.html.haml +4 -0
  47. data/app/views/administrador/home/_html_head_extras.html.haml +0 -0
  48. data/app/views/administrador/home/index.de.html.haml +6 -0
  49. data/app/views/administrador/home/index.en.html.haml +6 -0
  50. data/app/views/administrador/home_controller/base/_html_head_extras.html.haml +0 -0
  51. data/app/views/administrador/home_controller/base/index.html.haml +3 -0
  52. data/app/views/administrador/resource_controller/base/_after_show_table.html.haml +0 -0
  53. data/app/views/administrador/resource_controller/base/_before_show_table.html.haml +0 -0
  54. data/app/views/administrador/resource_controller/base/_edit_actions.html.haml +7 -0
  55. data/app/views/administrador/resource_controller/base/_form.html.haml +8 -0
  56. data/app/views/administrador/resource_controller/base/_form_buttons.html.haml +1 -0
  57. data/app/views/administrador/resource_controller/base/_form_errors.html.haml +6 -0
  58. data/app/views/administrador/resource_controller/base/_html_head_extras.html.haml +0 -0
  59. data/app/views/administrador/resource_controller/base/_new_actions.html.haml +3 -0
  60. data/app/views/administrador/resource_controller/base/_show_actions.html.haml +6 -0
  61. data/app/views/administrador/resource_controller/base/_show_table.html.haml +2 -0
  62. data/app/views/administrador/resource_controller/base/edit.html.haml +14 -0
  63. data/app/views/administrador/resource_controller/base/new.html.haml +14 -0
  64. data/app/views/administrador/resource_controller/base/show.html.haml +19 -0
  65. data/app/views/administrador/resources_controller/base/_after_index_table.html.haml +0 -0
  66. data/app/views/administrador/resources_controller/base/_after_show_table.html.haml +0 -0
  67. data/app/views/administrador/resources_controller/base/_before_index_table.html.haml +0 -0
  68. data/app/views/administrador/resources_controller/base/_before_show_table.html.haml +0 -0
  69. data/app/views/administrador/resources_controller/base/_edit_actions.html.haml +7 -0
  70. data/app/views/administrador/resources_controller/base/_form.html.haml +10 -0
  71. data/app/views/administrador/resources_controller/base/_form_buttons.html.haml +1 -0
  72. data/app/views/administrador/resources_controller/base/_form_errors.html.haml +6 -0
  73. data/app/views/administrador/resources_controller/base/_html_head_extras.html.haml +0 -0
  74. data/app/views/administrador/resources_controller/base/_index_actions.html.haml +4 -0
  75. data/app/views/administrador/resources_controller/base/_index_table.html.haml +2 -0
  76. data/app/views/administrador/resources_controller/base/_index_table_actions.html.haml +16 -0
  77. data/app/views/administrador/resources_controller/base/_index_table_actions.html.haml~ +16 -0
  78. data/app/views/administrador/resources_controller/base/_new_actions.html.haml +3 -0
  79. data/app/views/administrador/resources_controller/base/_pagination.html.haml +1 -0
  80. data/app/views/administrador/resources_controller/base/_query_form.html.haml +0 -0
  81. data/app/views/administrador/resources_controller/base/_query_form_buttons.html.haml +2 -0
  82. data/app/views/administrador/resources_controller/base/_show_actions.html.haml +10 -0
  83. data/app/views/administrador/resources_controller/base/_show_table.html.haml +5 -0
  84. data/app/views/administrador/resources_controller/base/edit.html.haml +14 -0
  85. data/app/views/administrador/resources_controller/base/index.html.haml +33 -0
  86. data/app/views/administrador/resources_controller/base/new.html.haml +14 -0
  87. data/app/views/administrador/resources_controller/base/show.html.haml +19 -0
  88. data/app/views/administrador/service_controller/base/_create_actions.html.haml +3 -0
  89. data/app/views/administrador/service_controller/base/_create_after_service_output.html.haml +0 -0
  90. data/app/views/administrador/service_controller/base/_create_before_service_output.html.haml +0 -0
  91. data/app/views/administrador/service_controller/base/_form_buttons.haml +1 -0
  92. data/app/views/administrador/service_controller/base/_form_errors.html.haml +6 -0
  93. data/app/views/administrador/service_controller/base/_html_head_extras.html.haml +0 -0
  94. data/app/views/administrador/service_controller/base/_new_actions.html.haml +3 -0
  95. data/app/views/administrador/service_controller/base/create.html.haml +24 -0
  96. data/app/views/administrador/service_controller/base/new.html.haml +14 -0
  97. data/app/views/administrador/sidebar_controller/base/show.html.haml +1 -0
  98. data/app/views/breadcrumbs/_render.html.haml +7 -0
  99. data/app/views/layouts/administrador/application.html.haml +64 -0
  100. data/app/views/offcanvas_view_helper/_offcanvas.html.erb +11 -0
  101. data/config/initializers/localized_engines_fix.rb +3 -0
  102. data/config/locales/de.yml +76 -0
  103. data/config/locales/en.yml +46 -0
  104. data/config/routes.rb +8 -0
  105. data/lib/administrador/configuration.rb +24 -0
  106. data/lib/administrador/engine.rb +5 -0
  107. data/lib/administrador/feature.rb +7 -0
  108. data/lib/administrador/registered_engine.rb +73 -0
  109. data/lib/administrador/version.rb +3 -0
  110. data/lib/administrador.rb +19 -0
  111. data/lib/generators/administrador/install/install_generator.rb +19 -0
  112. data/lib/generators/administrador/install/templates/initializer.rb +11 -0
  113. data/lib/generators/administrador/install/templates/routes.source +4 -0
  114. data/lib/tasks/administrador_tasks.rake +4 -0
  115. metadata +493 -0
@@ -0,0 +1,64 @@
1
+ !!!
2
+ %html{:lang => I18n.locale }
3
+ %head
4
+ / Required meta tags
5
+ %meta{:charset => "utf-8"}/
6
+ %meta{:content => "width=device-width, initial-scale=1, shrink-to-fit=no", :name => "viewport"}/
7
+ / Bootstrap CSS
8
+ %link{:crossorigin => "anonymous", :href => "https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css", :integrity => "sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS", :rel => "stylesheet"}/
9
+ / Font Awesome CSS
10
+ %link{:crossorigin => "anonymous", :href => "https://use.fontawesome.com/releases/v5.6.3/css/all.css", :integrity => "sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/", :rel => "stylesheet"}/
11
+ / js-offcanvas CSS
12
+ %link{:href => "https://unpkg.com/js-offcanvas@1.2.8/dist/_css/prefixed/js-offcanvas.css", :rel => "stylesheet"}/
13
+ / Fonts
14
+ %link{:href => "https://fonts.googleapis.com/css?family=Poppins", :rel => "stylesheet"}/
15
+ / jQuery JS
16
+ %script{:crossorigin => "anonymous", :integrity => "sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=", :src => "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"}
17
+ / jQuery UI JS
18
+ %script{:crossorigin => "anonymous", :integrity => "sha256-T0Vest3yCU7pafRw9r+settMBX6JkKN06dqBnpQ8d30=", :src => "https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.js"}
19
+ / jQuery redirect JS
20
+ %script{:src => "https://cdn.jsdelivr.net/npm/jquery.redirect@1.1.4/jquery.redirect.min.js"}
21
+ / js-offcanvas JS
22
+ %script{:src => "https://unpkg.com/js-offcanvas@1.2.8/dist/_js/js-offcanvas.pkgd.min.js"}
23
+
24
+ - Administrador::Configuration.engines.each do |engine, options|
25
+ = "<!-- Javascript for #{engine} -->".html_safe
26
+ = javascript_include_tag engine.underscore.gsub('/', '_').gsub('_engine', '')
27
+
28
+ - Administrador::Configuration.engines.each do |engine, options|
29
+ = "<!-- CSS for #{engine} -->".html_safe
30
+ = stylesheet_link_tag engine.underscore.gsub('/', '_').gsub('_engine', ''), media: "all"
31
+
32
+ %title Administrador
33
+
34
+ = csrf_meta_tags
35
+ = csp_meta_tag
36
+ = stylesheet_link_tag "administrador/application", media: "all"
37
+ = javascript_include_tag "administrador/application"
38
+
39
+ = render partial: 'html_head_extras'
40
+ %body
41
+ .container-fluid.c-offcanvas-content-wrapper
42
+ .row
43
+ .col-12.px-0
44
+ #main-navbar.mb-4
45
+ = render '/administrador/application/navbar'
46
+ .container-fluid
47
+ .row
48
+ .col-12
49
+ #main-breadcrumbs
50
+ = breadcrumbs(self).render
51
+ #main-content
52
+ #flash-messages
53
+ = administrador_helper(self).flash_messages
54
+ = yield
55
+
56
+ = render "/administrador/application/sidebars/engine"
57
+ = offcanvas(self).offcanvas("engine-sidebar", modifiers: 'left,overlay', triggerButton: "#engine-sidebar-trigger" )
58
+
59
+ = administrador_helper(self).render_engine_sidebars
60
+ / Optional JavaScript
61
+ / Popper.js JS
62
+ %script{:crossorigin => "anonymous", :integrity => "sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut", :src => "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"}
63
+ / Bootstrap JS
64
+ %script{:crossorigin => "anonymous", :integrity => "sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k", :src => "https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"}
@@ -0,0 +1,11 @@
1
+ <script>
2
+ $(document).ready(function() {
3
+ $('#<%= id %>').offcanvas({
4
+ <%= options.collect { |k,v| " #{k}: \"#{v}\"" }.join(",\n").html_safe %>
5
+ })
6
+ <% if on_open_url.present? %>
7
+ .on( "open.offcanvas", function( e ){ $( "#<%= id %>" ).load("<%= on_open_url %>"); } )
8
+ <% end %>
9
+ ;
10
+ });
11
+ </script>
@@ -0,0 +1,3 @@
1
+ Rails.application.config.to_prepare do
2
+ ActionView::Base.send(:prepend, Administrador::EngineRoutable::LocalizedConcern)
3
+ end
@@ -0,0 +1,76 @@
1
+ de:
2
+ administrador:
3
+ application:
4
+ sidebars:
5
+ engine:
6
+ home: 'Home'
7
+ i18n:
8
+ title: 'Überseztungen'
9
+ messages:
10
+ title: 'Nachrichten'
11
+ notifications:
12
+ title: 'Benachrichtigungen'
13
+ settings:
14
+ title: 'Einstellungen'
15
+ search:
16
+ title: 'Suche'
17
+ user:
18
+ title: 'Profil'
19
+ controller:
20
+ confirmations:
21
+ destroy: "Sind Sie sicher?"
22
+ home_controller:
23
+ base:
24
+ index:
25
+ title: "%{engine_name}"
26
+ resources_controller:
27
+ base:
28
+ edit:
29
+ title: "%{resource_name} bearbeiten"
30
+ edit_actions:
31
+ back: "Zurück"
32
+ index:
33
+ title: "%{collection_name}"
34
+ new:
35
+ title: "%{resource_name} erstellen"
36
+ new_actions:
37
+ back: "Zurück"
38
+ query_form_buttons:
39
+ reset: "Zurücksetzen"
40
+ show_actions:
41
+ back: "Zurück"
42
+ destroy: "Löschen"
43
+ service_controller:
44
+ base:
45
+ new:
46
+ title: "%{service_name} ausführen"
47
+ new_actions:
48
+ back: "Zurück"
49
+ administrador/breadcrumbs_view_helper:
50
+ generate_breadcrumbs!:
51
+ home: 'Home'
52
+ controller:
53
+ breadcrumbs_concern:
54
+ actions:
55
+ default:
56
+ create: 'Erstellen'
57
+ edit: 'Bearbeiten'
58
+ new: 'Erstellen'
59
+ service:
60
+ new: 'Ausführen'
61
+ page: "Seite %{page_number}"
62
+ helpers:
63
+ submit:
64
+ administrador:
65
+ service:
66
+ create: 'Ausführen'
67
+ q:
68
+ create: 'Filtern'
69
+ routes:
70
+ administrador-engine: backend
71
+ views:
72
+ pagination:
73
+ first: "<<"
74
+ next: ">"
75
+ last: ">>"
76
+ previous: "<"
@@ -0,0 +1,46 @@
1
+ en:
2
+ administrador:
3
+ application:
4
+ engine_navigation:
5
+ home: 'Home'
6
+ controller:
7
+ confirmations:
8
+ destroy: "Are you sure?"
9
+ home_controller:
10
+ base:
11
+ index:
12
+ title: "%{engine_name}"
13
+ resources_controller:
14
+ base:
15
+ edit_actions:
16
+ back: "Back"
17
+ index:
18
+ title: "%{collection_name}"
19
+ new:
20
+ title: "New %{resource_name}"
21
+ new_actions:
22
+ back: "Back"
23
+ query_form_buttons:
24
+ reset: "Reset"
25
+ show_actions:
26
+ back: "Back"
27
+ destroy: "Delete"
28
+ service_controller:
29
+ base:
30
+ new:
31
+ back: "Back"
32
+ title: "Run %{service_name}"
33
+ administrador/breadcrumbs_view_helper:
34
+ generate_breadcrumbs!:
35
+ home: 'Home'
36
+ controller:
37
+ breadcrumbs_concern:
38
+ actions:
39
+ default:
40
+ edit: 'Edit'
41
+ new: 'New'
42
+ service:
43
+ new: 'Ausführen'
44
+ page: "Page %{page_number}"
45
+ routes:
46
+ administrador-engine: backend
data/config/routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ Administrador::Engine.routes.draw do
2
+ root to: 'home#index'
3
+ # localized do
4
+ # scope :administrador do
5
+ # root to: 'home#index'
6
+ # end
7
+ # end
8
+ end
@@ -0,0 +1,24 @@
1
+ module Administrador
2
+ module Configuration
3
+ def configure
4
+ yield self
5
+ end
6
+
7
+ mattr_accessor(:engines) { {} }
8
+ mattr_accessor(:features) { {} }
9
+ mattr_accessor(:resource_label_methods) { [:human, :name, :email, :to_s] }
10
+ mattr_accessor(:base_controller_class_name) { '::ApplicationController' }
11
+
12
+ def register_engine(name, options = {})
13
+ @@engines[name] = Administrador::RegisteredEngine.new(name, options)
14
+ end
15
+
16
+ def enable_feature(name, options = {})
17
+ @@features[name] = Administrador::Feature.new(name, options)
18
+ end
19
+
20
+ def features?(name)
21
+ @@features.has_key?(name)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ module Administrador
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Administrador
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module Administrador
2
+ class Feature
3
+ def initialize(name, options = {})
4
+ @name, @options = name, options
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,73 @@
1
+ module Administrador
2
+ class RegisteredEngine
3
+ attr_accessor :options, :name
4
+
5
+ def initialize(name, options)
6
+ @name, @options = name, options
7
+ end
8
+
9
+ def engine
10
+ @name.constantize
11
+ end
12
+
13
+ def to_key
14
+ @name.underscore.split("/")
15
+ end
16
+
17
+ def model_name
18
+ OpenStruct.new param_key: self.class.name.underscore.gsub('/', '_')
19
+ end
20
+
21
+ def translated_name
22
+ I18n.t("classes.#{engine.name.underscore}")
23
+ end
24
+
25
+ def router_name
26
+ @name.deconstantize.underscore.gsub('/', '_')
27
+ end
28
+
29
+ def configuration
30
+ "#{@name.deconstantize}::Configuration".constantize
31
+ end
32
+
33
+ def resources_controllers
34
+ if configuration.respond_to?(:registered_controllers)
35
+ configuration.registered_controllers.call
36
+ elsif configuration.respond_to?(:resources_controllers)
37
+ configuration.resources_controllers.call
38
+ else
39
+ Rails.logger.warn("Administrador: The namespace #{engine.name.deconstantize} either does not define a Configuration class or the class #{engine.name.deconstantize}::Configuration does not respond_to :resources_controllers.")
40
+ []
41
+ end
42
+ end
43
+
44
+ def resource_controllers
45
+ if configuration.respond_to?(:resource_controllers)
46
+ configuration.resource_controllers.call
47
+ else
48
+ Rails.logger.warn("Administrador: The namespace #{engine.name.deconstantize} either does not define a Configuration class or the class #{engine.name.deconstantize}::Configuration does not respond_to :resource_controllers.")
49
+ []
50
+ end
51
+ end
52
+
53
+ def service_controllers
54
+ if configuration.respond_to?(:registered_services)
55
+ configuration.registered_services.call
56
+ elsif configuration.respond_to?(:service_controllers)
57
+ configuration.service_controllers.call
58
+ else
59
+ Rails.logger.warn("Administrador: The namespace #{engine.name.deconstantize} either does not define a Configuration class or the class #{engine.name.deconstantize}::Configuration does not respond_to :service_controllers.")
60
+ []
61
+ end
62
+ end
63
+
64
+ def sidebar_controllers
65
+ if configuration.respond_to?(:sidebar_controllers)
66
+ configuration.sidebar_controllers.call
67
+ else
68
+ Rails.logger.warn("Administrador: The namespace #{engine.name.deconstantize} either does not define a Configuration class or the class #{engine.name.deconstantize}::Configuration does not respond_to :sidebar_controllers.")
69
+ []
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,3 @@
1
+ module Administrador
2
+ VERSION = '0.0.1.pre'.freeze
3
+ end
@@ -0,0 +1,19 @@
1
+ require "coffee-rails"
2
+ require "haml-rails"
3
+ require "route_translator"
4
+ require "rao-query"
5
+ require "rao-component"
6
+ require "rao-view_helper"
7
+ require "rao-resources_controller"
8
+ require "rao-service_controller"
9
+ require "simple_form"
10
+ require "bootstrap4-kaminari-views"
11
+ require "rails-i18n"
12
+ require "administrador/feature"
13
+ require "administrador/configuration"
14
+ require "administrador/engine"
15
+ require "administrador/registered_engine"
16
+
17
+ module Administrador
18
+ extend Configuration
19
+ end
@@ -0,0 +1,19 @@
1
+ module Administrador
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ desc 'Generates the initializer'
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def generate_initializer
9
+ template 'initializer.rb', 'config/initializers/administador.rb'
10
+ end
11
+
12
+ def generate_routes
13
+ inject_into_file 'config/routes.rb', before: "\nend" do
14
+ File.read(File.join(File.expand_path('../templates', __FILE__), 'routes.source'))
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ Administrador.configure do |config|
2
+ # Methods, that will be tried on a resource to generate a nice title
3
+ #
4
+ # Default: config.resource_label_methods = [:human, :name, :email, :to_s]
5
+ #
6
+ config.resource_label_methods = [:human, :name, :email, :to_s]
7
+
8
+ # config.register_engine 'Ecm::Blog::Backend::Engine', {}
9
+
10
+ # config.base_controller_class_name = '::ApplicationController'
11
+ end
@@ -0,0 +1,4 @@
1
+
2
+ localized do
3
+ mount Administrador::Engine, at: '/administrador-engine'
4
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :administrador do
3
+ # # Task goes here
4
+ # end