next_rails_scaffold 0.1.8 → 0.1.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 874356e4aef8c89bd919acabd6f64357d469315b2d35f9b879f77dd7c5b1e5d9
4
- data.tar.gz: 55fa4d00935a81a56eb1db40a2f8bb40916c3b9ff74788b792b867ca98504bcd
3
+ metadata.gz: b9e43c5ca53fb69e1b2ad36d222316f092d83adcf22771de34838c9b176c5aa1
4
+ data.tar.gz: 383a69fa52d27c05645ae3db30a9e36a8b628ea7fab6f7c29dfc7c9c40162824
5
5
  SHA512:
6
- metadata.gz: 0c978bea988b2afeb8389e586a1f6e9ca27472f387971429c4452a87a023f18d132eab94ae87a9b11fed89d7e254f2a30b105d7ad20549b136f35ba13c097921
7
- data.tar.gz: 54550cbce8e66143690aae5519d184e41d86eadb6642af5a33919da47c546706854ac81dce3823c7e279039bbc68a3ab574c8b93dbd2f3595ef79114f0799dec
6
+ metadata.gz: 0fc1ab34055af28a30ba72b57d9e1c9e59aec332dc6e1e8c4a141537193d2fe11a8ba7f554e79f75e760eca6ffc2765ba055453c250218da22de0f653fddb546
7
+ data.tar.gz: beddbe982618623580da842ee049380f033739eb6dc5b1039ee6c342be06ecf37c890da19c938cf09053bde8049c9e40fb0fad556791707a157eb29deb5ada96
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NextRails
4
+ class StaticPagesController < ApplicationController
5
+ STATIC_FILES_PATH = Rails.root.join("public").to_s
6
+
7
+ def index
8
+ send_file file_path, type: "text/html", disposition: "inline"
9
+ rescue ActionController::ResourceNotFound
10
+ send_file File.join(STATIC_FILES_PATH, "404.html"), type: "text/html", disposition: "inline", status: 404
11
+ rescue StandardError => e
12
+ Rails.logger.error "StaticPagesController (#{e.class}): #{e.message}"
13
+ raise e
14
+ end
15
+
16
+ private
17
+
18
+ def file_path
19
+ path = params.require(:file_path)
20
+
21
+ raise ActionController::ResourceNotFound, "Not Found" unless File.exist?(path)
22
+ raise ActionController::RoutingError, "Forbidden" unless path.start_with?(STATIC_FILES_PATH)
23
+
24
+ path
25
+ end
26
+ end
27
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ parameter_regex = /\[([a-zA-Z0-9_-]+)\]/
5
+ static_files_path = Rails.root.join("public").to_s
6
+ static_files = File.join(static_files_path, "**", "index.html")
7
+
8
+ Dir.glob(static_files).each do |path|
9
+ next unless path.match?(parameter_regex)
10
+
11
+ route = path[%r{#{Regexp.escape(static_files_path)}(.*)/index.html}, 1]
12
+ route = route.gsub(parameter_regex, ':\1')
13
+
14
+ get route, to: "next_rails/static_pages#index", file_path: path
15
+ end
16
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NextRails
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace NextRails
6
+ config.eager_load_namespaces << NextRails
7
+ end
8
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NextRails
4
- VERSION = "0.1.8"
4
+ VERSION = "0.1.9"
5
5
  end
data/lib/next_rails.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "next_rails/actions"
4
+ require_relative "next_rails/engine"
4
5
  require_relative "next_rails/version"
5
6
 
6
7
  module NextRails
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: next_rails_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raphael Araújo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-16 00:00:00.000000000 Z
11
+ date: 2023-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -50,12 +50,15 @@ files:
50
50
  - LICENSE.txt
51
51
  - README.md
52
52
  - Rakefile
53
+ - app/controllers/next_rails/static_pages_controller.rb
54
+ - config/routes.rb
53
55
  - lib/generators/next_rails/USAGE
54
56
  - lib/generators/next_rails/install_generator.rb
55
57
  - lib/generators/next_rails/templates/config/initializers/next_rails.rb
56
58
  - lib/generators/rails/next_rails/next_rails_generator.rb
57
59
  - lib/next_rails.rb
58
60
  - lib/next_rails/actions.rb
61
+ - lib/next_rails/engine.rb
59
62
  - lib/next_rails/version.rb
60
63
  - sig/next_rails.rbs
61
64
  homepage: https://github.com/raphox/next-rails#readme