netzplan_micro_frontend 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +27 -0
  5. data/app/controllers/netzplan_micro_frontend/debug_controller.rb +7 -0
  6. data/app/controllers/netzplan_micro_frontend/sources_controller.rb +7 -0
  7. data/app/views/netzplan_micro_frontend/debug/index.html.erb +33 -0
  8. data/app/views/netzplan_micro_frontend/sources/index.json.jbuilder +2 -0
  9. data/lib/generators/netzplan_micro_frontend/install/install_generator.rb +11 -0
  10. data/lib/generators/netzplan_micro_frontend/install_asset_structure/install_asset_structure_generator.rb +25 -0
  11. data/lib/generators/netzplan_micro_frontend/install_asset_structure/templates/index_mapbox_styles.coffee +3 -0
  12. data/lib/generators/netzplan_micro_frontend/install_asset_structure/templates/index_models.js +2 -0
  13. data/lib/generators/netzplan_micro_frontend/install_asset_structure/templates/index_views.coffee +2 -0
  14. data/lib/generators/netzplan_micro_frontend/install_asset_structure/templates/manifest.css +15 -0
  15. data/lib/generators/netzplan_micro_frontend/install_asset_structure/templates/pack.coffee +9 -0
  16. data/lib/generators/netzplan_micro_frontend/install_file_types/install_file_types_generator.rb +48 -0
  17. data/lib/generators/netzplan_micro_frontend/install_file_types/templates/coffee_loader.js +6 -0
  18. data/lib/generators/netzplan_micro_frontend/install_file_types/templates/ejs_loader.js +6 -0
  19. data/lib/generators/netzplan_micro_frontend/install_user_rights/install_user_rights_generator.rb +19 -0
  20. data/lib/netzplan_micro_frontend.rb +8 -0
  21. data/lib/netzplan_micro_frontend/engine.rb +7 -0
  22. data/lib/netzplan_micro_frontend/rails/routes.rb +16 -0
  23. data/lib/netzplan_micro_frontend/railtie.rb +4 -0
  24. data/lib/netzplan_micro_frontend/version.rb +3 -0
  25. data/lib/tasks/netzplan_micro_frontend_tasks.rake +4 -0
  26. metadata +81 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4a8d6086791ef531396bb2bae22f5705311a09093f4ee8308411b632037f1acd
4
+ data.tar.gz: 5ae096f1c54af67363e65124b4c34788e9dfbc921e353623ba2bf7823a9b02ef
5
+ SHA512:
6
+ metadata.gz: 96c8151310164976f690afad83aaf33dcf2c3c42e33e081d6ad9e9c2362326cd809967df68f532ff57c92742f8762f26e2b60595551b78d76124479981460827
7
+ data.tar.gz: 32ccc476907231eed61b9540df8d6b1936050a4bf489919a0be81f6a9c056bd683aa039324aab738a8f81e7e0e1e39f163d79c3a7b7876a05bb39a745df9679e
@@ -0,0 +1,20 @@
1
+ Copyright 2020 René Meye
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.
@@ -0,0 +1,28 @@
1
+ # NetzplanMicroFrontend
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'netzplan_micro_frontend'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install netzplan_micro_frontend
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,27 @@
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 = 'NetzplanMicroFrontend'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ require 'bundler/gem_tasks'
18
+
19
+ require 'rake/testtask'
20
+
21
+ Rake::TestTask.new(:test) do |t|
22
+ t.libs << 'test'
23
+ t.pattern = 'test/**/*_test.rb'
24
+ t.verbose = false
25
+ end
26
+
27
+ task default: :test
@@ -0,0 +1,7 @@
1
+ class NetzplanMicroFrontend::DebugController < ApplicationController
2
+
3
+ def index
4
+ authorize! :admin, :micro_frontend
5
+ end
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ class NetzplanMicroFrontend::SourcesController < ApplicationController
2
+ #layout "micro_frontend_debug"
3
+
4
+ def index
5
+ authorize! :index, :micro_frontend_sources
6
+ end
7
+ end
@@ -0,0 +1,33 @@
1
+ <h1>Micro Frontend Debug</h1>
2
+
3
+ <h3>CSS</h3>
4
+ <p>
5
+ Current:
6
+ <a href="<%=asset_url 'micro_frontend.css'%>"><%=asset_url 'micro_frontend.css'%></a>
7
+ </p>
8
+ <iframe src="<%=asset_url 'micro_frontend.css'%>" frameborder="1" width="100%"></iframe>
9
+
10
+ <h3>Javascript</h3>
11
+ <p>
12
+ Current:
13
+ <a href="<%=asset_pack_url 'micro_frontend.js'%>"><%=asset_pack_url 'micro_frontend.js'%></a>
14
+ </p>
15
+ <iframe src="<%=asset_pack_url 'micro_frontend.js'%>" frameborder="1" width="100%"></iframe>
16
+
17
+ <h3>Registered Micro-Frontends</h3>
18
+ <ul class="registered_micro_frontends"></ul>
19
+
20
+ <h3>Registered Models</h3>
21
+ <ul class="registered_models"></ul>
22
+
23
+ <h3>Registered Collections</h3>
24
+ <ul class="registered_collections"></ul>
25
+
26
+ <h3>Registered Views</h3>
27
+ <ul class="registered_views"></ul>
28
+
29
+ <h3>Registered Mapbox Styles</h3>
30
+ <ul class="registered_mapbox_styles"></ul>
31
+
32
+ <h3>Micro-Frontend-Flow</h3>
33
+ <div class="micro_frontend_flows"></div>
@@ -0,0 +1,2 @@
1
+ json.javascript asset_pack_url 'micro_frontend.js'
2
+ json.stylesheet asset_url 'micro_frontend.css'
@@ -0,0 +1,11 @@
1
+ module NetzplanMicroFrontend
2
+ module Generators
3
+ class InstallGenerator < ::Rails::Generators::Base
4
+ def install
5
+ generate "netzplan_micro_frontend:install_asset_structure"
6
+ generate "netzplan_micro_frontend:install_user_rights"
7
+ generate "netzplan_micro_frontend:install_file_types"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,25 @@
1
+ module NetzplanMicroFrontend
2
+ module Generators
3
+ class InstallAssetStructureGenerator < ::Rails::Generators::Base
4
+ source_root File.expand_path('templates', __dir__)
5
+
6
+ def create_javascript
7
+ create_file "app/javascript/templates/.keep"
8
+ create_file "app/javascript/micro_frontend_management/.keep"
9
+
10
+ copy_file "index_mapbox_styles.coffee", "app/javascript/mapbox_styles/index.coffee"
11
+ copy_file "index_models.js", "app/javascript/models/index.js"
12
+ copy_file "index_views.coffee", "app/javascript/views/index.coffee"
13
+
14
+ copy_file "pack.coffee", "app/javascript/packs/micro_frontend.coffee"
15
+
16
+ end
17
+
18
+ def create_stylesheets
19
+ create_file "app/assets/stylesheets/info_window/.keep"
20
+
21
+ copy_file "manifest.css", "app/assets/stylesheets/micro_frontend.css"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ # mapbox_styles
2
+ mapbox_styles = require.context('.', true, /\.coffee/)
3
+ mapbox_styles.keys().forEach(mapbox_styles)
@@ -0,0 +1,2 @@
1
+ const models = require.context('.', true, /_model\.coffee/)
2
+ models.keys().forEach(models)
@@ -0,0 +1,2 @@
1
+ views = require.context('.', true, /\.coffee/)
2
+ views.keys().forEach(views)
@@ -0,0 +1,15 @@
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, or any plugin's
6
+ * vendor/assets/stylesheets directory 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 bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,9 @@
1
+ require("models")
2
+ require("views")
3
+ require("mapbox_styles")
4
+
5
+ window.__micro_frontend_registry ||= {}
6
+
7
+ # Import available micro_frontend Manager here:
8
+
9
+ # Register available micro_frontend Manager here:
@@ -0,0 +1,48 @@
1
+ module NetzplanMicroFrontend
2
+ module Generators
3
+ class InstallFileTypesGenerator < ::Rails::Generators::Base
4
+ source_root File.expand_path('templates', __dir__)
5
+
6
+ def add_yarn_dependencies
7
+ inject_into_file 'package.json', after: " \"dependencies\": {\n" do
8
+ <<-'JAVASCRIPT'
9
+ "coffee-loader": "^0.9.0",
10
+ "coffeescript": "1.12.7",
11
+ "ejs-webpack-loader": "^2.2.2",
12
+ "backbone": "^1.4.0",
13
+ "jquery": "^3.4.1",
14
+ JAVASCRIPT
15
+ end
16
+ end
17
+
18
+ def install_ejs
19
+ copy_file "ejs_loader.js", "config/webpack/loaders/ejs.js"
20
+
21
+ inject_into_file 'config/webpack/environment.js', after: "const { environment } = require('@rails/webpacker')\n" do
22
+ <<-'JAVASCRIPT'
23
+ const ejs = require('./loaders/ejs')
24
+ environment.loaders.prepend('ejs', ejs)
25
+
26
+ JAVASCRIPT
27
+ end
28
+ end
29
+
30
+ def install_coffeescript
31
+ copy_file "coffee_loader.js", "config/webpack/loaders/coffee.js"
32
+ inject_into_file 'config/webpacker.yml', after: " extensions:\n" do
33
+ <<-'YAML'
34
+ - .coffee
35
+ YAML
36
+ end
37
+
38
+ inject_into_file 'config/webpack/environment.js', after: "const { environment } = require('@rails/webpacker')\n" do
39
+ <<-'JAVASCRIPT'
40
+ const coffee = require('./loaders/coffee')
41
+ environment.loaders.prepend('coffee', coffee)
42
+
43
+ JAVASCRIPT
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ test: /\.coffee(\.erb)?$/,
3
+ use: [{
4
+ loader: 'coffee-loader'
5
+ }]
6
+ }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ test: /\.ejs$/,
3
+ use: [{
4
+ loader: "ejs-webpack-loader"
5
+ }]
6
+ }
@@ -0,0 +1,19 @@
1
+ module NetzplanMicroFrontend
2
+ module Generators
3
+ class InstallUserRightsGenerator < ::Rails::Generators::Base
4
+ def routes
5
+ route "use_netzplan_microfrontend"
6
+ end
7
+
8
+ def public_micro_frontend_sources
9
+ inject_into_file 'app/models/ability.rb', after: "def initialize(user)\n" do
10
+ <<-'RUBY'
11
+ can :read, :micro_frontend_sources
12
+ can :manage, :micro_frontend
13
+
14
+ RUBY
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,8 @@
1
+ require "netzplan_micro_frontend/railtie"
2
+
3
+ require "netzplan_micro_frontend/engine"
4
+ require "netzplan_micro_frontend/rails/routes"
5
+
6
+ module NetzplanMicroFrontend
7
+ # Your code goes here...
8
+ end
@@ -0,0 +1,7 @@
1
+ module NetzplanMicroFrontend
2
+ class Engine < Rails::Engine
3
+ initializer "netzplan_micro_frontend.routes" do
4
+ NetzplanMicroFrontend::Rails::Routes.install!
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ module NetzplanMicroFrontend
2
+ module Rails
3
+ class Routes
4
+ module Helper
5
+ def use_netzplan_microfrontend(options = {}, &block)
6
+ get '/micro_frontend/debug' => 'netzplan_micro_frontend/debug#index', :as => :micro_frontend_debug
7
+ get '/micro_frontend/sources' => 'netzplan_micro_frontend/sources#index', :as => :micro_frontend_sources
8
+ end
9
+ end
10
+
11
+ def self.install!
12
+ ActionDispatch::Routing::Mapper.send :include, NetzplanMicroFrontend::Rails::Routes::Helper
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,4 @@
1
+ module NetzplanMicroFrontend
2
+ class Railtie < ::Rails::Railtie
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module NetzplanMicroFrontend
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :netzplan_micro_frontend do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: netzplan_micro_frontend
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - René Meye
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-06-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '6.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '6.0'
27
+ description: Description of NetzplanMicroFrontend.
28
+ email:
29
+ - rene.meye@vesputi.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - MIT-LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - app/controllers/netzplan_micro_frontend/debug_controller.rb
38
+ - app/controllers/netzplan_micro_frontend/sources_controller.rb
39
+ - app/views/netzplan_micro_frontend/debug/index.html.erb
40
+ - app/views/netzplan_micro_frontend/sources/index.json.jbuilder
41
+ - lib/generators/netzplan_micro_frontend/install/install_generator.rb
42
+ - lib/generators/netzplan_micro_frontend/install_asset_structure/install_asset_structure_generator.rb
43
+ - lib/generators/netzplan_micro_frontend/install_asset_structure/templates/index_mapbox_styles.coffee
44
+ - lib/generators/netzplan_micro_frontend/install_asset_structure/templates/index_models.js
45
+ - lib/generators/netzplan_micro_frontend/install_asset_structure/templates/index_views.coffee
46
+ - lib/generators/netzplan_micro_frontend/install_asset_structure/templates/manifest.css
47
+ - lib/generators/netzplan_micro_frontend/install_asset_structure/templates/pack.coffee
48
+ - lib/generators/netzplan_micro_frontend/install_file_types/install_file_types_generator.rb
49
+ - lib/generators/netzplan_micro_frontend/install_file_types/templates/coffee_loader.js
50
+ - lib/generators/netzplan_micro_frontend/install_file_types/templates/ejs_loader.js
51
+ - lib/generators/netzplan_micro_frontend/install_user_rights/install_user_rights_generator.rb
52
+ - lib/netzplan_micro_frontend.rb
53
+ - lib/netzplan_micro_frontend/engine.rb
54
+ - lib/netzplan_micro_frontend/rails/routes.rb
55
+ - lib/netzplan_micro_frontend/railtie.rb
56
+ - lib/netzplan_micro_frontend/version.rb
57
+ - lib/tasks/netzplan_micro_frontend_tasks.rake
58
+ homepage: https://www.vesputi.com/
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubygems_version: 3.0.3
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Summary of NetzplanMicroFrontend.
81
+ test_files: []